diff options
-rw-r--r-- | bench/react-hello-world/react-hello-world.jsx | 5 | ||||
-rw-r--r-- | src/bun.js/bindings/JSSink.cpp | 491 | ||||
-rw-r--r-- | src/bun.js/bindings/JSSink.h | 912 | ||||
-rw-r--r-- | src/bun.js/bindings/JSSinkLookupTable.h | 2 | ||||
-rw-r--r-- | src/bun.js/generate-jssink.js | 57 |
5 files changed, 829 insertions, 638 deletions
diff --git a/bench/react-hello-world/react-hello-world.jsx b/bench/react-hello-world/react-hello-world.jsx index 4c3fc5967..9391963c3 100644 --- a/bench/react-hello-world/react-hello-world.jsx +++ b/bench/react-hello-world/react-hello-world.jsx @@ -1,7 +1,4 @@ -// import { renderToReadableStream } from "react-dom/server.browser"; -var { renderToReadableStream } = import.meta.require( - "../../test/bun.js/reactdom-bun.js" -); +import { renderToReadableStream } from "react-dom/server.browser"; const headers = { headers: { diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 84cb0bf1f..09163fb62 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2022-07-02T10:45:03.309Z +// Generated by 'make generate-sink' at 2022-08-17T12:00:00.776Z // To regenerate this file, run: // // make generate-sink @@ -54,12 +54,18 @@ #include "JavaScriptCore/Weak.h" #include "JavaScriptCore/WeakInlines.h" + + namespace WebCore { using namespace JSC; -JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) -{ + + + +JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -80,10 +86,12 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic onClose = JSC::jsUndefined(); } - JSC::JSFunction* onPullFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onPull); - JSC::JSFunction* onCloseFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onClose); + JSC::JSFunction *onPullFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onPull); + JSC::JSFunction *onCloseFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onClose); + + - if (WebCore::JSReadableArrayBufferSinkController* ArrayBufferSinkController = JSC::jsDynamicCast<WebCore::JSReadableArrayBufferSinkController*>(callFrame->thisValue())) { + if (WebCore::JSReadableArrayBufferSinkController* ArrayBufferSinkController = JSC::jsDynamicCast<WebCore::JSReadableArrayBufferSinkController*>(callFrame->thisValue())) { if (ArrayBufferSinkController->wrapped() == nullptr) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s)); return JSC::JSValue::encode(JSC::jsUndefined()); @@ -92,6 +100,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic ArrayBufferSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction); } + else if (WebCore::JSReadableHTTPResponseSinkController* HTTPResponseSinkController = JSC::jsDynamicCast<WebCore::JSReadableHTTPResponseSinkController*>(callFrame->thisValue())) { if (HTTPResponseSinkController->wrapped() == nullptr) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s)); @@ -101,6 +110,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic HTTPResponseSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction); } + else if (WebCore::JSReadableHTTPSResponseSinkController* HTTPSResponseSinkController = JSC::jsDynamicCast<WebCore::JSReadableHTTPSResponseSinkController*>(callFrame->thisValue())) { if (HTTPSResponseSinkController->wrapped() == nullptr) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s)); @@ -126,10 +136,11 @@ JSC_DEFINE_CUSTOM_GETTER(functionArrayBufferSink__getter, (JSC::JSGlobalObject * return JSC::JSValue::encode(globalObject->ArrayBufferSink()); } + JSC_DECLARE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close); -JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -139,20 +150,22 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close, (JSC::JSGlo return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = controller->wrapped(); + void *ptr = controller->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } controller->detach(); ArrayBufferSink__close(lexicalGlobalObject, ptr); + // Release the controller right before close. + controller->m_hasPendingActivity = false; return JSC::JSValue::encode(JSC::jsUndefined()); } JSC_DECLARE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end); -JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -162,7 +175,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGloba return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = controller->wrapped(); + void *ptr = controller->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -171,10 +184,11 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGloba return ArrayBufferSink__endWithSink(ptr, lexicalGlobalObject); } + JSC_DECLARE_HOST_FUNCTION(ArrayBufferSink__doClose); -JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -184,7 +198,7 @@ JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexica return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = sink->wrapped(); + void *ptr = sink->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -194,6 +208,8 @@ JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexica return JSC::JSValue::encode(JSC::jsUndefined()); } + + JSC_DEFINE_CUSTOM_GETTER(functionHTTPResponseSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { auto& vm = lexicalGlobalObject->vm(); @@ -202,10 +218,11 @@ JSC_DEFINE_CUSTOM_GETTER(functionHTTPResponseSink__getter, (JSC::JSGlobalObject return JSC::JSValue::encode(globalObject->HTTPResponseSink()); } + JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close); -JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -215,20 +232,22 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close, (JSC::JSGl return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = controller->wrapped(); + void *ptr = controller->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } controller->detach(); HTTPResponseSink__close(lexicalGlobalObject, ptr); + // Release the controller right before close. + controller->m_hasPendingActivity = false; return JSC::JSValue::encode(JSC::jsUndefined()); } JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end); -JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -238,7 +257,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlob return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = controller->wrapped(); + void *ptr = controller->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -247,10 +266,11 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlob return HTTPResponseSink__endWithSink(ptr, lexicalGlobalObject); } + JSC_DECLARE_HOST_FUNCTION(HTTPResponseSink__doClose); -JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -260,7 +280,7 @@ JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexic return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = sink->wrapped(); + void *ptr = sink->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -270,6 +290,8 @@ JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexic return JSC::JSValue::encode(JSC::jsUndefined()); } + + JSC_DEFINE_CUSTOM_GETTER(functionHTTPSResponseSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { auto& vm = lexicalGlobalObject->vm(); @@ -278,10 +300,11 @@ JSC_DEFINE_CUSTOM_GETTER(functionHTTPSResponseSink__getter, (JSC::JSGlobalObject return JSC::JSValue::encode(globalObject->HTTPSResponseSink()); } + JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close); -JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -291,20 +314,22 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close, (JSC::JSG return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = controller->wrapped(); + void *ptr = controller->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } controller->detach(); HTTPSResponseSink__close(lexicalGlobalObject, ptr); + // Release the controller right before close. + controller->m_hasPendingActivity = false; return JSC::JSValue::encode(JSC::jsUndefined()); } JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end); -JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -314,7 +339,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlo return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = controller->wrapped(); + void *ptr = controller->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -323,10 +348,11 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlo return HTTPSResponseSink__endWithSink(ptr, lexicalGlobalObject); } + JSC_DECLARE_HOST_FUNCTION(HTTPSResponseSink__doClose); -JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { - + auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject); @@ -336,7 +362,7 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi return JSC::JSValue::encode(JSC::jsUndefined()); } - void* ptr = sink->wrapped(); + void *ptr = sink->wrapped(); if (ptr == nullptr) { return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -346,8 +372,10 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi return JSC::JSValue::encode(JSC::jsUndefined()); } -#include "JSSinkLookupTable.h" + +#include "JSSinkLookupTable.h" + /* Source for JSArrayBufferSinkPrototypeTableValues.lut.h @begin JSArrayBufferSinkPrototypeTable close ArrayBufferSink__doClose ReadOnly|DontDelete|Function 0 @@ -355,10 +383,11 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi end ArrayBufferSink__end ReadOnly|DontDelete|Function 0 start ArrayBufferSink__start ReadOnly|DontDelete|Function 1 write ArrayBufferSink__write ReadOnly|DontDelete|Function 1 - + @end */ + /* Source for JSReadableArrayBufferSinkControllerPrototypeTableValues.lut.h @begin JSReadableArrayBufferSinkControllerPrototypeTable close JSReadableArrayBufferSinkController__close ReadOnly|DontDelete|Function 0 @@ -369,6 +398,7 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi @end */ + /* Source for JSHTTPResponseSinkPrototypeTableValues.lut.h @begin JSHTTPResponseSinkPrototypeTable close HTTPResponseSink__doClose ReadOnly|DontDelete|Function 0 @@ -376,10 +406,11 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi end HTTPResponseSink__end ReadOnly|DontDelete|Function 0 start HTTPResponseSink__start ReadOnly|DontDelete|Function 1 write HTTPResponseSink__write ReadOnly|DontDelete|Function 1 - + @end */ + /* Source for JSReadableHTTPResponseSinkControllerPrototypeTableValues.lut.h @begin JSReadableHTTPResponseSinkControllerPrototypeTable close JSReadableHTTPResponseSinkController__close ReadOnly|DontDelete|Function 0 @@ -390,6 +421,7 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi @end */ + /* Source for JSHTTPSResponseSinkPrototypeTableValues.lut.h @begin JSHTTPSResponseSinkPrototypeTable close HTTPSResponseSink__doClose ReadOnly|DontDelete|Function 0 @@ -397,10 +429,11 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi end HTTPSResponseSink__end ReadOnly|DontDelete|Function 0 start HTTPSResponseSink__start ReadOnly|DontDelete|Function 1 write HTTPSResponseSink__write ReadOnly|DontDelete|Function 1 - + @end */ + /* Source for JSReadableHTTPSResponseSinkControllerPrototypeTableValues.lut.h @begin JSReadableHTTPSResponseSinkControllerPrototypeTable close JSReadableHTTPSResponseSinkController__close ReadOnly|DontDelete|Function 0 @@ -411,6 +444,9 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi @end */ + + + #pragma mark - ArrayBufferSink class JSArrayBufferSinkPrototype final : public JSC::JSNonFinalObject { @@ -446,41 +482,42 @@ private: STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSArrayBufferSinkPrototype, JSArrayBufferSinkPrototype::Base); class JSReadableArrayBufferSinkControllerPrototype final : public JSC::JSNonFinalObject { -public: - using Base = JSC::JSNonFinalObject; - - static JSReadableArrayBufferSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSReadableArrayBufferSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableArrayBufferSinkControllerPrototype>(vm)) JSReadableArrayBufferSinkControllerPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - -private: - JSReadableArrayBufferSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); -}; -STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableArrayBufferSinkControllerPrototype, JSReadableArrayBufferSinkControllerPrototype::Base); + public: + using Base = JSC::JSNonFinalObject; + + static JSReadableArrayBufferSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSReadableArrayBufferSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableArrayBufferSinkControllerPrototype>(vm)) JSReadableArrayBufferSinkControllerPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + private: + JSReadableArrayBufferSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableArrayBufferSinkControllerPrototype, JSReadableArrayBufferSinkControllerPrototype::Base); const ClassInfo JSArrayBufferSinkPrototype::s_info = { "ArrayBufferSink"_s, &Base::s_info, &JSArrayBufferSinkPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSArrayBufferSinkPrototype) }; const ClassInfo JSArrayBufferSink::s_info = { "ArrayBufferSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSArrayBufferSink) }; const ClassInfo JSArrayBufferSinkConstructor::s_info = { "ArrayBufferSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSArrayBufferSinkConstructor) }; + const ClassInfo JSReadableArrayBufferSinkControllerPrototype::s_info = { "ReadableArrayBufferSinkController"_s, &Base::s_info, &JSReadableArrayBufferSinkControllerPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSReadableArrayBufferSinkControllerPrototype) }; const ClassInfo JSReadableArrayBufferSinkController::s_info = { "ReadableArrayBufferSinkController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableArrayBufferSinkController) }; @@ -491,6 +528,7 @@ JSArrayBufferSink::~JSArrayBufferSink() } } + JSReadableArrayBufferSinkController::~JSReadableArrayBufferSinkController() { if (m_sinkPtr) { @@ -508,8 +546,7 @@ JSObject* JSReadableArrayBufferSinkController::createPrototype(VM& vm, JSDOMGlob return JSReadableArrayBufferSinkControllerPrototype::create(vm, &globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); } -void JSReadableArrayBufferSinkController::detach() -{ +void JSReadableArrayBufferSinkController::detach() { m_sinkPtr = nullptr; m_onPull.clear(); @@ -518,17 +555,18 @@ void JSReadableArrayBufferSinkController::detach() m_onClose.clear(); if (readableStream && onClose) { - JSC::JSGlobalObject* globalObject = this->globalObject(); + JSC::JSGlobalObject *globalObject = this->globalObject(); auto callData = JSC::getCallData(onClose); JSC::MarkedArgumentBuffer arguments; arguments.append(readableStream); arguments.append(jsUndefined()); JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments); } - + m_weakReadableStream.clear(); } + JSArrayBufferSinkConstructor* JSArrayBufferSinkConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSObject* prototype) { JSArrayBufferSinkConstructor* ptr = new (NotNull, JSC::allocateCell<JSArrayBufferSinkConstructor>(vm)) JSArrayBufferSinkConstructor(vm, structure, ArrayBufferSink__construct); @@ -557,11 +595,11 @@ void JSArrayBufferSinkConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* g initializeProperties(vm, globalObject, prototype); } -JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSArrayBufferSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -{ +JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSArrayBufferSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) { return ArrayBufferSink__construct(globalObject, callFrame); } + void JSArrayBufferSinkConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype) { putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); @@ -598,10 +636,12 @@ void JSReadableArrayBufferSinkController::finishCreation(VM& vm) ASSERT(inherits(info())); } + void JSArrayBufferSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) { auto* thisObject = jsCast<JSArrayBufferSink*>(cell); if (void* wrapped = thisObject->wrapped()) { + analyzer.setWrappedObjectForCell(cell, wrapped); // if (thisObject->scriptExecutionContext()) // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); } @@ -612,12 +652,14 @@ void JSReadableArrayBufferSinkController::analyzeHeap(JSCell* cell, HeapAnalyzer { auto* thisObject = jsCast<JSReadableArrayBufferSinkController*>(cell); if (void* wrapped = thisObject->wrapped()) { + analyzer.setWrappedObjectForCell(cell, wrapped); // if (thisObject->scriptExecutionContext()) // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); } Base::analyzeHeap(cell, analyzer); } + template<typename Visitor> void JSReadableArrayBufferSinkController::visitChildrenImpl(JSCell* cell, Visitor& visitor) { @@ -631,8 +673,8 @@ void JSReadableArrayBufferSinkController::visitChildrenImpl(JSCell* cell, Visito DEFINE_VISIT_CHILDREN(JSReadableArrayBufferSinkController); -void JSReadableArrayBufferSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose) -{ + +void JSReadableArrayBufferSinkController::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); this->m_onClose.set(globalObject->vm(), this, onClose); @@ -643,11 +685,14 @@ void JSArrayBufferSink::destroy(JSCell* cell) static_cast<JSArrayBufferSink*>(cell)->JSArrayBufferSink::~JSArrayBufferSink(); } + void JSReadableArrayBufferSinkController::destroy(JSCell* cell) { static_cast<JSReadableArrayBufferSinkController*>(cell)->JSReadableArrayBufferSinkController::~JSReadableArrayBufferSinkController(); } + + #pragma mark - HTTPResponseSink class JSHTTPResponseSinkPrototype final : public JSC::JSNonFinalObject { @@ -683,41 +728,42 @@ private: STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPResponseSinkPrototype, JSHTTPResponseSinkPrototype::Base); class JSReadableHTTPResponseSinkControllerPrototype final : public JSC::JSNonFinalObject { -public: - using Base = JSC::JSNonFinalObject; - - static JSReadableHTTPResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSReadableHTTPResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPResponseSinkControllerPrototype>(vm)) JSReadableHTTPResponseSinkControllerPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - -private: - JSReadableHTTPResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); -}; -STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPResponseSinkControllerPrototype, JSReadableHTTPResponseSinkControllerPrototype::Base); + public: + using Base = JSC::JSNonFinalObject; + + static JSReadableHTTPResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSReadableHTTPResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPResponseSinkControllerPrototype>(vm)) JSReadableHTTPResponseSinkControllerPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + private: + JSReadableHTTPResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPResponseSinkControllerPrototype, JSReadableHTTPResponseSinkControllerPrototype::Base); const ClassInfo JSHTTPResponseSinkPrototype::s_info = { "HTTPResponseSink"_s, &Base::s_info, &JSHTTPResponseSinkPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSHTTPResponseSinkPrototype) }; const ClassInfo JSHTTPResponseSink::s_info = { "HTTPResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPResponseSink) }; const ClassInfo JSHTTPResponseSinkConstructor::s_info = { "HTTPResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPResponseSinkConstructor) }; + const ClassInfo JSReadableHTTPResponseSinkControllerPrototype::s_info = { "ReadableHTTPResponseSinkController"_s, &Base::s_info, &JSReadableHTTPResponseSinkControllerPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPResponseSinkControllerPrototype) }; const ClassInfo JSReadableHTTPResponseSinkController::s_info = { "ReadableHTTPResponseSinkController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPResponseSinkController) }; @@ -728,6 +774,7 @@ JSHTTPResponseSink::~JSHTTPResponseSink() } } + JSReadableHTTPResponseSinkController::~JSReadableHTTPResponseSinkController() { if (m_sinkPtr) { @@ -745,8 +792,7 @@ JSObject* JSReadableHTTPResponseSinkController::createPrototype(VM& vm, JSDOMGlo return JSReadableHTTPResponseSinkControllerPrototype::create(vm, &globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); } -void JSReadableHTTPResponseSinkController::detach() -{ +void JSReadableHTTPResponseSinkController::detach() { m_sinkPtr = nullptr; m_onPull.clear(); @@ -755,17 +801,18 @@ void JSReadableHTTPResponseSinkController::detach() m_onClose.clear(); if (readableStream && onClose) { - JSC::JSGlobalObject* globalObject = this->globalObject(); + JSC::JSGlobalObject *globalObject = this->globalObject(); auto callData = JSC::getCallData(onClose); JSC::MarkedArgumentBuffer arguments; arguments.append(readableStream); arguments.append(jsUndefined()); JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments); } - + m_weakReadableStream.clear(); } + JSHTTPResponseSinkConstructor* JSHTTPResponseSinkConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSObject* prototype) { JSHTTPResponseSinkConstructor* ptr = new (NotNull, JSC::allocateCell<JSHTTPResponseSinkConstructor>(vm)) JSHTTPResponseSinkConstructor(vm, structure, HTTPResponseSink__construct); @@ -794,11 +841,11 @@ void JSHTTPResponseSinkConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* initializeProperties(vm, globalObject, prototype); } -JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -{ +JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) { return HTTPResponseSink__construct(globalObject, callFrame); } + void JSHTTPResponseSinkConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype) { putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); @@ -835,10 +882,12 @@ void JSReadableHTTPResponseSinkController::finishCreation(VM& vm) ASSERT(inherits(info())); } + void JSHTTPResponseSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) { auto* thisObject = jsCast<JSHTTPResponseSink*>(cell); if (void* wrapped = thisObject->wrapped()) { + analyzer.setWrappedObjectForCell(cell, wrapped); // if (thisObject->scriptExecutionContext()) // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); } @@ -849,12 +898,14 @@ void JSReadableHTTPResponseSinkController::analyzeHeap(JSCell* cell, HeapAnalyze { auto* thisObject = jsCast<JSReadableHTTPResponseSinkController*>(cell); if (void* wrapped = thisObject->wrapped()) { + analyzer.setWrappedObjectForCell(cell, wrapped); // if (thisObject->scriptExecutionContext()) // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); } Base::analyzeHeap(cell, analyzer); } + template<typename Visitor> void JSReadableHTTPResponseSinkController::visitChildrenImpl(JSCell* cell, Visitor& visitor) { @@ -868,8 +919,8 @@ void JSReadableHTTPResponseSinkController::visitChildrenImpl(JSCell* cell, Visit DEFINE_VISIT_CHILDREN(JSReadableHTTPResponseSinkController); -void JSReadableHTTPResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose) -{ + +void JSReadableHTTPResponseSinkController::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); this->m_onClose.set(globalObject->vm(), this, onClose); @@ -880,11 +931,14 @@ void JSHTTPResponseSink::destroy(JSCell* cell) static_cast<JSHTTPResponseSink*>(cell)->JSHTTPResponseSink::~JSHTTPResponseSink(); } + void JSReadableHTTPResponseSinkController::destroy(JSCell* cell) { static_cast<JSReadableHTTPResponseSinkController*>(cell)->JSReadableHTTPResponseSinkController::~JSReadableHTTPResponseSinkController(); } + + #pragma mark - HTTPSResponseSink class JSHTTPSResponseSinkPrototype final : public JSC::JSNonFinalObject { @@ -920,41 +974,42 @@ private: STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPSResponseSinkPrototype, JSHTTPSResponseSinkPrototype::Base); class JSReadableHTTPSResponseSinkControllerPrototype final : public JSC::JSNonFinalObject { -public: - using Base = JSC::JSNonFinalObject; - - static JSReadableHTTPSResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - JSReadableHTTPSResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPSResponseSinkControllerPrototype>(vm)) JSReadableHTTPSResponseSinkControllerPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; - } - - DECLARE_INFO; - template<typename CellType, JSC::SubspaceAccess> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.plainObjectSpace(); - } - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - -private: - JSReadableHTTPSResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) - : Base(vm, structure) - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); -}; -STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPSResponseSinkControllerPrototype, JSReadableHTTPSResponseSinkControllerPrototype::Base); + public: + using Base = JSC::JSNonFinalObject; + + static JSReadableHTTPSResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSReadableHTTPSResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPSResponseSinkControllerPrototype>(vm)) JSReadableHTTPSResponseSinkControllerPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + DECLARE_INFO; + template<typename CellType, JSC::SubspaceAccess> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + private: + JSReadableHTTPSResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); + }; + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPSResponseSinkControllerPrototype, JSReadableHTTPSResponseSinkControllerPrototype::Base); const ClassInfo JSHTTPSResponseSinkPrototype::s_info = { "HTTPSResponseSink"_s, &Base::s_info, &JSHTTPSResponseSinkPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSHTTPSResponseSinkPrototype) }; const ClassInfo JSHTTPSResponseSink::s_info = { "HTTPSResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPSResponseSink) }; const ClassInfo JSHTTPSResponseSinkConstructor::s_info = { "HTTPSResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPSResponseSinkConstructor) }; + const ClassInfo JSReadableHTTPSResponseSinkControllerPrototype::s_info = { "ReadableHTTPSResponseSinkController"_s, &Base::s_info, &JSReadableHTTPSResponseSinkControllerPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPSResponseSinkControllerPrototype) }; const ClassInfo JSReadableHTTPSResponseSinkController::s_info = { "ReadableHTTPSResponseSinkController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPSResponseSinkController) }; @@ -965,6 +1020,7 @@ JSHTTPSResponseSink::~JSHTTPSResponseSink() } } + JSReadableHTTPSResponseSinkController::~JSReadableHTTPSResponseSinkController() { if (m_sinkPtr) { @@ -982,8 +1038,7 @@ JSObject* JSReadableHTTPSResponseSinkController::createPrototype(VM& vm, JSDOMGl return JSReadableHTTPSResponseSinkControllerPrototype::create(vm, &globalObject, JSReadableHTTPSResponseSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); } -void JSReadableHTTPSResponseSinkController::detach() -{ +void JSReadableHTTPSResponseSinkController::detach() { m_sinkPtr = nullptr; m_onPull.clear(); @@ -992,17 +1047,18 @@ void JSReadableHTTPSResponseSinkController::detach() m_onClose.clear(); if (readableStream && onClose) { - JSC::JSGlobalObject* globalObject = this->globalObject(); + JSC::JSGlobalObject *globalObject = this->globalObject(); auto callData = JSC::getCallData(onClose); JSC::MarkedArgumentBuffer arguments; arguments.append(readableStream); arguments.append(jsUndefined()); JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments); } - + m_weakReadableStream.clear(); } + JSHTTPSResponseSinkConstructor* JSHTTPSResponseSinkConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSObject* prototype) { JSHTTPSResponseSinkConstructor* ptr = new (NotNull, JSC::allocateCell<JSHTTPSResponseSinkConstructor>(vm)) JSHTTPSResponseSinkConstructor(vm, structure, HTTPSResponseSink__construct); @@ -1031,11 +1087,11 @@ void JSHTTPSResponseSinkConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* initializeProperties(vm, globalObject, prototype); } -JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPSResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -{ +JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPSResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) { return HTTPSResponseSink__construct(globalObject, callFrame); } + void JSHTTPSResponseSinkConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype) { putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); @@ -1072,10 +1128,12 @@ void JSReadableHTTPSResponseSinkController::finishCreation(VM& vm) ASSERT(inherits(info())); } + void JSHTTPSResponseSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) { auto* thisObject = jsCast<JSHTTPSResponseSink*>(cell); if (void* wrapped = thisObject->wrapped()) { + analyzer.setWrappedObjectForCell(cell, wrapped); // if (thisObject->scriptExecutionContext()) // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); } @@ -1086,12 +1144,14 @@ void JSReadableHTTPSResponseSinkController::analyzeHeap(JSCell* cell, HeapAnalyz { auto* thisObject = jsCast<JSReadableHTTPSResponseSinkController*>(cell); if (void* wrapped = thisObject->wrapped()) { + analyzer.setWrappedObjectForCell(cell, wrapped); // if (thisObject->scriptExecutionContext()) // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); } Base::analyzeHeap(cell, analyzer); } + template<typename Visitor> void JSReadableHTTPSResponseSinkController::visitChildrenImpl(JSCell* cell, Visitor& visitor) { @@ -1105,8 +1165,8 @@ void JSReadableHTTPSResponseSinkController::visitChildrenImpl(JSCell* cell, Visi DEFINE_VISIT_CHILDREN(JSReadableHTTPSResponseSinkController); -void JSReadableHTTPSResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose) -{ + +void JSReadableHTTPSResponseSinkController::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); this->m_onClose.set(globalObject->vm(), this, onClose); @@ -1117,15 +1177,18 @@ void JSHTTPSResponseSink::destroy(JSCell* cell) static_cast<JSHTTPSResponseSink*>(cell)->JSHTTPSResponseSink::~JSHTTPSResponseSink(); } + void JSReadableHTTPSResponseSinkController::destroy(JSCell* cell) { static_cast<JSReadableHTTPSResponseSinkController*>(cell)->JSReadableHTTPSResponseSinkController::~JSReadableHTTPSResponseSinkController(); } -JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID) -{ - switch (sinkID) { + + JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID) + { + switch (sinkID) { + case ArrayBufferSink: return JSArrayBufferSinkPrototype::create(vm, globalObject, JSArrayBufferSinkPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); @@ -1135,50 +1198,53 @@ JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, case HTTPSResponseSink: return JSHTTPSResponseSinkPrototype::create(vm, globalObject, JSHTTPSResponseSinkPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); - default: - RELEASE_ASSERT_NOT_REACHED(); +default: + RELEASE_ASSERT_NOT_REACHED(); } } JSObject* createJSSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID) { switch (sinkID) { + + case ArrayBufferSink: + return JSReadableArrayBufferSinkControllerPrototype::create(vm, globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); - case ArrayBufferSink: - return JSReadableArrayBufferSinkControllerPrototype::create(vm, globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); - - case HTTPResponseSink: - return JSReadableHTTPResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); + case HTTPResponseSink: + return JSReadableHTTPResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); - case HTTPSResponseSink: - return JSReadableHTTPSResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPSResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); + case HTTPSResponseSink: + return JSReadableHTTPSResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPSResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); - default: - RELEASE_ASSERT_NOT_REACHED(); - } +default: + RELEASE_ASSERT_NOT_REACHED(); + } } - Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID) { switch (sinkID) { - - case ArrayBufferSink: { - auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID); - return JSReadableArrayBufferSinkController::createStructure(vm, globalObject, prototype); - } - case HTTPResponseSink: { - auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID); - return JSReadableHTTPResponseSinkController::createStructure(vm, globalObject, prototype); - } - case HTTPSResponseSink: { - auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID); - return JSReadableHTTPSResponseSinkController::createStructure(vm, globalObject, prototype); - } - default: - RELEASE_ASSERT_NOT_REACHED(); - } + + case ArrayBufferSink: { + auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID); + return JSReadableArrayBufferSinkController::createStructure(vm, globalObject, prototype); + } + + case HTTPResponseSink: { + auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID); + return JSReadableHTTPResponseSinkController::createStructure(vm, globalObject, prototype); + } + + case HTTPSResponseSink: { + auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID); + return JSReadableHTTPSResponseSinkController::createStructure(vm, globalObject, prototype); + } + +default: + RELEASE_ASSERT_NOT_REACHED(); + } } } // namespace WebCore + extern "C" JSC__JSValue ArrayBufferSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr) { auto& vm = arg0->vm(); @@ -1206,6 +1272,7 @@ extern "C" void ArrayBufferSink__detachPtr(JSC__JSValue JSValue0) sink->detach(); return; } + if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(JSValue0))) { controller->detach(); @@ -1213,18 +1280,18 @@ extern "C" void ArrayBufferSink__detachPtr(JSC__JSValue JSValue0) } } -extern "C" JSC__JSValue ArrayBufferSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void** controllerValue) +extern "C" JSC__JSValue ArrayBufferSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void **controllerValue) { auto& vm = arg0->vm(); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0); auto clientData = WebCore::clientData(vm); - JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject(); + JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject(); auto scope = DECLARE_CATCH_SCOPE(vm); JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableArrayBufferSinkController>(vm, *globalObject); - WebCore::JSReadableArrayBufferSinkController* controller = WebCore::JSReadableArrayBufferSinkController::create(vm, globalObject, structure, sinkPtr); + WebCore::JSReadableArrayBufferSinkController *controller = WebCore::JSReadableArrayBufferSinkController::create(vm, globalObject, structure, sinkPtr); *controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller)); - JSC::JSObject* function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject(); + JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(JSC::JSValue::decode(stream)); @@ -1241,10 +1308,10 @@ extern "C" void ArrayBufferSink__onReady(JSC__JSValue controllerValue, JSC__JSVa { WebCore::JSReadableArrayBufferSinkController* controller = JSC::jsCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onPull.get(); + JSC::JSFunction *function = controller->m_onPull.get(); if (function == nullptr) return; - JSC::JSGlobalObject* globalObject = controller->globalObject(); + JSC::JSGlobalObject *globalObject = controller->globalObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; @@ -1257,18 +1324,19 @@ extern "C" void ArrayBufferSink__onReady(JSC__JSValue controllerValue, JSC__JSVa extern "C" void ArrayBufferSink__onStart(JSC__JSValue controllerValue) { + } extern "C" void ArrayBufferSink__onClose(JSC__JSValue controllerValue, JSC__JSValue reason) { WebCore::JSReadableArrayBufferSinkController* controller = JSC::jsCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onClose.get(); + JSC::JSFunction *function = controller->m_onClose.get(); if (function == nullptr) return; // only call close once controller->m_onClose.clear(); - JSC::JSGlobalObject* globalObject = controller->globalObject(); + JSC::JSGlobalObject *globalObject = controller->globalObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; @@ -1279,6 +1347,7 @@ extern "C" void ArrayBufferSink__onClose(JSC__JSValue controllerValue, JSC__JSVa JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); } + extern "C" JSC__JSValue HTTPResponseSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr) { auto& vm = arg0->vm(); @@ -1306,6 +1375,7 @@ extern "C" void HTTPResponseSink__detachPtr(JSC__JSValue JSValue0) sink->detach(); return; } + if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(JSValue0))) { controller->detach(); @@ -1313,18 +1383,18 @@ extern "C" void HTTPResponseSink__detachPtr(JSC__JSValue JSValue0) } } -extern "C" JSC__JSValue HTTPResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void** controllerValue) +extern "C" JSC__JSValue HTTPResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void **controllerValue) { auto& vm = arg0->vm(); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0); auto clientData = WebCore::clientData(vm); - JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject(); + JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject(); auto scope = DECLARE_CATCH_SCOPE(vm); - JSC::Structure* structure = globalObject->JSReadableHTTPResponseSinkController(); - WebCore::JSReadableHTTPResponseSinkController* controller = WebCore::JSReadableHTTPResponseSinkController::create(vm, globalObject, structure, sinkPtr); + JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableHTTPResponseSinkController>(vm, *globalObject); + WebCore::JSReadableHTTPResponseSinkController *controller = WebCore::JSReadableHTTPResponseSinkController::create(vm, globalObject, structure, sinkPtr); *controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller)); - JSC::JSObject* function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject(); + JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(JSC::JSValue::decode(stream)); @@ -1341,10 +1411,10 @@ extern "C" void HTTPResponseSink__onReady(JSC__JSValue controllerValue, JSC__JSV { WebCore::JSReadableHTTPResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onPull.get(); + JSC::JSFunction *function = controller->m_onPull.get(); if (function == nullptr) return; - JSC::JSGlobalObject* globalObject = controller->globalObject(); + JSC::JSGlobalObject *globalObject = controller->globalObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; @@ -1357,18 +1427,19 @@ extern "C" void HTTPResponseSink__onReady(JSC__JSValue controllerValue, JSC__JSV extern "C" void HTTPResponseSink__onStart(JSC__JSValue controllerValue) { + } extern "C" void HTTPResponseSink__onClose(JSC__JSValue controllerValue, JSC__JSValue reason) { WebCore::JSReadableHTTPResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onClose.get(); + JSC::JSFunction *function = controller->m_onClose.get(); if (function == nullptr) return; // only call close once controller->m_onClose.clear(); - JSC::JSGlobalObject* globalObject = controller->globalObject(); + JSC::JSGlobalObject *globalObject = controller->globalObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; @@ -1379,6 +1450,7 @@ extern "C" void HTTPResponseSink__onClose(JSC__JSValue controllerValue, JSC__JSV JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); } + extern "C" JSC__JSValue HTTPSResponseSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr) { auto& vm = arg0->vm(); @@ -1406,6 +1478,7 @@ extern "C" void HTTPSResponseSink__detachPtr(JSC__JSValue JSValue0) sink->detach(); return; } + if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(JSValue0))) { controller->detach(); @@ -1413,18 +1486,18 @@ extern "C" void HTTPSResponseSink__detachPtr(JSC__JSValue JSValue0) } } -extern "C" JSC__JSValue HTTPSResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void** controllerValue) +extern "C" JSC__JSValue HTTPSResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void **controllerValue) { auto& vm = arg0->vm(); Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0); auto clientData = WebCore::clientData(vm); - JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject(); + JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject(); auto scope = DECLARE_CATCH_SCOPE(vm); JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableHTTPSResponseSinkController>(vm, *globalObject); - WebCore::JSReadableHTTPSResponseSinkController* controller = WebCore::JSReadableHTTPSResponseSinkController::create(vm, globalObject, structure, sinkPtr); + WebCore::JSReadableHTTPSResponseSinkController *controller = WebCore::JSReadableHTTPSResponseSinkController::create(vm, globalObject, structure, sinkPtr); *controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller)); - JSC::JSObject* function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject(); + JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(JSC::JSValue::decode(stream)); @@ -1441,10 +1514,10 @@ extern "C" void HTTPSResponseSink__onReady(JSC__JSValue controllerValue, JSC__JS { WebCore::JSReadableHTTPSResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onPull.get(); + JSC::JSFunction *function = controller->m_onPull.get(); if (function == nullptr) return; - JSC::JSGlobalObject* globalObject = controller->globalObject(); + JSC::JSGlobalObject *globalObject = controller->globalObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; @@ -1457,18 +1530,19 @@ extern "C" void HTTPSResponseSink__onReady(JSC__JSValue controllerValue, JSC__JS extern "C" void HTTPSResponseSink__onStart(JSC__JSValue controllerValue) { + } extern "C" void HTTPSResponseSink__onClose(JSC__JSValue controllerValue, JSC__JSValue reason) { WebCore::JSReadableHTTPSResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onClose.get(); + JSC::JSFunction *function = controller->m_onClose.get(); if (function == nullptr) return; // only call close once controller->m_onClose.clear(); - JSC::JSGlobalObject* globalObject = controller->globalObject(); + JSC::JSGlobalObject *globalObject = controller->globalObject(); auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; @@ -1478,3 +1552,4 @@ extern "C" void HTTPSResponseSink__onClose(JSC__JSValue controllerValue, JSC__JS arguments.append(JSC::JSValue::decode(reason)); JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); } + diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h index 88954fd5a..b750cfabe 100644 --- a/src/bun.js/bindings/JSSink.h +++ b/src/bun.js/bindings/JSSink.h @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2022-07-02T10:45:03.308Z +// Generated by 'make generate-sink' at 2022-08-17T12:00:00.774Z // #pragma once @@ -17,432 +17,508 @@ namespace WebCore { using namespace JSC; JSC_DECLARE_HOST_FUNCTION(functionStartDirectStream); -class JSArrayBufferSinkConstructor final : public JSC::InternalFunction { -public: - using Base = JSC::InternalFunction; - static JSArrayBufferSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype); - static constexpr SinkID Sink = SinkID::ArrayBufferSink; - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSArrayBufferSinkConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); }); - } - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - -private: - JSArrayBufferSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); -}; - -class JSArrayBufferSink final : public JSC::JSDestructibleObject { -public: - using Base = JSC::JSDestructibleObject; - static JSArrayBufferSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); - static constexpr SinkID Sink = SinkID::ArrayBufferSink; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSArrayBufferSink, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); }); - } - - static void destroy(JSC::JSCell*); - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - - static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); - - ~JSArrayBufferSink(); - - void* wrapped() const { return m_sinkPtr; } - - void detach() - { - m_sinkPtr = nullptr; - } - - static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - - void* m_sinkPtr; - - JSArrayBufferSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) - : Base(vm, structure) - { - m_sinkPtr = sinkPtr; - } - - void finishCreation(JSC::VM&); -}; - -class JSReadableArrayBufferSinkController final : public JSC::JSDestructibleObject { -public: - using Base = JSC::JSDestructibleObject; - static JSReadableArrayBufferSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); - static constexpr SinkID Sink = SinkID::ArrayBufferSink; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSReadableArrayBufferSinkController, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); }); - } - - static void destroy(JSC::JSCell*); - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); - - ~JSReadableArrayBufferSinkController(); - - void* wrapped() const { return m_sinkPtr; } - void detach(); - - void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose); - DECLARE_VISIT_CHILDREN; - - static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - - void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; - mutable JSC::Weak<JSObject> m_weakReadableStream; - - JSReadableArrayBufferSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) - : Base(vm, structure) - { - m_sinkPtr = sinkPtr; - } - - void finishCreation(JSC::VM&); -}; +class JSArrayBufferSinkConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSArrayBufferSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype); + static constexpr SinkID Sink = SinkID::ArrayBufferSink; + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSArrayBufferSinkConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); }); + } + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); + + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + private: + JSArrayBufferSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) + : Base(vm, structure, nativeFunction, nativeFunction) + + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); + }; + + class JSArrayBufferSink final : public JSC::JSDestructibleObject { + public: + using Base = JSC::JSDestructibleObject; + static JSArrayBufferSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); + static constexpr SinkID Sink = SinkID::ArrayBufferSink; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSArrayBufferSink, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); + + ~JSArrayBufferSink(); + + void* wrapped() const { return m_sinkPtr; } + + void detach() { + m_sinkPtr = nullptr; + + } + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + + void* m_sinkPtr; + + JSArrayBufferSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_sinkPtr = sinkPtr; + } + + void finishCreation(JSC::VM&); + }; + + class JSReadableArrayBufferSinkController final : public JSC::JSDestructibleObject { + public: + using Base = JSC::JSDestructibleObject; + static JSReadableArrayBufferSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); + static constexpr SinkID Sink = SinkID::ArrayBufferSink; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSReadableArrayBufferSinkController, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); + + ~JSReadableArrayBufferSinkController(); + + + void* wrapped() const { return m_sinkPtr; } + void detach(); + + void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose); + DECLARE_VISIT_CHILDREN; + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + + bool hasPendingActivity() { return m_hasPendingActivity; } + + void* m_sinkPtr; + bool m_hasPendingActivity; + mutable WriteBarrier<JSC::JSFunction> m_onPull; + mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable JSC::Weak<JSObject> m_weakReadableStream; + JSC::Weak<JSReadableArrayBufferSinkController> m_weakThis; + + JSReadableArrayBufferSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_sinkPtr = sinkPtr; + m_hasPendingActivity = true; + m_weakThis = JSC::Weak<JSReadableArrayBufferSinkController>(this, getOwner()); + } + + void finishCreation(JSC::VM&); + + class Owner final : public JSC::WeakHandleOwner { + public: + bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final + { + auto* controller = JSC::jsCast<JSReadableArrayBufferSinkController*>(handle.slot()->asCell()); + return controller->hasPendingActivity(); + } + void finalize(JSC::Handle<JSC::Unknown>, void* context) final {} + }; + + static JSC::WeakHandleOwner* getOwner() + { + static NeverDestroyed<Owner> m_owner; + return &m_owner.get(); + } + }; JSC_DECLARE_CUSTOM_GETTER(functionArrayBufferSink__getter); -class JSHTTPResponseSinkConstructor final : public JSC::InternalFunction { -public: - using Base = JSC::InternalFunction; - static JSHTTPResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype); - static constexpr SinkID Sink = SinkID::HTTPResponseSink; - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSHTTPResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); }); - } - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - -private: - JSHTTPResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); -}; - -class JSHTTPResponseSink final : public JSC::JSDestructibleObject { -public: - using Base = JSC::JSDestructibleObject; - static JSHTTPResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); - static constexpr SinkID Sink = SinkID::HTTPResponseSink; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSHTTPResponseSink, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); }); - } - - static void destroy(JSC::JSCell*); - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - - static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); - - ~JSHTTPResponseSink(); - - void* wrapped() const { return m_sinkPtr; } - - void detach() - { - m_sinkPtr = nullptr; - } - - static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - - void* m_sinkPtr; - - JSHTTPResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) - : Base(vm, structure) - { - m_sinkPtr = sinkPtr; - } - - void finishCreation(JSC::VM&); -}; - -class JSReadableHTTPResponseSinkController final : public JSC::JSDestructibleObject { -public: - using Base = JSC::JSDestructibleObject; - static JSReadableHTTPResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); - static constexpr SinkID Sink = SinkID::HTTPResponseSink; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSReadableHTTPResponseSinkController, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); }); - } - - static void destroy(JSC::JSCell*); - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); - - ~JSReadableHTTPResponseSinkController(); - - void* wrapped() const { return m_sinkPtr; } - void detach(); - - void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose); - DECLARE_VISIT_CHILDREN; - - static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - - void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; - mutable JSC::Weak<JSObject> m_weakReadableStream; - - JSReadableHTTPResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) - : Base(vm, structure) - { - m_sinkPtr = sinkPtr; - } - - void finishCreation(JSC::VM&); -}; + +class JSHTTPResponseSinkConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSHTTPResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype); + static constexpr SinkID Sink = SinkID::HTTPResponseSink; + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSHTTPResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); }); + } + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); + + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + private: + JSHTTPResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) + : Base(vm, structure, nativeFunction, nativeFunction) + + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); + }; + + class JSHTTPResponseSink final : public JSC::JSDestructibleObject { + public: + using Base = JSC::JSDestructibleObject; + static JSHTTPResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); + static constexpr SinkID Sink = SinkID::HTTPResponseSink; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSHTTPResponseSink, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); + + ~JSHTTPResponseSink(); + + void* wrapped() const { return m_sinkPtr; } + + void detach() { + m_sinkPtr = nullptr; + + } + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + + void* m_sinkPtr; + + JSHTTPResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_sinkPtr = sinkPtr; + } + + void finishCreation(JSC::VM&); + }; + + class JSReadableHTTPResponseSinkController final : public JSC::JSDestructibleObject { + public: + using Base = JSC::JSDestructibleObject; + static JSReadableHTTPResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); + static constexpr SinkID Sink = SinkID::HTTPResponseSink; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSReadableHTTPResponseSinkController, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); + + ~JSReadableHTTPResponseSinkController(); + + + void* wrapped() const { return m_sinkPtr; } + void detach(); + + void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose); + DECLARE_VISIT_CHILDREN; + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + + bool hasPendingActivity() { return m_hasPendingActivity; } + + void* m_sinkPtr; + bool m_hasPendingActivity; + mutable WriteBarrier<JSC::JSFunction> m_onPull; + mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable JSC::Weak<JSObject> m_weakReadableStream; + JSC::Weak<JSReadableHTTPResponseSinkController> m_weakThis; + + JSReadableHTTPResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_sinkPtr = sinkPtr; + m_hasPendingActivity = true; + m_weakThis = JSC::Weak<JSReadableHTTPResponseSinkController>(this, getOwner()); + } + + void finishCreation(JSC::VM&); + + class Owner final : public JSC::WeakHandleOwner { + public: + bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final + { + auto* controller = JSC::jsCast<JSReadableHTTPResponseSinkController*>(handle.slot()->asCell()); + return controller->hasPendingActivity(); + } + void finalize(JSC::Handle<JSC::Unknown>, void* context) final {} + }; + + static JSC::WeakHandleOwner* getOwner() + { + static NeverDestroyed<Owner> m_owner; + return &m_owner.get(); + } + }; JSC_DECLARE_CUSTOM_GETTER(functionHTTPResponseSink__getter); -class JSHTTPSResponseSinkConstructor final : public JSC::InternalFunction { -public: - using Base = JSC::InternalFunction; - static JSHTTPSResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype); - static constexpr SinkID Sink = SinkID::HTTPSResponseSink; - - static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSHTTPSResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); }); - } - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); - - // Must be defined for each specialization class. - static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); - -private: - JSHTTPSResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) - : Base(vm, structure, nativeFunction, nativeFunction) - - { - } - - void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); -}; - -class JSHTTPSResponseSink final : public JSC::JSDestructibleObject { -public: - using Base = JSC::JSDestructibleObject; - static JSHTTPSResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); - static constexpr SinkID Sink = SinkID::HTTPSResponseSink; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSHTTPSResponseSink, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); }); - } - - static void destroy(JSC::JSCell*); - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - - static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); - - ~JSHTTPSResponseSink(); - - void* wrapped() const { return m_sinkPtr; } - - void detach() - { - m_sinkPtr = nullptr; - } - - static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - - void* m_sinkPtr; - - JSHTTPSResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) - : Base(vm, structure) - { - m_sinkPtr = sinkPtr; - } - - void finishCreation(JSC::VM&); -}; - -class JSReadableHTTPSResponseSinkController final : public JSC::JSDestructibleObject { -public: - using Base = JSC::JSDestructibleObject; - static JSReadableHTTPSResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); - static constexpr SinkID Sink = SinkID::HTTPSResponseSink; - - DECLARE_EXPORT_INFO; - template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSReadableHTTPSResponseSinkController, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); }); - } - - static void destroy(JSC::JSCell*); - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - } - static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); - - ~JSReadableHTTPSResponseSinkController(); - - void* wrapped() const { return m_sinkPtr; } - void detach(); - - void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose); - DECLARE_VISIT_CHILDREN; - - static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - - void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; - mutable JSC::Weak<JSObject> m_weakReadableStream; - - JSReadableHTTPSResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) - : Base(vm, structure) - { - m_sinkPtr = sinkPtr; - } - - void finishCreation(JSC::VM&); -}; + +class JSHTTPSResponseSinkConstructor final : public JSC::InternalFunction { + public: + using Base = JSC::InternalFunction; + static JSHTTPSResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype); + static constexpr SinkID Sink = SinkID::HTTPSResponseSink; + + static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr bool needsDestruction = false; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSHTTPSResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); }); + } + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + } + void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); + + + // Must be defined for each specialization class. + static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); + + private: + JSHTTPSResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction) + : Base(vm, structure, nativeFunction, nativeFunction) + + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype); + }; + + class JSHTTPSResponseSink final : public JSC::JSDestructibleObject { + public: + using Base = JSC::JSDestructibleObject; + static JSHTTPSResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); + static constexpr SinkID Sink = SinkID::HTTPSResponseSink; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSHTTPSResponseSink, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); + + ~JSHTTPSResponseSink(); + + void* wrapped() const { return m_sinkPtr; } + + void detach() { + m_sinkPtr = nullptr; + + } + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + + void* m_sinkPtr; + + JSHTTPSResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_sinkPtr = sinkPtr; + } + + void finishCreation(JSC::VM&); + }; + + class JSReadableHTTPSResponseSinkController final : public JSC::JSDestructibleObject { + public: + using Base = JSC::JSDestructibleObject; + static JSReadableHTTPSResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr); + static constexpr SinkID Sink = SinkID::HTTPSResponseSink; + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSReadableHTTPSResponseSinkController, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); + + ~JSReadableHTTPSResponseSinkController(); + + + void* wrapped() const { return m_sinkPtr; } + void detach(); + + void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose); + DECLARE_VISIT_CHILDREN; + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + + bool hasPendingActivity() { return m_hasPendingActivity; } + + void* m_sinkPtr; + bool m_hasPendingActivity; + mutable WriteBarrier<JSC::JSFunction> m_onPull; + mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable JSC::Weak<JSObject> m_weakReadableStream; + JSC::Weak<JSReadableHTTPSResponseSinkController> m_weakThis; + + JSReadableHTTPSResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_sinkPtr = sinkPtr; + m_hasPendingActivity = true; + m_weakThis = JSC::Weak<JSReadableHTTPSResponseSinkController>(this, getOwner()); + } + + void finishCreation(JSC::VM&); + + class Owner final : public JSC::WeakHandleOwner { + public: + bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final + { + auto* controller = JSC::jsCast<JSReadableHTTPSResponseSinkController*>(handle.slot()->asCell()); + return controller->hasPendingActivity(); + } + void finalize(JSC::Handle<JSC::Unknown>, void* context) final {} + }; + + static JSC::WeakHandleOwner* getOwner() + { + static NeverDestroyed<Owner> m_owner; + return &m_owner.get(); + } + }; JSC_DECLARE_CUSTOM_GETTER(functionHTTPSResponseSink__getter); + + JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID); JSObject* createJSSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID); Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID); diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h index bdd669d20..c57b50618 100644 --- a/src/bun.js/bindings/JSSinkLookupTable.h +++ b/src/bun.js/bindings/JSSinkLookupTable.h @@ -1,4 +1,4 @@ -// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/jarred/Code/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! +// Automatically generated from src/bun.js/bindings/JSSink.cpp using /build/bun-webkit//Source/JavaScriptCore/create_hash_table. DO NOT EDIT! diff --git a/src/bun.js/generate-jssink.js b/src/bun.js/generate-jssink.js index 56ffcfb06..aac782222 100644 --- a/src/bun.js/generate-jssink.js +++ b/src/bun.js/generate-jssink.js @@ -100,10 +100,10 @@ function header() { ${className}(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) : Base(vm, structure) { - m_sinkPtr = sinkPtr; + m_sinkPtr = sinkPtr; } - void finishCreation(JSC::VM&); + void finishCreation(JSC::VM&); }; class ${controller} final : public JSC::JSDestructibleObject { @@ -141,20 +141,42 @@ function header() { void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose); DECLARE_VISIT_CHILDREN; - static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + + bool hasPendingActivity() { return m_hasPendingActivity; } + void* m_sinkPtr; + bool m_hasPendingActivity; mutable WriteBarrier<JSC::JSFunction> m_onPull; mutable WriteBarrier<JSC::JSFunction> m_onClose; mutable JSC::Weak<JSObject> m_weakReadableStream; + JSC::Weak<${controller}> m_weakThis; ${controller}(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) : Base(vm, structure) { - m_sinkPtr = sinkPtr; + m_sinkPtr = sinkPtr; + m_hasPendingActivity = true; + m_weakThis = JSC::Weak<${controller}>(this, getOwner()); } - void finishCreation(JSC::VM&); + void finishCreation(JSC::VM&); + + class Owner final : public JSC::WeakHandleOwner { + public: + bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final + { + auto* controller = JSC::jsCast<${controller}*>(handle.slot()->asCell()); + return controller->hasPendingActivity(); + } + void finalize(JSC::Handle<JSC::Unknown>, void* context) final {} + }; + + static JSC::WeakHandleOwner* getOwner() + { + static NeverDestroyed<Owner> m_owner; + return &m_owner.get(); + } }; JSC_DECLARE_CUSTOM_GETTER(function${name}__getter); @@ -186,7 +208,7 @@ JSC_DECLARE_HOST_FUNCTION(functionStartDirectStream); const bottom = ` JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID); JSObject* createJSSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID); - +Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID); } // namespace WebCore `; var templ = outer; @@ -369,6 +391,8 @@ JSC_DEFINE_HOST_FUNCTION(${controller}__close, (JSC::JSGlobalObject * lexicalGlo controller->detach(); ${name}__close(lexicalGlobalObject, ptr); + // Release the controller right before close. + controller->m_hasPendingActivity = false; return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -778,6 +802,25 @@ default: } }`; + templ += ` +Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID) +{ + switch (sinkID) { + `; + for (let name of classes) { + templ += ` + case ${name}: { + auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID); + return JSReadable${name}Controller::createStructure(vm, globalObject, prototype); + } +`; + } + templ += ` +default: + RELEASE_ASSERT_NOT_REACHED(); + } +}`; + templ += footer; for (let name of classes) { |