diff options
Diffstat (limited to 'src/bun.js')
60 files changed, 926 insertions, 710 deletions
diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 752adea1e..24e5db5c6 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -1929,7 +1929,7 @@ fn NewSocket(comptime ssl: bool) type { } pub fn finalize(this: *This) callconv(.C) void { - log("finalize()", .{}); + log("finalize() {d}", .{@intFromPtr(this)}); if (!this.detached) { this.detached = true; if (!this.socket.isClosed()) { diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 26d5d74c3..6fcfb8a36 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -1178,8 +1178,7 @@ pub fn DOMCall( \\ thisObject->putDirect( \\ globalObject->vm(), \\ Identifier::fromString(globalObject->vm(), "{[name]s}"_s), - \\ function, - \\ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + \\ function \\ ); \\}} ; diff --git a/src/bun.js/bindings/AsyncContextFrame.cpp b/src/bun.js/bindings/AsyncContextFrame.cpp index 1c541b2a8..7b715d3d7 100644 --- a/src/bun.js/bindings/AsyncContextFrame.cpp +++ b/src/bun.js/bindings/AsyncContextFrame.cpp @@ -22,7 +22,7 @@ AsyncContextFrame* AsyncContextFrame::create(VM& vm, JSC::Structure* structure, AsyncContextFrame* AsyncContextFrame::create(JSGlobalObject* global, JSValue callback, JSValue context) { auto& vm = global->vm(); - AsyncContextFrame* asyncContextData = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, static_cast<Zig::GlobalObject*>(global)->AsyncContextFrameStructure()); + AsyncContextFrame* asyncContextData = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, jsCast<Zig::GlobalObject*>(global)->AsyncContextFrameStructure()); asyncContextData->finishCreation(vm); asyncContextData->callback.set(vm, asyncContextData, callback); asyncContextData->context.set(vm, asyncContextData, context); @@ -47,7 +47,7 @@ JSValue AsyncContextFrame::withAsyncContextIfNeeded(JSGlobalObject* globalObject auto& vm = globalObject->vm(); return AsyncContextFrame::create( vm, - static_cast<Zig::GlobalObject*>(globalObject)->AsyncContextFrameStructure(), + jsCast<Zig::GlobalObject*>(globalObject)->AsyncContextFrameStructure(), callback, context); } diff --git a/src/bun.js/bindings/BunObject.cpp b/src/bun.js/bindings/BunObject.cpp index 9d8ce6674..498b83b45 100644 --- a/src/bun.js/bindings/BunObject.cpp +++ b/src/bun.js/bindings/BunObject.cpp @@ -190,7 +190,7 @@ static JSValue constructPluginObject(VM& vm, JSObject* bunObject) auto* globalObject = bunObject->globalObject(); JSFunction* pluginFunction = JSFunction::create(vm, globalObject, 1, String("plugin"_s), jsFunctionBunPlugin, ImplementationVisibility::Public, NoIntrinsic); pluginFunction->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "clearAll"_s), 1, jsFunctionBunPluginClear, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); return pluginFunction; } @@ -222,33 +222,33 @@ static JSValue constructDNSObject(VM& vm, JSObject* bunObject) JSGlobalObject* globalObject = bunObject->globalObject(); JSC::JSObject* dnsObject = JSC::constructEmptyObject(globalObject); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookup"_s), 2, Bun__DNSResolver__lookup, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolve"_s), 2, Bun__DNSResolver__resolve, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSrv"_s), 2, Bun__DNSResolver__resolveSrv, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveTxt"_s), 2, Bun__DNSResolver__resolveTxt, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSoa"_s), 2, Bun__DNSResolver__resolveSoa, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNaptr"_s), 2, Bun__DNSResolver__resolveNaptr, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveMx"_s), 2, Bun__DNSResolver__resolveMx, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCaa"_s), 2, Bun__DNSResolver__resolveCaa, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNs"_s), 2, Bun__DNSResolver__resolveNs, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolvePtr"_s), 2, Bun__DNSResolver__resolvePtr, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCname"_s), 2, Bun__DNSResolver__resolveCname, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getServers"_s), 2, Bun__DNSResolver__getServers, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reverse"_s), 2, Bun__DNSResolver__reverse, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookupService"_s), 2, Bun__DNSResolver__lookupService, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + JSC::PropertyAttribute::DontDelete | 0); return dnsObject; } @@ -258,7 +258,7 @@ static JSValue constructBunPeekObject(VM& vm, JSObject* bunObject) JSC::Identifier identifier = JSC::Identifier::fromString(vm, "peek"_s); JSFunction* peekFunction = JSFunction::create(vm, globalObject, 2, WTF::String("peek"_s), functionBunPeek, ImplementationVisibility::Public, NoIntrinsic); JSFunction* peekStatus = JSFunction::create(vm, globalObject, 1, WTF::String("status"_s), functionBunPeekStatus, ImplementationVisibility::Public, NoIntrinsic); - peekFunction->putDirect(vm, PropertyName(JSC::Identifier::fromString(vm, "status"_s)), peekStatus, JSC::PropertyAttribute::Function | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0); + peekFunction->putDirect(vm, PropertyName(JSC::Identifier::fromString(vm, "status"_s)), peekStatus, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0); return peekFunction; } @@ -663,6 +663,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBunObject, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -673,15 +674,14 @@ public: void finishCreation(JSC::VM& vm) { Base::finishCreation(vm); - JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } static JSBunObject* create(JSC::VM& vm, JSGlobalObject* globalObject) { - auto* object = new (NotNull, JSC::allocateCell<JSBunObject>(vm)) JSBunObject(vm, createStructure(vm, globalObject, globalObject->objectPrototype())); + auto structure = createStructure(vm, globalObject, globalObject->objectPrototype()); + auto* object = new (NotNull, JSC::allocateCell<JSBunObject>(vm)) JSBunObject(vm, structure); object->finishCreation(vm); - return object; } }; @@ -702,11 +702,11 @@ public: #undef bunObjectReadableStreamToJSONCodeGenerator #undef bunObjectReadableStreamToTextCodeGenerator -const JSC::ClassInfo JSBunObject::s_info = { "Bun"_s, &JSNonFinalObject::s_info, &bunObjectTable, nullptr, CREATE_METHOD_TABLE(JSBunObject) }; +const JSC::ClassInfo JSBunObject::s_info = { "Bun"_s, &Base::s_info, &bunObjectTable, nullptr, CREATE_METHOD_TABLE(JSBunObject) }; JSC::JSObject* createBunObject(VM& vm, JSObject* globalObject) { - return JSBunObject::create(vm, static_cast<Zig::GlobalObject*>(globalObject)); + return JSBunObject::create(vm, jsCast<Zig::GlobalObject*>(globalObject)); } } diff --git a/src/bun.js/bindings/BunPlugin.cpp b/src/bun.js/bindings/BunPlugin.cpp index b53fcf313..e0527c724 100644 --- a/src/bun.js/bindings/BunPlugin.cpp +++ b/src/bun.js/bindings/BunPlugin.cpp @@ -11,6 +11,7 @@ #include "JavaScriptCore/JSObjectInlines.h" #include "wtf/text/WTFString.h" #include "JavaScriptCore/JSCInlines.h" +#include "JavaScriptCore/StrongInlines.h" #include "JavaScriptCore/ObjectConstructor.h" #include "JavaScriptCore/SubspaceInlines.h" diff --git a/src/bun.js/bindings/BunString.cpp b/src/bun.js/bindings/BunString.cpp index 2db2694f3..99fd02175 100644 --- a/src/bun.js/bindings/BunString.cpp +++ b/src/bun.js/bindings/BunString.cpp @@ -3,7 +3,7 @@ #include "JavaScriptCore/JSCJSValueInlines.h" #include "helpers.h" #include "simdutf.h" -#include "wtf/text/ExternalStringImpl.h" +#include "wtf/Seconds.h" #include "GCDefferalContext.h" #include <JavaScriptCore/JSONObject.h> #include <wtf/text/AtomString.h> diff --git a/src/bun.js/bindings/CallSitePrototype.h b/src/bun.js/bindings/CallSitePrototype.h index 000bce2de..8aa543fd3 100644 --- a/src/bun.js/bindings/CallSitePrototype.h +++ b/src/bun.js/bindings/CallSitePrototype.h @@ -26,6 +26,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(CallSitePrototype, Base); return &vm.plainObjectSpace(); } diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index 38b55ba4d..f47c57559 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -196,11 +196,25 @@ static const HashTableValue RequireFunctionPrototypeValues[] = { { "cache"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, jsRequireCacheGetter, jsRequireCacheSetter } }, }; +Structure* RequireFunctionPrototype::createStructure( + JSC::VM& vm, + JSC::JSGlobalObject* globalObject) +{ + return Structure::create(vm, globalObject, globalObject->functionPrototype(), TypeInfo(JSFunctionType, StructureFlags), info()); +} + +Structure* RequireResolveFunctionPrototype::createStructure( + JSC::VM& vm, + JSC::JSGlobalObject* globalObject) +{ + return Structure::create(vm, globalObject, globalObject->functionPrototype(), TypeInfo(JSFunctionType, StructureFlags), info()); +} + RequireResolveFunctionPrototype* RequireResolveFunctionPrototype::create(JSC::JSGlobalObject* globalObject) { auto& vm = globalObject->vm(); - auto* structure = RequireResolveFunctionPrototype::createStructure(vm, globalObject, globalObject->functionPrototype()); + auto* structure = RequireResolveFunctionPrototype::createStructure(vm, globalObject); RequireResolveFunctionPrototype* prototype = new (NotNull, JSC::allocateCell<RequireResolveFunctionPrototype>(vm)) RequireResolveFunctionPrototype(vm, structure); prototype->finishCreation(vm); return prototype; @@ -211,11 +225,11 @@ RequireFunctionPrototype* RequireFunctionPrototype::create( { auto& vm = globalObject->vm(); - auto* structure = RequireFunctionPrototype::createStructure(vm, globalObject, globalObject->functionPrototype()); + auto* structure = RequireFunctionPrototype::createStructure(vm, globalObject); RequireFunctionPrototype* prototype = new (NotNull, JSC::allocateCell<RequireFunctionPrototype>(vm)) RequireFunctionPrototype(vm, structure); prototype->finishCreation(vm); - prototype->putDirect(vm, JSC::Identifier::fromString(vm, "resolve"_s), static_cast<Zig::GlobalObject*>(globalObject)->requireResolveFunctionUnbound(), PropertyAttribute::Function | 0); + prototype->putDirect(vm, JSC::Identifier::fromString(vm, "resolve"_s), jsCast<Zig::GlobalObject*>(globalObject)->requireResolveFunctionUnbound(), 0); return prototype; } @@ -223,7 +237,7 @@ RequireFunctionPrototype* RequireFunctionPrototype::create( void RequireFunctionPrototype::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); - ASSERT(inherits(vm, info())); + ASSERT(inherits(info())); reifyStaticProperties(vm, info(), RequireFunctionPrototypeValues, *this); JSC::JSFunction* requireDotMainFunction = JSFunction::create( @@ -231,11 +245,11 @@ void RequireFunctionPrototype::finishCreation(JSC::VM& vm) moduleMainCodeGenerator(vm), globalObject()->globalScope()); - this->putDirect( - vm, + this->putDirectAccessor( + globalObject(), JSC::Identifier::fromString(vm, "main"_s), - JSC::GetterSetter::create(vm, globalObject(), requireDotMainFunction, JSValue()), - PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | 0); + JSC::GetterSetter::create(vm, globalObject(), requireDotMainFunction, requireDotMainFunction), + PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | 0); auto extensions = constructEmptyObject(globalObject()); extensions->putDirect(vm, JSC::Identifier::fromString(vm, ".js"_s), jsBoolean(true), 0); @@ -325,6 +339,16 @@ JSC_DEFINE_CUSTOM_GETTER(getterPaths, (JSC::JSGlobalObject * globalObject, JSC:: return JSValue::encode(thisObject->m_paths.get()); } +JSC_DEFINE_CUSTOM_GETTER(getterLoaded, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast<JSCommonJSModule*>(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) { + return JSValue::encode(jsUndefined()); + } + + return JSValue::encode(jsBoolean(thisObject->hasEvaluated)); +} + JSC_DEFINE_CUSTOM_SETTER(setterPaths, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName propertyName)) @@ -372,12 +396,19 @@ JSC_DEFINE_CUSTOM_SETTER(setterParent, return true; } - -static JSValue createLoaded(VM& vm, JSObject* object) +JSC_DEFINE_CUSTOM_SETTER(setterLoaded, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue value, JSC::PropertyName propertyName)) { - JSCommonJSModule* cjs = jsCast<JSCommonJSModule*>(object); - return jsBoolean(cjs->hasEvaluated); + JSCommonJSModule* thisObject = jsDynamicCast<JSCommonJSModule*>(JSValue::decode(thisValue)); + if (!thisObject) + return false; + + thisObject->hasEvaluated = JSValue::decode(value).toBoolean(globalObject); + + return true; } + static JSValue createChildren(VM& vm, JSObject* object) { return constructEmptyArray(object->globalObject(), nullptr, 0); @@ -445,7 +476,7 @@ static const struct HashTableValue JSCommonJSModulePrototypeTableValues[] = { { "children"_s, static_cast<unsigned>(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, createChildren } }, { "filename"_s, static_cast<unsigned>(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterFilename, setterFilename } }, { "id"_s, static_cast<unsigned>(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterId, setterId } }, - { "loaded"_s, static_cast<unsigned>(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, createLoaded } }, + { "loaded"_s, static_cast<unsigned>(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterLoaded, setterLoaded } }, { "parent"_s, static_cast<unsigned>(PropertyAttribute::CustomAccessor | PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, getterParent, setterParent } }, { "path"_s, static_cast<unsigned>(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterPath, setterPath } }, { "paths"_s, static_cast<unsigned>(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterPaths, setterPaths } }, @@ -464,6 +495,14 @@ public: return prototype; } + static JSC::Structure* createStructure( + JSC::VM& vm, + JSC::JSGlobalObject* globalObject, + JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + DECLARE_INFO; JSCommonJSModulePrototype( @@ -476,14 +515,15 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCommonJSModulePrototype, Base); return &vm.plainObjectSpace(); } void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { Base::finishCreation(vm); - ASSERT(inherits(vm, info())); - reifyStaticProperties(vm, JSCommonJSModule::info(), JSCommonJSModulePrototypeTableValues, *this); + ASSERT(inherits(info())); + reifyStaticProperties(vm, info(), JSCommonJSModulePrototypeTableValues, *this); this->putDirectNativeFunction( vm, @@ -494,16 +534,17 @@ public: } }; -const JSC::ClassInfo JSCommonJSModulePrototype::s_info = { "Module"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommonJSModulePrototype) }; +const JSC::ClassInfo JSCommonJSModulePrototype::s_info = { "ModulePrototype"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommonJSModulePrototype) }; void JSCommonJSModule::finishCreation(JSC::VM& vm, JSC::JSString* id, JSValue filename, JSC::JSString* dirname, JSC::JSSourceCode* sourceCode) { Base::finishCreation(vm); - ASSERT(inherits(vm, info())); + ASSERT(inherits(info())); m_id.set(vm, this, id); m_filename.set(vm, this, filename); m_dirname.set(vm, this, dirname); - this->sourceCode.set(vm, this, sourceCode); + if (sourceCode) + this->sourceCode.set(vm, this, sourceCode); } JSC::Structure* JSCommonJSModule::createStructure( @@ -569,7 +610,7 @@ JSCommonJSModule* JSCommonJSModule::create( vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), exportsObject, - exportsObject.isCallable() ? JSC::PropertyAttribute::Function | 0 : 0); + 0); out->hasEvaluated = hasEvaluated; out->m_parent.set(vm, out, parent); @@ -644,7 +685,7 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject, bool needsToAssignDefault = true; if (result.isObject()) { - auto* exports = asObject(result); + auto* exports = result.getObject(); auto* structure = exports->structure(); uint32_t size = structure->inlineSize() + structure->outOfLineSize(); @@ -774,18 +815,6 @@ JSValue JSCommonJSModule::id() return m_id.get(); } -template<typename, SubspaceAccess mode> JSC::GCClient::IsoSubspace* JSCommonJSModule::subspaceFor(JSC::VM& vm) -{ - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSCommonJSModule, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForCommonJSModuleRecord.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCommonJSModuleRecord = std::forward<decltype(space)>(space); }, - [](auto& spaces) { return spaces.m_subspaceForCommonJSModuleRecord.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForCommonJSModuleRecord = std::forward<decltype(space)>(space); }); -} - Structure* createCommonJSModuleStructure( Zig::GlobalObject* globalObject) { @@ -849,9 +878,9 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlo void RequireResolveFunctionPrototype::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); - ASSERT(inherits(vm, info())); + ASSERT(inherits(info())); - reifyStaticProperties(vm, RequireResolveFunctionPrototype::info(), RequireResolveFunctionPrototypeValues, *this); + reifyStaticProperties(vm, info(), RequireResolveFunctionPrototypeValues, *this); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } @@ -995,8 +1024,6 @@ JSObject* JSCommonJSModule::createBoundRequireFunction(VM& vm, JSGlobalObject* l globalObject->CommonJSModuleObjectStructure(), filename, filename, dirname, nullptr); - auto& builtinNames = WebCore::builtinNames(vm); - JSFunction* requireFunction = JSC::JSBoundFunction::create(vm, globalObject, globalObject->requireFunctionUnbound(), @@ -1009,7 +1036,7 @@ JSObject* JSCommonJSModule::createBoundRequireFunction(VM& vm, JSGlobalObject* l moduleObject, ArgList(), 1, jsString(vm, String("resolve"_s))); - requireFunction->putDirect(vm, builtinNames.resolvePublicName(), resolveFunction, PropertyAttribute::Function | 0); + requireFunction->putDirect(vm, vm.propertyNames->resolve, resolveFunction, 0); return requireFunction; } diff --git a/src/bun.js/bindings/CommonJSModuleRecord.h b/src/bun.js/bindings/CommonJSModuleRecord.h index 2f9ba648f..37353978e 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.h +++ b/src/bun.js/bindings/CommonJSModuleRecord.h @@ -72,11 +72,21 @@ public: JSValue exportsObject(); JSValue id(); + DECLARE_INFO; DECLARE_VISIT_CHILDREN; - DECLARE_INFO; template<typename, SubspaceAccess mode> - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm); + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSCommonJSModule, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForCommonJSModuleRecord.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCommonJSModuleRecord = std::forward<decltype(space)>(space); }, + [](auto& spaces) { return spaces.m_subspaceForCommonJSModuleRecord.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForCommonJSModuleRecord = std::forward<decltype(space)>(space); }); + } bool hasEvaluated = false; @@ -110,7 +120,9 @@ inline std::optional<JSC::SourceCode> createCommonJSModule( class RequireResolveFunctionPrototype final : public JSC::JSNonFinalObject { public: using Base = JSC::JSNonFinalObject; + static RequireResolveFunctionPrototype* create(JSC::JSGlobalObject* globalObject); + static Structure* createStructure(VM& vm, JSC::JSGlobalObject* globalObject); DECLARE_INFO; @@ -124,6 +136,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(RequireResolveFunctionPrototype, Base); return &vm.plainObjectSpace(); } @@ -133,7 +146,11 @@ public: class RequireFunctionPrototype final : public JSC::JSNonFinalObject { public: using Base = JSC::JSNonFinalObject; + static RequireFunctionPrototype* create(JSC::JSGlobalObject* globalObject); + static Structure* createStructure(VM& vm, JSC::JSGlobalObject* globalObject); + + DECLARE_INFO; RequireFunctionPrototype( JSC::VM& vm, @@ -145,12 +162,11 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(RequireFunctionPrototype, Base); return &vm.plainObjectSpace(); } - DECLARE_INFO; - - void finishCreation(JSC::VM& vm); + void finishCreation(JSC::VM&); }; } // namespace Bun diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp index 340c3319b..199a13392 100644 --- a/src/bun.js/bindings/ImportMetaObject.cpp +++ b/src/bun.js/bindings/ImportMetaObject.cpp @@ -266,7 +266,7 @@ extern "C" EncodedJSValue functionImportMeta__resolveSyncPrivate(JSC::JSGlobalOb if (LIKELY(global)) { auto overrideHandler = global->m_nodeModuleOverriddenResolveFilename.get(); if (UNLIKELY(overrideHandler)) { - ASSERT(overrideHandler.isCallable(globalObject)); + ASSERT(overrideHandler->isCallable()); MarkedArgumentBuffer args; args.append(moduleName); args.append(from); @@ -434,6 +434,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(ImportMetaObjectPrototype, Base); return &vm.plainObjectSpace(); } @@ -447,11 +448,13 @@ public: reifyStaticProperties(vm, ImportMetaObject::info(), ImportMetaObjectPrototypeValues, *this); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); - this->putDirect( - vm, + auto mainGetter = JSFunction::create(vm, importMetaObjectMainCodeGenerator(vm), globalObject); + + this->putDirectAccessor( + this->globalObject(), builtinNames.mainPublicName(), - GetterSetter::create(vm, globalObject, JSFunction::create(vm, importMetaObjectMainCodeGenerator(vm), globalObject), nullptr), - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin | 0); + GetterSetter::create(vm, globalObject, mainGetter, mainGetter), + JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | 0); } ImportMetaObjectPrototype(JSC::VM& vm, JSC::Structure* structure) @@ -463,7 +466,7 @@ public: const ClassInfo ImportMetaObjectPrototype::s_info = { "ImportMeta"_s, - Base::info(), nullptr, nullptr, CREATE_METHOD_TABLE(ImportMetaObjectPrototype) + &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ImportMetaObjectPrototype) }; JSC::Structure* ImportMetaObject::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) diff --git a/src/bun.js/bindings/InternalModuleRegistry.cpp b/src/bun.js/bindings/InternalModuleRegistry.cpp index 8a81b87cd..03f946192 100644 --- a/src/bun.js/bindings/InternalModuleRegistry.cpp +++ b/src/bun.js/bindings/InternalModuleRegistry.cpp @@ -120,16 +120,23 @@ DEFINE_VISIT_CHILDREN_WITH_MODIFIER(JS_EXPORT_PRIVATE, InternalModuleRegistry); InternalModuleRegistry* InternalModuleRegistry::create(VM& vm, Structure* structure) { InternalModuleRegistry* registry = new (NotNull, allocateCell<InternalModuleRegistry>(vm)) InternalModuleRegistry(vm, structure); + registry->finishCreation(vm); + return registry; +} + +void InternalModuleRegistry::finishCreation(VM& vm) +{ + Base::finishCreation(vm); + ASSERT(inherits(info())); + for (uint8_t i = 0; i < BUN_INTERNAL_MODULE_COUNT; i++) { - registry->internalField(static_cast<Field>(i)) - .set(vm, registry, jsUndefined()); + this->internalField(static_cast<Field>(i)).set(vm, this, jsUndefined()); } - return registry; } Structure* InternalModuleRegistry::createStructure(VM& vm, JSGlobalObject* globalObject) { - return Structure::create(vm, globalObject, jsNull(), TypeInfo(InternalFieldTupleType, StructureFlags), info(), 0, 48); + return Structure::create(vm, globalObject, jsNull(), TypeInfo(InternalFieldTupleType, StructureFlags), info(), 0, 0); } JSValue InternalModuleRegistry::requireId(JSGlobalObject* globalObject, VM& vm, Field id) @@ -152,7 +159,7 @@ JSC_DEFINE_HOST_FUNCTION(InternalModuleRegistry::jsCreateInternalModuleById, (JS auto throwScope = DECLARE_THROW_SCOPE(vm); auto id = callframe->argument(0).toUInt32(lexicalGlobalObject); - auto registry = static_cast<Zig::GlobalObject*>(lexicalGlobalObject)->internalModuleRegistry(); + auto registry = jsCast<Zig::GlobalObject*>(lexicalGlobalObject)->internalModuleRegistry(); auto mod = registry->createInternalModuleById(lexicalGlobalObject, vm, static_cast<Field>(id)); RETURN_IF_EXCEPTION(throwScope, {}); registry->internalField(static_cast<Field>(id)).set(vm, registry, mod); diff --git a/src/bun.js/bindings/InternalModuleRegistry.h b/src/bun.js/bindings/InternalModuleRegistry.h index d14625e00..0944a382a 100644 --- a/src/bun.js/bindings/InternalModuleRegistry.h +++ b/src/bun.js/bindings/InternalModuleRegistry.h @@ -16,19 +16,21 @@ using namespace JSC; // - some are written in JS (src/js, there is a readme file that explain those files more. // - others are native code (src/bun.js/modules), see _NativeModule.h in there. class InternalModuleRegistry : public JSInternalFieldObjectImpl<BUN_INTERNAL_MODULE_COUNT> { -protected: - JS_EXPORT_PRIVATE InternalModuleRegistry(VM&, Structure*); - DECLARE_DEFAULT_FINISH_CREATION; - DECLARE_VISIT_CHILDREN_WITH_MODIFIER(JS_EXPORT_PRIVATE); - public: using Base = JSInternalFieldObjectImpl<BUN_INTERNAL_MODULE_COUNT>; DECLARE_EXPORT_INFO; + static size_t allocationSize(Checked<size_t> inlineCapacity) + { + ASSERT_UNUSED(inlineCapacity, inlineCapacity == 0U); + return sizeof(InternalModuleRegistry); + } + enum Field : uint8_t { #include "../../../src/js/out/InternalModuleRegistry+enum.h" }; + const WriteBarrier<Unknown>& internalField(Field field) const { return Base::internalField(static_cast<uint32_t>(field)); } WriteBarrier<Unknown>& internalField(Field field) { return Base::internalField(static_cast<uint32_t>(field)); } @@ -52,8 +54,11 @@ public: static JSC_DECLARE_HOST_FUNCTION(jsCreateInternalModuleById); -protected: +private: + JS_EXPORT_PRIVATE InternalModuleRegistry(VM&, Structure*); + DECLARE_VISIT_CHILDREN_WITH_MODIFIER(JS_EXPORT_PRIVATE); JSValue createInternalModuleById(JSGlobalObject* globalObject, VM& vm, Field id); + void finishCreation(VM&); }; } // namespace Bun diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index f77cffac3..524007f86 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -819,6 +819,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBufferPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -1825,8 +1826,8 @@ static const HashTableValue JSBufferPrototypeTableValues[] { "lastIndexOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBufferPrototypeFunction_lastIndexOf, 3 } }, { "latin1Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeLatin1SliceCodeGenerator, 2 } }, { "latin1Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeLatin1WriteCodeGenerator, 1 } }, - { "offset"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeOffsetCodeGenerator, 0 } }, - { "parent"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeParentCodeGenerator, 0 } }, + { "offset"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinAccessorType, jsBufferPrototypeOffsetCodeGenerator, 0 } }, + { "parent"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinAccessorType, jsBufferPrototypeParentCodeGenerator, 0 } }, { "readBigInt64"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadBigInt64LECodeGenerator, 1 } }, { "readBigInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadBigInt64BECodeGenerator, 1 } }, { "readBigInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadBigInt64LECodeGenerator, 1 } }, @@ -1934,8 +1935,7 @@ const ClassInfo JSBufferPrototype::s_info = { // We must use the same naming convention to match Node // Some packages (like MongoDB's official Node.js client) rely on this behavior. "Uint8Array"_s, - - nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferPrototype) + &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferPrototype) }; static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorAlloc(jsBufferConstructorAllocWithoutTypeChecks, @@ -1968,7 +1968,7 @@ static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorAllocUnsaf */ #include "JSBuffer.lut.h" -const ClassInfo JSBufferConstructor::s_info = { "Buffer"_s, nullptr, &jsBufferConstructorTable, nullptr, CREATE_METHOD_TABLE(JSBufferConstructor) }; +const ClassInfo JSBufferConstructor::s_info = { "Buffer"_s, &Base::s_info, &jsBufferConstructorTable, nullptr, CREATE_METHOD_TABLE(JSBufferConstructor) }; void JSBufferConstructor::finishCreation(VM& vm, JSGlobalObject* globalObject, JSC::JSObject* prototype) { diff --git a/src/bun.js/bindings/JSBufferList.cpp b/src/bun.js/bindings/JSBufferList.cpp index a8cefa710..0db5527d7 100644 --- a/src/bun.js/bindings/JSBufferList.cpp +++ b/src/bun.js/bindings/JSBufferList.cpp @@ -118,8 +118,7 @@ JSC::JSValue JSBufferList::_getString(JSC::VM& vm, JSC::JSGlobalObject* lexicalG RELEASE_AND_RETURN(throwScope, JSC::jsEmptyString(vm)); } - auto iter = m_deque.begin(); - JSC::JSString* str = JSC::jsDynamicCast<JSC::JSString*>(iter->get()); + JSC::JSString* str = JSC::jsDynamicCast<JSC::JSString*>(m_deque.first().get()); if (UNLIKELY(!str)) { return throwTypeError(lexicalGlobalObject, throwScope, "_getString can only be called when all buffers are string"_s); } @@ -132,13 +131,14 @@ JSC::JSValue JSBufferList::_getString(JSC::VM& vm, JSC::JSGlobalObject* lexicalG } if (n < len) { JSString* firstHalf = JSC::jsSubstring(lexicalGlobalObject, str, 0, n); - iter->set(vm, this, JSC::jsSubstring(lexicalGlobalObject, str, n, len - n)); + m_deque.first().set(vm, this, JSC::jsSubstring(lexicalGlobalObject, str, n, len - n)); RELEASE_AND_RETURN(throwScope, firstHalf); } JSRopeString::RopeBuilder<RecordOverflow> ropeBuilder(vm); - for (const auto end = m_deque.end(); iter != end; ++iter) { - JSC::JSString* str = JSC::jsDynamicCast<JSC::JSString*>(iter->get()); + while (m_deque.size() > 0) { + auto& element = m_deque.first(); + JSC::JSString* str = JSC::jsDynamicCast<JSC::JSString*>(element.get()); if (UNLIKELY(!str)) { return throwTypeError(lexicalGlobalObject, throwScope, "_getString can only be called when all buffers are string"_s); } @@ -147,7 +147,7 @@ JSC::JSValue JSBufferList::_getString(JSC::VM& vm, JSC::JSGlobalObject* lexicalG JSString* firstHalf = JSC::jsSubstring(lexicalGlobalObject, str, 0, n); if (!ropeBuilder.append(firstHalf)) return throwOutOfMemoryError(lexicalGlobalObject, throwScope); - iter->set(vm, this, JSC::jsSubstring(lexicalGlobalObject, str, n, len - n)); + element.set(vm, this, JSC::jsSubstring(lexicalGlobalObject, str, n, len - n)); break; } if (!ropeBuilder.append(str)) @@ -169,8 +169,7 @@ JSC::JSValue JSBufferList::_getBuffer(JSC::VM& vm, JSC::JSGlobalObject* lexicalG RELEASE_AND_RETURN(throwScope, JSC::JSUint8Array::create(lexicalGlobalObject, subclassStructure, 0)); } - auto iter = m_deque.begin(); - JSC::JSUint8Array* array = JSC::jsDynamicCast<JSC::JSUint8Array*>(iter->get()); + JSC::JSUint8Array* array = JSC::jsDynamicCast<JSC::JSUint8Array*>(m_deque.first().get()); if (UNLIKELY(!array)) { return throwTypeError(lexicalGlobalObject, throwScope, "_getBuffer can only be called when all buffers are Uint8Array"_s); } @@ -185,7 +184,7 @@ JSC::JSValue JSBufferList::_getBuffer(JSC::VM& vm, JSC::JSGlobalObject* lexicalG auto buffer = array->possiblySharedBuffer(); JSC::JSUint8Array* retArray = JSC::JSUint8Array::create(lexicalGlobalObject, subclassStructure, buffer, 0, n); JSC::JSUint8Array* newArray = JSC::JSUint8Array::create(lexicalGlobalObject, subclassStructure, buffer, n, len - n); - iter->set(vm, this, newArray); + m_deque.first().set(vm, this, newArray); RELEASE_AND_RETURN(throwScope, retArray); } @@ -196,8 +195,9 @@ JSC::JSValue JSBufferList::_getBuffer(JSC::VM& vm, JSC::JSGlobalObject* lexicalG } JSC::JSUint8Array* uint8Array = JSC::JSUint8Array::create(lexicalGlobalObject, subclassStructure, WTFMove(arrayBuffer), 0, n); size_t offset = 0; - for (const auto end = m_deque.end(); iter != end; ++iter) { - JSC::JSUint8Array* array = JSC::jsDynamicCast<JSC::JSUint8Array*>(iter->get()); + while (m_deque.size() > 0) { + auto& element = m_deque.first(); + JSC::JSUint8Array* array = JSC::jsDynamicCast<JSC::JSUint8Array*>(element.get()); if (UNLIKELY(!array)) { return throwTypeError(lexicalGlobalObject, throwScope, "_getBuffer can only be called when all buffers are Uint8Array"_s); } @@ -208,7 +208,7 @@ JSC::JSValue JSBufferList::_getBuffer(JSC::VM& vm, JSC::JSGlobalObject* lexicalG } auto buffer = array->possiblySharedBuffer(); JSC::JSUint8Array* newArray = JSC::JSUint8Array::create(lexicalGlobalObject, subclassStructure, buffer, n, len - n); - iter->set(vm, this, newArray); + element.set(vm, this, newArray); offset += n; break; } @@ -411,11 +411,11 @@ static const HashTableValue JSBufferListPrototypeTableValues[] void JSBufferListPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis) { Base::finishCreation(vm); - this->setPrototypeDirect(vm, globalThis->objectPrototype()); reifyStaticProperties(vm, JSBufferList::info(), JSBufferListPrototypeTableValues, *this); + ASSERT(inherits(info())); } -const ClassInfo JSBufferListPrototype::s_info = { "BufferList"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferListPrototype) }; +const ClassInfo JSBufferListPrototype::s_info = { "BufferList"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferListPrototype) }; void JSBufferListConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSBufferListPrototype* prototype) { diff --git a/src/bun.js/bindings/JSBufferList.h b/src/bun.js/bindings/JSBufferList.h index 94a69c8d1..ebbc1781e 100644 --- a/src/bun.js/bindings/JSBufferList.h +++ b/src/bun.js/bindings/JSBufferList.h @@ -46,7 +46,7 @@ public: void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject); static void destroy(JSCell*) {} - size_t length() { return m_deque.size(); } + inline size_t length() { return m_deque.size(); } void push(JSC::VM& vm, JSC::JSValue v) { m_deque.append(WriteBarrier<Unknown>()); @@ -100,6 +100,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBufferListPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/bindings/JSDOMFile.cpp b/src/bun.js/bindings/JSDOMFile.cpp index 1d7770ac1..1e1f9f2bc 100644 --- a/src/bun.js/bindings/JSDOMFile.cpp +++ b/src/bun.js/bindings/JSDOMFile.cpp @@ -17,7 +17,7 @@ class JSDOMFile : public JSC::InternalFunction { public: JSDOMFile(JSC::VM& vm, JSC::Structure* structure) - : Base(vm, structure, nullptr, construct) + : Base(vm, structure, call, construct) { } @@ -43,7 +43,8 @@ public: static JSDOMFile* create(JSC::VM& vm, JSGlobalObject* globalObject) { auto* zigGlobal = reinterpret_cast<Zig::GlobalObject*>(globalObject); - auto* object = new (NotNull, JSC::allocateCell<JSDOMFile>(vm)) JSDOMFile(vm, createStructure(vm, globalObject, zigGlobal->functionPrototype())); + auto structure = createStructure(vm, globalObject, zigGlobal->functionPrototype()); + auto* object = new (NotNull, JSC::allocateCell<JSDOMFile>(vm)) JSDOMFile(vm, structure); object->finishCreation(vm); // This is not quite right. But we'll fix it if someone files an issue about it. @@ -91,6 +92,12 @@ public: return JSValue::encode( WebCore::JSBlob::create(vm, globalObject, structure, ptr)); } + + static EncodedJSValue call(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame) + { + auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); + throwTypeError(lexicalGlobalObject, scope, "Class constructor File cannot be invoked without 'new"_s); + } }; const JSC::ClassInfo JSDOMFile::s_info = { "File"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMFile) }; diff --git a/src/bun.js/bindings/JSDOMWrapperCache.h b/src/bun.js/bindings/JSDOMWrapperCache.h index 7656c7c17..e06f2607d 100644 --- a/src/bun.js/bindings/JSDOMWrapperCache.h +++ b/src/bun.js/bindings/JSDOMWrapperCache.h @@ -215,6 +215,10 @@ template<typename DOMClass> inline void setSubclassStructureIfNeeded(JSC::JSGlob JSC::VM& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); + // If the new target isn't actually callable + if (UNLIKELY(!newTarget->isCallable())) + newTarget = constructor; + auto* functionGlobalObject = JSC::getFunctionRealm(lexicalGlobalObject, newTarget); RETURN_IF_EXCEPTION(scope, void()); auto* newTargetGlobalObject = JSC::jsCast<JSDOMGlobalObject*>(functionGlobalObject); diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index a8bac7c56..498864dfc 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -486,6 +486,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMockFunctionPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -623,7 +624,6 @@ extern "C" EncodedJSValue JSMock__jsSpyOn(JSC::JSGlobalObject* lexicalGlobalObje mock->copyNameAndLength(vm, globalObject, value); - attributes |= PropertyAttribute::Function; object->putDirect(vm, propertyKey, mock, attributes); RETURN_IF_EXCEPTION(scope, {}); @@ -1320,7 +1320,7 @@ MockWithImplementationCleanupData* MockWithImplementationCleanupData::create(VM& } Structure* MockWithImplementationCleanupData::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); + return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); } MockWithImplementationCleanupData::MockWithImplementationCleanupData(VM& vm, Structure* structure) diff --git a/src/bun.js/bindings/JSNextTickQueue.cpp b/src/bun.js/bindings/JSNextTickQueue.cpp index 8916ef6c8..18963645c 100644 --- a/src/bun.js/bindings/JSNextTickQueue.cpp +++ b/src/bun.js/bindings/JSNextTickQueue.cpp @@ -18,7 +18,7 @@ namespace Bun { using namespace JSC; -const JSC::ClassInfo JSNextTickQueue::s_info = { "JSNextTickQueue"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNextTickQueue) }; +const JSC::ClassInfo JSNextTickQueue::s_info = { "NextTickQueue"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNextTickQueue) }; template<typename, JSC::SubspaceAccess mode> JSC::GCClient::IsoSubspace* JSNextTickQueue::subspaceFor(JSC::VM& vm) @@ -34,11 +34,12 @@ JSC::GCClient::IsoSubspace* JSNextTickQueue::subspaceFor(JSC::VM& vm) JSNextTickQueue* JSNextTickQueue::create(VM& vm, Structure* structure) { JSNextTickQueue* mod = new (NotNull, allocateCell<JSNextTickQueue>(vm)) JSNextTickQueue(vm, structure); + mod->finishCreation(vm); return mod; } Structure* JSNextTickQueue::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); + return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); } JSNextTickQueue::JSNextTickQueue(VM& vm, Structure* structure) @@ -65,7 +66,6 @@ JSNextTickQueue* JSNextTickQueue::create(JSC::JSGlobalObject* globalObject) { auto& vm = globalObject->vm(); auto* obj = create(vm, createStructure(vm, globalObject, jsNull())); - obj->finishCreation(vm); return obj; } diff --git a/src/bun.js/bindings/JSNextTickQueue.h b/src/bun.js/bindings/JSNextTickQueue.h index c3bd228cc..3a499345d 100644 --- a/src/bun.js/bindings/JSNextTickQueue.h +++ b/src/bun.js/bindings/JSNextTickQueue.h @@ -10,7 +10,6 @@ using namespace JSC; class JSNextTickQueue : public JSC::JSInternalFieldObjectImpl<3> { public: - static constexpr unsigned numberOfInternalFields = 3; using Base = JSC::JSInternalFieldObjectImpl<3>; template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm); diff --git a/src/bun.js/bindings/JSReadableState.h b/src/bun.js/bindings/JSReadableState.h index c67baebad..78a716910 100644 --- a/src/bun.js/bindings/JSReadableState.h +++ b/src/bun.js/bindings/JSReadableState.h @@ -107,6 +107,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStatePrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index e0abede33..ef6343849 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -711,6 +711,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSArrayBufferSinkPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -743,6 +744,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableArrayBufferSinkControllerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -967,6 +969,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFileSinkPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -999,6 +1002,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableFileSinkControllerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -1223,6 +1227,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPResponseSinkPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -1255,6 +1260,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPResponseSinkControllerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -1479,6 +1485,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPSResponseSinkPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -1511,6 +1518,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPSResponseSinkControllerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/bindings/JSStringDecoder.h b/src/bun.js/bindings/JSStringDecoder.h index bce1ae05d..cd2e017d6 100644 --- a/src/bun.js/bindings/JSStringDecoder.h +++ b/src/bun.js/bindings/JSStringDecoder.h @@ -77,6 +77,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSStringDecoderPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index 127fb6965..ac980d062 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -92,13 +92,20 @@ generateInternalModuleSourceCode(JSC::JSGlobalObject* globalObject, InternalModu exportNames.reserveCapacity(len); exportValues.ensureCapacity(len); - exportNames.append(vm.propertyNames->defaultKeyword); - exportValues.append(object); + bool hasDefault = false; for (auto& entry : properties) { + if (UNLIKELY(entry == vm.propertyNames->defaultKeyword)) { + hasDefault = true; + } exportNames.append(entry); exportValues.append(object->get(globalObject, entry)); } + + if (!hasDefault) { + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(object); + } }; } @@ -138,7 +145,7 @@ PendingVirtualModuleResult* PendingVirtualModuleResult::create(VM& vm, Structure } Structure* PendingVirtualModuleResult::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); + return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); } PendingVirtualModuleResult::PendingVirtualModuleResult(VM& vm, Structure* structure) @@ -533,7 +540,7 @@ JSValue fetchCommonJSModule( RELEASE_AND_RETURN(scope, {}); } - target->putDirect(vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), value, value.isCell() && value.isCallable() ? JSC::PropertyAttribute::Function | 0 : 0); + target->putDirect(vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), value, 0); target->hasEvaluated = true; RELEASE_AND_RETURN(scope, target); } diff --git a/src/bun.js/bindings/NodeVMScript.cpp b/src/bun.js/bindings/NodeVMScript.cpp index 16ae9e92c..e0e0dc93a 100644 --- a/src/bun.js/bindings/NodeVMScript.cpp +++ b/src/bun.js/bindings/NodeVMScript.cpp @@ -502,6 +502,7 @@ public: template<typename CellType, SubspaceAccess> static GCClient::IsoSubspace* subspaceFor(VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(NodeVMScriptPrototype, Base); return &vm.plainObjectSpace(); } static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) diff --git a/src/bun.js/bindings/Path.cpp b/src/bun.js/bindings/Path.cpp index 808613b0c..6507b7122 100644 --- a/src/bun.js/bindings/Path.cpp +++ b/src/bun.js/bindings/Path.cpp @@ -173,7 +173,7 @@ static JSC::JSObject* createPath(JSGlobalObject* globalThis, bool isWindows) JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0, "relative"_s, Path_functionRelative, ImplementationVisibility::Public), 0); - path->putDirect(vm, clientData->builtinNames().resolvePublicName(), + path->putDirect(vm, vm.propertyNames->resolve, JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalThis), 0, "resolve"_s, Path_functionResolve, ImplementationVisibility::Public), 0); diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index fd194f547..6fbc797cd 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -620,7 +620,7 @@ static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& e continue; JSGlobalObject* lexicalGlobalObject = context->jsGlobalObject(); - Zig::GlobalObject* globalObject = static_cast<Zig::GlobalObject*>(lexicalGlobalObject); + Zig::GlobalObject* globalObject = jsCast<Zig::GlobalObject*>(lexicalGlobalObject); Process* process = jsCast<Process*>(globalObject->processObject()); @@ -679,7 +679,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionAbort, (JSGlobalObject * globalObject, JSC_DEFINE_HOST_FUNCTION(Process_emitWarning, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = static_cast<Zig::GlobalObject*>(lexicalGlobalObject); + Zig::GlobalObject* globalObject = jsCast<Zig::GlobalObject*>(lexicalGlobalObject); VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1168,7 +1168,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionBinding, (JSGlobalObject * jsGlobalObje { auto& vm = jsGlobalObject->vm(); auto throwScope = DECLARE_THROW_SCOPE(vm); - auto globalObject = static_cast<Zig::GlobalObject*>(jsGlobalObject); + auto globalObject = jsCast<Zig::GlobalObject*>(jsGlobalObject); auto process = jsCast<Process*>(globalObject->processObject()); auto moduleName = callFrame->argument(0).toWTFString(globalObject); @@ -1624,7 +1624,7 @@ static JSValue constructMemoryUsage(VM& vm, JSObject* processObject) JSC::JSFunction* rss = JSC::JSFunction::create(vm, globalObject, 0, String("rss"_s), Process_functionMemoryUsageRSS, ImplementationVisibility::Public); - memoryUsage->putDirect(vm, JSC::Identifier::fromString(vm, "rss"_s), rss, JSC::PropertyAttribute::Function | 0); + memoryUsage->putDirect(vm, JSC::Identifier::fromString(vm, "rss"_s), rss, 0); return memoryUsage; } @@ -1647,14 +1647,14 @@ static JSValue constructProcessNextTickFn(VM& vm, JSObject* processObject) Zig::GlobalObject* globalObject = jsCast<Zig::GlobalObject*>(lexicalGlobalObject); JSValue nextTickQueueObject; if (!globalObject->m_nextTickQueue) { - Bun::JSNextTickQueue* queue = Bun::JSNextTickQueue::create(globalObject); - globalObject->m_nextTickQueue.set(vm, globalObject, queue); - nextTickQueueObject = queue; + nextTickQueueObject = Bun::JSNextTickQueue::create(globalObject); + globalObject->m_nextTickQueue.set(vm, globalObject, nextTickQueueObject); } else { nextTickQueueObject = jsCast<Bun::JSNextTickQueue*>(globalObject->m_nextTickQueue.get()); } JSC::JSFunction* initializer = JSC::JSFunction::create(vm, processObjectInternalsInitializeNextTickQueueCodeGenerator(vm), lexicalGlobalObject); + JSC::MarkedArgumentBuffer args; args.append(processObject); args.append(nextTickQueueObject); diff --git a/src/bun.js/bindings/ProcessBindingConstants.cpp b/src/bun.js/bindings/ProcessBindingConstants.cpp index 86b34d19f..8544b2f20 100644 --- a/src/bun.js/bindings/ProcessBindingConstants.cpp +++ b/src/bun.js/bindings/ProcessBindingConstants.cpp @@ -685,9 +685,6 @@ static JSValue processBindingConstantsGetFs(VM& vm, JSObject* bindingObject) #ifdef O_DIRECTORY object->putDirect(vm, PropertyName(Identifier::fromString(vm, "O_DIRECTORY"_s)), jsNumber(O_DIRECTORY)); #endif -#ifdef O_EXCL - object->putDirect(vm, PropertyName(Identifier::fromString(vm, "O_EXCL"_s)), jsNumber(O_EXCL)); -#endif #ifdef O_NOATIME object->putDirect(vm, PropertyName(Identifier::fromString(vm, "O_NOATIME"_s)), jsNumber(O_NOATIME)); #endif @@ -1093,7 +1090,7 @@ static JSValue processBindingConstantsGetZlib(VM& vm, JSObject* bindingObject) */ #include "ProcessBindingConstants.lut.h" -const ClassInfo ProcessBindingConstants::s_info = { "ProcessBindingConstants"_s, Base::info(), &processBindingConstantsTable, nullptr, CREATE_METHOD_TABLE(ProcessBindingConstants) }; +const ClassInfo ProcessBindingConstants::s_info = { "ProcessBindingConstants"_s, &Base::s_info, &processBindingConstantsTable, nullptr, CREATE_METHOD_TABLE(ProcessBindingConstants) }; ProcessBindingConstants* ProcessBindingConstants::create(VM& vm, Structure* structure) { @@ -1110,7 +1107,7 @@ Structure* ProcessBindingConstants::createStructure(VM& vm, JSGlobalObject* glob void ProcessBindingConstants::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); - ASSERT(inherits(vm, info())); + ASSERT(inherits(info())); } template<typename Visitor> diff --git a/src/bun.js/bindings/ProcessBindingConstants.h b/src/bun.js/bindings/ProcessBindingConstants.h index 912cc7a3e..6115534a0 100644 --- a/src/bun.js/bindings/ProcessBindingConstants.h +++ b/src/bun.js/bindings/ProcessBindingConstants.h @@ -20,6 +20,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(ProcessBindingConstants, Base); return &vm.plainObjectSpace(); } diff --git a/src/bun.js/bindings/ProcessBindingNatives.cpp b/src/bun.js/bindings/ProcessBindingNatives.cpp index fc481f1ae..2a2685524 100644 --- a/src/bun.js/bindings/ProcessBindingNatives.cpp +++ b/src/bun.js/bindings/ProcessBindingNatives.cpp @@ -98,7 +98,7 @@ static JSValue processBindingNativesReturnUndefined(VM& vm, JSObject* bindingObj */ #include "ProcessBindingNatives.lut.h" -const ClassInfo ProcessBindingNatives::s_info = { "ProcessBindingNatives"_s, Base::info(), &processBindingNativesTable, nullptr, CREATE_METHOD_TABLE(ProcessBindingNatives) }; +const ClassInfo ProcessBindingNatives::s_info = { "ProcessBindingNatives"_s, &Base::s_info, &processBindingNativesTable, nullptr, CREATE_METHOD_TABLE(ProcessBindingNatives) }; ProcessBindingNatives* ProcessBindingNatives::create(VM& vm, Structure* structure) { @@ -115,7 +115,7 @@ Structure* ProcessBindingNatives::createStructure(VM& vm, JSGlobalObject* global void ProcessBindingNatives::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); - ASSERT(inherits(vm, info())); + ASSERT(inherits(info())); } template<typename Visitor> diff --git a/src/bun.js/bindings/ProcessBindingNatives.h b/src/bun.js/bindings/ProcessBindingNatives.h index c8c1f0991..bbeaaa524 100644 --- a/src/bun.js/bindings/ProcessBindingNatives.h +++ b/src/bun.js/bindings/ProcessBindingNatives.h @@ -20,6 +20,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(ProcessBindingNatives, Base); return &vm.plainObjectSpace(); } diff --git a/src/bun.js/bindings/RegularExpression.cpp b/src/bun.js/bindings/RegularExpression.cpp index 1c8df1bc0..c59e6fa4c 100644 --- a/src/bun.js/bindings/RegularExpression.cpp +++ b/src/bun.js/bindings/RegularExpression.cpp @@ -1,12 +1,16 @@ #include "root.h" #include "headers-handwritten.h" #include "JavaScriptCore/RegularExpression.h" +#include "JavaScriptCore/Options.h" using namespace JSC; using namespace JSC::Yarr; extern "C" RegularExpression* Yarr__RegularExpression__init(BunString pattern, uint16_t flags) { + // TODO: Remove this, we technically are accessing options before we finalize them. + // This means you cannot use BUN_JSC_dumpCompiledRegExpPatterns on the flag passed to `bun test -t` + Options::AllowUnfinalizedAccessScope scope; return new RegularExpression(Bun::toWTFString(pattern), OptionSet<Flags>(static_cast<Flags>(flags))); } extern "C" void Yarr__RegularExpression__deinit(RegularExpression* re) diff --git a/src/bun.js/bindings/ScriptExecutionContext.cpp b/src/bun.js/bindings/ScriptExecutionContext.cpp index 2113c9f64..9f824dde5 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.cpp +++ b/src/bun.js/bindings/ScriptExecutionContext.cpp @@ -105,7 +105,7 @@ bool ScriptExecutionContext::postTaskTo(ScriptExecutionContextIdentifier identif void ScriptExecutionContext::didCreateDestructionObserver(ContextDestructionObserver& observer) { - ASSERT(!m_inScriptExecutionContextDestructor); + // ASSERT(!m_inScriptExecutionContextDestructor); m_destructionObservers.add(&observer); } @@ -181,7 +181,7 @@ void ScriptExecutionContext::dispatchMessagePortEvents() ASSERT(isContextThread()); checkConsistency(); - ASSERT(m_willprocessMessageWithMessagePortsSoon); + ASSERT(m_willProcessMessageWithMessagePortsSoon); m_willProcessMessageWithMessagePortsSoon = false; auto completionHandlers = std::exchange(m_processMessageWithMessagePortsSoonHandlers, Vector<CompletionHandler<void()>> {}); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index 6e3a2e1e5..0517832b0 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -43,6 +43,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSAttributeIteratorPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -150,7 +151,7 @@ void JSAttributeIteratorPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObje { Base::finishCreation(vm); reifyStaticProperties(vm, JSAttributeIterator::info(), JSAttributeIteratorPrototypeTableValues, *this); - this->putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject, 1, String("iterator"_s), AttributeIteratorPrototype__iteratorCallback, ImplementationVisibility::Public), PropertyAttribute::Function | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); + this->putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject, 1, String("iterator"_s), AttributeIteratorPrototype__iteratorCallback, ImplementationVisibility::Public), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } @@ -245,6 +246,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBigIntStatsPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -1301,6 +1303,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBlobPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -1924,6 +1927,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBuildArtifactPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -2471,6 +2475,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBuildMessagePrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -2752,7 +2757,7 @@ void JSBuildMessagePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* g { Base::finishCreation(vm); reifyStaticProperties(vm, JSBuildMessage::info(), JSBuildMessagePrototypeTableValues, *this); - this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), BuildMessagePrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::Function | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); + this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), BuildMessagePrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); this->putDirect(vm, vm.propertyNames->name, jsString(vm, String("BuildMessage"_s)), PropertyAttribute::ReadOnly | 0); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } @@ -2950,6 +2955,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCommentPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -3262,6 +3268,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCryptoPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -3715,6 +3722,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCryptoHasherPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -4146,6 +4154,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDebugHTTPSServerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -4660,6 +4669,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDebugHTTPServerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -5174,6 +5184,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDirentPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -5708,6 +5719,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDocEndPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -5878,6 +5890,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDocTypePrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -6156,6 +6169,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSElementPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -6872,6 +6886,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSEndTagPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -7136,6 +7151,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -9532,6 +9548,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectAnyPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -9700,6 +9717,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectAnythingPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -9823,6 +9841,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectArrayContainingPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -9991,6 +10010,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectStringContainingPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -10159,6 +10179,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectStringMatchingPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -10327,6 +10348,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFFIPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -10577,6 +10599,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFSWatcherPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -10881,6 +10904,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFileSystemRouterPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -11327,6 +11351,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTMLRewriterPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -11665,6 +11690,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPSServerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -12179,6 +12205,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPServerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -12693,6 +12720,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSListenerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -13109,6 +13137,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMD4Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -13439,6 +13468,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMD5Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -13769,6 +13799,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMatchedRoutePrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -14226,6 +14257,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSNodeJSFSPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -17217,6 +17249,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSRequestPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -17992,6 +18025,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSResolveMessagePrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -18413,7 +18447,7 @@ void JSResolveMessagePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* { Base::finishCreation(vm); reifyStaticProperties(vm, JSResolveMessage::info(), JSResolveMessagePrototypeTableValues, *this); - this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), ResolveMessagePrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::Function | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); + this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), ResolveMessagePrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); this->putDirect(vm, vm.propertyNames->name, jsString(vm, String("ResolveMessage"_s)), PropertyAttribute::ReadOnly | 0); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } @@ -18615,6 +18649,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSResponsePrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -19319,6 +19354,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA1Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -19649,6 +19685,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA224Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -19979,6 +20016,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA256Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -20309,6 +20347,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA384Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -20639,6 +20678,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA512Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -20969,6 +21009,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA512_256Prototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -21299,6 +21340,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSServerWebSocketPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -22257,6 +22299,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSStatWatcherPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -22529,6 +22572,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSStatsPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -23501,6 +23545,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSubprocessPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -24064,6 +24109,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTCPSocketPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -25051,8 +25097,10 @@ bool JSTCPSocket::hasPendingActivity(void* ctx) JSTCPSocket::~JSTCPSocket() { + printf("~JSTCPSocket\n"); if (m_ctx) { TCPSocketClass__finalize(m_ctx); + m_ctx = nullptr; } } void JSTCPSocket::destroy(JSCell* cell) @@ -25175,6 +25223,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTLSSocketPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -26286,6 +26335,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTextChunkPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -26652,6 +26702,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTextDecoderPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -27044,6 +27095,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTimeoutPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -27258,7 +27310,7 @@ void JSTimeoutPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* global { Base::finishCreation(vm); reifyStaticProperties(vm, JSTimeout::info(), JSTimeoutPrototypeTableValues, *this); - this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), TimeoutPrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::Function | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); + this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), TimeoutPrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } @@ -27386,6 +27438,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTranspilerPrototype, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/bindings/ZigGeneratedCode.cpp b/src/bun.js/bindings/ZigGeneratedCode.cpp index 057eaf28e..777c6455e 100644 --- a/src/bun.js/bindings/ZigGeneratedCode.cpp +++ b/src/bun.js/bindings/ZigGeneratedCode.cpp @@ -51,8 +51,7 @@ extern "C" void FFI__ptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSV thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "ptr"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u8__slowpathWrapper); @@ -92,8 +91,7 @@ extern "C" void Reader__u8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJ thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "u8"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u16__slowpathWrapper); @@ -133,8 +131,7 @@ extern "C" void Reader__u16__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "u16"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u32__slowpathWrapper); @@ -174,8 +171,7 @@ extern "C" void Reader__u32__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "u32"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__ptr__slowpathWrapper); @@ -215,8 +211,7 @@ extern "C" void Reader__ptr__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "ptr"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i8__slowpathWrapper); @@ -256,8 +251,7 @@ extern "C" void Reader__i8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJ thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "i8"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i16__slowpathWrapper); @@ -297,8 +291,7 @@ extern "C" void Reader__i16__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "i16"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i32__slowpathWrapper); @@ -338,8 +331,7 @@ extern "C" void Reader__i32__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "i32"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i64__slowpathWrapper); @@ -379,8 +371,7 @@ extern "C" void Reader__i64__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "i64"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u64__slowpathWrapper); @@ -420,8 +411,7 @@ extern "C" void Reader__u64__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "u64"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__intptr__slowpathWrapper); @@ -461,8 +451,7 @@ extern "C" void Reader__intptr__put(JSC::JSGlobalObject* globalObject, JSC::Enco thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "intptr"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__f32__slowpathWrapper); @@ -502,8 +491,7 @@ extern "C" void Reader__f32__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "f32"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__f64__slowpathWrapper); @@ -543,8 +531,7 @@ extern "C" void Reader__f64__put(JSC::JSGlobalObject* globalObject, JSC::Encoded thisObject->putDirect( globalObject->vm(), Identifier::fromString(globalObject->vm(), "f64"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + function); } /* -- END DOMCall DEFINITIONS-- */ diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 777e398d3..93f9a0fa2 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -765,9 +765,9 @@ extern "C" JSC__JSValue JSC__JSValue__makeWithNameAndPrototype(JSC__JSGlobalObje JSC::JSObject* wrapped = JSC::JSValue::decode(reinterpret_cast<JSC__JSValue>(wrappedRef)).getObject(); object->setPrototypeDirect(vm, wrapped); JSString* nameString = JSC::jsNontrivialString(vm, Zig::toString(*visibleInterfaceName)); - object->putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); + object->putDirect(vm, vm.propertyNames->name, nameString, PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum); object->putDirect(vm, vm.propertyNames->toStringTagSymbol, - nameString, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly); + nameString, PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); return JSC::JSValue::encode(JSC::JSValue(object)); } @@ -832,7 +832,7 @@ GlobalObject::~GlobalObject() finalizer(toNapi(this), napiInstanceData, napiInstanceDataFinalizerHint); } - delete crypto; + delete m_subtleCrypto; scriptExecutionContext()->removeFromContextsMap(); } @@ -1873,9 +1873,9 @@ JSC_DEFINE_HOST_FUNCTION(functionLazyLoad, auto* obj = constructEmptyObject(globalObject); obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0); Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, reinterpret_cast<Zig::GlobalObject*>(globalObject), 0, String(), functionNoop, JSC::NoIntrinsic); - obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "function"_s)), function, JSC::PropertyAttribute::Function | 0); - obj->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "functionRegular"_s), 1, functionNoop, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); - obj->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "callback"_s), 1, functionCallback, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); + obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "function"_s)), function, 0); + obj->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "functionRegular"_s), 1, functionNoop, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); + obj->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "callback"_s), 1, functionCallback, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); return JSC::JSValue::encode(obj); } @@ -1964,16 +1964,9 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionDispatchEvent, (JSGlobalObject * lexicalGloba return jsFunctionDispatchEventBody(lexicalGlobalObject, callFrame, jsDynamicCast<Zig::GlobalObject*>(lexicalGlobalObject)); } -static inline JSValue getterSubtleCryptoBody(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject) -{ - UNUSED_PARAM(lexicalGlobalObject); - return thisObject.subtleCrypto(); -} - JSC_DEFINE_CUSTOM_GETTER(getterSubtleCrypto, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { - return JSValue::encode( - getterSubtleCryptoBody(*lexicalGlobalObject, *reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject))); + return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject)->subtleCrypto()); } JSC_DECLARE_HOST_FUNCTION(makeThisTypeErrorForBuiltins); @@ -2249,7 +2242,7 @@ private: void finishCreation(JSC::VM& vm) { - + Base::finishCreation(vm); static const JSC::DOMJIT::Signature DOMJITSignatureForPerformanceNow( functionPerformanceNowWithoutTypeCheck, JSPerformanceObject::info(), @@ -2263,7 +2256,7 @@ private: String("now"_s), functionPerformanceNow, ImplementationVisibility::Public, NoIntrinsic, functionPerformanceNow, &DOMJITSignatureForPerformanceNow); - this->putDirect(vm, JSC::Identifier::fromString(vm, "now"_s), now, JSC::PropertyAttribute::Function | 0); + this->putDirect(vm, JSC::Identifier::fromString(vm, "now"_s), now, 0); JSFunction* noopNotImplemented = JSFunction::create( vm, @@ -2273,15 +2266,15 @@ private: functionNoop, ImplementationVisibility::Public, NoIntrinsic, functionNoop, nullptr); - this->putDirect(vm, JSC::Identifier::fromString(vm, "mark"_s), noopNotImplemented, JSC::PropertyAttribute::Function | 0); - this->putDirect(vm, JSC::Identifier::fromString(vm, "markResourceTiming"_s), noopNotImplemented, JSC::PropertyAttribute::Function | 0); - this->putDirect(vm, JSC::Identifier::fromString(vm, "measure"_s), noopNotImplemented, JSC::PropertyAttribute::Function | 0); + this->putDirect(vm, JSC::Identifier::fromString(vm, "mark"_s), noopNotImplemented, 0); + this->putDirect(vm, JSC::Identifier::fromString(vm, "markResourceTiming"_s), noopNotImplemented, 0); + this->putDirect(vm, JSC::Identifier::fromString(vm, "measure"_s), noopNotImplemented, 0); this->putDirect( vm, JSC::Identifier::fromString(vm, "timeOrigin"_s), jsNumber(Bun__readOriginTimerStart(reinterpret_cast<Zig::GlobalObject*>(this->globalObject())->bunVM())), - JSC::PropertyAttribute::ReadOnly | 0); + PropertyAttribute::ReadOnly | 0); } }; const ClassInfo JSPerformanceObject::s_info = { "Performance"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPerformanceObject) }; @@ -2816,7 +2809,7 @@ void GlobalObject::finishCreation(VM& vm) init.vm, Identifier::fromString(init.vm, "subtle"_s), JSC::CustomGetterSetter::create(init.vm, getterSubtleCrypto, nullptr), - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0); + PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | 0); init.set(crypto); }); @@ -2966,7 +2959,7 @@ void GlobalObject::finishCreation(VM& vm) m_utilInspectFunction.initLater( [](const Initializer<JSFunction>& init) { - JSValue nodeUtilValue = static_cast<Zig::GlobalObject*>(init.owner)->internalModuleRegistry()->requireId(init.owner, init.vm, Bun::InternalModuleRegistry::Field::NodeUtil); + JSValue nodeUtilValue = jsCast<Zig::GlobalObject*>(init.owner)->internalModuleRegistry()->requireId(init.owner, init.vm, Bun::InternalModuleRegistry::Field::NodeUtil); RELEASE_ASSERT(nodeUtilValue.isObject()); init.set(jsCast<JSFunction*>(nodeUtilValue.getObject()->getIfPropertyExists(init.owner, Identifier::fromString(init.vm, "inspect"_s)))); }); @@ -2978,7 +2971,7 @@ void GlobalObject::finishCreation(VM& vm) // RETURN_IF_EXCEPTION(scope, {}); JSC::MarkedArgumentBuffer args; - args.append(static_cast<Zig::GlobalObject*>(init.owner)->utilInspectFunction()); + args.append(jsCast<Zig::GlobalObject*>(init.owner)->utilInspectFunction()); auto clientData = WebCore::clientData(init.vm); JSC::CallData callData = JSC::getCallData(getStylize); @@ -3022,7 +3015,7 @@ void GlobalObject::finishCreation(VM& vm) JSC::JSObject* obj = JSC::constructEmptyObject(init.owner, init.owner->objectPrototype(), 4); obj->putDirect(init.vm, userAgentIdentifier, JSC::jsString(init.vm, str)); obj->putDirect(init.vm, init.vm.propertyNames->toStringTagSymbol, - jsNontrivialString(init.vm, "Navigator"_s), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly); + jsNontrivialString(init.vm, "Navigator"_s), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform // https://github.com/oven-sh/bun/issues/4588 @@ -3067,13 +3060,12 @@ void GlobalObject::finishCreation(VM& vm) m_subtleCryptoObject.initLater( [](const JSC::LazyProperty<JSC::JSGlobalObject, JSC::JSObject>::Initializer& init) { auto& global = *reinterpret_cast<Zig::GlobalObject*>(init.owner); - if (global.crypto == nullptr) { - global.crypto = WebCore::SubtleCrypto::createPtr(global.scriptExecutionContext()); - global.crypto->ref(); + + if (!global.m_subtleCrypto) { + global.m_subtleCrypto = &WebCore::SubtleCrypto::create(global.scriptExecutionContext()).leakRef(); } - init.set( - toJS<IDLInterface<SubtleCrypto>>(*init.owner, global, global.crypto).getObject()); + init.set(toJS<IDLInterface<SubtleCrypto>>(*init.owner, global, global.m_subtleCrypto).getObject()); }); m_NapiClassStructure.initLater( @@ -3319,13 +3311,13 @@ void GlobalObject::finishCreation(VM& vm) init.setConstructor(constructor); }); - addBuiltinGlobals(vm); - #if ENABLE(REMOTE_INSPECTOR) setInspectable(false); #endif - RELEASE_ASSERT(classInfo()); + addBuiltinGlobals(vm); + + ASSERT(classInfo()); } JSC_DEFINE_HOST_FUNCTION(jsFunctionPostMessage, @@ -3521,7 +3513,7 @@ JSC_DEFINE_CUSTOM_GETTER(getConsoleStdout, (JSGlobalObject * globalObject, Encod { auto& vm = globalObject->vm(); auto console = JSValue::decode(thisValue).getObject(); - auto global = static_cast<Zig::GlobalObject*>(globalObject); + auto global = jsCast<Zig::GlobalObject*>(globalObject); // instead of calling the constructor builtin, go through the process.stdout getter to ensure it's only created once. auto stdout = global->processObject()->get(globalObject, Identifier::fromString(vm, "stdout"_s)); @@ -3537,7 +3529,7 @@ JSC_DEFINE_CUSTOM_GETTER(getConsoleStderr, (JSGlobalObject * globalObject, Encod { auto& vm = globalObject->vm(); auto console = JSValue::decode(thisValue).getObject(); - auto global = static_cast<Zig::GlobalObject*>(globalObject); + auto global = jsCast<Zig::GlobalObject*>(globalObject); // instead of calling the constructor builtin, go through the process.stdout getter to ensure it's only created once. auto stdout = global->processObject()->get(globalObject, Identifier::fromString(vm, "stderr"_s)); @@ -3655,12 +3647,12 @@ extern "C" EncodedJSValue WebCore__confirm(JSC::JSGlobalObject*, JSC::CallFrame* JSValue GlobalObject_getPerformanceObject(VM& vm, JSObject* globalObject) { - return static_cast<Zig::GlobalObject*>(globalObject)->performanceObject(); + return jsCast<Zig::GlobalObject*>(globalObject)->performanceObject(); } JSValue GlobalObject_getGlobalThis(VM& vm, JSObject* globalObject) { - return static_cast<Zig::GlobalObject*>(globalObject)->globalThis(); + return jsCast<Zig::GlobalObject*>(globalObject)->globalThis(); } // This is like `putDirectBuiltinFunction` but for the global static list. @@ -3681,17 +3673,17 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) GlobalPropertyInfo { builtinNames.startDirectStreamPrivateName(), JSC::JSFunction::create(vm, this, 1, String(), functionStartDirectStream, ImplementationVisibility::Public), - JSC::PropertyAttribute::Function | 0 }, + PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | 0 }, // TODO: Remove the "Bun.lazy" symbol // The reason we cant do this easily is our tests rely on this being public to test the internals. GlobalPropertyInfo { JSC::Identifier::fromUid(vm.symbolRegistry().symbolForKey(MAKE_STATIC_STRING_IMPL("Bun.lazy"))), $lazy, - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::Function | 0 }, + PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | 0 }, GlobalPropertyInfo { builtinNames.lazyPrivateName(), $lazy, - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::Function | 0 }, + PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | 0 }, GlobalPropertyInfo(builtinNames.makeThisTypeErrorPrivateName(), JSFunction::create(vm, this, 2, String(), makeThisTypeErrorForBuiltins, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), GlobalPropertyInfo(builtinNames.makeGetterTypeErrorPrivateName(), JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), @@ -3702,13 +3694,13 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) GlobalPropertyInfo(builtinNames.isAbortSignalPrivateName(), JSFunction::create(vm, this, 1, String(), isAbortSignal, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), GlobalPropertyInfo(builtinNames.getInternalWritableStreamPrivateName(), JSFunction::create(vm, this, 1, String(), getInternalWritableStream, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), GlobalPropertyInfo(builtinNames.createWritableStreamFromInternalPrivateName(), JSFunction::create(vm, this, 1, String(), createWritableStreamFromInternal, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), - GlobalPropertyInfo(builtinNames.fulfillModuleSyncPrivateName(), JSFunction::create(vm, this, 1, String(), functionFulfillModuleSync, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function), - GlobalPropertyInfo(builtinNames.directPrivateName(), JSFunction::create(vm, this, 1, String(), functionGetDirectStreamDetails, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function), + GlobalPropertyInfo(builtinNames.fulfillModuleSyncPrivateName(), JSFunction::create(vm, this, 1, String(), functionFulfillModuleSync, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), + GlobalPropertyInfo(builtinNames.directPrivateName(), JSFunction::create(vm, this, 1, String(), functionGetDirectStreamDetails, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), GlobalPropertyInfo(vm.propertyNames->builtinNames().ArrayBufferPrivateName(), arrayBufferConstructor(), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), - GlobalPropertyInfo(builtinNames.LoaderPrivateName(), this->moduleLoader(), 0), + GlobalPropertyInfo(builtinNames.LoaderPrivateName(), this->moduleLoader(), PropertyAttribute::DontDelete | 0), GlobalPropertyInfo(builtinNames.internalModuleRegistryPrivateName(), this->internalModuleRegistry(), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), GlobalPropertyInfo(builtinNames.processBindingConstantsPrivateName(), this->processBindingConstants(), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), - GlobalPropertyInfo(builtinNames.requireMapPrivateName(), this->requireMap(), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0), + GlobalPropertyInfo(builtinNames.requireMapPrivateName(), this->requireMap(), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | 0), }; addStaticGlobals(staticGlobals, std::size(staticGlobals)); @@ -3727,39 +3719,39 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) putDirectBuiltinFunction(vm, this, builtinNames.overridableRequirePrivateName(), moduleOverridableRequireCodeGenerator(vm), 0); - putDirectNativeFunction(vm, this, builtinNames.createUninitializedArrayBufferPrivateName(), 1, functionCreateUninitializedArrayBuffer, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); - putDirectNativeFunction(vm, this, builtinNames.resolveSyncPrivateName(), 1, functionImportMeta__resolveSyncPrivate, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); - putDirectNativeFunction(vm, this, builtinNames.createInternalModuleByIdPrivateName(), 1, InternalModuleRegistry::jsCreateInternalModuleById, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); + putDirectNativeFunction(vm, this, builtinNames.createUninitializedArrayBufferPrivateName(), 1, functionCreateUninitializedArrayBuffer, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); + putDirectNativeFunction(vm, this, builtinNames.resolveSyncPrivateName(), 1, functionImportMeta__resolveSyncPrivate, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); + putDirectNativeFunction(vm, this, builtinNames.createInternalModuleByIdPrivateName(), 1, InternalModuleRegistry::jsCreateInternalModuleById, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); + putDirectNativeFunction(vm, this, builtinNames.createCommonJSModulePrivateName(), 2, Bun::jsFunctionCreateCommonJSModule, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | 0); putDirectNativeFunction(vm, this, builtinNames.evaluateCommonJSModulePrivateName(), 2, Bun::jsFunctionLoadModule, ImplementationVisibility::Public, NoIntrinsic, - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); - - putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().BufferPrivateName(), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, builtinNames.lazyStreamPrototypeMapPrivateName(), JSC::CustomGetterSetter::create(vm, functionLazyLoadStreamPrototypeMap_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0); - - putDirectCustomAccessor(vm, builtinNames.TransformStreamPrivateName(), CustomGetterSetter::create(vm, TransformStream_getter, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); - putDirectCustomAccessor(vm, builtinNames.TransformStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, TransformStreamDefaultController_getter, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); - putDirectCustomAccessor(vm, builtinNames.ReadableByteStreamControllerPrivateName(), CustomGetterSetter::create(vm, ReadableByteStreamController_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.ReadableStreamPrivateName(), CustomGetterSetter::create(vm, ReadableStream_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBReaderPrivateName(), CustomGetterSetter::create(vm, ReadableStreamBYOBReader_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBRequestPrivateName(), CustomGetterSetter::create(vm, ReadableStreamBYOBRequest_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, ReadableStreamDefaultController_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultReaderPrivateName(), CustomGetterSetter::create(vm, ReadableStreamDefaultReader_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.WritableStreamPrivateName(), CustomGetterSetter::create(vm, WritableStream_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, WritableStreamDefaultController_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultWriterPrivateName(), CustomGetterSetter::create(vm, WritableStreamDefaultWriter_getter, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, builtinNames.AbortSignalPrivateName(), CustomGetterSetter::create(vm, AbortSignal_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | 0); + + putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().BufferPrivateName(), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.lazyStreamPrototypeMapPrivateName(), JSC::CustomGetterSetter::create(vm, functionLazyLoadStreamPrototypeMap_getter, nullptr), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.TransformStreamPrivateName(), CustomGetterSetter::create(vm, TransformStream_getter, nullptr), attributesForStructure(static_cast<unsigned>(PropertyAttribute::DontEnum)) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.TransformStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, TransformStreamDefaultController_getter, nullptr), attributesForStructure(static_cast<unsigned>(PropertyAttribute::DontEnum)) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.ReadableByteStreamControllerPrivateName(), CustomGetterSetter::create(vm, ReadableByteStreamController_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamPrivateName(), CustomGetterSetter::create(vm, ReadableStream_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBReaderPrivateName(), CustomGetterSetter::create(vm, ReadableStreamBYOBReader_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBRequestPrivateName(), CustomGetterSetter::create(vm, ReadableStreamBYOBRequest_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, ReadableStreamDefaultController_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultReaderPrivateName(), CustomGetterSetter::create(vm, ReadableStreamDefaultReader_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.WritableStreamPrivateName(), CustomGetterSetter::create(vm, WritableStream_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, WritableStreamDefaultController_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultWriterPrivateName(), CustomGetterSetter::create(vm, WritableStreamDefaultWriter_getter, nullptr), attributesForStructure(PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly) | PropertyAttribute::CustomAccessorOrValue); + putDirectCustomAccessor(vm, builtinNames.AbortSignalPrivateName(), CustomGetterSetter::create(vm, AbortSignal_getter, nullptr), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::CustomAccessorOrValue); // ----- Public Properties ----- @@ -3772,7 +3764,7 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) this, JSFunction::create(vm, this, 0, "get"_s, functionGetSelf, ImplementationVisibility::Public), JSFunction::create(vm, this, 0, "set"_s, functionSetSelf, ImplementationVisibility::Public)), - 0); + PropertyAttribute::Accessor | 0); // TODO: this should be usable on the lookup table. it crashed las time i tried it putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "onmessage"_s), JSC::CustomGetterSetter::create(vm, globalOnMessage, setGlobalOnMessage), 0); @@ -3783,14 +3775,14 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) JSC::JSObject* errorConstructor = this->errorConstructor(); errorConstructor->putDirectNativeFunction(vm, this, JSC::Identifier::fromString(vm, "captureStackTrace"_s), 2, errorConstructorFuncCaptureStackTrace, ImplementationVisibility::Public, JSC::NoIntrinsic, PropertyAttribute::DontEnum | 0); errorConstructor->putDirectNativeFunction(vm, this, JSC::Identifier::fromString(vm, "appendStackTrace"_s), 2, errorConstructorFuncAppendStackTrace, ImplementationVisibility::Private, JSC::NoIntrinsic, PropertyAttribute::DontEnum | 0); - errorConstructor->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "prepareStackTrace"_s), JSC::CustomGetterSetter::create(vm, errorConstructorPrepareStackTraceGetter, errorConstructorPrepareStackTraceSetter), PropertyAttribute::DontEnum | 0); + errorConstructor->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "prepareStackTrace"_s), JSC::CustomGetterSetter::create(vm, errorConstructorPrepareStackTraceGetter, errorConstructorPrepareStackTraceSetter), PropertyAttribute::DontEnum | PropertyAttribute::CustomValue); JSC::JSObject* consoleObject = this->get(this, JSC::Identifier::fromString(vm, "console"_s)).getObject(); consoleObject->putDirectBuiltinFunction(vm, this, vm.propertyNames->asyncIteratorSymbol, consoleObjectAsyncIteratorCodeGenerator(vm), PropertyAttribute::Builtin | 0); consoleObject->putDirectBuiltinFunction(vm, this, clientData->builtinNames().writePublicName(), consoleObjectWriteCodeGenerator(vm), PropertyAttribute::Builtin | 0); - consoleObject->putDirectCustomAccessor(vm, Identifier::fromString(vm, "Console"_s), CustomGetterSetter::create(vm, getConsoleConstructor, nullptr), 0); - consoleObject->putDirectCustomAccessor(vm, Identifier::fromString(vm, "_stdout"_s), CustomGetterSetter::create(vm, getConsoleStdout, nullptr), PropertyAttribute::DontEnum | 0); - consoleObject->putDirectCustomAccessor(vm, Identifier::fromString(vm, "_stderr"_s), CustomGetterSetter::create(vm, getConsoleStderr, nullptr), PropertyAttribute::DontEnum | 0); + consoleObject->putDirectCustomAccessor(vm, Identifier::fromString(vm, "Console"_s), CustomGetterSetter::create(vm, getConsoleConstructor, nullptr), PropertyAttribute::CustomValue | 0); + consoleObject->putDirectCustomAccessor(vm, Identifier::fromString(vm, "_stdout"_s), CustomGetterSetter::create(vm, getConsoleStdout, nullptr), PropertyAttribute::DontEnum | PropertyAttribute::CustomValue | 0); + consoleObject->putDirectCustomAccessor(vm, Identifier::fromString(vm, "_stderr"_s), CustomGetterSetter::create(vm, getConsoleStderr, nullptr), PropertyAttribute::DontEnum | PropertyAttribute::CustomValue | 0); } extern "C" bool JSC__JSGlobalObject__startRemoteInspector(JSC__JSGlobalObject* globalObject, unsigned char* host, uint16_t arg1) @@ -4022,7 +4014,7 @@ template void GlobalObject::visitOutputConstraints(JSCell*, SlotVisitor&); // void GlobalObject::destroy(JSCell* cell) // { -// static_cast<Zig::GlobalObject*>(cell)->Zig::GlobalObject::~Zig::GlobalObject(); +// jsCast<Zig::GlobalObject*>(cell)->Zig::GlobalObject::~Zig::GlobalObject(); // } // template<typename Visitor> diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index a36752398..19630d4b7 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -422,6 +422,7 @@ public: private: void addBuiltinGlobals(JSC::VM&); + void finishCreation(JSC::VM&); friend void WebCore::JSBuiltinInternalFunctions::initialize(Zig::GlobalObject&); WebCore::JSBuiltinInternalFunctions m_builtinInternalFunctions; @@ -517,7 +518,7 @@ private: DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock); void* m_bunVM; - WebCore::SubtleCrypto* crypto = nullptr; + WebCore::SubtleCrypto* m_subtleCrypto = nullptr; WTF::Vector<JSC::Strong<JSC::JSPromise>> m_aboutToBeNotifiedRejectedPromises; WTF::Vector<JSC::Strong<JSC::JSFunction>> m_ffiFunctions; diff --git a/src/bun.js/bindings/ZigLazyStaticFunctions-inlines.h b/src/bun.js/bindings/ZigLazyStaticFunctions-inlines.h index c97393723..0c13ecd58 100644 --- a/src/bun.js/bindings/ZigLazyStaticFunctions-inlines.h +++ b/src/bun.js/bindings/ZigLazyStaticFunctions-inlines.h @@ -25,7 +25,7 @@ static void DOMCall__FFI__ptr__put(JSC::JSGlobalObject* globalObject, JSC::Encod globalObject->vm(), Identifier::fromString(globalObject->vm(), "ptr"_s), function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); + 0); } /* -- END DOMCall DEFINITIONS-- */ diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 49300198e..117b848ef 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -348,10 +348,8 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, // need to check this before primitives, asymmetric matchers // can match against any type of value. if constexpr (enableAsymmetricMatchers) { - JSCell* c1 = v1.asCell(); - JSCell* c2 = v2.asCell(); - if (v2.isCell() && !v2.isEmpty() && c2->type() == JSC::JSType(JSDOMWrapperType)) { - switch (matchAsymmetricMatcher(globalObject, c2, v1, scope)) { + if (v2.isCell() && !v2.isEmpty() && v2.asCell()->type() == JSC::JSType(JSDOMWrapperType)) { + switch (matchAsymmetricMatcher(globalObject, v2.asCell(), v1, scope)) { case AsymmetricMatcherResult::FAIL: return false; case AsymmetricMatcherResult::PASS: @@ -360,8 +358,8 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, // continue comparison break; } - } else if (v1.isCell() && !v1.isEmpty() && c1->type() == JSC::JSType(JSDOMWrapperType)) { - switch (matchAsymmetricMatcher(globalObject, c1, v2, scope)) { + } else if (v1.isCell() && !v1.isEmpty() && v1.asCell()->type() == JSC::JSType(JSDOMWrapperType)) { + switch (matchAsymmetricMatcher(globalObject, v1.asCell(), v2, scope)) { case AsymmetricMatcherResult::FAIL: return false; case AsymmetricMatcherResult::PASS: @@ -1084,7 +1082,9 @@ void WebCore__FetchHeaders__toUWSResponse(WebCore__FetchHeaders* arg0, bool is_s WebCore__FetchHeaders* WebCore__FetchHeaders__createEmpty() { - return new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }); + auto* headers = new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }); + headers->relaxAdoptionRequirement(); + return headers; } void WebCore__FetchHeaders__append(WebCore__FetchHeaders* headers, const ZigString* arg1, const ZigString* arg2, JSC__JSGlobalObject* lexicalGlobalObject) @@ -1113,6 +1113,7 @@ WebCore__FetchHeaders* WebCore__FetchHeaders__createFromJS(JSC__JSGlobalObject* RETURN_IF_EXCEPTION(throwScope, nullptr); auto* headers = new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }); + headers->relaxAdoptionRequirement(); if (init) { // `fill` doesn't set an exception on the VM if it fails, it returns an // ExceptionOr<void>. So we need to check for the exception and, if set, @@ -1151,6 +1152,7 @@ WebCore__FetchHeaders* WebCore__FetchHeaders__cloneThis(WebCore__FetchHeaders* h { auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); auto* clone = new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }); + clone->relaxAdoptionRequirement(); WebCore::propagateException(*lexicalGlobalObject, throwScope, clone->fill(*headers)); return clone; @@ -1220,6 +1222,7 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createFromPicoHeaders_(const void* { PicoHTTPHeaders pico_headers = *reinterpret_cast<const PicoHTTPHeaders*>(arg1); auto* headers = new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }); + headers->relaxAdoptionRequirement(); // This prevents an assertion later, but may not be the proper approach. if (pico_headers.len > 0) { HTTPHeaderMap map = HTTPHeaderMap(); @@ -1262,6 +1265,8 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* size_t i = 0; auto* headers = new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }); + headers->relaxAdoptionRequirement(); // This prevents an assertion later, but may not be the proper approach. + HTTPHeaderMap map = HTTPHeaderMap(); for (const auto& header : req) { @@ -1285,7 +1290,6 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* if (i > 56) __builtin_unreachable(); } - headers->setInternalHeaders(WTFMove(map)); return headers; } @@ -2357,29 +2361,31 @@ JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject* globalObject, JSC::JSArray* array = nullptr; { + JSC::GCDeferralContext deferralContext(vm); JSC::ObjectInitializationScope initializationScope(vm); if ((array = JSC::JSArray::tryCreateUninitializedRestricted( - initializationScope, nullptr, + initializationScope, &deferralContext, globalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous), arg2))) { if (!clone) { for (size_t i = 0; i < arg2; ++i) { - array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toString(arg1[i]))); + array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toString(arg1[i]), &deferralContext)); } } else { for (size_t i = 0; i < arg2; ++i) { - array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toStringCopy(arg1[i]))); + array->putDirectIndex(globalObject, i, JSC::jsString(vm, Zig::toStringCopy(arg1[i]), &deferralContext)); } } } - } - if (!array) { - JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue()); - } - RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::JSValue(array))); + if (!array) { + JSC::throwOutOfMemoryError(globalObject, scope); + return JSC::JSValue::encode(JSC::JSValue()); + } + + RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::JSValue(array))); + } } JSC__JSValue JSC__JSGlobalObject__createAggregateError(JSC__JSGlobalObject* globalObject, @@ -2857,7 +2863,7 @@ JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0) { return &arg0->vm() void JSC__JSGlobalObject__handleRejectedPromises(JSC__JSGlobalObject* arg0) { - return static_cast<Zig::GlobalObject*>(arg0)->handleRejectedPromises(); + return jsCast<Zig::GlobalObject*>(arg0)->handleRejectedPromises(); } #pragma mark - JSC::JSValue @@ -3066,20 +3072,16 @@ JSC__JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0) int64_t JSC__JSValue__toInt64(JSC__JSValue val) { - JSC::JSValue _val = JSC::JSValue::decode(val); - - int64_t result = JSC::tryConvertToInt52(_val.asDouble()); - if (result != JSC::JSValue::notInt52) { - return result; - } - - if (_val.isHeapBigInt()) { - - if (auto* heapBigInt = _val.asHeapBigInt()) { + JSC::JSValue value = JSC::JSValue::decode(val); + ASSERT(value.isHeapBigInt() || value.isNumber()); + if (value.isHeapBigInt()) { + if (auto* heapBigInt = value.asHeapBigInt()) { return heapBigInt->toBigInt64(heapBigInt); } } - return _val.asAnyInt(); + if (value.isInt32()) + return value.asInt32(); + return static_cast<int64_t>(value.asDouble()); } uint8_t JSC__JSValue__asBigIntCompare(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, JSC__JSValue JSValue1) @@ -3140,28 +3142,28 @@ JSC__JSValue JSC__JSValue__fromUInt64NoTruncate(JSC__JSGlobalObject* globalObjec uint64_t JSC__JSValue__toUInt64NoTruncate(JSC__JSValue val) { - JSC::JSValue _val = JSC::JSValue::decode(val); - - int64_t result = JSC::tryConvertToInt52(_val.asDouble()); - if (result != JSC::JSValue::notInt52) { - if (result < 0) - return 0; - - return static_cast<uint64_t>(result); - } + JSC::JSValue value = JSC::JSValue::decode(val); + ASSERT(value.isHeapBigInt() || value.isNumber()); - if (_val.isHeapBigInt()) { - - if (auto* heapBigInt = _val.asHeapBigInt()) { + if (value.isHeapBigInt()) { + if (auto* heapBigInt = value.asHeapBigInt()) { return heapBigInt->toBigUInt64(heapBigInt); } } - if (!_val.isNumber()) { - return 0; + if (value.isInt32()) { + return static_cast<uint64_t>(value.asInt32()); } + ASSERT(value.isDouble()); - return static_cast<uint64_t>(_val.asAnyInt()); + int64_t result = JSC::tryConvertToInt52(value.asDouble()); + if (result != JSC::JSValue::notInt52) { + if (result < 0) + return 0; + + return static_cast<uint64_t>(result); + } + return 0; } JSC__JSValue JSC__JSValue__createObject2(JSC__JSGlobalObject* globalObject, const ZigString* arg1, diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index e4fb9d624..cffb9f0c9 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -298,7 +298,7 @@ CPP_DECL void JSC__JSMap__set(JSC__JSMap* arg0, JSC__JSGlobalObject* arg1, JSC__ #pragma mark - JSC::JSValue -CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__JSValue(* ArgFn3)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1), JSC__JSValue(* ArgFn4)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1)); +CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__JSValue(* ArgFn3)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1), JSC__JSValue(* ArgFn4)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1)) __attribute__((nonnull (3, 4))); CPP_DECL bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, Bun__ArrayBuffer* arg2); CPP_DECL unsigned char JSC__JSValue__asBigIntCompare(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0); diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index 9823a59b6..005a753d0 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -200,10 +200,6 @@ static uint32_t getPropertyAttributes(napi_property_descriptor prop) // result |= JSC::PropertyAttribute::ReadOnly; // } - if (prop.method) { - result |= JSC::PropertyAttribute::Function; - } - return result; } @@ -257,7 +253,7 @@ static void defineNapiProperty(Zig::GlobalObject* globalObject, JSC::JSObject* t value = JSC::JSValue(function); // } - to->putDirect(vm, propertyName, value, getPropertyAttributes(property) | JSC::PropertyAttribute::Function); + to->putDirect(vm, propertyName, value, getPropertyAttributes(property)); return; } diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index cad20df6f..2ce4cc9a6 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -188,7 +188,7 @@ public: JSC::JSValue rebind(JSGlobalObject* globalObject, JSC::JSValue values, bool clone); 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()); + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSFunctionType, StructureFlags), info()); } bool need_update() { return version_db->version.load() != version; } @@ -341,10 +341,6 @@ void JSSQLStatement::destroy(JSC::JSCell* cell) thisObject->stmt = nullptr; } -void JSSQLStatementConstructor::destroy(JSC::JSCell* cell) -{ -} - static inline bool rebindValue(JSC::JSGlobalObject* lexicalGlobalObject, sqlite3_stmt* stmt, int i, JSC::JSValue value, JSC::ThrowScope& scope, bool clone) { #define CHECK_BIND(param) \ @@ -695,7 +691,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje return JSValue::encode(JSC::jsUndefined()); } - if(sqlite3_compileoption_used("SQLITE_OMIT_LOAD_EXTENSION")) { + if (sqlite3_compileoption_used("SQLITE_OMIT_LOAD_EXTENSION")) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "This build of sqlite3 does not support dynamic extension loading"_s)); return JSValue::encode(JSC::jsUndefined()); } @@ -1064,7 +1060,7 @@ static const HashTableValue JSSQLStatementConstructorTableValues[] = { { "deserialize"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsSQLStatementDeserialize, 2 } }, }; -const ClassInfo JSSQLStatementConstructor::s_info = { "SQLStatement"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLStatementConstructor) }; +const ClassInfo JSSQLStatementConstructor::s_info = { "SQLStatement"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLStatementConstructor) }; void JSSQLStatementConstructor::finishCreation(VM& vm) { @@ -1636,7 +1632,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFunctionFinalize, (JSC::JSGlobalObject * RELEASE_AND_RETURN(scope, JSValue::encode(jsUndefined())); } -const ClassInfo JSSQLStatement::s_info = { "SQLStatement"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLStatement) }; +const ClassInfo JSSQLStatement::s_info = { "SQLStatement"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLStatement) }; /* Hash table for prototype */ static const HashTableValue JSSQLStatementTableValues[] = { diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.h b/src/bun.js/bindings/sqlite/JSSQLStatement.h index 8566fcdd9..b628f2a38 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.h +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.h @@ -50,25 +50,15 @@ namespace WebCore { class JSSQLStatementConstructor final : public JSC::JSFunction { public: using Base = JSC::JSFunction; + static constexpr unsigned StructureFlags = Base::StructureFlags; + static JSSQLStatementConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure); DECLARE_INFO; - template<typename, SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl<JSSQLStatementConstructor, WebCore::UseCustomHeapCellType::No>( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForJSSQLStatementConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSQLStatementConstructor = std::forward<decltype(space)>(space); }, - [](auto& spaces) { return spaces.m_subspaceForJSSQLStatementConstructor.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSQLStatementConstructor = std::forward<decltype(space)>(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()); + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSFunctionType, StructureFlags), info()); } private: @@ -79,5 +69,6 @@ private: void finishCreation(JSC::VM&); }; +static_assert(sizeof(JSSQLStatementConstructor) == sizeof(JSFunction), "Allocate JSSQLStatementConstructor in JSFunction IsoSubspace"); }
\ No newline at end of file diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.cpp b/src/bun.js/bindings/webcore/JSEventEmitter.cpp index 959cbd8d7..e81af9549 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.cpp +++ b/src/bun.js/bindings/webcore/JSEventEmitter.cpp @@ -109,9 +109,10 @@ template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSEventEmitterDOMConstructor: if constexpr (IsExceptionOr<decltype(object)>) RETURN_IF_EXCEPTION(throwScope, {}); - if (JSValue maxListeners = castedThis->getIfPropertyExists(lexicalGlobalObject, JSC::Identifier::fromString(vm, "defaultMaxListeners"_s))) { - if (maxListeners.isUInt32()) - object->setMaxListeners(maxListeners.toUInt32(lexicalGlobalObject)); + JSValue maxListeners = castedThis->getIfPropertyExists(lexicalGlobalObject, JSC::Identifier::fromString(vm, "defaultMaxListeners"_s)); + RETURN_IF_EXCEPTION(throwScope, {}); + if (maxListeners && maxListeners.isUInt32()) { + object->setMaxListeners(maxListeners.toUInt32(lexicalGlobalObject)); } static_assert(TypeOrExceptionOrUnderlyingType<decltype(object)>::isRef); auto jsValue = toJSNewlyCreated<IDLInterface<EventEmitter>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object)); diff --git a/src/bun.js/bindings/webcore/JSReadableStream.cpp b/src/bun.js/bindings/webcore/JSReadableStream.cpp index 3fea3d44f..0a0ef3b23 100644 --- a/src/bun.js/bindings/webcore/JSReadableStream.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStream.cpp @@ -108,7 +108,7 @@ template<> FunctionExecutable* JSReadableStreamDOMConstructor::initializeExecuta static const HashTableValue JSReadableStreamPrototypeTableValues[] = { { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, jsReadableStreamConstructor, 0 } }, - { "locked"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamLockedCodeGenerator, 0 } }, + { "locked"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinAccessorType, readableStreamLockedCodeGenerator, 0 } }, { "cancel"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamCancelCodeGenerator, 0 } }, { "getReader"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamGetReaderCodeGenerator, 0 } }, { "pipeTo"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamPipeToCodeGenerator, 1 } }, diff --git a/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp b/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp index fea3ffc8c..b15084041 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp @@ -108,7 +108,7 @@ template<> FunctionExecutable* JSReadableStreamDefaultControllerDOMConstructor:: static const HashTableValue JSReadableStreamDefaultControllerPrototypeTableValues[] = { { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, jsReadableStreamDefaultControllerConstructor, 0 } }, - { "desiredSize"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultControllerDesiredSizeCodeGenerator, 0 } }, + { "desiredSize"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinAccessorType, readableStreamDefaultControllerDesiredSizeCodeGenerator, 0 } }, { "enqueue"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultControllerEnqueueCodeGenerator, 0 } }, { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultControllerCloseCodeGenerator, 0 } }, { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultControllerErrorCodeGenerator, 0 } }, diff --git a/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp b/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp index 55b89ad46..68b587a92 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp @@ -108,7 +108,7 @@ template<> FunctionExecutable* JSReadableStreamDefaultReaderDOMConstructor::init static const HashTableValue JSReadableStreamDefaultReaderPrototypeTableValues[] = { { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, jsReadableStreamDefaultReaderConstructor, 0 } }, - { "closed"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultReaderClosedCodeGenerator, 0 } }, + { "closed"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinAccessorType, readableStreamDefaultReaderClosedCodeGenerator, 0 } }, { "read"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultReaderReadCodeGenerator, 0 } }, { "readMany"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultReaderReadManyCodeGenerator, 0 } }, { "cancel"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, readableStreamDefaultReaderCancelCodeGenerator, 0 } }, diff --git a/src/bun.js/bindings/webcore/MessagePort.cpp b/src/bun.js/bindings/webcore/MessagePort.cpp index da2bd32e8..b463791df 100644 --- a/src/bun.js/bindings/webcore/MessagePort.cpp +++ b/src/bun.js/bindings/webcore/MessagePort.cpp @@ -141,7 +141,7 @@ MessagePort::MessagePort(ScriptExecutionContext& scriptExecutionContext, const M , m_identifier(local) , m_remoteIdentifier(remote) { - LOG(MessagePorts, "Created MessagePort %s (%p) in process %" PRIu64, m_identifier.logString().utf8().data(), this, ProcessIdent::identifier().toUInt64()); + // LOG(MessagePorts, "Created MessagePort %s (%p) in process %" PRIu64, m_identifier.logString().utf8().data(), this, ProcessIdent::identifier().toUInt64()); Locker locker { allMessagePortsLock }; allMessagePorts().set(m_identifier, this); @@ -157,7 +157,7 @@ MessagePort::MessagePort(ScriptExecutionContext& scriptExecutionContext, const M MessagePort::~MessagePort() { - LOG(MessagePorts, "Destroyed MessagePort %s (%p) in process %" PRIu64, m_identifier.logString().utf8().data(), this, ProcessIdent::identifier().toUInt64()); + // LOG(MessagePorts, "Destroyed MessagePort %s (%p) in process %" PRIu64, m_identifier.logString().utf8().data(), this, ProcessIdent::identifier().toUInt64()); ASSERT(allMessagePortsLock.isLocked()); @@ -175,7 +175,7 @@ void MessagePort::entangle() ExceptionOr<void> MessagePort::postMessage(JSC::JSGlobalObject& state, JSC::JSValue messageValue, StructuredSerializeOptions&& options) { - LOG(MessagePorts, "Attempting to post message to port %s (to be received by port %s)", m_identifier.logString().utf8().data(), m_remoteIdentifier.logString().utf8().data()); + // LOG(MessagePorts, "Attempting to post message to port %s (to be received by port %s)", m_identifier.logString().utf8().data(), m_remoteIdentifier.logString().utf8().data()); Vector<RefPtr<MessagePort>> ports; auto messageData = SerializedScriptValue::create(state, messageValue, WTFMove(options.transfer), ports, SerializationForStorage::No, SerializationContext::WorkerPostMessage); @@ -202,7 +202,7 @@ ExceptionOr<void> MessagePort::postMessage(JSC::JSGlobalObject& state, JSC::JSVa MessageWithMessagePorts message { messageData.releaseReturnValue(), WTFMove(transferredPorts) }; - LOG(MessagePorts, "Actually posting message to port %s (to be received by port %s)", m_identifier.logString().utf8().data(), m_remoteIdentifier.logString().utf8().data()); + // LOG(MessagePorts, "Actually posting message to port %s (to be received by port %s)", m_identifier.logString().utf8().data(), m_remoteIdentifier.logString().utf8().data()); ScriptExecutionContextIdentifier contextId = contextIdForMessagePortId(m_remoteIdentifier); @@ -280,7 +280,7 @@ void MessagePort::dispatchMessages() auto messagesTakenHandler = [this, protectedThis = Ref { *this }](Vector<MessageWithMessagePorts>&& messages, CompletionHandler<void()>&& completionCallback) mutable { auto scopeExit = makeScopeExit(WTFMove(completionCallback)); - LOG(MessagePorts, "MessagePort %s (%p) dispatching %zu messages", m_identifier.logString().utf8().data(), this, messages.size()); + // LOG(MessagePorts, "MessagePort %s (%p) dispatching %zu messages", m_identifier.logString().utf8().data(), this, messages.size()); auto* context = scriptExecutionContext(); if (!context || !context->jsGlobalObject()) @@ -382,7 +382,7 @@ ExceptionOr<Vector<TransferredMessagePort>> MessagePort::disentanglePorts(Vector Vector<RefPtr<MessagePort>> MessagePort::entanglePorts(ScriptExecutionContext& context, Vector<TransferredMessagePort>&& transferredPorts) { - LOG(MessagePorts, "Entangling %zu transferred ports to ScriptExecutionContext %s (%p)", transferredPorts.size(), context.url().string().utf8().data(), &context); + // LOG(MessagePorts, "Entangling %zu transferred ports to ScriptExecutionContext %s (%p)", transferredPorts.size(), context.url().string().utf8().data(), &context); if (transferredPorts.isEmpty()) return {}; diff --git a/src/bun.js/bindings/webcore/MessagePortChannel.cpp b/src/bun.js/bindings/webcore/MessagePortChannel.cpp index 031679204..425fb8c11 100644 --- a/src/bun.js/bindings/webcore/MessagePortChannel.cpp +++ b/src/bun.js/bindings/webcore/MessagePortChannel.cpp @@ -75,7 +75,7 @@ void MessagePortChannel::entanglePortWithProcess(const MessagePortIdentifier& po ASSERT(port == m_ports[0] || port == m_ports[1]); size_t i = port == m_ports[0] ? 0 : 1; - LOG(MessagePorts, "MessagePortChannel %s (%p) entangling port %s (that port has %zu messages available)", logString().utf8().data(), this, port.logString().utf8().data(), m_pendingMessages[i].size()); + // LOG(MessagePorts, "MessagePortChannel %s (%p) entangling port %s (that port has %zu messages available)", logString().utf8().data(), this, port.logString().utf8().data(), m_pendingMessages[i].size()); ASSERT(!m_processes[i] || *m_processes[i] == process); m_processes[i] = process; @@ -85,7 +85,7 @@ void MessagePortChannel::entanglePortWithProcess(const MessagePortIdentifier& po void MessagePortChannel::disentanglePort(const MessagePortIdentifier& port) { - LOG(MessagePorts, "MessagePortChannel %s (%p) disentangling port %s", logString().utf8().data(), this, port.logString().utf8().data()); + // LOG(MessagePorts, "MessagePortChannel %s (%p) disentangling port %s", logString().utf8().data(), this, port.logString().utf8().data()); ASSERT(port == m_ports[0] || port == m_ports[1]); size_t i = port == m_ports[0] ? 0 : 1; @@ -123,7 +123,7 @@ bool MessagePortChannel::postMessageToRemote(MessageWithMessagePorts&& message, size_t i = remoteTarget == m_ports[0] ? 0 : 1; m_pendingMessages[i].append(WTFMove(message)); - LOG(MessagePorts, "MessagePortChannel %s (%p) now has %zu messages pending on port %s", logString().utf8().data(), this, m_pendingMessages[i].size(), remoteTarget.logString().utf8().data()); + // LOG(MessagePorts, "MessagePortChannel %s (%p) now has %zu messages pending on port %s", logString().utf8().data(), this, m_pendingMessages[i].size(), remoteTarget.logString().utf8().data()); if (m_pendingMessages[i].size() == 1) { m_pendingMessageProtectors[i] = this; @@ -136,7 +136,7 @@ bool MessagePortChannel::postMessageToRemote(MessageWithMessagePorts&& message, void MessagePortChannel::takeAllMessagesForPort(const MessagePortIdentifier& port, CompletionHandler<void(Vector<MessageWithMessagePorts>&&, CompletionHandler<void()>&&)>&& callback) { - LOG(MessagePorts, "MessagePortChannel %p taking all messages for port %s", this, port.logString().utf8().data()); + // LOG(MessagePorts, "MessagePortChannel %p taking all messages for port %s", this, port.logString().utf8().data()); ASSERT(port == m_ports[0] || port == m_ports[1]); size_t i = port == m_ports[0] ? 0 : 1; @@ -153,7 +153,7 @@ void MessagePortChannel::takeAllMessagesForPort(const MessagePortIdentifier& por ++m_messageBatchesInFlight; - LOG(MessagePorts, "There are %zu messages to take for port %s. Taking them now, messages in flight is now %" PRIu64, result.size(), port.logString().utf8().data(), m_messageBatchesInFlight); + // LOG(MessagePorts, "There are %zu messages to take for port %s. Taking them now, messages in flight is now %" PRIu64, result.size(), port.logString().utf8().data(), m_messageBatchesInFlight); auto size = result.size(); callback(WTFMove(result), [size, this, port, protectedThis = WTFMove(m_pendingMessageProtectors[i])] { @@ -162,7 +162,7 @@ void MessagePortChannel::takeAllMessagesForPort(const MessagePortIdentifier& por UNUSED_PARAM(size); #endif --m_messageBatchesInFlight; - LOG(MessagePorts, "Message port channel %s was notified that a batch of %zu message port messages targeted for port %s just completed dispatch, in flight is now %" PRIu64, logString().utf8().data(), size, port.logString().utf8().data(), m_messageBatchesInFlight); + // LOG(MessagePorts, "Message port channel %s was notified that a batch of %zu message port messages targeted for port %s just completed dispatch, in flight is now %" PRIu64, logString().utf8().data(), size, port.logString().utf8().data(), m_messageBatchesInFlight); }); } diff --git a/src/bun.js/bindings/webcore/MessagePortChannelProvider.cpp b/src/bun.js/bindings/webcore/MessagePortChannelProvider.cpp index 7675a2e75..cde0d0dd4 100644 --- a/src/bun.js/bindings/webcore/MessagePortChannelProvider.cpp +++ b/src/bun.js/bindings/webcore/MessagePortChannelProvider.cpp @@ -38,7 +38,8 @@ static MessagePortChannelProviderImpl* globalProvider; MessagePortChannelProvider& MessagePortChannelProvider::singleton() { - ASSERT(isMainThread()); + // TODO: I think this assertion is relevant. Bun will call this on the Worker's thread + // ASSERT(isMainThread()); static std::once_flag onceFlag; std::call_once(onceFlag, [] { if (!globalProvider) diff --git a/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp b/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp index 5096357f2..a92262f63 100644 --- a/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp +++ b/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp @@ -30,6 +30,9 @@ #include <wtf/CompletionHandler.h> #include <wtf/MainThread.h> +// ASSERT(isMainThread()) is used alot here, and I think it may be required, but i'm not 100% sure. +// we totally are calling these off the main thread in many cases in Bun, so ........ + namespace WebCore { MessagePortChannelRegistry::MessagePortChannelRegistry() = default; @@ -41,15 +44,15 @@ MessagePortChannelRegistry::~MessagePortChannelRegistry() void MessagePortChannelRegistry::didCreateMessagePortChannel(const MessagePortIdentifier& port1, const MessagePortIdentifier& port2) { - LOG(MessagePorts, "Registry: Creating MessagePortChannel %p linking %s and %s", this, port1.logString().utf8().data(), port2.logString().utf8().data()); - ASSERT(isMainThread()); + // LOG(MessagePorts, "Registry: Creating MessagePortChannel %p linking %s and %s", this, port1.logString().utf8().data(), port2.logString().utf8().data()); + // ASSERT(isMainThread()); MessagePortChannel::create(*this, port1, port2); } void MessagePortChannelRegistry::messagePortChannelCreated(MessagePortChannel& channel) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); auto result = m_openChannels.ensure(channel.port1(), [channel = &channel] { return channel; @@ -64,7 +67,7 @@ void MessagePortChannelRegistry::messagePortChannelCreated(MessagePortChannel& c void MessagePortChannelRegistry::messagePortChannelDestroyed(MessagePortChannel& channel) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); ASSERT(m_openChannels.get(channel.port1()) == &channel); ASSERT(m_openChannels.get(channel.port2()) == &channel); @@ -72,12 +75,12 @@ void MessagePortChannelRegistry::messagePortChannelDestroyed(MessagePortChannel& m_openChannels.remove(channel.port1()); m_openChannels.remove(channel.port2()); - LOG(MessagePorts, "Registry: After removing channel %s there are %u channels left in the registry:", channel.logString().utf8().data(), m_openChannels.size()); + // LOG(MessagePorts, "Registry: After removing channel %s there are %u channels left in the registry:", channel.logString().utf8().data(), m_openChannels.size()); } void MessagePortChannelRegistry::didEntangleLocalToRemote(const MessagePortIdentifier& local, const MessagePortIdentifier& remote, ProcessIdentifier process) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); // The channel might be gone if the remote side was closed. auto* channel = m_openChannels.get(local); @@ -91,7 +94,7 @@ void MessagePortChannelRegistry::didEntangleLocalToRemote(const MessagePortIdent void MessagePortChannelRegistry::didDisentangleMessagePort(const MessagePortIdentifier& port) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); // The channel might be gone if the remote side was closed. auto* channel = m_openChannels.get(port); @@ -103,17 +106,17 @@ void MessagePortChannelRegistry::didDisentangleMessagePort(const MessagePortIden void MessagePortChannelRegistry::didCloseMessagePort(const MessagePortIdentifier& port) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); - LOG(MessagePorts, "Registry: MessagePort %s closed in registry", port.logString().utf8().data()); + // LOG(MessagePorts, "Registry: MessagePort %s closed in registry", port.logString().utf8().data()); auto* channel = m_openChannels.get(port); if (!channel) return; #ifndef NDEBUG - if (channel && channel->hasAnyMessagesPendingOrInFlight()) - LOG(MessagePorts, "Registry: (Note) The channel closed for port %s had messages pending or in flight", port.logString().utf8().data()); + // if (channel && channel->hasAnyMessagesPendingOrInFlight()) + // LOG(MessagePorts, "Registry: (Note) The channel closed for port %s had messages pending or in flight", port.logString().utf8().data()); #endif channel->closePort(port); @@ -124,14 +127,14 @@ void MessagePortChannelRegistry::didCloseMessagePort(const MessagePortIdentifier bool MessagePortChannelRegistry::didPostMessageToRemote(MessageWithMessagePorts&& message, const MessagePortIdentifier& remoteTarget) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); - LOG(MessagePorts, "Registry: Posting message to MessagePort %s in registry", remoteTarget.logString().utf8().data()); + // LOG(MessagePorts, "Registry: Posting message to MessagePort %s in registry", remoteTarget.logString().utf8().data()); // The channel might be gone if the remote side was closed. auto* channel = m_openChannels.get(remoteTarget); if (!channel) { - LOG(MessagePorts, "Registry: Could not find MessagePortChannel for port %s; It was probably closed. Message will be dropped.", remoteTarget.logString().utf8().data()); + // LOG(MessagePorts, "Registry: Could not find MessagePortChannel for port %s; It was probably closed. Message will be dropped.", remoteTarget.logString().utf8().data()); return false; } @@ -140,9 +143,9 @@ bool MessagePortChannelRegistry::didPostMessageToRemote(MessageWithMessagePorts& void MessagePortChannelRegistry::takeAllMessagesForPort(const MessagePortIdentifier& port, CompletionHandler<void(Vector<MessageWithMessagePorts>&&, CompletionHandler<void()>&&)>&& callback) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); - LOG(MessagePorts, "Registry: Taking all messages for MessagePort %s", port.logString().utf8().data()); + // LOG(MessagePorts, "Registry: Taking all messages for MessagePort %s", port.logString().utf8().data()); // The channel might be gone if the remote side was closed. auto* channel = m_openChannels.get(port); @@ -156,9 +159,9 @@ void MessagePortChannelRegistry::takeAllMessagesForPort(const MessagePortIdentif std::optional<MessageWithMessagePorts> MessagePortChannelRegistry::tryTakeMessageForPort(const MessagePortIdentifier& port) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); - LOG(MessagePorts, "Registry: Trying to take a message for MessagePort %s", port.logString().utf8().data()); + // LOG(MessagePorts, "Registry: Trying to take a message for MessagePort %s", port.logString().utf8().data()); // The channel might be gone if the remote side was closed. auto* channel = m_openChannels.get(port); @@ -170,7 +173,7 @@ std::optional<MessageWithMessagePorts> MessagePortChannelRegistry::tryTakeMessag MessagePortChannel* MessagePortChannelRegistry::existingChannelContainingPort(const MessagePortIdentifier& port) { - ASSERT(isMainThread()); + // ASSERT(isMainThread()); return m_openChannels.get(port); } diff --git a/src/bun.js/bindings/webcore/WebSocket.cpp b/src/bun.js/bindings/webcore/WebSocket.cpp index c1a4054f5..4f7f933c5 100644 --- a/src/bun.js/bindings/webcore/WebSocket.cpp +++ b/src/bun.js/bindings/webcore/WebSocket.cpp @@ -161,7 +161,6 @@ WebSocket::WebSocket(ScriptExecutionContext& context) { m_state = CONNECTING; m_hasPendingActivity.store(true); - ref(); } WebSocket::~WebSocket() @@ -650,7 +649,7 @@ ExceptionOr<void> WebSocket::close(std::optional<unsigned short> optionalCode, c ExceptionOr<void> WebSocket::terminate() { - LOG(Network, "WebSocket %p terminate()", this); + // LOG(Network, "WebSocket %p terminate()", this); if (m_state == CLOSING || m_state == CLOSED) return {}; @@ -692,7 +691,7 @@ ExceptionOr<void> WebSocket::terminate() ExceptionOr<void> WebSocket::ping() { auto message = WTF::String::number(WTF::jsCurrentTime()); - LOG(Network, "WebSocket %p ping() Sending Timestamp '%s'", this, message.data()); + // LOG(Network, "WebSocket %p ping() Sending Timestamp '%s'", this, message.data()); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -711,7 +710,7 @@ ExceptionOr<void> WebSocket::ping() ExceptionOr<void> WebSocket::ping(const String& message) { - LOG(Network, "WebSocket %p ping() Sending String '%s'", this, message.utf8().data()); + // LOG(Network, "WebSocket %p ping() Sending String '%s'", this, message.utf8().data()); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -731,7 +730,7 @@ ExceptionOr<void> WebSocket::ping(const String& message) ExceptionOr<void> WebSocket::ping(ArrayBuffer& binaryData) { - LOG(Network, "WebSocket %p ping() Sending ArrayBuffer %p", this, &binaryData); + // LOG(Network, "WebSocket %p ping() Sending ArrayBuffer %p", this, &binaryData); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -751,7 +750,7 @@ ExceptionOr<void> WebSocket::ping(ArrayBuffer& binaryData) ExceptionOr<void> WebSocket::ping(ArrayBufferView& arrayBufferView) { - LOG(Network, "WebSocket %p ping() Sending ArrayBufferView %p", this, &arrayBufferView); + // LOG(Network, "WebSocket %p ping() Sending ArrayBufferView %p", this, &arrayBufferView); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -774,7 +773,7 @@ ExceptionOr<void> WebSocket::ping(ArrayBufferView& arrayBufferView) ExceptionOr<void> WebSocket::pong() { auto message = WTF::String::number(WTF::jsCurrentTime()); - LOG(Network, "WebSocket %p pong() Sending Timestamp '%s'", this, message.data()); + // LOG(Network, "WebSocket %p pong() Sending Timestamp '%s'", this, message.data()); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -793,7 +792,7 @@ ExceptionOr<void> WebSocket::pong() ExceptionOr<void> WebSocket::pong(const String& message) { - LOG(Network, "WebSocket %p pong() Sending String '%s'", this, message.utf8().data()); + // LOG(Network, "WebSocket %p pong() Sending String '%s'", this, message.utf8().data()); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -813,7 +812,7 @@ ExceptionOr<void> WebSocket::pong(const String& message) ExceptionOr<void> WebSocket::pong(ArrayBuffer& binaryData) { - LOG(Network, "WebSocket %p pong() Sending ArrayBuffer %p", this, &binaryData); + // LOG(Network, "WebSocket %p pong() Sending ArrayBuffer %p", this, &binaryData); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -833,7 +832,7 @@ ExceptionOr<void> WebSocket::pong(ArrayBuffer& binaryData) ExceptionOr<void> WebSocket::pong(ArrayBufferView& arrayBufferView) { - LOG(Network, "WebSocket %p pong() Sending ArrayBufferView %p", this, &arrayBufferView); + // LOG(Network, "WebSocket %p pong() Sending ArrayBufferView %p", this, &arrayBufferView); if (m_state == CONNECTING) return Exception { InvalidStateError }; @@ -1431,7 +1430,7 @@ extern "C" void WebSocket__didAbruptClose(WebCore::WebSocket* webSocket, int32_t { webSocket->didFailWithErrorCode(errorCode); } -extern "C" void WebSocket__didClose(WebCore::WebSocket* webSocket, uint16_t errorCode, const BunString *reason) +extern "C" void WebSocket__didClose(WebCore::WebSocket* webSocket, uint16_t errorCode, const BunString* reason) { WTF::String wtf_reason = Bun::toWTFString(*reason); webSocket->didClose(0, errorCode, WTFMove(wtf_reason)); diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 8bc6a771e..c41b05e15 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -118,6 +118,7 @@ pub fn WorkTask(comptime Context: type, comptime async_io: bool) type { } pub fn runFromThreadPool(task: *TaskType) void { + JSC.markBinding(@src()); var this = @fieldParentPtr(This, "task", task); Context.run(this.ctx, this); } @@ -405,7 +406,7 @@ pub const Task = TaggedPointerUnion(.{ }); const UnboundedQueue = @import("./unbounded_queue.zig").UnboundedQueue; pub const ConcurrentTask = struct { - task: Task = undefined, + task: if (JSC.is_bindgen) void else Task = undefined, next: ?*ConcurrentTask = null, auto_delete: bool = false, @@ -426,14 +427,19 @@ pub const ConcurrentTask = struct { } pub fn createFrom(task: anytype) *ConcurrentTask { + JSC.markBinding(@src()); return create(Task.init(task)); } pub fn fromCallback(ptr: anytype, comptime callback: anytype) *ConcurrentTask { + JSC.markBinding(@src()); + return create(ManagedTask.New(std.meta.Child(@TypeOf(ptr)), callback).init(ptr)); } pub fn from(this: *ConcurrentTask, of: anytype, auto_deinit: AutoDeinit) *ConcurrentTask { + JSC.markBinding(@src()); + this.* = .{ .task = Task.init(of), .next = null, @@ -601,7 +607,7 @@ comptime { pub const DeferredRepeatingTask = *const (fn (*anyopaque) bool); pub const EventLoop = struct { - tasks: Queue = undefined, + tasks: if (JSC.is_bindgen) void else Queue = undefined, concurrent_tasks: ConcurrentTask.Queue = ConcurrentTask.Queue{}, global: *JSGlobalObject = undefined, virtual_machine: *JSC.VirtualMachine = undefined, @@ -925,6 +931,7 @@ pub const EventLoop = struct { } pub fn tickConcurrentWithCount(this: *EventLoop) usize { + JSC.markBinding(@src()); var concurrent = this.concurrent_tasks.popBatch(); const count = concurrent.count; if (count == 0) @@ -1067,6 +1074,8 @@ pub const EventLoop = struct { } pub fn tick(this: *EventLoop) void { + JSC.markBinding(@src()); + var ctx = this.virtual_machine; this.tickConcurrent(); @@ -1136,6 +1145,7 @@ pub const EventLoop = struct { } pub fn enqueueTask(this: *EventLoop, task: Task) void { + JSC.markBinding(@src()); this.tasks.writeItem(task) catch unreachable; } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index e93e65399..1c996039d 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -311,6 +311,7 @@ pub export fn Bun__Process__disconnect( globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame, ) JSValue { + JSC.markBinding(@src()); _ = callFrame; _ = globalObject; return .undefined; @@ -319,14 +320,20 @@ pub export fn Bun__Process__disconnect( /// This function is called on the main thread /// The bunVM() call will assert this pub export fn Bun__queueTask(global: *JSGlobalObject, task: *JSC.CppTask) void { + JSC.markBinding(@src()); + global.bunVM().eventLoop().enqueueTask(Task.init(task)); } pub export fn Bun__queueTaskWithTimeout(global: *JSGlobalObject, task: *JSC.CppTask, milliseconds: i32) void { + JSC.markBinding(@src()); + global.bunVM().eventLoop().enqueueTaskWithTimeout(Task.init(task), milliseconds); } pub export fn Bun__reportUnhandledError(globalObject: *JSGlobalObject, value: JSValue) callconv(.C) JSValue { + JSC.markBinding(@src()); + var jsc_vm = globalObject.bunVM(); jsc_vm.onUnhandledError(globalObject, value); return JSC.JSValue.jsUndefined(); @@ -336,6 +343,8 @@ pub export fn Bun__reportUnhandledError(globalObject: *JSGlobalObject, value: JS /// The main difference: we need to allocate the task & wakeup the thread /// We can avoid that if we run it from the main thread. pub export fn Bun__queueTaskConcurrently(global: *JSGlobalObject, task: *JSC.CppTask) void { + JSC.markBinding(@src()); + var concurrent = bun.default_allocator.create(JSC.ConcurrentTask) catch unreachable; concurrent.* = JSC.ConcurrentTask{ .task = Task.init(task), @@ -345,6 +354,8 @@ pub export fn Bun__queueTaskConcurrently(global: *JSGlobalObject, task: *JSC.Cpp } pub export fn Bun__handleRejectedPromise(global: *JSGlobalObject, promise: *JSC.JSPromise) void { + JSC.markBinding(@src()); + const result = promise.result(global.vm()); var jsc_vm = global.bunVM(); @@ -1030,6 +1041,8 @@ pub const VirtualMachine = struct { pub const MacroMap = std.AutoArrayHashMap(i32, js.JSObjectRef); pub fn enableMacroMode(this: *VirtualMachine) void { + JSC.markBinding(@src()); + if (!this.has_enabled_macro_mode) { this.has_enabled_macro_mode = true; this.macro_event_loop.tasks = EventLoop.Queue.init(default_allocator); @@ -1083,6 +1096,7 @@ pub const VirtualMachine = struct { pub fn initWithModuleGraph( opts: Options, ) !*VirtualMachine { + JSC.markBinding(@src()); const allocator = opts.allocator; VMHolder.vm = try allocator.create(VirtualMachine); var console = try allocator.create(ZigConsoleClient); @@ -1179,6 +1193,7 @@ pub const VirtualMachine = struct { }; pub fn init(opts: Options) !*VirtualMachine { + JSC.markBinding(@src()); const allocator = opts.allocator; var log: *logger.Log = undefined; if (opts.log) |__log| { @@ -1308,6 +1323,7 @@ pub const VirtualMachine = struct { worker: *WebWorker, opts: Options, ) anyerror!*VirtualMachine { + JSC.markBinding(@src()); var log: *logger.Log = undefined; const allocator = opts.allocator; if (opts.log) |__log| { @@ -1422,6 +1438,7 @@ pub const VirtualMachine = struct { pub fn refCountedStringWithWasNew(this: *VirtualMachine, new: *bool, input_: []const u8, hash_: ?u32, comptime dupe: bool) *JSC.RefString { JSC.markBinding(@src()); + std.debug.assert(input_.len > 0); const hash = hash_ orelse JSC.RefString.computeHash(input_); this.ref_strings_mutex.lock(); defer this.ref_strings_mutex.unlock(); @@ -1450,6 +1467,7 @@ pub const VirtualMachine = struct { } pub fn refCountedString(this: *VirtualMachine, input_: []const u8, hash_: ?u32, comptime dupe: bool) *JSC.RefString { + std.debug.assert(input_.len > 0); var _was_new = false; return this.refCountedStringWithWasNew(&_was_new, input_, hash_, comptime dupe); } diff --git a/src/bun.js/modules/BunJSCModule.h b/src/bun.js/modules/BunJSCModule.h index 1e64e7a02..74e745bad 100644 --- a/src/bun.js/modules/BunJSCModule.h +++ b/src/bun.js/modules/BunJSCModule.h @@ -746,7 +746,7 @@ JSC_DEFINE_HOST_FUNCTION(functionCodeCoverageForFile, namespace Zig { DEFINE_NATIVE_MODULE(BunJSC) { - INIT_NATIVE_MODULE(33); + INIT_NATIVE_MODULE(34); putNativeFn(Identifier::fromString(vm, "callerSourceOrigin"_s), functionCallerSourceOrigin); putNativeFn(Identifier::fromString(vm, "jscDescribe"_s), functionDescribe); diff --git a/src/bun.js/modules/NodeConstantsModule.h b/src/bun.js/modules/NodeConstantsModule.h index c1e324b0a..ce701f5e3 100644 --- a/src/bun.js/modules/NodeConstantsModule.h +++ b/src/bun.js/modules/NodeConstantsModule.h @@ -1,6 +1,8 @@ #include "_NativeModule.h" -// Modelled off of https://github.com/nodejs/node/blob/main/src/node_constants.cc -// Note that if you change any of this code, you probably also have to change ProcessBindingConstants.cpp +// Modelled off of +// https://github.com/nodejs/node/blob/main/src/node_constants.cc Note that if +// you change any of this code, you probably also have to change +// ProcessBindingConstants.cpp // require('constants') is implemented in node as a spread of: // - constants.os.dlopen @@ -12,16 +14,17 @@ // Instead of loading $processBindingConstants, we just inline it // These headers may not all be needed, but they are the ones node references. -// Most of the constants are defined with #if checks on existing #defines, instead of platform-checks -#include <openssl/ec.h> -#include <openssl/ssl.h> -#include <zlib.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> +// Most of the constants are defined with #if checks on existing #defines, +// instead of platform-checks #include <cerrno> #include <csignal> +#include <fcntl.h> #include <limits> +#include <openssl/ec.h> +#include <openssl/ssl.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <zlib.h> #ifndef OPENSSL_NO_ENGINE #include <openssl/engine.h> @@ -47,870 +50,940 @@ namespace Zig { using namespace WebCore; DEFINE_NATIVE_MODULE(NodeConstants) { - INIT_NATIVE_MODULE(63); + INIT_NATIVE_MODULE(0); #ifdef RTLD_LAZY - put(Identifier::fromString(vm, "RTLD_LAZY"_s), jsNumber(RTLD_LAZY)); + put(Identifier::fromString(vm, "RTLD_LAZY"_s), jsNumber(RTLD_LAZY)); #endif #ifdef RTLD_NOW - put(Identifier::fromString(vm, "RTLD_NOW"_s), jsNumber(RTLD_NOW)); + put(Identifier::fromString(vm, "RTLD_NOW"_s), jsNumber(RTLD_NOW)); #endif #ifdef RTLD_GLOBAL - put(Identifier::fromString(vm, "RTLD_GLOBAL"_s), jsNumber(RTLD_GLOBAL)); + put(Identifier::fromString(vm, "RTLD_GLOBAL"_s), jsNumber(RTLD_GLOBAL)); #endif #ifdef RTLD_LOCAL - put(Identifier::fromString(vm, "RTLD_LOCAL"_s), jsNumber(RTLD_LOCAL)); + put(Identifier::fromString(vm, "RTLD_LOCAL"_s), jsNumber(RTLD_LOCAL)); #endif #ifdef RTLD_DEEPBIND - put(Identifier::fromString(vm, "RTLD_DEEPBIND"_s), jsNumber(RTLD_DEEPBIND)); + put(Identifier::fromString(vm, "RTLD_DEEPBIND"_s), jsNumber(RTLD_DEEPBIND)); #endif #ifdef E2BIG - put(Identifier::fromString(vm, "E2BIG"_s), jsNumber(E2BIG)); + put(Identifier::fromString(vm, "E2BIG"_s), jsNumber(E2BIG)); #endif #ifdef EACCES - put(Identifier::fromString(vm, "EACCES"_s), jsNumber(EACCES)); + put(Identifier::fromString(vm, "EACCES"_s), jsNumber(EACCES)); #endif #ifdef EADDRINUSE - put(Identifier::fromString(vm, "EADDRINUSE"_s), jsNumber(EADDRINUSE)); + put(Identifier::fromString(vm, "EADDRINUSE"_s), jsNumber(EADDRINUSE)); #endif #ifdef EADDRNOTAVAIL - put(Identifier::fromString(vm, "EADDRNOTAVAIL"_s), jsNumber(EADDRNOTAVAIL)); + put(Identifier::fromString(vm, "EADDRNOTAVAIL"_s), jsNumber(EADDRNOTAVAIL)); #endif #ifdef EAFNOSUPPORT - put(Identifier::fromString(vm, "EAFNOSUPPORT"_s), jsNumber(EAFNOSUPPORT)); + put(Identifier::fromString(vm, "EAFNOSUPPORT"_s), jsNumber(EAFNOSUPPORT)); #endif #ifdef EAGAIN - put(Identifier::fromString(vm, "EAGAIN"_s), jsNumber(EAGAIN)); + put(Identifier::fromString(vm, "EAGAIN"_s), jsNumber(EAGAIN)); #endif #ifdef EALREADY - put(Identifier::fromString(vm, "EALREADY"_s), jsNumber(EALREADY)); + put(Identifier::fromString(vm, "EALREADY"_s), jsNumber(EALREADY)); #endif #ifdef EBADF - put(Identifier::fromString(vm, "EBADF"_s), jsNumber(EBADF)); + put(Identifier::fromString(vm, "EBADF"_s), jsNumber(EBADF)); #endif #ifdef EBADMSG - put(Identifier::fromString(vm, "EBADMSG"_s), jsNumber(EBADMSG)); + put(Identifier::fromString(vm, "EBADMSG"_s), jsNumber(EBADMSG)); #endif #ifdef EBUSY - put(Identifier::fromString(vm, "EBUSY"_s), jsNumber(EBUSY)); + put(Identifier::fromString(vm, "EBUSY"_s), jsNumber(EBUSY)); #endif #ifdef ECANCELED - put(Identifier::fromString(vm, "ECANCELED"_s), jsNumber(ECANCELED)); + put(Identifier::fromString(vm, "ECANCELED"_s), jsNumber(ECANCELED)); #endif #ifdef ECHILD - put(Identifier::fromString(vm, "ECHILD"_s), jsNumber(ECHILD)); + put(Identifier::fromString(vm, "ECHILD"_s), jsNumber(ECHILD)); #endif #ifdef ECONNABORTED - put(Identifier::fromString(vm, "ECONNABORTED"_s), jsNumber(ECONNABORTED)); + put(Identifier::fromString(vm, "ECONNABORTED"_s), jsNumber(ECONNABORTED)); #endif #ifdef ECONNREFUSED - put(Identifier::fromString(vm, "ECONNREFUSED"_s), jsNumber(ECONNREFUSED)); + put(Identifier::fromString(vm, "ECONNREFUSED"_s), jsNumber(ECONNREFUSED)); #endif #ifdef ECONNRESET - put(Identifier::fromString(vm, "ECONNRESET"_s), jsNumber(ECONNRESET)); + put(Identifier::fromString(vm, "ECONNRESET"_s), jsNumber(ECONNRESET)); #endif #ifdef EDEADLK - put(Identifier::fromString(vm, "EDEADLK"_s), jsNumber(EDEADLK)); + put(Identifier::fromString(vm, "EDEADLK"_s), jsNumber(EDEADLK)); #endif #ifdef EDESTADDRREQ - put(Identifier::fromString(vm, "EDESTADDRREQ"_s), jsNumber(EDESTADDRREQ)); + put(Identifier::fromString(vm, "EDESTADDRREQ"_s), jsNumber(EDESTADDRREQ)); #endif #ifdef EDOM - put(Identifier::fromString(vm, "EDOM"_s), jsNumber(EDOM)); + put(Identifier::fromString(vm, "EDOM"_s), jsNumber(EDOM)); #endif #ifdef EDQUOT - put(Identifier::fromString(vm, "EDQUOT"_s), jsNumber(EDQUOT)); + put(Identifier::fromString(vm, "EDQUOT"_s), jsNumber(EDQUOT)); #endif #ifdef EEXIST - put(Identifier::fromString(vm, "EEXIST"_s), jsNumber(EEXIST)); + put(Identifier::fromString(vm, "EEXIST"_s), jsNumber(EEXIST)); #endif #ifdef EFAULT - put(Identifier::fromString(vm, "EFAULT"_s), jsNumber(EFAULT)); + put(Identifier::fromString(vm, "EFAULT"_s), jsNumber(EFAULT)); #endif #ifdef EFBIG - put(Identifier::fromString(vm, "EFBIG"_s), jsNumber(EFBIG)); + put(Identifier::fromString(vm, "EFBIG"_s), jsNumber(EFBIG)); #endif #ifdef EHOSTUNREACH - put(Identifier::fromString(vm, "EHOSTUNREACH"_s), jsNumber(EHOSTUNREACH)); + put(Identifier::fromString(vm, "EHOSTUNREACH"_s), jsNumber(EHOSTUNREACH)); #endif #ifdef EIDRM - put(Identifier::fromString(vm, "EIDRM"_s), jsNumber(EIDRM)); + put(Identifier::fromString(vm, "EIDRM"_s), jsNumber(EIDRM)); #endif #ifdef EILSEQ - put(Identifier::fromString(vm, "EILSEQ"_s), jsNumber(EILSEQ)); + put(Identifier::fromString(vm, "EILSEQ"_s), jsNumber(EILSEQ)); #endif #ifdef EINPROGRESS - put(Identifier::fromString(vm, "EINPROGRESS"_s), jsNumber(EINPROGRESS)); + put(Identifier::fromString(vm, "EINPROGRESS"_s), jsNumber(EINPROGRESS)); #endif #ifdef EINTR - put(Identifier::fromString(vm, "EINTR"_s), jsNumber(EINTR)); + put(Identifier::fromString(vm, "EINTR"_s), jsNumber(EINTR)); #endif #ifdef EINVAL - put(Identifier::fromString(vm, "EINVAL"_s), jsNumber(EINVAL)); + put(Identifier::fromString(vm, "EINVAL"_s), jsNumber(EINVAL)); #endif #ifdef EIO - put(Identifier::fromString(vm, "EIO"_s), jsNumber(EIO)); + put(Identifier::fromString(vm, "EIO"_s), jsNumber(EIO)); #endif #ifdef EISCONN - put(Identifier::fromString(vm, "EISCONN"_s), jsNumber(EISCONN)); + put(Identifier::fromString(vm, "EISCONN"_s), jsNumber(EISCONN)); #endif #ifdef EISDIR - put(Identifier::fromString(vm, "EISDIR"_s), jsNumber(EISDIR)); + put(Identifier::fromString(vm, "EISDIR"_s), jsNumber(EISDIR)); #endif #ifdef ELOOP - put(Identifier::fromString(vm, "ELOOP"_s), jsNumber(ELOOP)); + put(Identifier::fromString(vm, "ELOOP"_s), jsNumber(ELOOP)); #endif #ifdef EMFILE - put(Identifier::fromString(vm, "EMFILE"_s), jsNumber(EMFILE)); + put(Identifier::fromString(vm, "EMFILE"_s), jsNumber(EMFILE)); #endif #ifdef EMLINK - put(Identifier::fromString(vm, "EMLINK"_s), jsNumber(EMLINK)); + put(Identifier::fromString(vm, "EMLINK"_s), jsNumber(EMLINK)); #endif #ifdef EMSGSIZE - put(Identifier::fromString(vm, "EMSGSIZE"_s), jsNumber(EMSGSIZE)); + put(Identifier::fromString(vm, "EMSGSIZE"_s), jsNumber(EMSGSIZE)); #endif #ifdef EMULTIHOP - put(Identifier::fromString(vm, "EMULTIHOP"_s), jsNumber(EMULTIHOP)); + put(Identifier::fromString(vm, "EMULTIHOP"_s), jsNumber(EMULTIHOP)); #endif #ifdef ENAMETOOLONG - put(Identifier::fromString(vm, "ENAMETOOLONG"_s), jsNumber(ENAMETOOLONG)); + put(Identifier::fromString(vm, "ENAMETOOLONG"_s), jsNumber(ENAMETOOLONG)); #endif #ifdef ENETDOWN - put(Identifier::fromString(vm, "ENETDOWN"_s), jsNumber(ENETDOWN)); + put(Identifier::fromString(vm, "ENETDOWN"_s), jsNumber(ENETDOWN)); #endif #ifdef ENETRESET - put(Identifier::fromString(vm, "ENETRESET"_s), jsNumber(ENETRESET)); + put(Identifier::fromString(vm, "ENETRESET"_s), jsNumber(ENETRESET)); #endif #ifdef ENETUNREACH - put(Identifier::fromString(vm, "ENETUNREACH"_s), jsNumber(ENETUNREACH)); + put(Identifier::fromString(vm, "ENETUNREACH"_s), jsNumber(ENETUNREACH)); #endif #ifdef ENFILE - put(Identifier::fromString(vm, "ENFILE"_s), jsNumber(ENFILE)); + put(Identifier::fromString(vm, "ENFILE"_s), jsNumber(ENFILE)); #endif #ifdef ENOBUFS - put(Identifier::fromString(vm, "ENOBUFS"_s), jsNumber(ENOBUFS)); + put(Identifier::fromString(vm, "ENOBUFS"_s), jsNumber(ENOBUFS)); #endif #ifdef ENODATA - put(Identifier::fromString(vm, "ENODATA"_s), jsNumber(ENODATA)); + put(Identifier::fromString(vm, "ENODATA"_s), jsNumber(ENODATA)); #endif #ifdef ENODEV - put(Identifier::fromString(vm, "ENODEV"_s), jsNumber(ENODEV)); + put(Identifier::fromString(vm, "ENODEV"_s), jsNumber(ENODEV)); #endif #ifdef ENOENT - put(Identifier::fromString(vm, "ENOENT"_s), jsNumber(ENOENT)); + put(Identifier::fromString(vm, "ENOENT"_s), jsNumber(ENOENT)); #endif #ifdef ENOEXEC - put(Identifier::fromString(vm, "ENOEXEC"_s), jsNumber(ENOEXEC)); + put(Identifier::fromString(vm, "ENOEXEC"_s), jsNumber(ENOEXEC)); #endif #ifdef ENOLCK - put(Identifier::fromString(vm, "ENOLCK"_s), jsNumber(ENOLCK)); + put(Identifier::fromString(vm, "ENOLCK"_s), jsNumber(ENOLCK)); #endif #ifdef ENOLINK - put(Identifier::fromString(vm, "ENOLINK"_s), jsNumber(ENOLINK)); + put(Identifier::fromString(vm, "ENOLINK"_s), jsNumber(ENOLINK)); #endif #ifdef ENOMEM - put(Identifier::fromString(vm, "ENOMEM"_s), jsNumber(ENOMEM)); + put(Identifier::fromString(vm, "ENOMEM"_s), jsNumber(ENOMEM)); #endif #ifdef ENOMSG - put(Identifier::fromString(vm, "ENOMSG"_s), jsNumber(ENOMSG)); + put(Identifier::fromString(vm, "ENOMSG"_s), jsNumber(ENOMSG)); #endif #ifdef ENOPROTOOPT - put(Identifier::fromString(vm, "ENOPROTOOPT"_s), jsNumber(ENOPROTOOPT)); + put(Identifier::fromString(vm, "ENOPROTOOPT"_s), jsNumber(ENOPROTOOPT)); #endif #ifdef ENOSPC - put(Identifier::fromString(vm, "ENOSPC"_s), jsNumber(ENOSPC)); + put(Identifier::fromString(vm, "ENOSPC"_s), jsNumber(ENOSPC)); #endif #ifdef ENOSR - put(Identifier::fromString(vm, "ENOSR"_s), jsNumber(ENOSR)); + put(Identifier::fromString(vm, "ENOSR"_s), jsNumber(ENOSR)); #endif #ifdef ENOSTR - put(Identifier::fromString(vm, "ENOSTR"_s), jsNumber(ENOSTR)); + put(Identifier::fromString(vm, "ENOSTR"_s), jsNumber(ENOSTR)); #endif #ifdef ENOSYS - put(Identifier::fromString(vm, "ENOSYS"_s), jsNumber(ENOSYS)); + put(Identifier::fromString(vm, "ENOSYS"_s), jsNumber(ENOSYS)); #endif #ifdef ENOTCONN - put(Identifier::fromString(vm, "ENOTCONN"_s), jsNumber(ENOTCONN)); + put(Identifier::fromString(vm, "ENOTCONN"_s), jsNumber(ENOTCONN)); #endif #ifdef ENOTDIR - put(Identifier::fromString(vm, "ENOTDIR"_s), jsNumber(ENOTDIR)); + put(Identifier::fromString(vm, "ENOTDIR"_s), jsNumber(ENOTDIR)); #endif #ifdef ENOTEMPTY - put(Identifier::fromString(vm, "ENOTEMPTY"_s), jsNumber(ENOTEMPTY)); + put(Identifier::fromString(vm, "ENOTEMPTY"_s), jsNumber(ENOTEMPTY)); #endif #ifdef ENOTSOCK - put(Identifier::fromString(vm, "ENOTSOCK"_s), jsNumber(ENOTSOCK)); + put(Identifier::fromString(vm, "ENOTSOCK"_s), jsNumber(ENOTSOCK)); #endif #ifdef ENOTSUP - put(Identifier::fromString(vm, "ENOTSUP"_s), jsNumber(ENOTSUP)); + put(Identifier::fromString(vm, "ENOTSUP"_s), jsNumber(ENOTSUP)); #endif #ifdef ENOTTY - put(Identifier::fromString(vm, "ENOTTY"_s), jsNumber(ENOTTY)); + put(Identifier::fromString(vm, "ENOTTY"_s), jsNumber(ENOTTY)); #endif #ifdef ENXIO - put(Identifier::fromString(vm, "ENXIO"_s), jsNumber(ENXIO)); + put(Identifier::fromString(vm, "ENXIO"_s), jsNumber(ENXIO)); #endif #ifdef EOPNOTSUPP - put(Identifier::fromString(vm, "EOPNOTSUPP"_s), jsNumber(EOPNOTSUPP)); + put(Identifier::fromString(vm, "EOPNOTSUPP"_s), jsNumber(EOPNOTSUPP)); #endif #ifdef EOVERFLOW - put(Identifier::fromString(vm, "EOVERFLOW"_s), jsNumber(EOVERFLOW)); + put(Identifier::fromString(vm, "EOVERFLOW"_s), jsNumber(EOVERFLOW)); #endif #ifdef EPERM - put(Identifier::fromString(vm, "EPERM"_s), jsNumber(EPERM)); + put(Identifier::fromString(vm, "EPERM"_s), jsNumber(EPERM)); #endif #ifdef EPIPE - put(Identifier::fromString(vm, "EPIPE"_s), jsNumber(EPIPE)); + put(Identifier::fromString(vm, "EPIPE"_s), jsNumber(EPIPE)); #endif #ifdef EPROTO - put(Identifier::fromString(vm, "EPROTO"_s), jsNumber(EPROTO)); + put(Identifier::fromString(vm, "EPROTO"_s), jsNumber(EPROTO)); #endif #ifdef EPROTONOSUPPORT - put(Identifier::fromString(vm, "EPROTONOSUPPORT"_s), jsNumber(EPROTONOSUPPORT)); + put(Identifier::fromString(vm, "EPROTONOSUPPORT"_s), + jsNumber(EPROTONOSUPPORT)); #endif #ifdef EPROTOTYPE - put(Identifier::fromString(vm, "EPROTOTYPE"_s), jsNumber(EPROTOTYPE)); + put(Identifier::fromString(vm, "EPROTOTYPE"_s), jsNumber(EPROTOTYPE)); #endif #ifdef ERANGE - put(Identifier::fromString(vm, "ERANGE"_s), jsNumber(ERANGE)); + put(Identifier::fromString(vm, "ERANGE"_s), jsNumber(ERANGE)); #endif #ifdef EROFS - put(Identifier::fromString(vm, "EROFS"_s), jsNumber(EROFS)); + put(Identifier::fromString(vm, "EROFS"_s), jsNumber(EROFS)); #endif #ifdef ESPIPE - put(Identifier::fromString(vm, "ESPIPE"_s), jsNumber(ESPIPE)); + put(Identifier::fromString(vm, "ESPIPE"_s), jsNumber(ESPIPE)); #endif #ifdef ESRCH - put(Identifier::fromString(vm, "ESRCH"_s), jsNumber(ESRCH)); + put(Identifier::fromString(vm, "ESRCH"_s), jsNumber(ESRCH)); #endif #ifdef ESTALE - put(Identifier::fromString(vm, "ESTALE"_s), jsNumber(ESTALE)); + put(Identifier::fromString(vm, "ESTALE"_s), jsNumber(ESTALE)); #endif #ifdef ETIME - put(Identifier::fromString(vm, "ETIME"_s), jsNumber(ETIME)); + put(Identifier::fromString(vm, "ETIME"_s), jsNumber(ETIME)); #endif #ifdef ETIMEDOUT - put(Identifier::fromString(vm, "ETIMEDOUT"_s), jsNumber(ETIMEDOUT)); + put(Identifier::fromString(vm, "ETIMEDOUT"_s), jsNumber(ETIMEDOUT)); #endif #ifdef ETXTBSY - put(Identifier::fromString(vm, "ETXTBSY"_s), jsNumber(ETXTBSY)); + put(Identifier::fromString(vm, "ETXTBSY"_s), jsNumber(ETXTBSY)); #endif #ifdef EWOULDBLOCK - put(Identifier::fromString(vm, "EWOULDBLOCK"_s), jsNumber(EWOULDBLOCK)); + put(Identifier::fromString(vm, "EWOULDBLOCK"_s), jsNumber(EWOULDBLOCK)); #endif #ifdef EXDEV - put(Identifier::fromString(vm, "EXDEV"_s), jsNumber(EXDEV)); + put(Identifier::fromString(vm, "EXDEV"_s), jsNumber(EXDEV)); #endif #ifdef WSAEINTR - put(Identifier::fromString(vm, "WSAEINTR"_s), jsNumber(WSAEINTR)); + put(Identifier::fromString(vm, "WSAEINTR"_s), jsNumber(WSAEINTR)); #endif #ifdef WSAEBADF - put(Identifier::fromString(vm, "WSAEBADF"_s), jsNumber(WSAEBADF)); + put(Identifier::fromString(vm, "WSAEBADF"_s), jsNumber(WSAEBADF)); #endif #ifdef WSAEACCES - put(Identifier::fromString(vm, "WSAEACCES"_s), jsNumber(WSAEACCES)); + put(Identifier::fromString(vm, "WSAEACCES"_s), jsNumber(WSAEACCES)); #endif #ifdef WSAEFAULT - put(Identifier::fromString(vm, "WSAEFAULT"_s), jsNumber(WSAEFAULT)); + put(Identifier::fromString(vm, "WSAEFAULT"_s), jsNumber(WSAEFAULT)); #endif #ifdef WSAEINVAL - put(Identifier::fromString(vm, "WSAEINVAL"_s), jsNumber(WSAEINVAL)); + put(Identifier::fromString(vm, "WSAEINVAL"_s), jsNumber(WSAEINVAL)); #endif #ifdef WSAEMFILE - put(Identifier::fromString(vm, "WSAEMFILE"_s), jsNumber(WSAEMFILE)); + put(Identifier::fromString(vm, "WSAEMFILE"_s), jsNumber(WSAEMFILE)); #endif #ifdef WSAEWOULDBLOCK - put(Identifier::fromString(vm, "WSAEWOULDBLOCK"_s), jsNumber(WSAEWOULDBLOCK)); + put(Identifier::fromString(vm, "WSAEWOULDBLOCK"_s), jsNumber(WSAEWOULDBLOCK)); #endif #ifdef WSAEINPROGRESS - put(Identifier::fromString(vm, "WSAEINPROGRESS"_s), jsNumber(WSAEINPROGRESS)); + put(Identifier::fromString(vm, "WSAEINPROGRESS"_s), jsNumber(WSAEINPROGRESS)); #endif #ifdef WSAEALREADY - put(Identifier::fromString(vm, "WSAEALREADY"_s), jsNumber(WSAEALREADY)); + put(Identifier::fromString(vm, "WSAEALREADY"_s), jsNumber(WSAEALREADY)); #endif #ifdef WSAENOTSOCK - put(Identifier::fromString(vm, "WSAENOTSOCK"_s), jsNumber(WSAENOTSOCK)); + put(Identifier::fromString(vm, "WSAENOTSOCK"_s), jsNumber(WSAENOTSOCK)); #endif #ifdef WSAEDESTADDRREQ - put(Identifier::fromString(vm, "WSAEDESTADDRREQ"_s), jsNumber(WSAEDESTADDRREQ)); + put(Identifier::fromString(vm, "WSAEDESTADDRREQ"_s), + jsNumber(WSAEDESTADDRREQ)); #endif #ifdef WSAEMSGSIZE - put(Identifier::fromString(vm, "WSAEMSGSIZE"_s), jsNumber(WSAEMSGSIZE)); + put(Identifier::fromString(vm, "WSAEMSGSIZE"_s), jsNumber(WSAEMSGSIZE)); #endif #ifdef WSAEPROTOTYPE - put(Identifier::fromString(vm, "WSAEPROTOTYPE"_s), jsNumber(WSAEPROTOTYPE)); + put(Identifier::fromString(vm, "WSAEPROTOTYPE"_s), jsNumber(WSAEPROTOTYPE)); #endif #ifdef WSAENOPROTOOPT - put(Identifier::fromString(vm, "WSAENOPROTOOPT"_s), jsNumber(WSAENOPROTOOPT)); + put(Identifier::fromString(vm, "WSAENOPROTOOPT"_s), jsNumber(WSAENOPROTOOPT)); #endif #ifdef WSAEPROTONOSUPPORT - put(Identifier::fromString(vm, "WSAEPROTONOSUPPORT"_s), jsNumber(WSAEPROTONOSUPPORT)); + put(Identifier::fromString(vm, "WSAEPROTONOSUPPORT"_s), + jsNumber(WSAEPROTONOSUPPORT)); #endif #ifdef WSAESOCKTNOSUPPORT - put(Identifier::fromString(vm, "WSAESOCKTNOSUPPORT"_s), jsNumber(WSAESOCKTNOSUPPORT)); + put(Identifier::fromString(vm, "WSAESOCKTNOSUPPORT"_s), + jsNumber(WSAESOCKTNOSUPPORT)); #endif #ifdef WSAEOPNOTSUPP - put(Identifier::fromString(vm, "WSAEOPNOTSUPP"_s), jsNumber(WSAEOPNOTSUPP)); + put(Identifier::fromString(vm, "WSAEOPNOTSUPP"_s), jsNumber(WSAEOPNOTSUPP)); #endif #ifdef WSAEPFNOSUPPORT - put(Identifier::fromString(vm, "WSAEPFNOSUPPORT"_s), jsNumber(WSAEPFNOSUPPORT)); + put(Identifier::fromString(vm, "WSAEPFNOSUPPORT"_s), + jsNumber(WSAEPFNOSUPPORT)); #endif #ifdef WSAEAFNOSUPPORT - put(Identifier::fromString(vm, "WSAEAFNOSUPPORT"_s), jsNumber(WSAEAFNOSUPPORT)); + put(Identifier::fromString(vm, "WSAEAFNOSUPPORT"_s), + jsNumber(WSAEAFNOSUPPORT)); #endif #ifdef WSAEADDRINUSE - put(Identifier::fromString(vm, "WSAEADDRINUSE"_s), jsNumber(WSAEADDRINUSE)); + put(Identifier::fromString(vm, "WSAEADDRINUSE"_s), jsNumber(WSAEADDRINUSE)); #endif #ifdef WSAEADDRNOTAVAIL - put(Identifier::fromString(vm, "WSAEADDRNOTAVAIL"_s), jsNumber(WSAEADDRNOTAVAIL)); + put(Identifier::fromString(vm, "WSAEADDRNOTAVAIL"_s), + jsNumber(WSAEADDRNOTAVAIL)); #endif #ifdef WSAENETDOWN - put(Identifier::fromString(vm, "WSAENETDOWN"_s), jsNumber(WSAENETDOWN)); + put(Identifier::fromString(vm, "WSAENETDOWN"_s), jsNumber(WSAENETDOWN)); #endif #ifdef WSAENETUNREACH - put(Identifier::fromString(vm, "WSAENETUNREACH"_s), jsNumber(WSAENETUNREACH)); + put(Identifier::fromString(vm, "WSAENETUNREACH"_s), jsNumber(WSAENETUNREACH)); #endif #ifdef WSAENETRESET - put(Identifier::fromString(vm, "WSAENETRESET"_s), jsNumber(WSAENETRESET)); + put(Identifier::fromString(vm, "WSAENETRESET"_s), jsNumber(WSAENETRESET)); #endif #ifdef WSAECONNABORTED - put(Identifier::fromString(vm, "WSAECONNABORTED"_s), jsNumber(WSAECONNABORTED)); + put(Identifier::fromString(vm, "WSAECONNABORTED"_s), + jsNumber(WSAECONNABORTED)); #endif #ifdef WSAECONNRESET - put(Identifier::fromString(vm, "WSAECONNRESET"_s), jsNumber(WSAECONNRESET)); + put(Identifier::fromString(vm, "WSAECONNRESET"_s), jsNumber(WSAECONNRESET)); #endif #ifdef WSAENOBUFS - put(Identifier::fromString(vm, "WSAENOBUFS"_s), jsNumber(WSAENOBUFS)); + put(Identifier::fromString(vm, "WSAENOBUFS"_s), jsNumber(WSAENOBUFS)); #endif #ifdef WSAEISCONN - put(Identifier::fromString(vm, "WSAEISCONN"_s), jsNumber(WSAEISCONN)); + put(Identifier::fromString(vm, "WSAEISCONN"_s), jsNumber(WSAEISCONN)); #endif #ifdef WSAENOTCONN - put(Identifier::fromString(vm, "WSAENOTCONN"_s), jsNumber(WSAENOTCONN)); + put(Identifier::fromString(vm, "WSAENOTCONN"_s), jsNumber(WSAENOTCONN)); #endif #ifdef WSAESHUTDOWN - put(Identifier::fromString(vm, "WSAESHUTDOWN"_s), jsNumber(WSAESHUTDOWN)); + put(Identifier::fromString(vm, "WSAESHUTDOWN"_s), jsNumber(WSAESHUTDOWN)); #endif #ifdef WSAETOOMANYREFS - put(Identifier::fromString(vm, "WSAETOOMANYREFS"_s), jsNumber(WSAETOOMANYREFS)); + put(Identifier::fromString(vm, "WSAETOOMANYREFS"_s), + jsNumber(WSAETOOMANYREFS)); #endif #ifdef WSAETIMEDOUT - put(Identifier::fromString(vm, "WSAETIMEDOUT"_s), jsNumber(WSAETIMEDOUT)); + put(Identifier::fromString(vm, "WSAETIMEDOUT"_s), jsNumber(WSAETIMEDOUT)); #endif #ifdef WSAECONNREFUSED - put(Identifier::fromString(vm, "WSAECONNREFUSED"_s), jsNumber(WSAECONNREFUSED)); + put(Identifier::fromString(vm, "WSAECONNREFUSED"_s), + jsNumber(WSAECONNREFUSED)); #endif #ifdef WSAELOOP - put(Identifier::fromString(vm, "WSAELOOP"_s), jsNumber(WSAELOOP)); + put(Identifier::fromString(vm, "WSAELOOP"_s), jsNumber(WSAELOOP)); #endif #ifdef WSAENAMETOOLONG - put(Identifier::fromString(vm, "WSAENAMETOOLONG"_s), jsNumber(WSAENAMETOOLONG)); + put(Identifier::fromString(vm, "WSAENAMETOOLONG"_s), + jsNumber(WSAENAMETOOLONG)); #endif #ifdef WSAEHOSTDOWN - put(Identifier::fromString(vm, "WSAEHOSTDOWN"_s), jsNumber(WSAEHOSTDOWN)); + put(Identifier::fromString(vm, "WSAEHOSTDOWN"_s), jsNumber(WSAEHOSTDOWN)); #endif #ifdef WSAEHOSTUNREACH - put(Identifier::fromString(vm, "WSAEHOSTUNREACH"_s), jsNumber(WSAEHOSTUNREACH)); + put(Identifier::fromString(vm, "WSAEHOSTUNREACH"_s), + jsNumber(WSAEHOSTUNREACH)); #endif #ifdef WSAENOTEMPTY - put(Identifier::fromString(vm, "WSAENOTEMPTY"_s), jsNumber(WSAENOTEMPTY)); + put(Identifier::fromString(vm, "WSAENOTEMPTY"_s), jsNumber(WSAENOTEMPTY)); #endif #ifdef WSAEPROCLIM - put(Identifier::fromString(vm, "WSAEPROCLIM"_s), jsNumber(WSAEPROCLIM)); + put(Identifier::fromString(vm, "WSAEPROCLIM"_s), jsNumber(WSAEPROCLIM)); #endif #ifdef WSAEUSERS - put(Identifier::fromString(vm, "WSAEUSERS"_s), jsNumber(WSAEUSERS)); + put(Identifier::fromString(vm, "WSAEUSERS"_s), jsNumber(WSAEUSERS)); #endif #ifdef WSAEDQUOT - put(Identifier::fromString(vm, "WSAEDQUOT"_s), jsNumber(WSAEDQUOT)); + put(Identifier::fromString(vm, "WSAEDQUOT"_s), jsNumber(WSAEDQUOT)); #endif #ifdef WSAESTALE - put(Identifier::fromString(vm, "WSAESTALE"_s), jsNumber(WSAESTALE)); + put(Identifier::fromString(vm, "WSAESTALE"_s), jsNumber(WSAESTALE)); #endif #ifdef WSAEREMOTE - put(Identifier::fromString(vm, "WSAEREMOTE"_s), jsNumber(WSAEREMOTE)); + put(Identifier::fromString(vm, "WSAEREMOTE"_s), jsNumber(WSAEREMOTE)); #endif #ifdef WSASYSNOTREADY - put(Identifier::fromString(vm, "WSASYSNOTREADY"_s), jsNumber(WSASYSNOTREADY)); + put(Identifier::fromString(vm, "WSASYSNOTREADY"_s), jsNumber(WSASYSNOTREADY)); #endif #ifdef WSAVERNOTSUPPORTED - put(Identifier::fromString(vm, "WSAVERNOTSUPPORTED"_s), jsNumber(WSAVERNOTSUPPORTED)); + put(Identifier::fromString(vm, "WSAVERNOTSUPPORTED"_s), + jsNumber(WSAVERNOTSUPPORTED)); #endif #ifdef WSANOTINITIALISED - put(Identifier::fromString(vm, "WSANOTINITIALISED"_s), jsNumber(WSANOTINITIALISED)); + put(Identifier::fromString(vm, "WSANOTINITIALISED"_s), + jsNumber(WSANOTINITIALISED)); #endif #ifdef WSAEDISCON - put(Identifier::fromString(vm, "WSAEDISCON"_s), jsNumber(WSAEDISCON)); + put(Identifier::fromString(vm, "WSAEDISCON"_s), jsNumber(WSAEDISCON)); #endif #ifdef WSAENOMORE - put(Identifier::fromString(vm, "WSAENOMORE"_s), jsNumber(WSAENOMORE)); + put(Identifier::fromString(vm, "WSAENOMORE"_s), jsNumber(WSAENOMORE)); #endif #ifdef WSAECANCELLED - put(Identifier::fromString(vm, "WSAECANCELLED"_s), jsNumber(WSAECANCELLED)); + put(Identifier::fromString(vm, "WSAECANCELLED"_s), jsNumber(WSAECANCELLED)); #endif #ifdef WSAEINVALIDPROCTABLE - put(Identifier::fromString(vm, "WSAEINVALIDPROCTABLE"_s), jsNumber(WSAEINVALIDPROCTABLE)); + put(Identifier::fromString(vm, "WSAEINVALIDPROCTABLE"_s), + jsNumber(WSAEINVALIDPROCTABLE)); #endif #ifdef WSAEINVALIDPROVIDER - put(Identifier::fromString(vm, "WSAEINVALIDPROVIDER"_s), jsNumber(WSAEINVALIDPROVIDER)); + put(Identifier::fromString(vm, "WSAEINVALIDPROVIDER"_s), + jsNumber(WSAEINVALIDPROVIDER)); #endif #ifdef WSAEPROVIDERFAILEDINIT - put(Identifier::fromString(vm, "WSAEPROVIDERFAILEDINIT"_s), jsNumber(WSAEPROVIDERFAILEDINIT)); + put(Identifier::fromString(vm, "WSAEPROVIDERFAILEDINIT"_s), + jsNumber(WSAEPROVIDERFAILEDINIT)); #endif #ifdef WSASYSCALLFAILURE - put(Identifier::fromString(vm, "WSASYSCALLFAILURE"_s), jsNumber(WSASYSCALLFAILURE)); + put(Identifier::fromString(vm, "WSASYSCALLFAILURE"_s), + jsNumber(WSASYSCALLFAILURE)); #endif #ifdef WSASERVICE_NOT_FOUND - put(Identifier::fromString(vm, "WSASERVICE_NOT_FOUND"_s), jsNumber(WSASERVICE_NOT_FOUND)); + put(Identifier::fromString(vm, "WSASERVICE_NOT_FOUND"_s), + jsNumber(WSASERVICE_NOT_FOUND)); #endif #ifdef WSATYPE_NOT_FOUND - put(Identifier::fromString(vm, "WSATYPE_NOT_FOUND"_s), jsNumber(WSATYPE_NOT_FOUND)); + put(Identifier::fromString(vm, "WSATYPE_NOT_FOUND"_s), + jsNumber(WSATYPE_NOT_FOUND)); #endif #ifdef WSA_E_NO_MORE - put(Identifier::fromString(vm, "WSA_E_NO_MORE"_s), jsNumber(WSA_E_NO_MORE)); + put(Identifier::fromString(vm, "WSA_E_NO_MORE"_s), jsNumber(WSA_E_NO_MORE)); #endif #ifdef WSA_E_CANCELLED - put(Identifier::fromString(vm, "WSA_E_CANCELLED"_s), jsNumber(WSA_E_CANCELLED)); + put(Identifier::fromString(vm, "WSA_E_CANCELLED"_s), + jsNumber(WSA_E_CANCELLED)); #endif #ifdef WSAEREFUSED - put(Identifier::fromString(vm, "WSAEREFUSED"_s), jsNumber(WSAEREFUSED)); -#endif - put(Identifier::fromString(vm, "PRIORITY_LOW"_s), jsNumber(19)); - put(Identifier::fromString(vm, "PRIORITY_BELOW_NORMAL"_s), jsNumber(10)); - put(Identifier::fromString(vm, "PRIORITY_NORMAL"_s), jsNumber(0)); - put(Identifier::fromString(vm, "PRIORITY_ABOVE_NORMAL"_s), jsNumber(-7)); - put(Identifier::fromString(vm, "PRIORITY_HIGH"_s), jsNumber(-14)); - put(Identifier::fromString(vm, "PRIORITY_HIGHEST"_s), jsNumber(-20)); + put(Identifier::fromString(vm, "WSAEREFUSED"_s), jsNumber(WSAEREFUSED)); +#endif + put(Identifier::fromString(vm, "PRIORITY_LOW"_s), jsNumber(19)); + put(Identifier::fromString(vm, "PRIORITY_BELOW_NORMAL"_s), jsNumber(10)); + put(Identifier::fromString(vm, "PRIORITY_NORMAL"_s), jsNumber(0)); + put(Identifier::fromString(vm, "PRIORITY_ABOVE_NORMAL"_s), jsNumber(-7)); + put(Identifier::fromString(vm, "PRIORITY_HIGH"_s), jsNumber(-14)); + put(Identifier::fromString(vm, "PRIORITY_HIGHEST"_s), jsNumber(-20)); #ifdef SIGHUP - put(Identifier::fromString(vm, "SIGHUP"_s), jsNumber(SIGHUP)); + put(Identifier::fromString(vm, "SIGHUP"_s), jsNumber(SIGHUP)); #endif #ifdef SIGINT - put(Identifier::fromString(vm, "SIGINT"_s), jsNumber(SIGINT)); + put(Identifier::fromString(vm, "SIGINT"_s), jsNumber(SIGINT)); #endif #ifdef SIGQUIT - put(Identifier::fromString(vm, "SIGQUIT"_s), jsNumber(SIGQUIT)); + put(Identifier::fromString(vm, "SIGQUIT"_s), jsNumber(SIGQUIT)); #endif #ifdef SIGILL - put(Identifier::fromString(vm, "SIGILL"_s), jsNumber(SIGILL)); + put(Identifier::fromString(vm, "SIGILL"_s), jsNumber(SIGILL)); #endif #ifdef SIGTRAP - put(Identifier::fromString(vm, "SIGTRAP"_s), jsNumber(SIGTRAP)); + put(Identifier::fromString(vm, "SIGTRAP"_s), jsNumber(SIGTRAP)); #endif #ifdef SIGABRT - put(Identifier::fromString(vm, "SIGABRT"_s), jsNumber(SIGABRT)); + put(Identifier::fromString(vm, "SIGABRT"_s), jsNumber(SIGABRT)); #endif #ifdef SIGIOT - put(Identifier::fromString(vm, "SIGIOT"_s), jsNumber(SIGIOT)); + put(Identifier::fromString(vm, "SIGIOT"_s), jsNumber(SIGIOT)); #endif #ifdef SIGBUS - put(Identifier::fromString(vm, "SIGBUS"_s), jsNumber(SIGBUS)); + put(Identifier::fromString(vm, "SIGBUS"_s), jsNumber(SIGBUS)); #endif #ifdef SIGFPE - put(Identifier::fromString(vm, "SIGFPE"_s), jsNumber(SIGFPE)); + put(Identifier::fromString(vm, "SIGFPE"_s), jsNumber(SIGFPE)); #endif #ifdef SIGKILL - put(Identifier::fromString(vm, "SIGKILL"_s), jsNumber(SIGKILL)); + put(Identifier::fromString(vm, "SIGKILL"_s), jsNumber(SIGKILL)); #endif #ifdef SIGUSR1 - put(Identifier::fromString(vm, "SIGUSR1"_s), jsNumber(SIGUSR1)); + put(Identifier::fromString(vm, "SIGUSR1"_s), jsNumber(SIGUSR1)); #endif #ifdef SIGSEGV - put(Identifier::fromString(vm, "SIGSEGV"_s), jsNumber(SIGSEGV)); + put(Identifier::fromString(vm, "SIGSEGV"_s), jsNumber(SIGSEGV)); #endif #ifdef SIGUSR2 - put(Identifier::fromString(vm, "SIGUSR2"_s), jsNumber(SIGUSR2)); + put(Identifier::fromString(vm, "SIGUSR2"_s), jsNumber(SIGUSR2)); #endif #ifdef SIGPIPE - put(Identifier::fromString(vm, "SIGPIPE"_s), jsNumber(SIGPIPE)); + put(Identifier::fromString(vm, "SIGPIPE"_s), jsNumber(SIGPIPE)); #endif #ifdef SIGALRM - put(Identifier::fromString(vm, "SIGALRM"_s), jsNumber(SIGALRM)); + put(Identifier::fromString(vm, "SIGALRM"_s), jsNumber(SIGALRM)); #endif #ifdef SIGTERM - put(Identifier::fromString(vm, "SIGTERM"_s), jsNumber(SIGTERM)); + put(Identifier::fromString(vm, "SIGTERM"_s), jsNumber(SIGTERM)); #endif #ifdef SIGCHLD - put(Identifier::fromString(vm, "SIGCHLD"_s), jsNumber(SIGCHLD)); + put(Identifier::fromString(vm, "SIGCHLD"_s), jsNumber(SIGCHLD)); #endif #ifdef SIGSTKFLT - put(Identifier::fromString(vm, "SIGSTKFLT"_s), jsNumber(SIGSTKFLT)); + put(Identifier::fromString(vm, "SIGSTKFLT"_s), jsNumber(SIGSTKFLT)); #endif #ifdef SIGCONT - put(Identifier::fromString(vm, "SIGCONT"_s), jsNumber(SIGCONT)); + put(Identifier::fromString(vm, "SIGCONT"_s), jsNumber(SIGCONT)); #endif #ifdef SIGSTOP - put(Identifier::fromString(vm, "SIGSTOP"_s), jsNumber(SIGSTOP)); + put(Identifier::fromString(vm, "SIGSTOP"_s), jsNumber(SIGSTOP)); #endif #ifdef SIGTSTP - put(Identifier::fromString(vm, "SIGTSTP"_s), jsNumber(SIGTSTP)); + put(Identifier::fromString(vm, "SIGTSTP"_s), jsNumber(SIGTSTP)); #endif #ifdef SIGBREAK - put(Identifier::fromString(vm, "SIGBREAK"_s), jsNumber(SIGBREAK)); + put(Identifier::fromString(vm, "SIGBREAK"_s), jsNumber(SIGBREAK)); #endif #ifdef SIGTTIN - put(Identifier::fromString(vm, "SIGTTIN"_s), jsNumber(SIGTTIN)); + put(Identifier::fromString(vm, "SIGTTIN"_s), jsNumber(SIGTTIN)); #endif #ifdef SIGTTOU - put(Identifier::fromString(vm, "SIGTTOU"_s), jsNumber(SIGTTOU)); + put(Identifier::fromString(vm, "SIGTTOU"_s), jsNumber(SIGTTOU)); #endif #ifdef SIGURG - put(Identifier::fromString(vm, "SIGURG"_s), jsNumber(SIGURG)); + put(Identifier::fromString(vm, "SIGURG"_s), jsNumber(SIGURG)); #endif #ifdef SIGXCPU - put(Identifier::fromString(vm, "SIGXCPU"_s), jsNumber(SIGXCPU)); + put(Identifier::fromString(vm, "SIGXCPU"_s), jsNumber(SIGXCPU)); #endif #ifdef SIGXFSZ - put(Identifier::fromString(vm, "SIGXFSZ"_s), jsNumber(SIGXFSZ)); + put(Identifier::fromString(vm, "SIGXFSZ"_s), jsNumber(SIGXFSZ)); #endif #ifdef SIGVTALRM - put(Identifier::fromString(vm, "SIGVTALRM"_s), jsNumber(SIGVTALRM)); + put(Identifier::fromString(vm, "SIGVTALRM"_s), jsNumber(SIGVTALRM)); #endif #ifdef SIGPROF - put(Identifier::fromString(vm, "SIGPROF"_s), jsNumber(SIGPROF)); + put(Identifier::fromString(vm, "SIGPROF"_s), jsNumber(SIGPROF)); #endif #ifdef SIGWINCH - put(Identifier::fromString(vm, "SIGWINCH"_s), jsNumber(SIGWINCH)); + put(Identifier::fromString(vm, "SIGWINCH"_s), jsNumber(SIGWINCH)); #endif #ifdef SIGIO - put(Identifier::fromString(vm, "SIGIO"_s), jsNumber(SIGIO)); + put(Identifier::fromString(vm, "SIGIO"_s), jsNumber(SIGIO)); #endif #ifdef SIGPOLL - put(Identifier::fromString(vm, "SIGPOLL"_s), jsNumber(SIGPOLL)); + put(Identifier::fromString(vm, "SIGPOLL"_s), jsNumber(SIGPOLL)); #endif #ifdef SIGLOST - put(Identifier::fromString(vm, "SIGLOST"_s), jsNumber(SIGLOST)); + put(Identifier::fromString(vm, "SIGLOST"_s), jsNumber(SIGLOST)); #endif #ifdef SIGPWR - put(Identifier::fromString(vm, "SIGPWR"_s), jsNumber(SIGPWR)); + put(Identifier::fromString(vm, "SIGPWR"_s), jsNumber(SIGPWR)); #endif #ifdef SIGINFO - put(Identifier::fromString(vm, "SIGINFO"_s), jsNumber(SIGINFO)); + put(Identifier::fromString(vm, "SIGINFO"_s), jsNumber(SIGINFO)); #endif #ifdef SIGSYS - put(Identifier::fromString(vm, "SIGSYS"_s), jsNumber(SIGSYS)); + put(Identifier::fromString(vm, "SIGSYS"_s), jsNumber(SIGSYS)); #endif #ifdef SIGUNUSED - put(Identifier::fromString(vm, "SIGUNUSED"_s), jsNumber(SIGUNUSED)); + put(Identifier::fromString(vm, "SIGUNUSED"_s), jsNumber(SIGUNUSED)); #endif - put(Identifier::fromString(vm, "UV_FS_SYMLINK_DIR"_s), jsNumber(1)); - put(Identifier::fromString(vm, "UV_FS_SYMLINK_JUNCTION"_s), jsNumber(2)); - put(Identifier::fromString(vm, "O_RDONLY"_s), jsNumber(O_RDONLY)); - put(Identifier::fromString(vm, "O_WRONLY"_s), jsNumber(O_WRONLY)); - put(Identifier::fromString(vm, "O_RDWR"_s), jsNumber(O_RDWR)); + put(Identifier::fromString(vm, "UV_FS_SYMLINK_DIR"_s), jsNumber(1)); + put(Identifier::fromString(vm, "UV_FS_SYMLINK_JUNCTION"_s), jsNumber(2)); + put(Identifier::fromString(vm, "O_RDONLY"_s), jsNumber(O_RDONLY)); + put(Identifier::fromString(vm, "O_WRONLY"_s), jsNumber(O_WRONLY)); + put(Identifier::fromString(vm, "O_RDWR"_s), jsNumber(O_RDWR)); - put(Identifier::fromString(vm, "UV_DIRENT_UNKNOWN"_s), jsNumber(0)); - put(Identifier::fromString(vm, "UV_DIRENT_FILE"_s), jsNumber(1)); - put(Identifier::fromString(vm, "UV_DIRENT_DIR"_s), jsNumber(2)); - put(Identifier::fromString(vm, "UV_DIRENT_LINK"_s), jsNumber(3)); - put(Identifier::fromString(vm, "UV_DIRENT_FIFO"_s), jsNumber(4)); - put(Identifier::fromString(vm, "UV_DIRENT_SOCKET"_s), jsNumber(5)); - put(Identifier::fromString(vm, "UV_DIRENT_CHAR"_s), jsNumber(6)); - put(Identifier::fromString(vm, "UV_DIRENT_BLOCK"_s), jsNumber(7)); + put(Identifier::fromString(vm, "UV_DIRENT_UNKNOWN"_s), jsNumber(0)); + put(Identifier::fromString(vm, "UV_DIRENT_FILE"_s), jsNumber(1)); + put(Identifier::fromString(vm, "UV_DIRENT_DIR"_s), jsNumber(2)); + put(Identifier::fromString(vm, "UV_DIRENT_LINK"_s), jsNumber(3)); + put(Identifier::fromString(vm, "UV_DIRENT_FIFO"_s), jsNumber(4)); + put(Identifier::fromString(vm, "UV_DIRENT_SOCKET"_s), jsNumber(5)); + put(Identifier::fromString(vm, "UV_DIRENT_CHAR"_s), jsNumber(6)); + put(Identifier::fromString(vm, "UV_DIRENT_BLOCK"_s), jsNumber(7)); - put(Identifier::fromString(vm, "S_IFMT"_s), jsNumber(S_IFMT)); - put(Identifier::fromString(vm, "S_IFREG"_s), jsNumber(S_IFREG)); - put(Identifier::fromString(vm, "S_IFDIR"_s), jsNumber(S_IFDIR)); - put(Identifier::fromString(vm, "S_IFCHR"_s), jsNumber(S_IFCHR)); + put(Identifier::fromString(vm, "S_IFMT"_s), jsNumber(S_IFMT)); + put(Identifier::fromString(vm, "S_IFREG"_s), jsNumber(S_IFREG)); + put(Identifier::fromString(vm, "S_IFDIR"_s), jsNumber(S_IFDIR)); + put(Identifier::fromString(vm, "S_IFCHR"_s), jsNumber(S_IFCHR)); #ifdef S_IFBLK - put(Identifier::fromString(vm, "S_IFBLK"_s), jsNumber(S_IFBLK)); + put(Identifier::fromString(vm, "S_IFBLK"_s), jsNumber(S_IFBLK)); #endif #ifdef S_IFIFO - put(Identifier::fromString(vm, "S_IFIFO"_s), jsNumber(S_IFIFO)); + put(Identifier::fromString(vm, "S_IFIFO"_s), jsNumber(S_IFIFO)); #endif #ifdef S_IFLNK - put(Identifier::fromString(vm, "S_IFLNK"_s), jsNumber(S_IFLNK)); + put(Identifier::fromString(vm, "S_IFLNK"_s), jsNumber(S_IFLNK)); #endif #ifdef S_IFSOCK - put(Identifier::fromString(vm, "S_IFSOCK"_s), jsNumber(S_IFSOCK)); + put(Identifier::fromString(vm, "S_IFSOCK"_s), jsNumber(S_IFSOCK)); #endif #ifdef O_CREAT - put(Identifier::fromString(vm, "O_CREAT"_s), jsNumber(O_CREAT)); + put(Identifier::fromString(vm, "O_CREAT"_s), jsNumber(O_CREAT)); #endif #ifdef O_EXCL - put(Identifier::fromString(vm, "O_EXCL"_s), jsNumber(O_EXCL)); + put(Identifier::fromString(vm, "O_EXCL"_s), jsNumber(O_EXCL)); #endif - put(Identifier::fromString(vm, "UV_FS_O_FILEMAP"_s), jsNumber(0)); + put(Identifier::fromString(vm, "UV_FS_O_FILEMAP"_s), jsNumber(0)); #ifdef O_NOCTTY - put(Identifier::fromString(vm, "O_NOCTTY"_s), jsNumber(O_NOCTTY)); + put(Identifier::fromString(vm, "O_NOCTTY"_s), jsNumber(O_NOCTTY)); #endif #ifdef O_TRUNC - put(Identifier::fromString(vm, "O_TRUNC"_s), jsNumber(O_TRUNC)); + put(Identifier::fromString(vm, "O_TRUNC"_s), jsNumber(O_TRUNC)); #endif #ifdef O_APPEND - put(Identifier::fromString(vm, "O_APPEND"_s), jsNumber(O_APPEND)); + put(Identifier::fromString(vm, "O_APPEND"_s), jsNumber(O_APPEND)); #endif #ifdef O_DIRECTORY - put(Identifier::fromString(vm, "O_DIRECTORY"_s), jsNumber(O_DIRECTORY)); -#endif -#ifdef O_EXCL - put(Identifier::fromString(vm, "O_EXCL"_s), jsNumber(O_EXCL)); + put(Identifier::fromString(vm, "O_DIRECTORY"_s), jsNumber(O_DIRECTORY)); #endif #ifdef O_NOATIME - put(Identifier::fromString(vm, "O_NOATIME"_s), jsNumber(O_NOATIME)); + put(Identifier::fromString(vm, "O_NOATIME"_s), jsNumber(O_NOATIME)); #endif #ifdef O_NOFOLLOW - put(Identifier::fromString(vm, "O_NOFOLLOW"_s), jsNumber(O_NOFOLLOW)); + put(Identifier::fromString(vm, "O_NOFOLLOW"_s), jsNumber(O_NOFOLLOW)); #endif #ifdef O_SYNC - put(Identifier::fromString(vm, "O_SYNC"_s), jsNumber(O_SYNC)); + put(Identifier::fromString(vm, "O_SYNC"_s), jsNumber(O_SYNC)); #endif #ifdef O_DSYNC - put(Identifier::fromString(vm, "O_DSYNC"_s), jsNumber(O_DSYNC)); + put(Identifier::fromString(vm, "O_DSYNC"_s), jsNumber(O_DSYNC)); #endif #ifdef O_SYMLINK - put(Identifier::fromString(vm, "O_SYMLINK"_s), jsNumber(O_SYMLINK)); + put(Identifier::fromString(vm, "O_SYMLINK"_s), jsNumber(O_SYMLINK)); #endif #ifdef O_DIRECT - put(Identifier::fromString(vm, "O_DIRECT"_s), jsNumber(O_DIRECT)); + put(Identifier::fromString(vm, "O_DIRECT"_s), jsNumber(O_DIRECT)); #endif #ifdef O_NONBLOCK - put(Identifier::fromString(vm, "O_NONBLOCK"_s), jsNumber(O_NONBLOCK)); + put(Identifier::fromString(vm, "O_NONBLOCK"_s), jsNumber(O_NONBLOCK)); #endif #ifdef S_IRWXU - put(Identifier::fromString(vm, "S_IRWXU"_s), jsNumber(S_IRWXU)); + put(Identifier::fromString(vm, "S_IRWXU"_s), jsNumber(S_IRWXU)); #endif #ifdef S_IRUSR - put(Identifier::fromString(vm, "S_IRUSR"_s), jsNumber(S_IRUSR)); + put(Identifier::fromString(vm, "S_IRUSR"_s), jsNumber(S_IRUSR)); #endif #ifdef S_IWUSR - put(Identifier::fromString(vm, "S_IWUSR"_s), jsNumber(S_IWUSR)); + put(Identifier::fromString(vm, "S_IWUSR"_s), jsNumber(S_IWUSR)); #endif #ifdef S_IXUSR - put(Identifier::fromString(vm, "S_IXUSR"_s), jsNumber(S_IXUSR)); + put(Identifier::fromString(vm, "S_IXUSR"_s), jsNumber(S_IXUSR)); #endif #ifdef S_IRWXG - put(Identifier::fromString(vm, "S_IRWXG"_s), jsNumber(S_IRWXG)); + put(Identifier::fromString(vm, "S_IRWXG"_s), jsNumber(S_IRWXG)); #endif #ifdef S_IRGRP - put(Identifier::fromString(vm, "S_IRGRP"_s), jsNumber(S_IRGRP)); + put(Identifier::fromString(vm, "S_IRGRP"_s), jsNumber(S_IRGRP)); #endif #ifdef S_IWGRP - put(Identifier::fromString(vm, "S_IWGRP"_s), jsNumber(S_IWGRP)); + put(Identifier::fromString(vm, "S_IWGRP"_s), jsNumber(S_IWGRP)); #endif #ifdef S_IXGRP - put(Identifier::fromString(vm, "S_IXGRP"_s), jsNumber(S_IXGRP)); + put(Identifier::fromString(vm, "S_IXGRP"_s), jsNumber(S_IXGRP)); #endif #ifdef S_IRWXO - put(Identifier::fromString(vm, "S_IRWXO"_s), jsNumber(S_IRWXO)); + put(Identifier::fromString(vm, "S_IRWXO"_s), jsNumber(S_IRWXO)); #endif #ifdef S_IROTH - put(Identifier::fromString(vm, "S_IROTH"_s), jsNumber(S_IROTH)); + put(Identifier::fromString(vm, "S_IROTH"_s), jsNumber(S_IROTH)); #endif #ifdef S_IWOTH - put(Identifier::fromString(vm, "S_IWOTH"_s), jsNumber(S_IWOTH)); + put(Identifier::fromString(vm, "S_IWOTH"_s), jsNumber(S_IWOTH)); #endif #ifdef S_IXOTH - put(Identifier::fromString(vm, "S_IXOTH"_s), jsNumber(S_IXOTH)); + put(Identifier::fromString(vm, "S_IXOTH"_s), jsNumber(S_IXOTH)); #endif #ifdef F_OK - put(Identifier::fromString(vm, "F_OK"_s), jsNumber(F_OK)); + put(Identifier::fromString(vm, "F_OK"_s), jsNumber(F_OK)); #endif #ifdef R_OK - put(Identifier::fromString(vm, "R_OK"_s), jsNumber(R_OK)); + put(Identifier::fromString(vm, "R_OK"_s), jsNumber(R_OK)); #endif #ifdef W_OK - put(Identifier::fromString(vm, "W_OK"_s), jsNumber(W_OK)); + put(Identifier::fromString(vm, "W_OK"_s), jsNumber(W_OK)); #endif #ifdef X_OK - put(Identifier::fromString(vm, "X_OK"_s), jsNumber(X_OK)); -#endif - put(Identifier::fromString(vm, "UV_FS_COPYFILE_EXCL"_s), jsNumber(1)); - put(Identifier::fromString(vm, "COPYFILE_EXCL"_s), jsNumber(1)); - put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE"_s), jsNumber(2)); - put(Identifier::fromString(vm, "COPYFILE_FICLONE"_s), jsNumber(2)); - put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE_FORCE"_s), jsNumber(4)); - put(Identifier::fromString(vm, "COPYFILE_FICLONE_FORCE"_s), jsNumber(4)); + put(Identifier::fromString(vm, "X_OK"_s), jsNumber(X_OK)); +#endif + put(Identifier::fromString(vm, "UV_FS_COPYFILE_EXCL"_s), jsNumber(1)); + put(Identifier::fromString(vm, "COPYFILE_EXCL"_s), jsNumber(1)); + put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE"_s), jsNumber(2)); + put(Identifier::fromString(vm, "COPYFILE_FICLONE"_s), jsNumber(2)); + put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE_FORCE"_s), + jsNumber(4)); + put(Identifier::fromString(vm, "COPYFILE_FICLONE_FORCE"_s), jsNumber(4)); #ifdef OPENSSL_VERSION_NUMBER - put(Identifier::fromString(vm, "OPENSSL_VERSION_NUMBER"_s), jsNumber(OPENSSL_VERSION_NUMBER)); + put(Identifier::fromString(vm, "OPENSSL_VERSION_NUMBER"_s), + jsNumber(OPENSSL_VERSION_NUMBER)); #endif #ifdef SSL_OP_ALL - put(Identifier::fromString(vm, "SSL_OP_ALL"_s), jsNumber(SSL_OP_ALL)); + put(Identifier::fromString(vm, "SSL_OP_ALL"_s), jsNumber(SSL_OP_ALL)); #endif #ifdef SSL_OP_ALLOW_NO_DHE_KEX - put(Identifier::fromString(vm, "SSL_OP_ALLOW_NO_DHE_KEX"_s), jsNumber(SSL_OP_ALLOW_NO_DHE_KEX)); + put(Identifier::fromString(vm, "SSL_OP_ALLOW_NO_DHE_KEX"_s), + jsNumber(SSL_OP_ALLOW_NO_DHE_KEX)); #endif #ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION - put(Identifier::fromString(vm, "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION"_s), jsNumber(SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)); + put(Identifier::fromString(vm, "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION"_s), + jsNumber(SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)); #endif #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE - put(Identifier::fromString(vm, "SSL_OP_CIPHER_SERVER_PREFERENCE"_s), jsNumber(SSL_OP_CIPHER_SERVER_PREFERENCE)); + put(Identifier::fromString(vm, "SSL_OP_CIPHER_SERVER_PREFERENCE"_s), + jsNumber(SSL_OP_CIPHER_SERVER_PREFERENCE)); #endif #ifdef SSL_OP_CISCO_ANYCONNECT - put(Identifier::fromString(vm, "SSL_OP_CISCO_ANYCONNECT"_s), jsNumber(SSL_OP_CISCO_ANYCONNECT)); + put(Identifier::fromString(vm, "SSL_OP_CISCO_ANYCONNECT"_s), + jsNumber(SSL_OP_CISCO_ANYCONNECT)); #endif #ifdef SSL_OP_COOKIE_EXCHANGE - put(Identifier::fromString(vm, "SSL_OP_COOKIE_EXCHANGE"_s), jsNumber(SSL_OP_COOKIE_EXCHANGE)); + put(Identifier::fromString(vm, "SSL_OP_COOKIE_EXCHANGE"_s), + jsNumber(SSL_OP_COOKIE_EXCHANGE)); #endif #ifdef SSL_OP_CRYPTOPRO_TLSEXT_BUG - put(Identifier::fromString(vm, "SSL_OP_CRYPTOPRO_TLSEXT_BUG"_s), jsNumber(SSL_OP_CRYPTOPRO_TLSEXT_BUG)); + put(Identifier::fromString(vm, "SSL_OP_CRYPTOPRO_TLSEXT_BUG"_s), + jsNumber(SSL_OP_CRYPTOPRO_TLSEXT_BUG)); #endif #ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS - put(Identifier::fromString(vm, "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS"_s), jsNumber(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); + put(Identifier::fromString(vm, "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS"_s), + jsNumber(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); #endif #ifdef SSL_OP_LEGACY_SERVER_CONNECT - put(Identifier::fromString(vm, "SSL_OP_LEGACY_SERVER_CONNECT"_s), jsNumber(SSL_OP_LEGACY_SERVER_CONNECT)); + put(Identifier::fromString(vm, "SSL_OP_LEGACY_SERVER_CONNECT"_s), + jsNumber(SSL_OP_LEGACY_SERVER_CONNECT)); #endif #ifdef SSL_OP_NO_COMPRESSION - put(Identifier::fromString(vm, "SSL_OP_NO_COMPRESSION"_s), jsNumber(SSL_OP_NO_COMPRESSION)); + put(Identifier::fromString(vm, "SSL_OP_NO_COMPRESSION"_s), + jsNumber(SSL_OP_NO_COMPRESSION)); #endif #ifdef SSL_OP_NO_ENCRYPT_THEN_MAC - put(Identifier::fromString(vm, "SSL_OP_NO_ENCRYPT_THEN_MAC"_s), jsNumber(SSL_OP_NO_ENCRYPT_THEN_MAC)); + put(Identifier::fromString(vm, "SSL_OP_NO_ENCRYPT_THEN_MAC"_s), + jsNumber(SSL_OP_NO_ENCRYPT_THEN_MAC)); #endif #ifdef SSL_OP_NO_QUERY_MTU - put(Identifier::fromString(vm, "SSL_OP_NO_QUERY_MTU"_s), jsNumber(SSL_OP_NO_QUERY_MTU)); + put(Identifier::fromString(vm, "SSL_OP_NO_QUERY_MTU"_s), + jsNumber(SSL_OP_NO_QUERY_MTU)); #endif #ifdef SSL_OP_NO_RENEGOTIATION - put(Identifier::fromString(vm, "SSL_OP_NO_RENEGOTIATION"_s), jsNumber(SSL_OP_NO_RENEGOTIATION)); + put(Identifier::fromString(vm, "SSL_OP_NO_RENEGOTIATION"_s), + jsNumber(SSL_OP_NO_RENEGOTIATION)); #endif #ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION - put(Identifier::fromString(vm, "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION"_s), jsNumber(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)); + put(Identifier::fromString(vm, + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION"_s), + jsNumber(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)); #endif #ifdef SSL_OP_NO_SSLv2 - put(Identifier::fromString(vm, "SSL_OP_NO_SSLv2"_s), jsNumber(SSL_OP_NO_SSLv2)); + put(Identifier::fromString(vm, "SSL_OP_NO_SSLv2"_s), + jsNumber(SSL_OP_NO_SSLv2)); #endif #ifdef SSL_OP_NO_SSLv3 - put(Identifier::fromString(vm, "SSL_OP_NO_SSLv3"_s), jsNumber(SSL_OP_NO_SSLv3)); + put(Identifier::fromString(vm, "SSL_OP_NO_SSLv3"_s), + jsNumber(SSL_OP_NO_SSLv3)); #endif #ifdef SSL_OP_NO_TICKET - put(Identifier::fromString(vm, "SSL_OP_NO_TICKET"_s), jsNumber(SSL_OP_NO_TICKET)); + put(Identifier::fromString(vm, "SSL_OP_NO_TICKET"_s), + jsNumber(SSL_OP_NO_TICKET)); #endif #ifdef SSL_OP_NO_TLSv1 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1"_s), jsNumber(SSL_OP_NO_TLSv1)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1"_s), + jsNumber(SSL_OP_NO_TLSv1)); #endif #ifdef SSL_OP_NO_TLSv1_1 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_1"_s), jsNumber(SSL_OP_NO_TLSv1_1)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_1"_s), + jsNumber(SSL_OP_NO_TLSv1_1)); #endif #ifdef SSL_OP_NO_TLSv1_2 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_2"_s), jsNumber(SSL_OP_NO_TLSv1_2)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_2"_s), + jsNumber(SSL_OP_NO_TLSv1_2)); #endif #ifdef SSL_OP_NO_TLSv1_3 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_3"_s), jsNumber(SSL_OP_NO_TLSv1_3)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_3"_s), + jsNumber(SSL_OP_NO_TLSv1_3)); #endif #ifdef SSL_OP_PRIORITIZE_CHACHA - put(Identifier::fromString(vm, "SSL_OP_PRIORITIZE_CHACHA"_s), jsNumber(SSL_OP_PRIORITIZE_CHACHA)); + put(Identifier::fromString(vm, "SSL_OP_PRIORITIZE_CHACHA"_s), + jsNumber(SSL_OP_PRIORITIZE_CHACHA)); #endif #ifdef SSL_OP_TLS_ROLLBACK_BUG - put(Identifier::fromString(vm, "SSL_OP_TLS_ROLLBACK_BUG"_s), jsNumber(SSL_OP_TLS_ROLLBACK_BUG)); + put(Identifier::fromString(vm, "SSL_OP_TLS_ROLLBACK_BUG"_s), + jsNumber(SSL_OP_TLS_ROLLBACK_BUG)); #endif #ifndef OPENSSL_NO_ENGINE #ifdef ENGINE_METHOD_RSA - put(Identifier::fromString(vm, "ENGINE_METHOD_RSA"_s), jsNumber(ENGINE_METHOD_RSA)); + put(Identifier::fromString(vm, "ENGINE_METHOD_RSA"_s), + jsNumber(ENGINE_METHOD_RSA)); #endif #ifdef ENGINE_METHOD_DSA - put(Identifier::fromString(vm, "ENGINE_METHOD_DSA"_s), jsNumber(ENGINE_METHOD_DSA)); + put(Identifier::fromString(vm, "ENGINE_METHOD_DSA"_s), + jsNumber(ENGINE_METHOD_DSA)); #endif #ifdef ENGINE_METHOD_DH - put(Identifier::fromString(vm, "ENGINE_METHOD_DH"_s), jsNumber(ENGINE_METHOD_DH)); + put(Identifier::fromString(vm, "ENGINE_METHOD_DH"_s), + jsNumber(ENGINE_METHOD_DH)); #endif #ifdef ENGINE_METHOD_RAND - put(Identifier::fromString(vm, "ENGINE_METHOD_RAND"_s), jsNumber(ENGINE_METHOD_RAND)); + put(Identifier::fromString(vm, "ENGINE_METHOD_RAND"_s), + jsNumber(ENGINE_METHOD_RAND)); #endif #ifdef ENGINE_METHOD_EC - put(Identifier::fromString(vm, "ENGINE_METHOD_EC"_s), jsNumber(ENGINE_METHOD_EC)); + put(Identifier::fromString(vm, "ENGINE_METHOD_EC"_s), + jsNumber(ENGINE_METHOD_EC)); #endif #ifdef ENGINE_METHOD_CIPHERS - put(Identifier::fromString(vm, "ENGINE_METHOD_CIPHERS"_s), jsNumber(ENGINE_METHOD_CIPHERS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_CIPHERS"_s), + jsNumber(ENGINE_METHOD_CIPHERS)); #endif #ifdef ENGINE_METHOD_DIGESTS - put(Identifier::fromString(vm, "ENGINE_METHOD_DIGESTS"_s), jsNumber(ENGINE_METHOD_DIGESTS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_DIGESTS"_s), + jsNumber(ENGINE_METHOD_DIGESTS)); #endif #ifdef ENGINE_METHOD_PKEY_METHS - put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_METHS"_s), jsNumber(ENGINE_METHOD_PKEY_METHS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_METHS"_s), + jsNumber(ENGINE_METHOD_PKEY_METHS)); #endif #ifdef ENGINE_METHOD_PKEY_ASN1_METHS - put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_ASN1_METHS"_s), jsNumber(ENGINE_METHOD_PKEY_ASN1_METHS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_ASN1_METHS"_s), + jsNumber(ENGINE_METHOD_PKEY_ASN1_METHS)); #endif #ifdef ENGINE_METHOD_ALL - put(Identifier::fromString(vm, "ENGINE_METHOD_ALL"_s), jsNumber(ENGINE_METHOD_ALL)); + put(Identifier::fromString(vm, "ENGINE_METHOD_ALL"_s), + jsNumber(ENGINE_METHOD_ALL)); #endif #ifdef ENGINE_METHOD_NONE - put(Identifier::fromString(vm, "ENGINE_METHOD_NONE"_s), jsNumber(ENGINE_METHOD_NONE)); + put(Identifier::fromString(vm, "ENGINE_METHOD_NONE"_s), + jsNumber(ENGINE_METHOD_NONE)); #endif #endif // !OPENSSL_NO_ENGINE #ifdef DH_CHECK_P_NOT_SAFE_PRIME - put(Identifier::fromString(vm, "DH_CHECK_P_NOT_SAFE_PRIME"_s), jsNumber(DH_CHECK_P_NOT_SAFE_PRIME)); + put(Identifier::fromString(vm, "DH_CHECK_P_NOT_SAFE_PRIME"_s), + jsNumber(DH_CHECK_P_NOT_SAFE_PRIME)); #endif #ifdef DH_CHECK_P_NOT_PRIME - put(Identifier::fromString(vm, "DH_CHECK_P_NOT_PRIME"_s), jsNumber(DH_CHECK_P_NOT_PRIME)); + put(Identifier::fromString(vm, "DH_CHECK_P_NOT_PRIME"_s), + jsNumber(DH_CHECK_P_NOT_PRIME)); #endif #ifdef DH_UNABLE_TO_CHECK_GENERATOR - put(Identifier::fromString(vm, "DH_UNABLE_TO_CHECK_GENERATOR"_s), jsNumber(DH_UNABLE_TO_CHECK_GENERATOR)); + put(Identifier::fromString(vm, "DH_UNABLE_TO_CHECK_GENERATOR"_s), + jsNumber(DH_UNABLE_TO_CHECK_GENERATOR)); #endif #ifdef DH_NOT_SUITABLE_GENERATOR - put(Identifier::fromString(vm, "DH_NOT_SUITABLE_GENERATOR"_s), jsNumber(DH_NOT_SUITABLE_GENERATOR)); + put(Identifier::fromString(vm, "DH_NOT_SUITABLE_GENERATOR"_s), + jsNumber(DH_NOT_SUITABLE_GENERATOR)); #endif #ifdef RSA_PKCS1_PADDING - put(Identifier::fromString(vm, "RSA_PKCS1_PADDING"_s), jsNumber(RSA_PKCS1_PADDING)); + put(Identifier::fromString(vm, "RSA_PKCS1_PADDING"_s), + jsNumber(RSA_PKCS1_PADDING)); #endif #ifdef RSA_SSLV23_PADDING - put(Identifier::fromString(vm, "RSA_SSLV23_PADDING"_s), jsNumber(RSA_SSLV23_PADDING)); + put(Identifier::fromString(vm, "RSA_SSLV23_PADDING"_s), + jsNumber(RSA_SSLV23_PADDING)); #endif #ifdef RSA_NO_PADDING - put(Identifier::fromString(vm, "RSA_NO_PADDING"_s), jsNumber(RSA_NO_PADDING)); + put(Identifier::fromString(vm, "RSA_NO_PADDING"_s), jsNumber(RSA_NO_PADDING)); #endif #ifdef RSA_PKCS1_OAEP_PADDING - put(Identifier::fromString(vm, "RSA_PKCS1_OAEP_PADDING"_s), jsNumber(RSA_PKCS1_OAEP_PADDING)); + put(Identifier::fromString(vm, "RSA_PKCS1_OAEP_PADDING"_s), + jsNumber(RSA_PKCS1_OAEP_PADDING)); #endif #ifdef RSA_X931_PADDING - put(Identifier::fromString(vm, "RSA_X931_PADDING"_s), jsNumber(RSA_X931_PADDING)); + put(Identifier::fromString(vm, "RSA_X931_PADDING"_s), + jsNumber(RSA_X931_PADDING)); #endif #ifdef RSA_PKCS1_PSS_PADDING - put(Identifier::fromString(vm, "RSA_PKCS1_PSS_PADDING"_s), jsNumber(RSA_PKCS1_PSS_PADDING)); + put(Identifier::fromString(vm, "RSA_PKCS1_PSS_PADDING"_s), + jsNumber(RSA_PKCS1_PSS_PADDING)); #endif #ifdef RSA_PSS_SALTLEN_DIGEST - put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s), jsNumber(RSA_PSS_SALTLEN_DIGEST)); + put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s), + jsNumber(RSA_PSS_SALTLEN_DIGEST)); #endif #ifdef RSA_PSS_SALTLEN_MAX_SIGN - put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s), jsNumber(RSA_PSS_SALTLEN_MAX_SIGN)); + put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s), + jsNumber(RSA_PSS_SALTLEN_MAX_SIGN)); #endif #ifdef RSA_PSS_SALTLEN_AUTO - put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s), jsNumber(RSA_PSS_SALTLEN_AUTO)); -#endif - auto cipherList = String("TLS_AES_256_GCM_SHA384:" - "TLS_CHACHA20_POLY1305_SHA256:" - "TLS_AES_128_GCM_SHA256:" - "ECDHE-RSA-AES128-GCM-SHA256:" - "ECDHE-ECDSA-AES128-GCM-SHA256:" - "ECDHE-RSA-AES256-GCM-SHA384:" - "ECDHE-ECDSA-AES256-GCM-SHA384:" - "DHE-RSA-AES128-GCM-SHA256:" - "ECDHE-RSA-AES128-SHA256:" - "DHE-RSA-AES128-SHA256:" - "ECDHE-RSA-AES256-SHA384:" - "DHE-RSA-AES256-SHA384:" - "ECDHE-RSA-AES256-SHA256:" - "DHE-RSA-AES256-SHA256:" - "HIGH:" - "!aNULL:" - "!eNULL:" - "!EXPORT:" - "!DES:" - "!RC4:" - "!MD5:" - "!PSK:" - "!SRP:" - "!CAMELLIA"_s); - put(Identifier::fromString(vm, "defaultCoreCipherList"_s), - jsString(vm, cipherList)); - put(Identifier::fromString(vm, "defaultCipherList"_s), - jsString(vm, cipherList)); + put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s), + jsNumber(RSA_PSS_SALTLEN_AUTO)); +#endif + auto cipherList = String("TLS_AES_256_GCM_SHA384:" + "TLS_CHACHA20_POLY1305_SHA256:" + "TLS_AES_128_GCM_SHA256:" + "ECDHE-RSA-AES128-GCM-SHA256:" + "ECDHE-ECDSA-AES128-GCM-SHA256:" + "ECDHE-RSA-AES256-GCM-SHA384:" + "ECDHE-ECDSA-AES256-GCM-SHA384:" + "DHE-RSA-AES128-GCM-SHA256:" + "ECDHE-RSA-AES128-SHA256:" + "DHE-RSA-AES128-SHA256:" + "ECDHE-RSA-AES256-SHA384:" + "DHE-RSA-AES256-SHA384:" + "ECDHE-RSA-AES256-SHA256:" + "DHE-RSA-AES256-SHA256:" + "HIGH:" + "!aNULL:" + "!eNULL:" + "!EXPORT:" + "!DES:" + "!RC4:" + "!MD5:" + "!PSK:" + "!SRP:" + "!CAMELLIA"_s); + put(Identifier::fromString(vm, "defaultCoreCipherList"_s), + jsString(vm, cipherList)); + put(Identifier::fromString(vm, "defaultCipherList"_s), + jsString(vm, cipherList)); #ifdef TLS1_VERSION - put(Identifier::fromString(vm, "TLS1_VERSION"_s), jsNumber(TLS1_VERSION)); + put(Identifier::fromString(vm, "TLS1_VERSION"_s), jsNumber(TLS1_VERSION)); #endif #ifdef TLS1_1_VERSION - put(Identifier::fromString(vm, "TLS1_1_VERSION"_s), jsNumber(TLS1_1_VERSION)); + put(Identifier::fromString(vm, "TLS1_1_VERSION"_s), jsNumber(TLS1_1_VERSION)); #endif #ifdef TLS1_2_VERSION - put(Identifier::fromString(vm, "TLS1_2_VERSION"_s), jsNumber(TLS1_2_VERSION)); + put(Identifier::fromString(vm, "TLS1_2_VERSION"_s), jsNumber(TLS1_2_VERSION)); #endif #ifdef TLS1_3_VERSION - put(Identifier::fromString(vm, "TLS1_3_VERSION"_s), jsNumber(TLS1_3_VERSION)); -#endif - put(Identifier::fromString(vm, "POINT_CONVERSION_COMPRESSED"_s), jsNumber(POINT_CONVERSION_COMPRESSED)); - put(Identifier::fromString(vm, "POINT_CONVERSION_UNCOMPRESSED"_s), jsNumber(POINT_CONVERSION_UNCOMPRESSED)); - put(Identifier::fromString(vm, "POINT_CONVERSION_HYBRID"_s), jsNumber(POINT_CONVERSION_HYBRID)); - RETURN_NATIVE_MODULE(); + put(Identifier::fromString(vm, "TLS1_3_VERSION"_s), jsNumber(TLS1_3_VERSION)); +#endif + put(Identifier::fromString(vm, "POINT_CONVERSION_COMPRESSED"_s), + jsNumber(POINT_CONVERSION_COMPRESSED)); + put(Identifier::fromString(vm, "POINT_CONVERSION_UNCOMPRESSED"_s), + jsNumber(POINT_CONVERSION_UNCOMPRESSED)); + put(Identifier::fromString(vm, "POINT_CONVERSION_HYBRID"_s), + jsNumber(POINT_CONVERSION_HYBRID)); + + // RETURN_NATIVE_MODULE(); } } // namespace Zig diff --git a/src/bun.js/modules/NodeModuleModule.h b/src/bun.js/modules/NodeModuleModule.h index 0da967f65..804d1dd9d 100644 --- a/src/bun.js/modules/NodeModuleModule.h +++ b/src/bun.js/modules/NodeModuleModule.h @@ -417,8 +417,6 @@ DEFINE_NATIVE_MODULE(NodeModule) { } put(JSC::Identifier::fromString(vm, "builtinModules"_s), builtinModules); - - RETURN_NATIVE_MODULE(); } } // namespace Zig diff --git a/src/bun.js/modules/_NativeModule.h b/src/bun.js/modules/_NativeModule.h index b23906ad0..6d3d76176 100644 --- a/src/bun.js/modules/_NativeModule.h +++ b/src/bun.js/modules/_NativeModule.h @@ -40,18 +40,19 @@ // that what you passed to INIT_NATIVE_MODULE is indeed correct. #define RETURN_NATIVE_MODULE() \ ASSERT_WITH_MESSAGE(numberOfActualExportNames == passedNumberOfExportNames, \ - "NATIVE_MODULE_START() was given the incorrect value."); + "NATIVE_MODULE_START() was should be given %d", numberOfActualExportNames); -#define __NATIVE_MODULE_ASSERT_DECL \ +#define __NATIVE_MODULE_ASSERT_DECL(numberOfExportNames) \ int numberOfActualExportNames = 0; \ int passedNumberOfExportNames = numberOfExportNames; \ + #define __NATIVE_MODULE_ASSERT_INCR numberOfActualExportNames++; #else #define RETURN_NATIVE_MODULE() ; #define __NATIVE_MODULE_ASSERT_INCR ; -#define __NATIVE_MODULE_ASSERT_DECL ; +#define __NATIVE_MODULE_ASSERT_DECL(numberOfExportNames) ; #endif @@ -67,7 +68,7 @@ JSC::VM &vm = globalObject->vm(); \ JSC::JSObject *defaultObject = JSC::constructEmptyObject( \ globalObject, globalObject->objectPrototype(), numberOfExportNames); \ - __NATIVE_MODULE_ASSERT_DECL \ + __NATIVE_MODULE_ASSERT_DECL(numberOfExportNames); \ auto put = [&](JSC::Identifier name, JSC::JSValue value) { \ defaultObject->putDirect(vm, name, value); \ exportNames.append(name); \ diff --git a/src/bun.js/scripts/generate-classes.ts b/src/bun.js/scripts/generate-classes.ts index 294e07494..ae28f4fe5 100644 --- a/src/bun.js/scripts/generate-classes.ts +++ b/src/bun.js/scripts/generate-classes.ts @@ -335,7 +335,7 @@ function generatePrototype(typeName, obj) { this->putDirect(vm, vm.propertyNames->${symbol}Symbol, JSFunction::create(vm, globalObject, 1, String("${symbol}"_s), ${protoSymbolName( typeName, symbol, - )}Callback, ImplementationVisibility::Public), PropertyAttribute::Function | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0);`; + )}Callback, ImplementationVisibility::Public), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0);`; } return ` @@ -420,6 +420,7 @@ function generatePrototypeHeader(typename) { template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(${proto}, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/scripts/generate-jssink.js b/src/bun.js/scripts/generate-jssink.js index 93bf842c4..758b1863b 100644 --- a/src/bun.js/scripts/generate-jssink.js +++ b/src/bun.js/scripts/generate-jssink.js @@ -548,6 +548,7 @@ public: template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(${prototypeName}, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) @@ -580,6 +581,7 @@ class ${controllerPrototypeName} final : public JSC::JSNonFinalObject { template<typename CellType, JSC::SubspaceAccess> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(${controllerPrototypeName}, Base); return &vm.plainObjectSpace(); } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |