diff options
author | 2022-06-29 07:09:25 -0700 | |
---|---|---|
committer | 2022-06-29 07:09:25 -0700 | |
commit | 647110d5134d52ff59e6afe4503c9c1a7a19a45e (patch) | |
tree | 87784ad044d7de486ed98b1a7212046c19006931 | |
parent | 425846f86867d75ac9bfcf4fb0a7d6ae32f6bef8 (diff) | |
download | bun-647110d5134d52ff59e6afe4503c9c1a7a19a45e.tar.gz bun-647110d5134d52ff59e6afe4503c9c1a7a19a45e.tar.zst bun-647110d5134d52ff59e6afe4503c9c1a7a19a45e.zip |
[React SSR] Avoid `getById` slow path
thanks @Constellation
-rw-r--r-- | src/bun.js/bindings/JSSink.cpp | 167 | ||||
-rw-r--r-- | src/bun.js/bindings/JSSink.h | 849 | ||||
-rw-r--r-- | src/bun.js/bindings/JSSinkLookupTable.h | 187 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.h | 2 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.zig | 47 | ||||
-rw-r--r-- | src/bun.js/generate-jssink.js | 98 |
6 files changed, 812 insertions, 538 deletions
diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 22423127a..1e5e71662 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 /Users/jarred/Code/bun/src/bun.js/generate-jssink.js at 2022-06-26T11:24:51.211Z +// Generated by /Users/jarred/Code/bun/src/bun.js/generate-jssink.js at 2022-06-29T05:28:50.141Z // To regenerate this file, run: // // bun src/bun.js/generate-jssink.js @@ -194,24 +194,6 @@ JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexica return JSC::JSValue::encode(JSC::jsUndefined()); } -static const HashTableValue JSArrayBufferSinkPrototypeTableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__doClose), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__write), (intptr_t)(1) } }, - }; - -static const HashTableValue JSReadableArrayBufferSinkControllerPrototypeTableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableArrayBufferSinkController__close), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableArrayBufferSinkController__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__write), (intptr_t)(1) } }, - }; - JSC_DEFINE_CUSTOM_GETTER(functionHTTPResponseSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { auto& vm = lexicalGlobalObject->vm(); @@ -288,24 +270,6 @@ JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexic return JSC::JSValue::encode(JSC::jsUndefined()); } -static const HashTableValue JSHTTPResponseSinkPrototypeTableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__doClose), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__write), (intptr_t)(1) } }, - }; - -static const HashTableValue JSReadableHTTPResponseSinkControllerPrototypeTableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPResponseSinkController__close), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPResponseSinkController__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__write), (intptr_t)(1) } }, - }; - JSC_DEFINE_CUSTOM_GETTER(functionHTTPSResponseSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { auto& vm = lexicalGlobalObject->vm(); @@ -382,23 +346,67 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi return JSC::JSValue::encode(JSC::jsUndefined()); } -static const HashTableValue JSHTTPSResponseSinkPrototypeTableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__doClose), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__write), (intptr_t)(1) } }, - }; - -static const HashTableValue JSReadableHTTPSResponseSinkControllerPrototypeTableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPSResponseSinkController__close), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPSResponseSinkController__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__write), (intptr_t)(1) } }, - }; +#include "JSSinkLookupTable.h" + +/* Source for JSArrayBufferSinkPrototypeTableValues.lut.h +@begin JSArrayBufferSinkPrototypeTable + close ArrayBufferSink__doClose ReadOnly|DontDelete|Function 0 + drain ArrayBufferSink__drain ReadOnly|DontDelete|Function 1 + 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 + drain ArrayBufferSink__drain ReadOnly|DontDelete|Function 1 + end JSReadableArrayBufferSinkController__end ReadOnly|DontDelete|Function 0 + start ArrayBufferSink__start ReadOnly|DontDelete|Function 1 + write ArrayBufferSink__write ReadOnly|DontDelete|Function 1 +@end +*/ + +/* Source for JSHTTPResponseSinkPrototypeTableValues.lut.h +@begin JSHTTPResponseSinkPrototypeTable + close HTTPResponseSink__doClose ReadOnly|DontDelete|Function 0 + drain HTTPResponseSink__drain ReadOnly|DontDelete|Function 1 + 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 + drain HTTPResponseSink__drain ReadOnly|DontDelete|Function 1 + end JSReadableHTTPResponseSinkController__end ReadOnly|DontDelete|Function 0 + start HTTPResponseSink__start ReadOnly|DontDelete|Function 1 + write HTTPResponseSink__write ReadOnly|DontDelete|Function 1 +@end +*/ + +/* Source for JSHTTPSResponseSinkPrototypeTableValues.lut.h +@begin JSHTTPSResponseSinkPrototypeTable + close HTTPSResponseSink__doClose ReadOnly|DontDelete|Function 0 + drain HTTPSResponseSink__drain ReadOnly|DontDelete|Function 1 + 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 + drain HTTPSResponseSink__drain ReadOnly|DontDelete|Function 1 + end JSReadableHTTPSResponseSinkController__end ReadOnly|DontDelete|Function 0 + start HTTPSResponseSink__start ReadOnly|DontDelete|Function 1 + write HTTPSResponseSink__write ReadOnly|DontDelete|Function 1 +@end +*/ #pragma mark - ArrayBufferSink @@ -466,11 +474,11 @@ private: }; STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableArrayBufferSinkControllerPrototype, JSReadableArrayBufferSinkControllerPrototype::Base); -const ClassInfo JSArrayBufferSinkPrototype::s_info = { "ArrayBufferSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSArrayBufferSinkPrototype) }; +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, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableArrayBufferSinkControllerPrototype) }; +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) }; JSArrayBufferSink::~JSArrayBufferSink() @@ -487,6 +495,16 @@ JSReadableArrayBufferSinkController::~JSReadableArrayBufferSinkController() } } +JSObject* JSArrayBufferSink::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return JSArrayBufferSinkPrototype::create(vm, &globalObject, JSArrayBufferSinkPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} + +JSObject* JSReadableArrayBufferSinkController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return JSReadableArrayBufferSinkControllerPrototype::create(vm, &globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} + 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); @@ -672,11 +690,11 @@ private: }; STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPResponseSinkControllerPrototype, JSReadableHTTPResponseSinkControllerPrototype::Base); -const ClassInfo JSHTTPResponseSinkPrototype::s_info = { "HTTPResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPResponseSinkPrototype) }; +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, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPResponseSinkControllerPrototype) }; +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) }; JSHTTPResponseSink::~JSHTTPResponseSink() @@ -693,6 +711,16 @@ JSReadableHTTPResponseSinkController::~JSReadableHTTPResponseSinkController() } } +JSObject* JSHTTPResponseSink::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return JSHTTPResponseSinkPrototype::create(vm, &globalObject, JSHTTPResponseSinkPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} + +JSObject* JSReadableHTTPResponseSinkController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return JSReadableHTTPResponseSinkControllerPrototype::create(vm, &globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} + 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); @@ -878,11 +906,11 @@ private: }; STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPSResponseSinkControllerPrototype, JSReadableHTTPSResponseSinkControllerPrototype::Base); -const ClassInfo JSHTTPSResponseSinkPrototype::s_info = { "HTTPSResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPSResponseSinkPrototype) }; +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, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPSResponseSinkControllerPrototype) }; +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) }; JSHTTPSResponseSink::~JSHTTPSResponseSink() @@ -899,6 +927,16 @@ JSReadableHTTPSResponseSinkController::~JSReadableHTTPSResponseSinkController() } } +JSObject* JSHTTPSResponseSink::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return JSHTTPSResponseSinkPrototype::create(vm, &globalObject, JSHTTPSResponseSinkPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} + +JSObject* JSReadableHTTPSResponseSinkController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return JSReadableHTTPSResponseSinkControllerPrototype::create(vm, &globalObject, JSReadableHTTPSResponseSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} + 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); @@ -1096,8 +1134,7 @@ extern "C" JSC__JSValue ArrayBufferSink__assignToStream(JSC__JSGlobalObject* arg JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject(); auto scope = DECLARE_CATCH_SCOPE(vm); - JSC::JSValue prototype = globalObject->JSReadableArrayBufferSinkControllerPrototype(); - JSC::Structure* structure = WebCore::JSReadableArrayBufferSinkController::createStructure(vm, globalObject, prototype); + JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableArrayBufferSinkController>(vm, *globalObject); 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(); @@ -1195,8 +1232,7 @@ extern "C" JSC__JSValue HTTPResponseSink__assignToStream(JSC__JSGlobalObject* ar JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject(); auto scope = DECLARE_CATCH_SCOPE(vm); - JSC::JSValue prototype = globalObject->JSReadableHTTPResponseSinkControllerPrototype(); - JSC::Structure* structure = WebCore::JSReadableHTTPResponseSinkController::createStructure(vm, globalObject, prototype); + 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(); @@ -1294,8 +1330,7 @@ extern "C" JSC__JSValue HTTPSResponseSink__assignToStream(JSC__JSGlobalObject* a JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject(); auto scope = DECLARE_CATCH_SCOPE(vm); - JSC::JSValue prototype = globalObject->JSReadableHTTPSResponseSinkControllerPrototype(); - JSC::Structure* structure = WebCore::JSReadableHTTPSResponseSinkController::createStructure(vm, globalObject, prototype); + JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableHTTPSResponseSinkController>(vm, *globalObject); 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(); diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h index 014e3449f..af12eac09 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 /Users/jarred/Code/bun/src/bun.js/generate-jssink.js at 2022-06-26T11:24:51.209Z +// Generated by /Users/jarred/Code/bun/src/bun.js/generate-jssink.js at 2022-06-29T05:28:50.140Z // #pragma once @@ -17,436 +17,441 @@ 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()); - } - - ~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()); - } - - ~JSReadableArrayBufferSinkController(); - - - void* wrapped() const { return m_sinkPtr; } - void detach() { - m_sinkPtr = nullptr; - } - - 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() + { + m_sinkPtr = nullptr; + } + + 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&); +}; 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()); - } - - ~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()); - } - - ~JSReadableHTTPResponseSinkController(); - - - void* wrapped() const { return m_sinkPtr; } - void detach() { - m_sinkPtr = nullptr; - } - - 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() + { + m_sinkPtr = nullptr; + } + + 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&); +}; 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()); - } - - ~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()); - } - - ~JSReadableHTTPSResponseSinkController(); - - - void* wrapped() const { return m_sinkPtr; } - void detach() { - m_sinkPtr = nullptr; - } - - 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() + { + m_sinkPtr = nullptr; + } + + 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&); +}; 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); diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h new file mode 100644 index 000000000..f79fdb9b7 --- /dev/null +++ b/src/bun.js/bindings/JSSinkLookupTable.h @@ -0,0 +1,187 @@ +// 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! + +static const struct CompactHashIndex JSArrayBufferSinkPrototypeTableIndex[18] = { + { 1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 0, 16 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 4, -1 }, + { 2, 17 }, + { 3, -1 }, +}; + +static const struct HashTableValue JSArrayBufferSinkPrototypeTableValues[5] = { + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__doClose), (intptr_t)(0) } }, + { "drain"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__drain), (intptr_t)(1) } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__end), (intptr_t)(0) } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__start), (intptr_t)(1) } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__write), (intptr_t)(1) } }, +}; + +static const struct HashTable JSArrayBufferSinkPrototypeTable = { 5, 15, false, nullptr, JSArrayBufferSinkPrototypeTableValues, JSArrayBufferSinkPrototypeTableIndex }; + +static const struct CompactHashIndex JSReadableArrayBufferSinkControllerPrototypeTableIndex[18] = { + { 1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 0, 16 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 4, -1 }, + { 2, 17 }, + { 3, -1 }, +}; + +static const struct HashTableValue JSReadableArrayBufferSinkControllerPrototypeTableValues[5] = { + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableArrayBufferSinkController__close), (intptr_t)(0) } }, + { "drain"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__drain), (intptr_t)(1) } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableArrayBufferSinkController__end), (intptr_t)(0) } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__start), (intptr_t)(1) } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(ArrayBufferSink__write), (intptr_t)(1) } }, +}; + +static const struct HashTable JSReadableArrayBufferSinkControllerPrototypeTable = { 5, 15, false, nullptr, JSReadableArrayBufferSinkControllerPrototypeTableValues, JSReadableArrayBufferSinkControllerPrototypeTableIndex }; + +static const struct CompactHashIndex JSHTTPResponseSinkPrototypeTableIndex[18] = { + { 1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 0, 16 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 4, -1 }, + { 2, 17 }, + { 3, -1 }, +}; + +static const struct HashTableValue JSHTTPResponseSinkPrototypeTableValues[5] = { + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__doClose), (intptr_t)(0) } }, + { "drain"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__drain), (intptr_t)(1) } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__end), (intptr_t)(0) } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__start), (intptr_t)(1) } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__write), (intptr_t)(1) } }, +}; + +static const struct HashTable JSHTTPResponseSinkPrototypeTable = { 5, 15, false, nullptr, JSHTTPResponseSinkPrototypeTableValues, JSHTTPResponseSinkPrototypeTableIndex }; + +static const struct CompactHashIndex JSReadableHTTPResponseSinkControllerPrototypeTableIndex[18] = { + { 1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 0, 16 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 4, -1 }, + { 2, 17 }, + { 3, -1 }, +}; + +static const struct HashTableValue JSReadableHTTPResponseSinkControllerPrototypeTableValues[5] = { + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPResponseSinkController__close), (intptr_t)(0) } }, + { "drain"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__drain), (intptr_t)(1) } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPResponseSinkController__end), (intptr_t)(0) } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__start), (intptr_t)(1) } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPResponseSink__write), (intptr_t)(1) } }, +}; + +static const struct HashTable JSReadableHTTPResponseSinkControllerPrototypeTable = { 5, 15, false, nullptr, JSReadableHTTPResponseSinkControllerPrototypeTableValues, JSReadableHTTPResponseSinkControllerPrototypeTableIndex }; + +static const struct CompactHashIndex JSHTTPSResponseSinkPrototypeTableIndex[18] = { + { 1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 0, 16 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 4, -1 }, + { 2, 17 }, + { 3, -1 }, +}; + +static const struct HashTableValue JSHTTPSResponseSinkPrototypeTableValues[5] = { + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__doClose), (intptr_t)(0) } }, + { "drain"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__drain), (intptr_t)(1) } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__end), (intptr_t)(0) } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__start), (intptr_t)(1) } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__write), (intptr_t)(1) } }, +}; + +static const struct HashTable JSHTTPSResponseSinkPrototypeTable = { 5, 15, false, nullptr, JSHTTPSResponseSinkPrototypeTableValues, JSHTTPSResponseSinkPrototypeTableIndex }; + +static const struct CompactHashIndex JSReadableHTTPSResponseSinkControllerPrototypeTableIndex[18] = { + { 1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 0, 16 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 4, -1 }, + { 2, 17 }, + { 3, -1 }, +}; + +static const struct HashTableValue JSReadableHTTPSResponseSinkControllerPrototypeTableValues[5] = { + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPSResponseSinkController__close), (intptr_t)(0) } }, + { "drain"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__drain), (intptr_t)(1) } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(JSReadableHTTPSResponseSinkController__end), (intptr_t)(0) } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__start), (intptr_t)(1) } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(HTTPSResponseSink__write), (intptr_t)(1) } }, +}; + +static const struct HashTable JSReadableHTTPSResponseSinkControllerPrototypeTable = { 5, 15, false, nullptr, JSReadableHTTPSResponseSinkControllerPrototypeTableValues, JSReadableHTTPSResponseSinkControllerPrototypeTableIndex }; diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index 6d866d082..660e8b250 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -1,5 +1,5 @@ // clang-format off -//-- AUTOGENERATED FILE -- 1656336782 +//-- AUTOGENERATED FILE -- 1656340744 #pragma once #include <stddef.h> diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig index 54b132d79..10a13dc97 100644 --- a/src/bun.js/bindings/headers.zig +++ b/src/bun.js/bindings/headers.zig @@ -83,47 +83,47 @@ pub const __mbstate_t = extern union { __mbstate8: [128]u8, _mbstateL: c_longlong, }; - + pub const VirtualMachine = struct_VirtualMachine; - + pub const JSC__GeneratorPrototype = struct_JSC__GeneratorPrototype; - + pub const JSC__ArrayIteratorPrototype = struct_JSC__ArrayIteratorPrototype; - + pub const JSC__JSPromisePrototype = struct_JSC__JSPromisePrototype; pub const JSC__PropertyName = bJSC__PropertyName; pub const JSC__JSObject = bJSC__JSObject; pub const WTF__ExternalStringImpl = bWTF__ExternalStringImpl; - + pub const JSC__AsyncIteratorPrototype = struct_JSC__AsyncIteratorPrototype; pub const JSC__JSModuleLoader = bJSC__JSModuleLoader; - + pub const JSC__AsyncGeneratorPrototype = struct_JSC__AsyncGeneratorPrototype; - + pub const JSC__AsyncGeneratorFunctionPrototype = struct_JSC__AsyncGeneratorFunctionPrototype; pub const JSC__Identifier = bJSC__Identifier; - + pub const JSC__ArrayPrototype = struct_JSC__ArrayPrototype; - + pub const Zig__JSMicrotaskCallback = struct_Zig__JSMicrotaskCallback; pub const JSC__JSPromise = bJSC__JSPromise; - + pub const JSC__SetIteratorPrototype = struct_JSC__SetIteratorPrototype; pub const JSC__JSCell = bJSC__JSCell; pub const JSC__SourceOrigin = bJSC__SourceOrigin; pub const JSC__JSModuleRecord = bJSC__JSModuleRecord; pub const WTF__String = bWTF__String; pub const WTF__URL = bWTF__URL; - + pub const JSC__IteratorPrototype = struct_JSC__IteratorPrototype; pub const JSC__JSInternalPromise = bJSC__JSInternalPromise; - + pub const JSC__RegExpPrototype = struct_JSC__RegExpPrototype; - + pub const JSC__CallFrame = struct_JSC__CallFrame; - + pub const JSC__MapIteratorPrototype = struct_JSC__MapIteratorPrototype; - + pub const WebCore__FetchHeaders = struct_WebCore__FetchHeaders; pub const WTF__StringView = bWTF__StringView; pub const JSC__ThrowScope = bJSC__ThrowScope; @@ -131,23 +131,24 @@ pub const WTF__StringImpl = bWTF__StringImpl; pub const JSC__VM = bJSC__VM; pub const JSC__JSGlobalObject = bJSC__JSGlobalObject; pub const JSC__JSFunction = bJSC__JSFunction; - + pub const JSC__AsyncFunctionPrototype = struct_JSC__AsyncFunctionPrototype; pub const JSC__SourceCode = bJSC__SourceCode; - + pub const JSC__BigIntPrototype = struct_JSC__BigIntPrototype; - + pub const JSC__GeneratorFunctionPrototype = struct_JSC__GeneratorFunctionPrototype; - + pub const WebCore__DOMURL = struct_WebCore__DOMURL; - + + pub const JSC__FunctionPrototype = struct_JSC__FunctionPrototype; pub const Inspector__ScriptArguments = bInspector__ScriptArguments; pub const JSC__Exception = bJSC__Exception; pub const JSC__JSString = bJSC__JSString; - + pub const JSC__ObjectPrototype = struct_JSC__ObjectPrototype; - + pub const JSC__StringPrototype = struct_JSC__StringPrototype; pub extern fn JSC__JSObject__create(arg0: [*c]JSC__JSGlobalObject, arg1: usize, arg2: ?*anyopaque, ArgFn3: ?fn (?*anyopaque, [*c]JSC__JSObject, [*c]JSC__JSGlobalObject) callconv(.C) void) JSC__JSValue; pub extern fn JSC__JSObject__getArrayLength(arg0: [*c]JSC__JSObject) usize; @@ -486,4 +487,4 @@ pub extern fn HTTPResponseSink__detachPtr(JSValue0: JSC__JSValue) void; pub extern fn HTTPResponseSink__fromJS(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque; pub extern fn HTTPResponseSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void; pub extern fn HTTPResponseSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void; -pub extern fn ZigException__fromException(arg0: [*c]JSC__Exception) ZigException; +pub extern fn ZigException__fromException(arg0: [*c]JSC__Exception) ZigException;
\ No newline at end of file diff --git a/src/bun.js/generate-jssink.js b/src/bun.js/generate-jssink.js index 5ff5827ba..d272f60a6 100644 --- a/src/bun.js/generate-jssink.js +++ b/src/bun.js/generate-jssink.js @@ -80,7 +80,9 @@ function header() { 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); ~${className}(); @@ -126,7 +128,8 @@ function header() { 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); ~${controller}(); @@ -252,12 +255,15 @@ async function implementation() { #include "JavaScriptCore/Weak.h" #include "JavaScriptCore/WeakInlines.h" + + namespace WebCore { using namespace JSC; + JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame)) { @@ -332,7 +338,8 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic controllerPrototypeName, constructor, } = names(name); - + const protopad = `${controller}__close`.length; + const padding = `${name}__doClose`.length; templ += ` JSC_DEFINE_CUSTOM_GETTER(function${name}__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { @@ -413,33 +420,64 @@ JSC_DEFINE_HOST_FUNCTION(${name}__doClose, (JSC::JSGlobalObject * lexicalGlobalO } +`; + } + templ += ` +#include "JSSinkLookupTable.h" + `; -static const HashTableValue JS${name}PrototypeTableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__doClose), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__write), (intptr_t)(1) } }, - }; - -static const HashTableValue ${controllerPrototypeName}TableValues[] - = { - { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${controller}__close), (intptr_t)(0) } }, - { "drain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__drain), (intptr_t)(1) } }, - { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${controller}__end), (intptr_t)(0) } }, - { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__start), (intptr_t)(1) } }, - { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(${name}__write), (intptr_t)(1) } }, - }; + for (let name of classes) { + const { + className, + controller, + prototypeName, + controllerName, + controllerPrototypeName, + constructor, + } = names(name); + const protopad = `${controller}__close`.length; + const padding = `${name}__doClose`.length; + templ += ` +/* Source for JS${name}PrototypeTableValues.lut.h +@begin JS${name}PrototypeTable + close ${`${name}__doClose`.padEnd( + padding + 8 + )} ReadOnly|DontDelete|Function 0 + drain ${`${name}__drain`.padEnd(padding + 8)} ReadOnly|DontDelete|Function 1 + end ${`${name}__end`.padEnd(padding + 8)} ReadOnly|DontDelete|Function 0 + start ${`${name}__start`.padEnd(padding + 8)} ReadOnly|DontDelete|Function 1 + write ${`${name}__write`.padEnd(padding + 8)} ReadOnly|DontDelete|Function 1 +@end +*/ + + +/* Source for ${controllerPrototypeName}TableValues.lut.h +@begin ${controllerPrototypeName}Table + close ${`${controller}__close`.padEnd( + protopad + 4 + )} ReadOnly|DontDelete|Function 0 + drain ${`${name}__drain`.padEnd( + protopad + 4 + )} ReadOnly|DontDelete|Function 1 + end ${`${controller}__end`.padEnd( + protopad + 4 + )} ReadOnly|DontDelete|Function 0 + start ${`${name}__start`.padEnd( + protopad + 4 + )} ReadOnly|DontDelete|Function 1 + write ${`${name}__write`.padEnd( + protopad + 4 + )} ReadOnly|DontDelete|Function 1 +@end +*/ -`; + `; } templ += ` ${(await Bun.file(import.meta.dir + "/bindings/JSSink+custom.h").text()).trim()} `; - const footer = ` } // namespace WebCore @@ -521,12 +559,12 @@ class ${controllerPrototypeName} final : public JSC::JSNonFinalObject { }; STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(${controllerPrototypeName}, ${controllerPrototypeName}::Base); -const ClassInfo ${prototypeName}::s_info = { "${name}"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(${prototypeName}) }; +const ClassInfo ${prototypeName}::s_info = { "${name}"_s, &Base::s_info, &JS${name}PrototypeTable, nullptr, CREATE_METHOD_TABLE(${prototypeName}) }; const ClassInfo ${className}::s_info = { "${name}"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(${className}) }; const ClassInfo ${constructor}::s_info = { "${name}"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(${constructor}) }; -const ClassInfo ${controllerPrototypeName}::s_info = { "${controllerName}"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(${controllerPrototypeName}) }; +const ClassInfo ${controllerPrototypeName}::s_info = { "${controllerName}"_s, &Base::s_info, &${controllerPrototypeName}Table, nullptr, CREATE_METHOD_TABLE(${controllerPrototypeName}) }; const ClassInfo ${controller}::s_info = { "${controllerName}"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(${controller}) }; ${className}::~${className}() @@ -544,6 +582,15 @@ ${controller}::~${controller}() } } +JSObject* ${className}::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return ${prototypeName}::create(vm, &globalObject, ${prototypeName}::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} + +JSObject* JS${controllerName}::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +{ + return ${controllerPrototypeName}::create(vm, &globalObject, ${controllerPrototypeName}::createStructure(vm, &globalObject, globalObject.objectPrototype())); +} `; @@ -765,8 +812,7 @@ extern "C" JSC__JSValue ${name}__assignToStream(JSC__JSGlobalObject* arg0, JSC__ JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject(); auto scope = DECLARE_CATCH_SCOPE(vm); - JSC::JSValue prototype = globalObject->${controllerPrototypeName}(); - JSC::Structure* structure = WebCore::${controller}::createStructure(vm, globalObject, prototype); + JSC::Structure* structure = WebCore::getDOMStructure<WebCore::${controller}>(vm, *globalObject); WebCore::${controller} *controller = WebCore::${controller}::create(vm, globalObject, structure, sinkPtr); *controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller)); JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject(); |