aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/bindings')
-rw-r--r--src/bun.js/bindings/AsyncContextFrame.cpp4
-rw-r--r--src/bun.js/bindings/BunObject.cpp42
-rw-r--r--src/bun.js/bindings/BunPlugin.cpp1
-rw-r--r--src/bun.js/bindings/BunString.cpp2
-rw-r--r--src/bun.js/bindings/CallSitePrototype.h1
-rw-r--r--src/bun.js/bindings/CommonJSModuleRecord.cpp101
-rw-r--r--src/bun.js/bindings/CommonJSModuleRecord.h26
-rw-r--r--src/bun.js/bindings/ImportMetaObject.cpp15
-rw-r--r--src/bun.js/bindings/InternalModuleRegistry.cpp17
-rw-r--r--src/bun.js/bindings/InternalModuleRegistry.h17
-rw-r--r--src/bun.js/bindings/JSBuffer.cpp10
-rw-r--r--src/bun.js/bindings/JSBufferList.cpp28
-rw-r--r--src/bun.js/bindings/JSBufferList.h3
-rw-r--r--src/bun.js/bindings/JSDOMFile.cpp11
-rw-r--r--src/bun.js/bindings/JSDOMWrapperCache.h4
-rw-r--r--src/bun.js/bindings/JSMockFunction.cpp4
-rw-r--r--src/bun.js/bindings/JSNextTickQueue.cpp6
-rw-r--r--src/bun.js/bindings/JSNextTickQueue.h1
-rw-r--r--src/bun.js/bindings/JSReadableState.h1
-rw-r--r--src/bun.js/bindings/JSSink.cpp8
-rw-r--r--src/bun.js/bindings/JSStringDecoder.h1
-rw-r--r--src/bun.js/bindings/ModuleLoader.cpp15
-rw-r--r--src/bun.js/bindings/NodeVMScript.cpp1
-rw-r--r--src/bun.js/bindings/Path.cpp2
-rw-r--r--src/bun.js/bindings/Process.cpp14
-rw-r--r--src/bun.js/bindings/ProcessBindingConstants.cpp7
-rw-r--r--src/bun.js/bindings/ProcessBindingConstants.h1
-rw-r--r--src/bun.js/bindings/ProcessBindingNatives.cpp4
-rw-r--r--src/bun.js/bindings/ProcessBindingNatives.h1
-rw-r--r--src/bun.js/bindings/RegularExpression.cpp4
-rw-r--r--src/bun.js/bindings/ScriptExecutionContext.cpp4
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp61
-rw-r--r--src/bun.js/bindings/ZigGeneratedCode.cpp39
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp132
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.h3
-rw-r--r--src/bun.js/bindings/ZigLazyStaticFunctions-inlines.h2
-rw-r--r--src/bun.js/bindings/bindings.cpp90
-rw-r--r--src/bun.js/bindings/headers.h2
-rw-r--r--src/bun.js/bindings/napi.cpp6
-rw-r--r--src/bun.js/bindings/sqlite/JSSQLStatement.cpp12
-rw-r--r--src/bun.js/bindings/sqlite/JSSQLStatement.h17
-rw-r--r--src/bun.js/bindings/webcore/JSEventEmitter.cpp7
-rw-r--r--src/bun.js/bindings/webcore/JSReadableStream.cpp2
-rw-r--r--src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp2
-rw-r--r--src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp2
-rw-r--r--src/bun.js/bindings/webcore/MessagePort.cpp12
-rw-r--r--src/bun.js/bindings/webcore/MessagePortChannel.cpp12
-rw-r--r--src/bun.js/bindings/webcore/MessagePortChannelProvider.cpp3
-rw-r--r--src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp41
-rw-r--r--src/bun.js/bindings/webcore/WebSocket.cpp21
50 files changed, 468 insertions, 354 deletions
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));