diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index aafc09f309..4b3a02b169 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -1089,6 +1089,7 @@ add_custom_target(dependencies DEPENDS ${BUN_TARGETS}) if(APPLE) target_link_libraries(${bun} PRIVATE icucore resolv) + target_compile_definitions(${bun} PRIVATE U_DISABLE_RENAMING=1) endif() if(USE_STATIC_SQLITE) diff --git a/cmake/tools/SetupWebKit.cmake b/cmake/tools/SetupWebKit.cmake index 417b0289a4..d8714f2263 100644 --- a/cmake/tools/SetupWebKit.cmake +++ b/cmake/tools/SetupWebKit.cmake @@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use") option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading") if(NOT WEBKIT_VERSION) - set(WEBKIT_VERSION 851aabf42b06ba583cc0485ff9088e3f84c22f3d) + set(WEBKIT_VERSION 57004f91903936881b3301594d9d67708f1ff64c) endif() string(SUBSTRING ${WEBKIT_VERSION} 0 16 WEBKIT_VERSION_PREFIX) diff --git a/misctools/lldb/lldb_commands b/misctools/lldb/lldb_commands index d4ad6a560b..fde59a77a9 100644 --- a/misctools/lldb/lldb_commands +++ b/misctools/lldb/lldb_commands @@ -1,4 +1,10 @@ -process handle -p true -s false -n false SIGUSR1 +# Tell LLDB what to do when the debugged process receives SIGPWR: pass it through to the process +# (-p), but do not stop the process (-s) or notify the user (-n). +# +# JSC's garbage collector sends this signal (as configured by Bun WebKit in +# Thread::initializePlatformThreading() in ThreadingPOSIX.cpp) to the JS thread to suspend or resume +# it. So stopping the process would just create noise when debugging any long-running script. +process handle -p true -s false -n false SIGPWR command script import misctools/lldb/lldb_pretty_printers.py type category enable zig.lang diff --git a/src/bun.js/bindings/BunClientData.h b/src/bun.js/bindings/BunClientData.h index ef210b02ad..32b9174a8a 100644 --- a/src/bun.js/bindings/BunClientData.h +++ b/src/bun.js/bindings/BunClientData.h @@ -73,9 +73,11 @@ private: Vector m_outputConstraintSpaces; }; +DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(JSVMClientData); + class JSVMClientData : public JSC::VM::ClientData { WTF_MAKE_NONCOPYABLE(JSVMClientData); - WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(JSVMClientData); public: explicit JSVMClientData(JSC::VM&, RefPtr); @@ -113,6 +115,8 @@ public: Bun::JSCTaskScheduler deferredWorkTimer; private: + bool isWebCoreJSClientData() const final { return true; } + BunBuiltinNames m_builtinNames; JSBuiltinFunctions m_builtinFunctions; @@ -127,10 +131,18 @@ private: Vector m_outputConstraintSpaces; }; +} // namespace WebCore + +SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::JSVMClientData) +static bool isType(const JSC::VM::ClientData& clientData) { return clientData.isWebCoreJSClientData(); } +SPECIALIZE_TYPE_TRAITS_END() + +namespace WebCore { + template ALWAYS_INLINE JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm, GetClient getClient, SetClient setClient, GetServer getServer, SetServer setServer, JSC::HeapCellType& (*getCustomHeapCellType)(JSHeapData&) = nullptr) { - auto& clientData = *static_cast(vm.clientData); + auto& clientData = *downcast(vm.clientData); auto& clientSubspaces = clientData.clientSubspaces(); if (auto* clientSpace = getClient(clientSubspaces)) return clientSpace; @@ -143,7 +155,7 @@ ALWAYS_INLINE JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm, GetClient if (!space) { JSC::Heap& heap = vm.heap; std::unique_ptr uniqueSubspace; - static_assert(useCustomHeapCellType == UseCustomHeapCellType::Yes || std::is_base_of_v || !T::needsDestruction); + static_assert(useCustomHeapCellType == UseCustomHeapCellType::Yes || std::is_base_of_v || T::needsDestruction == JSC::DoesNotNeedDestruction); if constexpr (useCustomHeapCellType == UseCustomHeapCellType::Yes) uniqueSubspace = makeUnique ISO_SUBSPACE_INIT(heap, getCustomHeapCellType(heapData), T); else { @@ -182,7 +194,7 @@ ALWAYS_INLINE JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm, GetClient static JSVMClientData* clientData(JSC::VM& vm) { - return static_cast(vm.clientData); + return downcast(vm.clientData); } static inline BunBuiltinNames& builtinNames(JSC::VM& vm) diff --git a/src/bun.js/bindings/BunDebugger.cpp b/src/bun.js/bindings/BunDebugger.cpp index 5b0d930ce4..c4a781d2ae 100644 --- a/src/bun.js/bindings/BunDebugger.cpp +++ b/src/bun.js/bindings/BunDebugger.cpp @@ -392,7 +392,7 @@ class JSBunInspectorConnection final : public JSC::JSNonFinalObject { public: using Base = JSC::JSNonFinalObject; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static JSBunInspectorConnection* create(JSC::VM& vm, JSC::Structure* structure, BunInspectorConnection* connection) { diff --git a/src/bun.js/bindings/BunObject.cpp b/src/bun.js/bindings/BunObject.cpp index 53c5e12193..e95acf429f 100644 --- a/src/bun.js/bindings/BunObject.cpp +++ b/src/bun.js/bindings/BunObject.cpp @@ -787,7 +787,7 @@ public: DECLARE_INFO; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable; template diff --git a/src/bun.js/bindings/BunWorkerGlobalScope.cpp b/src/bun.js/bindings/BunWorkerGlobalScope.cpp index 40b1fbfddb..b4844710fb 100644 --- a/src/bun.js/bindings/BunWorkerGlobalScope.cpp +++ b/src/bun.js/bindings/BunWorkerGlobalScope.cpp @@ -2,10 +2,11 @@ #include "BunWorkerGlobalScope.h" #include "MessagePortChannelProviderImpl.h" +#include namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(WorkerGlobalScope); +WTF_MAKE_TZONE_ALLOCATED_IMPL(WorkerGlobalScope); MessagePortChannelProvider& WorkerGlobalScope::messagePortChannelProvider() { diff --git a/src/bun.js/bindings/BunWorkerGlobalScope.h b/src/bun.js/bindings/BunWorkerGlobalScope.h index ad9114de84..fac0329391 100644 --- a/src/bun.js/bindings/BunWorkerGlobalScope.h +++ b/src/bun.js/bindings/BunWorkerGlobalScope.h @@ -16,7 +16,7 @@ class MessagePortChannelProvider; class MessagePortChannelProviderImpl; class WorkerGlobalScope : public RefCounted, public EventTargetWithInlineData { - WTF_MAKE_ISO_ALLOCATED(WorkerGlobalScope); + WTF_MAKE_TZONE_ALLOCATED(WorkerGlobalScope); uint32_t m_messageEventCount { 0 }; diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index b2d67fd498..813b332a8c 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -141,9 +141,9 @@ static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Zig::GlobalObject* globalObj // https://github.com/nodejs/node/blob/592c6907bfe1922f36240e9df076be1864c3d1bd/lib/internal/process/execution.js#L92 globalObject->putDirect(vm, builtinNames(vm).exportsPublicName(), moduleObject->exportsObject(), 0); globalObject->putDirect(vm, builtinNames(vm).requirePublicName(), requireFunction, 0); - globalObject->putDirect(vm, Identifier::fromLatin1(vm, "module"_s), moduleObject, 0); - globalObject->putDirect(vm, Identifier::fromLatin1(vm, "__filename"_s), filename, 0); - globalObject->putDirect(vm, Identifier::fromLatin1(vm, "__dirname"_s), dirname, 0); + globalObject->putDirect(vm, Identifier::fromString(vm, "module"_s), moduleObject, 0); + globalObject->putDirect(vm, Identifier::fromString(vm, "__filename"_s), filename, 0); + globalObject->putDirect(vm, Identifier::fromString(vm, "__dirname"_s), dirname, 0); JSValue result = JSC::evaluate(globalObject, code, jsUndefined(), exception); diff --git a/src/bun.js/bindings/EventLoopTask.h b/src/bun.js/bindings/EventLoopTask.h index 8461ac17dd..953fc0da85 100644 --- a/src/bun.js/bindings/EventLoopTask.h +++ b/src/bun.js/bindings/EventLoopTask.h @@ -4,7 +4,7 @@ namespace WebCore { class EventLoopTask { - WTF_MAKE_ISO_ALLOCATED(EventLoopTask); + WTF_MAKE_TZONE_ALLOCATED(EventLoopTask); public: enum CleanupTaskTag { CleanupTask }; diff --git a/src/bun.js/bindings/EventLoopTaskNoContext.cpp b/src/bun.js/bindings/EventLoopTaskNoContext.cpp index 473bc3f11f..6f1f3d367a 100644 --- a/src/bun.js/bindings/EventLoopTaskNoContext.cpp +++ b/src/bun.js/bindings/EventLoopTaskNoContext.cpp @@ -2,8 +2,6 @@ namespace Bun { -WTF_MAKE_ISO_ALLOCATED_IMPL(EventLoopTaskNoContext); - extern "C" void Bun__EventLoopTaskNoContext__performTask(EventLoopTaskNoContext* task) { task->performTask(); diff --git a/src/bun.js/bindings/EventLoopTaskNoContext.h b/src/bun.js/bindings/EventLoopTaskNoContext.h index 0f3491ce76..e795a23ccb 100644 --- a/src/bun.js/bindings/EventLoopTaskNoContext.h +++ b/src/bun.js/bindings/EventLoopTaskNoContext.h @@ -7,7 +7,7 @@ namespace Bun { // Just like WebCore::EventLoopTask but does not take a ScriptExecutionContext class EventLoopTaskNoContext { - WTF_MAKE_ISO_ALLOCATED(EventLoopTaskNoContext); + WTF_MAKE_TZONE_ALLOCATED(EventLoopTaskNoContext); public: EventLoopTaskNoContext(JSC::JSGlobalObject* globalObject, Function&& task) diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index ecd0e243ed..77da534f64 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -294,7 +294,7 @@ public: using Operation = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, ClassParameter); template - static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName) + static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, ASCIILiteral operationName) { auto& vm = JSC::getVM(&lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -307,7 +307,7 @@ public: auto thisObject = JSC::jsDynamicCast(thisValue); if (UNLIKELY(!thisObject)) - return throwThisTypeError(lexicalGlobalObject, throwScope, "Buffer", operationName); + return throwThisTypeError(lexicalGlobalObject, throwScope, "Buffer"_s, operationName); RELEASE_AND_RETURN(throwScope, (operation(&lexicalGlobalObject, &callFrame, thisObject))); } diff --git a/src/bun.js/bindings/JSBufferList.h b/src/bun.js/bindings/JSBufferList.h index 78b6ddf60e..713b706152 100644 --- a/src/bun.js/bindings/JSBufferList.h +++ b/src/bun.js/bindings/JSBufferList.h @@ -146,7 +146,7 @@ public: static JSBufferListConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBufferListPrototype* prototype); static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { diff --git a/src/bun.js/bindings/JSCTaskScheduler.cpp b/src/bun.js/bindings/JSCTaskScheduler.cpp index 22125a19bf..7652caabef 100644 --- a/src/bun.js/bindings/JSCTaskScheduler.cpp +++ b/src/bun.js/bindings/JSCTaskScheduler.cpp @@ -29,11 +29,9 @@ public: JSC::VM& vm() const { return ticket->scriptExecutionOwner()->vm(); } - WTF_MAKE_ISO_ALLOCATED(JSCDeferredWorkTask); + WTF_MAKE_TZONE_ALLOCATED(JSCDeferredWorkTask); }; -WTF_MAKE_ISO_ALLOCATED_IMPL(JSCDeferredWorkTask); - static JSC::VM& getVM(Ticket& ticket) { return ticket->scriptExecutionOwner()->vm(); diff --git a/src/bun.js/bindings/JSDOMExceptionHandling.cpp b/src/bun.js/bindings/JSDOMExceptionHandling.cpp index b673cc1a43..a5c09653cf 100644 --- a/src/bun.js/bindings/JSDOMExceptionHandling.cpp +++ b/src/bun.js/bindings/JSDOMExceptionHandling.cpp @@ -290,12 +290,6 @@ JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject& lexica return createRejectedPromiseWithTypeError(lexicalGlobalObject, JSC::makeDOMAttributeGetterTypeErrorMessage(classInfo->className, String(attributeName.uid())), RejectedPromiseWithTypeErrorCause::NativeGetter); } -String makeThisTypeErrorMessage(const char* interfaceName, const char* functionName) -{ - auto interfaceNameSpan = span(interfaceName); - return makeString("Can only call "_s, interfaceNameSpan, '.', span(functionName), " on instances of "_s, interfaceNameSpan); -} - String makeThisTypeErrorMessage(ASCIILiteral interfaceName, ASCIILiteral functionName) { return makeString("Can only call "_s, interfaceName, '.', functionName, " on instances of "_s, interfaceName); @@ -306,25 +300,19 @@ String makeUnsupportedIndexedSetterErrorMessage(ASCIILiteral interfaceName) return makeString("Failed to set an indexed property on "_s, interfaceName, ": Indexed property setter is not supported."_s); } -EncodedJSValue throwThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, const char* interfaceName, const char* functionName) -{ - scope.throwException(&lexicalGlobalObject, Bun::createInvalidThisError(&lexicalGlobalObject, makeThisTypeErrorMessage(interfaceName, functionName))); - return {}; -} - EncodedJSValue throwThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, ASCIILiteral interfaceName, ASCIILiteral attributeName) { scope.throwException(&lexicalGlobalObject, Bun::createInvalidThisError(&lexicalGlobalObject, makeThisTypeErrorMessage(interfaceName, attributeName))); return {}; } -JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, const char* interfaceName, const char* methodName) +JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, ASCIILiteral interfaceName, ASCIILiteral methodName) { promise.reject(ExceptionCode::InvalidThisError, makeThisTypeErrorMessage(interfaceName, methodName)); return JSValue::encode(jsUndefined()); } -JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const char* interfaceName, const char* methodName) +JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, ASCIILiteral interfaceName, ASCIILiteral methodName) { return createRejectedPromiseWithTypeError(lexicalGlobalObject, makeThisTypeErrorMessage(interfaceName, methodName), RejectedPromiseWithTypeErrorCause::InvalidThis); } diff --git a/src/bun.js/bindings/JSDOMExceptionHandling.h b/src/bun.js/bindings/JSDOMExceptionHandling.h index 3b0fad9f3b..553dad6852 100644 --- a/src/bun.js/bindings/JSDOMExceptionHandling.h +++ b/src/bun.js/bindings/JSDOMExceptionHandling.h @@ -54,16 +54,14 @@ WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentTypeError(JSC::JSGlobalObject&, WEBCORE_EXPORT JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::JSGlobalObject&, JSC::ThrowScope&, ASCIILiteral memberName, ASCIILiteral dictionaryName, ASCIILiteral expectedType); JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::JSGlobalObject&, JSC::ThrowScope&, ASCIILiteral interfaceName); -String makeThisTypeErrorMessage(const char* interfaceName, const char* attributeName); String makeThisTypeErrorMessage(ASCIILiteral interfaceName, ASCIILiteral functionName); String makeUnsupportedIndexedSetterErrorMessage(ASCIILiteral interfaceName); -WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::JSGlobalObject&, JSC::ThrowScope&, const char* interfaceName, const char* functionName); WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::JSGlobalObject&, JSC::ThrowScope&, ASCIILiteral interfaceName, ASCIILiteral attributeName); WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject&, const JSC::ClassInfo*, JSC::PropertyName attributeName); -WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName); -WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, const char* interfaceName, const char* operationName); +WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, ASCIILiteral interfaceName, ASCIILiteral operationName); +WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, ASCIILiteral interfaceName, ASCIILiteral operationName); String retrieveErrorMessageWithoutName(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&); String retrieveErrorMessage(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&); diff --git a/src/bun.js/bindings/JSFFIFunction.h b/src/bun.js/bindings/JSFFIFunction.h index 9bd99c34e5..4b7cc250e9 100644 --- a/src/bun.js/bindings/JSFFIFunction.h +++ b/src/bun.js/bindings/JSFFIFunction.h @@ -49,7 +49,7 @@ public: using Base = JSFunction; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static void destroy(JSCell* cell) { static_cast(cell)->JSFFIFunction::~JSFFIFunction(); diff --git a/src/bun.js/bindings/JSS3File.h b/src/bun.js/bindings/JSS3File.h index fab0927efb..8ba8c2839d 100644 --- a/src/bun.js/bindings/JSS3File.h +++ b/src/bun.js/bindings/JSS3File.h @@ -11,7 +11,7 @@ class JSS3File : public WebCore::JSBlob { using Base = WebCore::JSBlob; public: - static constexpr bool needsDestruction = true; + static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; static constexpr unsigned StructureFlags = Base::StructureFlags; JSS3File(JSC::VM& vm, Structure* structure, void* ptr) diff --git a/src/bun.js/bindings/JSStringDecoder.h b/src/bun.js/bindings/JSStringDecoder.h index 58f1b270f1..ff3effc24a 100644 --- a/src/bun.js/bindings/JSStringDecoder.h +++ b/src/bun.js/bindings/JSStringDecoder.h @@ -102,7 +102,7 @@ public: static JSStringDecoderConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSStringDecoderPrototype* prototype); static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { diff --git a/src/bun.js/bindings/JSWrappingFunction.h b/src/bun.js/bindings/JSWrappingFunction.h index ac9b9d1919..1b11fb45de 100644 --- a/src/bun.js/bindings/JSWrappingFunction.h +++ b/src/bun.js/bindings/JSWrappingFunction.h @@ -31,7 +31,7 @@ public: using Base = JSC::JSFunction; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static void destroy(JSCell* cell) { static_cast(cell)->JSWrappingFunction::~JSWrappingFunction(); diff --git a/src/bun.js/bindings/JSX509Certificate.h b/src/bun.js/bindings/JSX509Certificate.h index 3014c7f6b3..0a473af7f6 100644 --- a/src/bun.js/bindings/JSX509Certificate.h +++ b/src/bun.js/bindings/JSX509Certificate.h @@ -26,7 +26,7 @@ class JSX509Certificate final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = true; + static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; // The underlying X509 certificate ncrypto::X509Pointer m_x509; diff --git a/src/bun.js/bindings/NodeVM.h b/src/bun.js/bindings/NodeVM.h index 721507d11f..349ace6537 100644 --- a/src/bun.js/bindings/NodeVM.h +++ b/src/bun.js/bindings/NodeVM.h @@ -19,7 +19,7 @@ class NodeVMGlobalObject final : public Bun::GlobalScope { public: static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::OverridesGetOwnPropertySlot | JSC::OverridesPut | JSC::OverridesGetOwnPropertyNames | JSC::GetOwnPropertySlotMayBeWrongAboutDontEnum | JSC::ProhibitsPropertyCaching; - static constexpr bool needsDestruction = true; + static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm); static NodeVMGlobalObject* create(JSC::VM& vm, JSC::Structure* structure); diff --git a/src/bun.js/bindings/ProcessBindingTTYWrap.cpp b/src/bun.js/bindings/ProcessBindingTTYWrap.cpp index 17a2fb6abb..c41551b76e 100644 --- a/src/bun.js/bindings/ProcessBindingTTYWrap.cpp +++ b/src/bun.js/bindings/ProcessBindingTTYWrap.cpp @@ -387,7 +387,7 @@ public: } static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { diff --git a/src/bun.js/bindings/ScriptExecutionContext.cpp b/src/bun.js/bindings/ScriptExecutionContext.cpp index 326aa556ba..4b9e5ba42a 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.cpp +++ b/src/bun.js/bindings/ScriptExecutionContext.cpp @@ -31,7 +31,9 @@ static ScriptExecutionContextIdentifier initialIdentifier() } #endif +#if ENABLE(MALLOC_BREAKDOWN) DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ScriptExecutionContext); +#endif ScriptExecutionContext::ScriptExecutionContext(JSC::VM* vm, JSC::JSGlobalObject* globalObject) : m_vm(vm) @@ -57,12 +59,6 @@ ScriptExecutionContext::ScriptExecutionContext(JSC::VM* vm, JSC::JSGlobalObject* addToContextsMap(); } -WTF_MAKE_ISO_ALLOCATED_IMPL(EventLoopTask); - -#if !ENABLE(MALLOC_BREAKDOWN) -WTF_MAKE_ISO_ALLOCATED_IMPL(ScriptExecutionContext); -#endif - static Lock allScriptExecutionContextsMapLock; static HashMap& allScriptExecutionContextsMap() WTF_REQUIRES_LOCK(allScriptExecutionContextsMapLock) { diff --git a/src/bun.js/bindings/ScriptExecutionContext.h b/src/bun.js/bindings/ScriptExecutionContext.h index 51b49cada1..675a37f5b1 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.h +++ b/src/bun.js/bindings/ScriptExecutionContext.h @@ -35,13 +35,15 @@ class EventLoopTask; class ContextDestructionObserver; using ScriptExecutionContextIdentifier = uint32_t; -DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ScriptExecutionContext); +#if ENABLE(MALLOC_BREAKDOWN) +DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ScriptExecutionContext); +#endif class ScriptExecutionContext : public CanMakeWeakPtr, public RefCounted { #if ENABLE(MALLOC_BREAKDOWN) WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ScriptExecutionContext); #else - WTF_MAKE_ISO_ALLOCATED(ScriptExecutionContext); + WTF_MAKE_TZONE_ALLOCATED(ScriptExecutionContext); #endif public: diff --git a/src/bun.js/bindings/Strong.cpp b/src/bun.js/bindings/Strong.cpp index 20728656e6..f30bd7f758 100644 --- a/src/bun.js/bindings/Strong.cpp +++ b/src/bun.js/bindings/Strong.cpp @@ -5,12 +5,8 @@ #include "Strong.h" namespace Bun { -DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StrongRef); - #if ENABLE(MALLOC_BREAKDOWN) -WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(StrongRef); -#else -WTF_MAKE_ISO_ALLOCATED_IMPL(StrongRef); +DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StrongRef); #endif } diff --git a/src/bun.js/bindings/Strong.h b/src/bun.js/bindings/Strong.h index f8b2bd7b01..bd87efd7c9 100644 --- a/src/bun.js/bindings/Strong.h +++ b/src/bun.js/bindings/Strong.h @@ -2,19 +2,20 @@ #include "root.h" #include "wtf/DebugHeap.h" -#include "wtf/IsoMalloc.h" #include namespace Bun { -DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StrongRef); // We tried to pool these // But it was very complicated +#if ENABLE(MALLOC_BREAKDOWN) +DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StrongRef); +#endif class StrongRef { #if ENABLE(MALLOC_BREAKDOWN) WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(StrongRef); #else - WTF_MAKE_ISO_ALLOCATED(StrongRef); + WTF_MAKE_TZONE_ALLOCATED(StrongRef); #endif public: diff --git a/src/bun.js/bindings/Weak.cpp b/src/bun.js/bindings/Weak.cpp index 2d1a8e5018..5d40ffbb4b 100644 --- a/src/bun.js/bindings/Weak.cpp +++ b/src/bun.js/bindings/Weak.cpp @@ -71,7 +71,7 @@ static JSC::WeakHandleOwner* getWeakRefOwner(WeakRefType type) } class WeakRef { - WTF_MAKE_ISO_ALLOCATED(WeakRef); + WTF_MAKE_TZONE_ALLOCATED(WeakRef); public: WeakRef(JSC::VM& vm, JSC::JSValue value, WeakRefType kind, void* ctx = nullptr) @@ -91,8 +91,6 @@ public: JSC::Weak m_cell; }; -WTF_MAKE_ISO_ALLOCATED_IMPL(WeakRef); - } extern "C" void Bun__WeakRef__clear(Bun::WeakRef* weakRef) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 30bad90124..ac945e43ca 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -162,7 +162,6 @@ #include "JSS3File.h" #include "S3Error.h" #include "ProcessBindingBuffer.h" -#include #if ENABLE(REMOTE_INSPECTOR) #include "JavaScriptCore/RemoteInspectorServer.h" @@ -239,22 +238,6 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c return; has_loaded_jsc = true; JSC::Config::enableRestrictedOptions(); -#if OS(LINUX) - { - // By default, JavaScriptCore's garbage collector sends SIGUSR1 to the JS thread to suspend - // and resume it in order to scan its stack memory. Whatever signal it uses can't be - // reliably intercepted by JS code, and several npm packages use SIGUSR1 for various - // features. We tell it to use SIGPWR instead, which we assume is unlikely to be reliable - // for its stated purpose. Mono's garbage collector also uses SIGPWR: - // https://www.mono-project.com/docs/advanced/embedding/#signal-handling - // - // This call needs to be before most of the other JSC initialization, as we can't - // reconfigure which signal is used once the signal handler has already been registered. - bool configure_signal_success = JSConfigureSignalForGC(SIGPWR); - ASSERT(configure_signal_success); - ASSERT(g_wtfConfig.sigThreadSuspendResume == SIGPWR); - } -#endif std::set_terminate([]() { Zig__GlobalObject__onCrash(); }); WTF::initializeMainThread(); @@ -905,6 +888,9 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(void* console_client, vm.heap.disableStopIfNecessaryTimer(); + // Every JS VM's RunLoop should use Bun's RunLoop implementation + ASSERT(vmPtr->runLoop().kind() == WTF::RunLoop::Kind::Bun); + WebCore::JSVMClientData::create(&vm, Bun__getVM()); const auto createGlobalObject = [&]() -> Zig::GlobalObject* { @@ -1752,7 +1738,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBTOA, throwOutOfMemoryError(globalObject, throwScope); return {}; } - WTF::StringImpl::copyCharacters(ptr.data(), encodedString.span16()); + WTF::StringImpl::copyCharacters(ptr, encodedString.span16()); encodedString = WTFMove(dest); } diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 207ef3a684..4225193c35 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -6991,7 +6991,6 @@ pub const URLSearchParams = opaque { }; pub const WTF = struct { - extern fn WTF__copyLCharsFromUCharSource(dest: [*]u8, source: *const anyopaque, len: usize) void; extern fn WTF__parseDouble(bytes: [*]const u8, length: usize, counted: *usize) f64; pub fn parseDouble(buf: []const u8) !f64 { @@ -7007,15 +7006,6 @@ pub const WTF = struct { return error.InvalidCharacter; return res; } - - /// This uses SSE2 instructions and/or ARM NEON to copy 16-bit characters efficiently - /// See wtf/Text/ASCIIFastPath.h for details - pub fn copyLCharsFromUCharSource(destination: [*]u8, comptime Source: type, source: Source) void { - JSC.markBinding(@src()); - - // This is any alignment - WTF__copyLCharsFromUCharSource(destination, source.ptr, source.len); - } }; pub usingnamespace @import("./JSPropertyIterator.zig"); diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index bd028319ff..5b8a8924e8 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -322,8 +322,6 @@ void NapiRef::clear() // class Reference // } -WTF_MAKE_ISO_ALLOCATED_IMPL(NapiRef); - static uint32_t getPropertyAttributes(napi_property_attributes attributes_) { const uint32_t attributes = static_cast(attributes_); diff --git a/src/bun.js/bindings/napi.h b/src/bun.js/bindings/napi.h index a26022c1e8..b27a3a21e3 100644 --- a/src/bun.js/bindings/napi.h +++ b/src/bun.js/bindings/napi.h @@ -140,7 +140,7 @@ private: }; class NapiRef { - WTF_MAKE_ISO_ALLOCATED(NapiRef); + WTF_MAKE_TZONE_ALLOCATED(NapiRef); public: void ref(); @@ -190,7 +190,7 @@ public: using Base = JSFunction; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static void destroy(JSCell* cell) { static_cast(cell)->NapiClass::~NapiClass(); @@ -250,7 +250,7 @@ public: using Base = JSC::JSDestructibleObject; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = true; + static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; template static CompleteSubspace* subspaceFor(VM& vm) diff --git a/src/bun.js/bindings/ncrypto.cpp b/src/bun.js/bindings/ncrypto.cpp index 0b12ac0ea4..20d78bb385 100644 --- a/src/bun.js/bindings/ncrypto.cpp +++ b/src/bun.js/bindings/ncrypto.cpp @@ -21,14 +21,6 @@ namespace ncrypto { -WTF_MAKE_ISO_ALLOCATED_IMPL(BIOPointer); -WTF_MAKE_ISO_ALLOCATED_IMPL(CipherCtxPointer); -WTF_MAKE_ISO_ALLOCATED_IMPL(EVPKeyPointer); -WTF_MAKE_ISO_ALLOCATED_IMPL(DHPointer); -WTF_MAKE_ISO_ALLOCATED_IMPL(SSLCtxPointer); -WTF_MAKE_ISO_ALLOCATED_IMPL(SSLPointer); -WTF_MAKE_ISO_ALLOCATED_IMPL(X509Pointer); - namespace { static constexpr int kX509NameFlagsRFC2253WithinUtf8JSON = XN_FLAG_RFC2253 & ~ASN1_STRFLGS_ESC_MSB & ~ASN1_STRFLGS_ESC_CTRL; diff --git a/src/bun.js/bindings/ncrypto.h b/src/bun.js/bindings/ncrypto.h index 82651af467..d580e9af30 100644 --- a/src/bun.js/bindings/ncrypto.h +++ b/src/bun.js/bindings/ncrypto.h @@ -312,7 +312,7 @@ private: }; class BIOPointer final { - WTF_MAKE_ISO_ALLOCATED(BIOPointer); + WTF_MAKE_TZONE_ALLOCATED(BIOPointer); public: static BIOPointer NewMem(); @@ -446,7 +446,7 @@ private: }; class CipherCtxPointer final { - WTF_MAKE_ISO_ALLOCATED(CipherCtxPointer); + WTF_MAKE_TZONE_ALLOCATED(CipherCtxPointer); public: static CipherCtxPointer New(); @@ -494,7 +494,7 @@ private: }; class EVPKeyPointer final { - WTF_MAKE_ISO_ALLOCATED(EVPKeyPointer); + WTF_MAKE_TZONE_ALLOCATED(EVPKeyPointer); public: static EVPKeyPointer New(); @@ -611,7 +611,7 @@ private: }; class DHPointer final { - WTF_MAKE_ISO_ALLOCATED(DHPointer); + WTF_MAKE_TZONE_ALLOCATED(DHPointer); public: enum class FindGroupOption { @@ -701,7 +701,7 @@ class X509Pointer; class X509View; class SSLCtxPointer final { - WTF_MAKE_ISO_ALLOCATED(SSLCtxPointer); + WTF_MAKE_TZONE_ALLOCATED(SSLCtxPointer); public: SSLCtxPointer() = default; @@ -738,7 +738,7 @@ private: }; class SSLPointer final { - WTF_MAKE_ISO_ALLOCATED(SSLPointer); + WTF_MAKE_TZONE_ALLOCATED(SSLPointer); public: SSLPointer() = default; @@ -840,7 +840,7 @@ private: }; class X509Pointer final { - WTF_MAKE_ISO_ALLOCATED(X509Pointer); + WTF_MAKE_TZONE_ALLOCATED(X509Pointer); public: static Result Parse(Buffer buffer); @@ -874,7 +874,7 @@ private: }; class ECDSASigPointer final { - WTF_MAKE_ISO_ALLOCATED(ECDSASigPointer); + WTF_MAKE_TZONE_ALLOCATED(ECDSASigPointer); public: explicit ECDSASigPointer(); @@ -908,7 +908,7 @@ private: }; class ECGroupPointer final { - WTF_MAKE_ISO_ALLOCATED(ECGroupPointer); + WTF_MAKE_TZONE_ALLOCATED(ECGroupPointer); public: explicit ECGroupPointer(); @@ -932,7 +932,7 @@ private: }; class ECPointPointer final { - WTF_MAKE_ISO_ALLOCATED(ECPointPointer); + WTF_MAKE_TZONE_ALLOCATED(ECPointPointer); public: ECPointPointer(); @@ -960,7 +960,7 @@ private: }; class ECKeyPointer final { - WTF_MAKE_ISO_ALLOCATED(ECKeyPointer); + WTF_MAKE_TZONE_ALLOCATED(ECKeyPointer); public: ECKeyPointer(); diff --git a/src/bun.js/bindings/objects.h b/src/bun.js/bindings/objects.h index caf520dd8e..246cc3fc57 100644 --- a/src/bun.js/bindings/objects.h +++ b/src/bun.js/bindings/objects.h @@ -14,7 +14,7 @@ // using Base = JSC::JSNonFinalObject; // DECLARE_EXPORT_INFO; // static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance; -// static constexpr bool needsDestruction = true; +// static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; // template // static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) @@ -54,7 +54,7 @@ // using Base = JSC::JSNonFinalObject; // DECLARE_EXPORT_INFO; // static constexpr unsigned StructureFlags = Base::StructureFlags; -// static constexpr bool needsDestruction = true; +// static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; // template // static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) @@ -98,7 +98,7 @@ // using Base = JSC::JSNonFinalObject; // DECLARE_EXPORT_INFO; // static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance; -// static constexpr bool needsDestruction = true; +// static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; // template // static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) @@ -209,7 +209,7 @@ // using Base = JSC::JSNonFinalObject; // DECLARE_EXPORT_INFO; // static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance; -// static constexpr bool needsDestruction = true; +// static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; // template // static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) diff --git a/src/bun.js/bindings/root.h b/src/bun.js/bindings/root.h index 22615ad374..fd32e5868b 100644 --- a/src/bun.js/bindings/root.h +++ b/src/bun.js/bindings/root.h @@ -75,8 +75,6 @@ #include #include #include -#include -#include #include #define ENABLE_WEB_CRYPTO 1 diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index 7f70a1022d..aca5df69dc 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -44,7 +44,6 @@ #include "sqlite3_error_codes.h" #include "wtf/BitVector.h" #include "wtf/FastBitVector.h" -#include "wtf/IsoMalloc.h" #include "wtf/Vector.h" #include #include "wtf/LazyRef.h" @@ -411,7 +410,7 @@ public: class JSSQLStatement : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; - static constexpr bool needsDestruction = true; + static constexpr JSC::DestructionMode needsDestruction = NeedsDestruction; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { diff --git a/src/bun.js/bindings/v8/shim/Oddball.h b/src/bun.js/bindings/v8/shim/Oddball.h index e445e5ead8..272030d1ad 100644 --- a/src/bun.js/bindings/v8/shim/Oddball.h +++ b/src/bun.js/bindings/v8/shim/Oddball.h @@ -1,8 +1,8 @@ #pragma once +#include "root.h" #include "TaggedPointer.h" #include "Map.h" -#include "JavaScriptCore/JSCJSValue.h" namespace v8 { namespace shim { diff --git a/src/bun.js/bindings/webcore/AbortController.cpp b/src/bun.js/bindings/webcore/AbortController.cpp index 8fa6b496ab..2a0a10678f 100644 --- a/src/bun.js/bindings/webcore/AbortController.cpp +++ b/src/bun.js/bindings/webcore/AbortController.cpp @@ -29,13 +29,13 @@ #include "AbortSignal.h" #include "DOMException.h" #include "JSDOMException.h" -#include +#include #include "WebCoreOpaqueRoot.h" #include "WebCoreOpaqueRootInlines.h" namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(AbortController); +WTF_MAKE_TZONE_ALLOCATED_IMPL(AbortController); Ref AbortController::create(ScriptExecutionContext& context) { diff --git a/src/bun.js/bindings/webcore/AbortController.h b/src/bun.js/bindings/webcore/AbortController.h index 563cffed6c..580f6810ea 100644 --- a/src/bun.js/bindings/webcore/AbortController.h +++ b/src/bun.js/bindings/webcore/AbortController.h @@ -50,7 +50,7 @@ class AbortSignal; class ScriptExecutionContext; class AbortController final : public ScriptWrappable, public RefCounted { - WTF_MAKE_ISO_ALLOCATED(AbortController); + WTF_MAKE_TZONE_ALLOCATED(AbortController); public: static Ref create(ScriptExecutionContext&); diff --git a/src/bun.js/bindings/webcore/AbortSignal.cpp b/src/bun.js/bindings/webcore/AbortSignal.cpp index e37bd9f7ff..08009ad840 100644 --- a/src/bun.js/bindings/webcore/AbortSignal.cpp +++ b/src/bun.js/bindings/webcore/AbortSignal.cpp @@ -36,14 +36,13 @@ #include "ScriptExecutionContext.h" #include "WebCoreOpaqueRoot.h" #include "wtf/DebugHeap.h" -#include "wtf/FastMalloc.h" +#include #include #include -#include namespace WebCore { -DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(AbortSignal); +WTF_MAKE_TZONE_ALLOCATED_IMPL(AbortSignal); Ref AbortSignal::create(ScriptExecutionContext* context) { diff --git a/src/bun.js/bindings/webcore/AbortSignal.h b/src/bun.js/bindings/webcore/AbortSignal.h index 92cd30f4fd..8b59f12644 100644 --- a/src/bun.js/bindings/webcore/AbortSignal.h +++ b/src/bun.js/bindings/webcore/AbortSignal.h @@ -58,7 +58,7 @@ enum class CommonAbortReason : uint8_t { JSC::JSValue toJS(JSC::JSGlobalObject*, CommonAbortReason); class AbortSignal final : public RefCounted, public EventTargetWithInlineData, private ContextDestructionObserver { - WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(AbortSignal); + WTF_MAKE_TZONE_ALLOCATED(AbortSignal); public: static Ref create(ScriptExecutionContext*); diff --git a/src/bun.js/bindings/webcore/BroadcastChannel.cpp b/src/bun.js/bindings/webcore/BroadcastChannel.cpp index 61c07cf5f9..67fcd6d330 100644 --- a/src/bun.js/bindings/webcore/BroadcastChannel.cpp +++ b/src/bun.js/bindings/webcore/BroadcastChannel.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ extern "C" void Bun__eventLoop__incrementRefConcurrently(void* bunVM, int delta) namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(BroadcastChannel); +WTF_MAKE_TZONE_ALLOCATED_IMPL(BroadcastChannel); static Lock allBroadcastChannelsLock; static UncheckedKeyHashMap& allBroadcastChannels() WTF_REQUIRES_LOCK(allBroadcastChannelsLock) diff --git a/src/bun.js/bindings/webcore/BroadcastChannel.h b/src/bun.js/bindings/webcore/BroadcastChannel.h index f218005fff..8743ce3d0b 100644 --- a/src/bun.js/bindings/webcore/BroadcastChannel.h +++ b/src/bun.js/bindings/webcore/BroadcastChannel.h @@ -44,7 +44,7 @@ namespace WebCore { class SerializedScriptValue; class BroadcastChannel : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr, public EventTarget /*, public ActiveDOMObject*/, public ContextDestructionObserver { - WTF_MAKE_ISO_ALLOCATED(BroadcastChannel); + WTF_MAKE_TZONE_ALLOCATED(BroadcastChannel); public: static Ref create(ScriptExecutionContext& context, const String& name) diff --git a/src/bun.js/bindings/webcore/CloseEvent.cpp b/src/bun.js/bindings/webcore/CloseEvent.cpp index 7d0522adb7..25691b03e7 100644 --- a/src/bun.js/bindings/webcore/CloseEvent.cpp +++ b/src/bun.js/bindings/webcore/CloseEvent.cpp @@ -25,11 +25,10 @@ #include "root.h" #include "CloseEvent.h" - -// #include +#include namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(CloseEvent); +WTF_MAKE_TZONE_ALLOCATED_IMPL(CloseEvent); } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/CloseEvent.h b/src/bun.js/bindings/webcore/CloseEvent.h index 6681727f6b..1fec2924b3 100644 --- a/src/bun.js/bindings/webcore/CloseEvent.h +++ b/src/bun.js/bindings/webcore/CloseEvent.h @@ -37,7 +37,7 @@ namespace WebCore { class CloseEvent final : public Event { - WTF_MAKE_ISO_ALLOCATED(CloseEvent); + WTF_MAKE_TZONE_ALLOCATED(CloseEvent); public: static Ref create(bool wasClean, unsigned short code, const String& reason) diff --git a/src/bun.js/bindings/webcore/CustomEvent.cpp b/src/bun.js/bindings/webcore/CustomEvent.cpp index 2f17f794b9..848bf6ae5b 100644 --- a/src/bun.js/bindings/webcore/CustomEvent.cpp +++ b/src/bun.js/bindings/webcore/CustomEvent.cpp @@ -28,11 +28,11 @@ #include "CustomEvent.h" #include -// #include +#include namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(CustomEvent); +WTF_MAKE_TZONE_ALLOCATED_IMPL(CustomEvent); inline CustomEvent::CustomEvent(IsTrusted isTrusted) : Event(isTrusted) diff --git a/src/bun.js/bindings/webcore/CustomEvent.h b/src/bun.js/bindings/webcore/CustomEvent.h index 53df6d9859..2b407ceae0 100644 --- a/src/bun.js/bindings/webcore/CustomEvent.h +++ b/src/bun.js/bindings/webcore/CustomEvent.h @@ -34,7 +34,7 @@ namespace WebCore { class CustomEvent final : public Event { - WTF_MAKE_ISO_ALLOCATED(CustomEvent); + WTF_MAKE_TZONE_ALLOCATED(CustomEvent); public: virtual ~CustomEvent(); @@ -62,4 +62,4 @@ private: JSValueInWrappedObject m_cachedDetail; }; -} // namespace WebCore \ No newline at end of file +} // namespace WebCore diff --git a/src/bun.js/bindings/webcore/ErrorEvent.cpp b/src/bun.js/bindings/webcore/ErrorEvent.cpp index 4f6c618f76..973d9065e7 100644 --- a/src/bun.js/bindings/webcore/ErrorEvent.cpp +++ b/src/bun.js/bindings/webcore/ErrorEvent.cpp @@ -36,12 +36,12 @@ #include "EventNames.h" #include #include -// #include +#include namespace WebCore { using namespace JSC; -WTF_MAKE_ISO_ALLOCATED_IMPL(ErrorEvent); +WTF_MAKE_TZONE_ALLOCATED_IMPL(ErrorEvent); ErrorEvent::ErrorEvent(const AtomString& type, const Init& initializer, IsTrusted isTrusted) : Event(type, initializer, isTrusted) diff --git a/src/bun.js/bindings/webcore/ErrorEvent.h b/src/bun.js/bindings/webcore/ErrorEvent.h index 400c91daeb..7bbae9cd40 100644 --- a/src/bun.js/bindings/webcore/ErrorEvent.h +++ b/src/bun.js/bindings/webcore/ErrorEvent.h @@ -40,7 +40,7 @@ namespace WebCore { class ErrorEvent final : public Event { - WTF_MAKE_ISO_ALLOCATED(ErrorEvent); + WTF_MAKE_TZONE_ALLOCATED(ErrorEvent); public: static Ref create(const String& message, const String& fileName, unsigned lineNumber, unsigned columnNumber, JSC::Strong error) diff --git a/src/bun.js/bindings/webcore/Event.cpp b/src/bun.js/bindings/webcore/Event.cpp index a834a5e336..0e4bd33690 100644 --- a/src/bun.js/bindings/webcore/Event.cpp +++ b/src/bun.js/bindings/webcore/Event.cpp @@ -33,13 +33,13 @@ // #include "UserGestureIndicator.h" // #include "WorkerGlobalScope.h" #include -// #include +#include #include #include namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(Event); +WTF_MAKE_TZONE_ALLOCATED_IMPL(Event); ALWAYS_INLINE Event::Event(MonotonicTime createTime, const AtomString& type, IsTrusted isTrusted, CanBubble canBubble, IsCancelable cancelable, IsComposed composed) : m_isInitialized { !type.isNull() } diff --git a/src/bun.js/bindings/webcore/Event.h b/src/bun.js/bindings/webcore/Event.h index 748251f9b4..5c1018ce4b 100644 --- a/src/bun.js/bindings/webcore/Event.h +++ b/src/bun.js/bindings/webcore/Event.h @@ -46,7 +46,7 @@ class EventTarget; class ScriptExecutionContext; class Event : public ScriptWrappable, public RefCounted { - WTF_MAKE_ISO_ALLOCATED(Event); + WTF_MAKE_TZONE_ALLOCATED(Event); public: using IsTrusted = EventIsTrusted; diff --git a/src/bun.js/bindings/webcore/EventEmitter.cpp b/src/bun.js/bindings/webcore/EventEmitter.cpp index 8db15a8e5b..0e791cdafc 100644 --- a/src/bun.js/bindings/webcore/EventEmitter.cpp +++ b/src/bun.js/bindings/webcore/EventEmitter.cpp @@ -12,10 +12,11 @@ #include #include #include +#include namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(EventEmitter); +WTF_MAKE_TZONE_ALLOCATED_IMPL(EventEmitter); Ref EventEmitter::create(ScriptExecutionContext& context) { diff --git a/src/bun.js/bindings/webcore/EventEmitter.h b/src/bun.js/bindings/webcore/EventEmitter.h index e9f6aa167d..dbd5166bac 100644 --- a/src/bun.js/bindings/webcore/EventEmitter.h +++ b/src/bun.js/bindings/webcore/EventEmitter.h @@ -24,7 +24,7 @@ class JSEventListener; struct EventEmitterData { WTF_MAKE_NONCOPYABLE(EventEmitterData); - WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_TZONE_ALLOCATED(EventEmitterData); public: EventEmitterData() = default; @@ -33,7 +33,7 @@ public: }; class EventEmitter final : public ScriptWrappable, public CanMakeWeakPtr, public RefCounted, public ContextDestructionObserver { - WTF_MAKE_ISO_ALLOCATED(EventEmitter); + WTF_MAKE_TZONE_ALLOCATED(EventEmitter); public: static Ref create(ScriptExecutionContext&); diff --git a/src/bun.js/bindings/webcore/EventTarget.cpp b/src/bun.js/bindings/webcore/EventTarget.cpp index 0ba12bf3df..74b08bf4de 100644 --- a/src/bun.js/bindings/webcore/EventTarget.cpp +++ b/src/bun.js/bindings/webcore/EventTarget.cpp @@ -49,7 +49,7 @@ // #include "ScriptController.h" // #include "ScriptDisallowedScope.h" // #include "Settings.h" -// #include +#include #include #include #include @@ -59,8 +59,8 @@ namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(EventTarget); -WTF_MAKE_ISO_ALLOCATED_IMPL(EventTargetWithInlineData); +WTF_MAKE_TZONE_ALLOCATED_IMPL(EventTarget); +WTF_MAKE_TZONE_ALLOCATED_IMPL(EventTargetWithInlineData); Ref EventTarget::create(ScriptExecutionContext& context) { diff --git a/src/bun.js/bindings/webcore/EventTarget.h b/src/bun.js/bindings/webcore/EventTarget.h index 1515a349c1..960d673832 100644 --- a/src/bun.js/bindings/webcore/EventTarget.h +++ b/src/bun.js/bindings/webcore/EventTarget.h @@ -38,7 +38,6 @@ #include #include #include -// #include #include @@ -57,7 +56,7 @@ class JSEventListener; struct EventTargetData { WTF_MAKE_NONCOPYABLE(EventTargetData); - WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_TZONE_ALLOCATED(EventTargetData); public: EventTargetData() = default; @@ -81,7 +80,7 @@ private: }; class EventTarget : public ScriptWrappable, public CanMakeWeakPtrWithBitField { - WTF_MAKE_ISO_ALLOCATED(EventTarget); + WTF_MAKE_TZONE_ALLOCATED(EventTarget); public: static Ref create(ScriptExecutionContext&); @@ -159,7 +158,7 @@ private: }; class EventTargetWithInlineData : public EventTarget { - WTF_MAKE_ISO_ALLOCATED_EXPORT(EventTargetWithInlineData, WEBCORE_EXPORT); + WTF_MAKE_TZONE_ALLOCATED(EventTargetWithInlineData); protected: EventTargetData* eventTargetData() final { return &m_eventTargetData; } diff --git a/src/bun.js/bindings/webcore/EventTargetConcrete.cpp b/src/bun.js/bindings/webcore/EventTargetConcrete.cpp index ded224beb9..97cfcc6329 100644 --- a/src/bun.js/bindings/webcore/EventTargetConcrete.cpp +++ b/src/bun.js/bindings/webcore/EventTargetConcrete.cpp @@ -25,10 +25,11 @@ #include "config.h" #include "EventTargetConcrete.h" +#include namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(EventTargetConcrete); +WTF_MAKE_TZONE_ALLOCATED_IMPL(EventTargetConcrete); Ref EventTargetConcrete::create(ScriptExecutionContext& context) { diff --git a/src/bun.js/bindings/webcore/EventTargetConcrete.h b/src/bun.js/bindings/webcore/EventTargetConcrete.h index 202be2d9e3..837251b3b6 100644 --- a/src/bun.js/bindings/webcore/EventTargetConcrete.h +++ b/src/bun.js/bindings/webcore/EventTargetConcrete.h @@ -30,13 +30,12 @@ #include "EventTarget.h" #include "EventTargetInterfaces.h" #include "ScriptExecutionContext.h" -// #include #include namespace WebCore { class EventTargetConcrete final : public RefCounted, public EventTargetWithInlineData, private ContextDestructionObserver { - WTF_MAKE_ISO_ALLOCATED(EventTargetConcrete); + WTF_MAKE_TZONE_ALLOCATED(EventTargetConcrete); public: static Ref create(ScriptExecutionContext&); diff --git a/src/bun.js/bindings/webcore/HTTPParsers.cpp b/src/bun.js/bindings/webcore/HTTPParsers.cpp index 7318ce5914..5367ab1f9f 100644 --- a/src/bun.js/bindings/webcore/HTTPParsers.cpp +++ b/src/bun.js/bindings/webcore/HTTPParsers.cpp @@ -335,7 +335,8 @@ static String trimInputSample(CharType* p, size_t length) std::optional parseHTTPDate(const String& value) { - double dateInMillisecondsSinceEpoch = parseDate(value.utf8().span()); + auto utf8Data = value.utf8(); + double dateInMillisecondsSinceEpoch = parseDate({ reinterpret_cast(utf8Data.data()), utf8Data.length() }); if (!std::isfinite(dateInMillisecondsSinceEpoch)) return std::nullopt; // This assumes system_clock epoch equals Unix epoch which is true for all implementations but unspecified. diff --git a/src/bun.js/bindings/webcore/JSDOMConstructorBase.h b/src/bun.js/bindings/webcore/JSDOMConstructorBase.h index 44c60e69ce..5fa27b5ce9 100644 --- a/src/bun.js/bindings/webcore/JSDOMConstructorBase.h +++ b/src/bun.js/bindings/webcore/JSDOMConstructorBase.h @@ -34,7 +34,7 @@ public: using Base = InternalFunction; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) @@ -53,8 +53,8 @@ public: protected: JSDOMConstructorBase(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction functionForConstruct, JSC::NativeFunction functionForCall = nullptr) : Base(vm, structure, - functionForCall ? functionForCall : callThrowTypeErrorForJSDOMConstructor, - functionForConstruct ? functionForConstruct : callThrowTypeErrorForJSDOMConstructor) + functionForCall ? functionForCall : callThrowTypeErrorForJSDOMConstructor, + functionForConstruct ? functionForConstruct : callThrowTypeErrorForJSDOMConstructor) { } }; diff --git a/src/bun.js/bindings/webcore/JSDOMConstructorNotCallable.h b/src/bun.js/bindings/webcore/JSDOMConstructorNotCallable.h index 779bf88766..49ab06ef04 100644 --- a/src/bun.js/bindings/webcore/JSDOMConstructorNotCallable.h +++ b/src/bun.js/bindings/webcore/JSDOMConstructorNotCallable.h @@ -36,7 +36,7 @@ public: using Base = JSDOMObject; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static JSDOMConstructorNotCallable* create(JSC::VM&, JSC::Structure*, JSDOMGlobalObject&); static JSC::Structure* createStructure(JSC::VM&, JSC::JSGlobalObject&, JSC::JSValue prototype); diff --git a/src/bun.js/bindings/webcore/JSDOMOperation.h b/src/bun.js/bindings/webcore/JSDOMOperation.h index aa834053b1..4a3fa99191 100644 --- a/src/bun.js/bindings/webcore/JSDOMOperation.h +++ b/src/bun.js/bindings/webcore/JSDOMOperation.h @@ -46,7 +46,7 @@ public: } template - static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName) + static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, ASCIILiteral operationName) { auto throwScope = DECLARE_THROW_SCOPE(JSC::getVM(&lexicalGlobalObject)); diff --git a/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h b/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h index c90c5f2536..d71ce3208c 100644 --- a/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h +++ b/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h @@ -36,7 +36,7 @@ public: using StaticOperation = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, Ref&&); template - static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName) + static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, ASCIILiteral operationName) { return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [&operationName](JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref&& promise) { auto* thisObject = IDLOperation::cast(lexicalGlobalObject, callFrame); @@ -56,7 +56,7 @@ public: // This function is a special case for custom operations want to handle the creation of the promise themselves. // It is triggered via the extended attribute [ReturnsOwnPromise]. template::Operation operation, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise> - static JSC::EncodedJSValue callReturningOwnPromise(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName) + static JSC::EncodedJSValue callReturningOwnPromise(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, ASCIILiteral operationName) { auto* thisObject = IDLOperation::cast(lexicalGlobalObject, callFrame); if constexpr (shouldThrow != CastedThisErrorBehavior::Assert) { diff --git a/src/bun.js/bindings/webcore/JSEventEmitterCustom.h b/src/bun.js/bindings/webcore/JSEventEmitterCustom.h index b75ee57747..8835363b60 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitterCustom.h +++ b/src/bun.js/bindings/webcore/JSEventEmitterCustom.h @@ -35,7 +35,7 @@ public: using Operation = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, ClassParameter); template - static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName) + static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, ASCIILiteral operationName) { auto& vm = JSC::getVM(&lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); diff --git a/src/bun.js/bindings/webcore/JSEventTargetCustom.h b/src/bun.js/bindings/webcore/JSEventTargetCustom.h index 92ce177a9e..019bca3dbd 100644 --- a/src/bun.js/bindings/webcore/JSEventTargetCustom.h +++ b/src/bun.js/bindings/webcore/JSEventTargetCustom.h @@ -58,7 +58,7 @@ public: using Operation = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, ClassParameter); template - static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName) + static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, ASCIILiteral operationName) { auto& vm = JSC::getVM(&lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); diff --git a/src/bun.js/bindings/webcore/MessageEvent.cpp b/src/bun.js/bindings/webcore/MessageEvent.cpp index b5a96a4a2e..68482ead1d 100644 --- a/src/bun.js/bindings/webcore/MessageEvent.cpp +++ b/src/bun.js/bindings/webcore/MessageEvent.cpp @@ -33,14 +33,13 @@ #include "JSDOMConvert.h" #include "JSMessageEvent.h" #include - -// #include +#include namespace WebCore { using namespace JSC; -WTF_MAKE_ISO_ALLOCATED_IMPL(MessageEvent); +WTF_MAKE_TZONE_ALLOCATED_IMPL(MessageEvent); MessageEvent::MessageEvent() = default; diff --git a/src/bun.js/bindings/webcore/MessageEvent.h b/src/bun.js/bindings/webcore/MessageEvent.h index 184aa63a14..3010f27eb3 100644 --- a/src/bun.js/bindings/webcore/MessageEvent.h +++ b/src/bun.js/bindings/webcore/MessageEvent.h @@ -43,7 +43,7 @@ class MessageEventSource { }; class MessageEvent final : public Event { - WTF_MAKE_ISO_ALLOCATED(MessageEvent); + WTF_MAKE_TZONE_ALLOCATED(MessageEvent); public: struct JSValueTag { diff --git a/src/bun.js/bindings/webcore/MessagePort.cpp b/src/bun.js/bindings/webcore/MessagePort.cpp index 3acb241686..6c3b67c5f5 100644 --- a/src/bun.js/bindings/webcore/MessagePort.cpp +++ b/src/bun.js/bindings/webcore/MessagePort.cpp @@ -41,7 +41,7 @@ // #include "WorkerThread.h" #include "TaskSource.h" #include -#include +#include #include #include @@ -49,11 +49,7 @@ extern "C" void Bun__eventLoop__incrementRefConcurrently(void* bunVM, int delta) namespace WebCore { -#if ENABLE(MALLOC_BREAKDOWN) -DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(MessagePort); -#else -WTF_MAKE_ISO_ALLOCATED_IMPL(MessagePort); -#endif +WTF_MAKE_TZONE_ALLOCATED_IMPL(MessagePort); static Lock allMessagePortsLock; static UncheckedKeyHashMap>& allMessagePorts() WTF_REQUIRES_LOCK(allMessagePortsLock) diff --git a/src/bun.js/bindings/webcore/MessagePort.h b/src/bun.js/bindings/webcore/MessagePort.h index aa386fb27a..a5c9b8bc42 100644 --- a/src/bun.js/bindings/webcore/MessagePort.h +++ b/src/bun.js/bindings/webcore/MessagePort.h @@ -51,11 +51,7 @@ DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(MessagePort); class MessagePort final : /* public ActiveDOMObject, */ public ContextDestructionObserver, public EventTarget, public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr { WTF_MAKE_NONCOPYABLE(MessagePort); -#if ENABLE(MALLOC_BREAKDOWN) - WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(MessagePort); -#else - WTF_MAKE_ISO_ALLOCATED(MessagePort); -#endif + WTF_MAKE_TZONE_ALLOCATED(MessagePort); public: static Ref create(ScriptExecutionContext&, const MessagePortIdentifier& local, const MessagePortIdentifier& remote); diff --git a/src/bun.js/bindings/webcore/MessagePortChannelProviderImpl.h b/src/bun.js/bindings/webcore/MessagePortChannelProviderImpl.h index fd029672c8..17429b0d5e 100644 --- a/src/bun.js/bindings/webcore/MessagePortChannelProviderImpl.h +++ b/src/bun.js/bindings/webcore/MessagePortChannelProviderImpl.h @@ -25,7 +25,6 @@ #pragma once -#include #include "MessagePortChannelProvider.h" #include "MessagePortChannelRegistry.h" #include "MessageWithMessagePorts.h" diff --git a/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp b/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp index e4e9b82bd5..f5888e9ed2 100644 --- a/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp +++ b/src/bun.js/bindings/webcore/MessagePortChannelRegistry.cpp @@ -25,7 +25,7 @@ #include "config.h" -#include +#include #include "MessagePortChannelRegistry.h" // #include "Logging.h" @@ -37,7 +37,7 @@ namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(MessagePortChannelRegistry); +WTF_MAKE_TZONE_ALLOCATED_IMPL(MessagePortChannelRegistry); MessagePortChannelRegistry::MessagePortChannelRegistry() = default; diff --git a/src/bun.js/bindings/webcore/MessagePortChannelRegistry.h b/src/bun.js/bindings/webcore/MessagePortChannelRegistry.h index 1bbf560339..0eed464aee 100644 --- a/src/bun.js/bindings/webcore/MessagePortChannelRegistry.h +++ b/src/bun.js/bindings/webcore/MessagePortChannelRegistry.h @@ -31,12 +31,11 @@ #include "ProcessIdentifier.h" #include #include -#include namespace WebCore { class MessagePortChannelRegistry final : public CanMakeWeakPtr, public CanMakeCheckedPtr { - WTF_MAKE_ISO_ALLOCATED(MessagePortChannelRegistry); + WTF_MAKE_TZONE_ALLOCATED(MessagePortChannelRegistry); WTF_OVERRIDE_DELETE_FOR_CHECKED_PTR(MessagePortChannelRegistry); public: diff --git a/src/bun.js/bindings/webcore/Node.h b/src/bun.js/bindings/webcore/Node.h index 509e041928..5c8aed686d 100644 --- a/src/bun.js/bindings/webcore/Node.h +++ b/src/bun.js/bindings/webcore/Node.h @@ -31,7 +31,6 @@ #include #include #include -// #include #include #include #include @@ -44,7 +43,7 @@ namespace WebCore { // The full Node type is way too much stuff // this ones just a baby class Node : public RefPtr, CanMakeWeakPtr, public EventTarget { - WTF_MAKE_ISO_ALLOCATED(Node); + WTF_MAKE_TZONE_ALLOCATED(Node); static constexpr uint32_t s_refCountIncrement = 2; static constexpr uint32_t s_refCountMask = ~static_cast(1); @@ -106,4 +105,4 @@ ALWAYS_INLINE unsigned Node::refCount() const return m_refCountAndParentBit / s_refCountIncrement; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/webcore/Performance.cpp b/src/bun.js/bindings/webcore/Performance.cpp index 46478e1a85..5d3a885db2 100644 --- a/src/bun.js/bindings/webcore/Performance.cpp +++ b/src/bun.js/bindings/webcore/Performance.cpp @@ -51,12 +51,12 @@ #include "PerformanceUserTiming.h" // #include "ResourceResponse.h" #include "ScriptExecutionContext.h" -#include +#include #include "BunClientData.h" namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(Performance); +WTF_MAKE_TZONE_ALLOCATED_IMPL(Performance); constexpr Seconds highTimePrecision { 20_us }; static Seconds timePrecision { 1_ms }; diff --git a/src/bun.js/bindings/webcore/Performance.h b/src/bun.js/bindings/webcore/Performance.h index 49c9bb07f1..e4be046e69 100644 --- a/src/bun.js/bindings/webcore/Performance.h +++ b/src/bun.js/bindings/webcore/Performance.h @@ -77,7 +77,7 @@ struct PerformanceMarkOptions; struct PerformanceMeasureOptions; class Performance final : public RefCounted, public ContextDestructionObserver, public EventTarget { - WTF_MAKE_ISO_ALLOCATED(Performance); + WTF_MAKE_TZONE_ALLOCATED(Performance); public: static Ref create(ScriptExecutionContext* context, MonotonicTime timeOrigin) { return adoptRef(*new Performance(context, timeOrigin)); } diff --git a/src/bun.js/bindings/webcore/ScriptWrappable.cpp b/src/bun.js/bindings/webcore/ScriptWrappable.cpp deleted file mode 100644 index 4982dc70a6..0000000000 --- a/src/bun.js/bindings/webcore/ScriptWrappable.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2019 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "ScriptWrappable.h" - -// #include - -namespace WebCore { - -// WTF_MAKE_FAST_ALLOCATED - -} // namespace WebCore diff --git a/src/bun.js/bindings/webcore/ScriptWrappable.h b/src/bun.js/bindings/webcore/ScriptWrappable.h index 265282045b..4bff08ff7f 100644 --- a/src/bun.js/bindings/webcore/ScriptWrappable.h +++ b/src/bun.js/bindings/webcore/ScriptWrappable.h @@ -35,12 +35,10 @@ #include "JSDOMWrapper.h" -// #include - namespace WebCore { class ScriptWrappable { - WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_TZONE_ALLOCATED(ScriptWrappable); public: JSDOMObject* wrapper() const; diff --git a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp index c86548ac0d..390d9d539d 100644 --- a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp +++ b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp @@ -4831,7 +4831,7 @@ private: auto& vm = m_lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - JSWebAssemblyMemory* result = JSC::JSWebAssemblyMemory::tryCreate(m_lexicalGlobalObject, vm, m_globalObject->webAssemblyMemoryStructure()); + JSWebAssemblyMemory* result = JSC::JSWebAssemblyMemory::create(vm, m_globalObject->webAssemblyMemoryStructure()); // Since we are cloning a JSWebAssemblyMemory, it's impossible for that // module to not have been a valid module. Therefore, createStub should // not throw. diff --git a/src/bun.js/bindings/webcore/WebSocket.cpp b/src/bun.js/bindings/webcore/WebSocket.cpp index c35bf6c3e9..df421e74c1 100644 --- a/src/bun.js/bindings/webcore/WebSocket.cpp +++ b/src/bun.js/bindings/webcore/WebSocket.cpp @@ -62,7 +62,7 @@ #include #include #include -// #include +#include #include // #include #include @@ -77,7 +77,7 @@ // #endif namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(WebSocket); +WTF_MAKE_TZONE_ALLOCATED_IMPL(WebSocket); extern "C" int Bun__getTLSRejectUnauthorizedValue(); static size_t getFramingOverhead(size_t payloadSize) diff --git a/src/bun.js/bindings/webcore/WebSocket.h b/src/bun.js/bindings/webcore/WebSocket.h index 8aa4a8d6f2..19c3f93930 100644 --- a/src/bun.js/bindings/webcore/WebSocket.h +++ b/src/bun.js/bindings/webcore/WebSocket.h @@ -52,7 +52,7 @@ namespace WebCore { // class Blob; class WebSocket final : public RefCounted, public EventTargetWithInlineData, public ContextDestructionObserver { - WTF_MAKE_ISO_ALLOCATED(WebSocket); + WTF_MAKE_TZONE_ALLOCATED(WebSocket); public: static ASCIILiteral subprotocolSeparator(); diff --git a/src/bun.js/bindings/webcore/Worker.cpp b/src/bun.js/bindings/webcore/Worker.cpp index f55eaf567a..9a2c38b232 100644 --- a/src/bun.js/bindings/webcore/Worker.cpp +++ b/src/bun.js/bindings/webcore/Worker.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include @@ -66,7 +66,7 @@ namespace WebCore { -WTF_MAKE_ISO_ALLOCATED_IMPL(Worker); +WTF_MAKE_TZONE_ALLOCATED_IMPL(Worker); extern "C" void WebWorker__requestTerminate( void* worker); diff --git a/src/bun.js/bindings/webcore/Worker.h b/src/bun.js/bindings/webcore/Worker.h index 9fe3aba7ac..8d3044f212 100644 --- a/src/bun.js/bindings/webcore/Worker.h +++ b/src/bun.js/bindings/webcore/Worker.h @@ -56,7 +56,7 @@ struct StructuredSerializeOptions; struct WorkerOptions; class Worker final : public ThreadSafeRefCounted, public EventTargetWithInlineData, private ContextDestructionObserver { - WTF_MAKE_ISO_ALLOCATED_EXPORT(Worker, WEBCORE_EXPORT); + WTF_MAKE_TZONE_ALLOCATED(Worker); public: static ExceptionOr> create(ScriptExecutionContext&, const String& url, WorkerOptions&&); diff --git a/src/bun.js/bindings/wtf-bindings.cpp b/src/bun.js/bindings/wtf-bindings.cpp index d33725bbae..073ff9e31b 100644 --- a/src/bun.js/bindings/wtf-bindings.cpp +++ b/src/bun.js/bindings/wtf-bindings.cpp @@ -175,11 +175,6 @@ extern "C" double WTF__parseDouble(const LChar* string, size_t length, size_t* p return WTF::parseDouble({ string, length }, *position); } -extern "C" void WTF__copyLCharsFromUCharSource(LChar* destination, const UChar* source, size_t length) -{ - WTF::StringImpl::copyCharacters(destination, { source, length }); -} - extern "C" size_t WTF__base64URLEncode(const char* __restrict inputDataBuffer, size_t inputDataBufferSize, char* __restrict destinationDataBuffer, size_t destinationDataBufferSize) diff --git a/src/bun.js/bindings/wtf-bindings.h b/src/bun.js/bindings/wtf-bindings.h index d7298c77a5..092bada040 100644 --- a/src/bun.js/bindings/wtf-bindings.h +++ b/src/bun.js/bindings/wtf-bindings.h @@ -3,8 +3,6 @@ #include "root.h" #include -extern "C" void WTF__copyLCharsFromUCharSource(LChar* destination, const UChar* source, size_t length); - namespace JSC { class VM; } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 351a6b285e..e9f1993589 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -992,6 +992,10 @@ pub const VirtualMachine = struct { return null; }; } + + pub export fn Bun__thisThreadHasVM() bool { + return vm != null; + } }; pub inline fn get() *VirtualMachine { diff --git a/src/bun.js/modules/BunJSCModule.h b/src/bun.js/modules/BunJSCModule.h index 3ed9377134..ce6c5a8491 100644 --- a/src/bun.js/modules/BunJSCModule.h +++ b/src/bun.js/modules/BunJSCModule.h @@ -231,7 +231,7 @@ JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, for (auto& it : *typeCounts) { if (it.value > 0) counts.append( - std::make_pair(Identifier::fromLatin1(vm, it.key), it.value)); + std::make_pair(Identifier::fromString(vm, it.key), it.value)); } // Sort by count first, then by name. @@ -272,7 +272,7 @@ JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, objectTypeCounts); object->putDirect(vm, - Identifier::fromLatin1(vm, "protectedObjectTypeCounts"_s), + Identifier::fromString(vm, "protectedObjectTypeCounts"_s), protectedCounts); object->putDirect(vm, Identifier::fromString(vm, "heapSize"_s), jsNumber(vm.heap.size())); diff --git a/src/bun.js/modules/NodeModuleModule.cpp b/src/bun.js/modules/NodeModuleModule.cpp index 305b16ed1f..c5448fb519 100644 --- a/src/bun.js/modules/NodeModuleModule.cpp +++ b/src/bun.js/modules/NodeModuleModule.cpp @@ -732,7 +732,7 @@ class JSModuleConstructor : public JSC::InternalFunction { public: DECLARE_EXPORT_INFO; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable; static JSC::Structure* createStructure(JSC::VM& vm, diff --git a/src/codegen/generate-classes.ts b/src/codegen/generate-classes.ts index 844a64c4c5..995b846803 100644 --- a/src/codegen/generate-classes.ts +++ b/src/codegen/generate-classes.ts @@ -560,7 +560,7 @@ class ${name} final : public JSC::InternalFunction { )}* prototype); static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { diff --git a/src/codegen/generate-jssink.ts b/src/codegen/generate-jssink.ts index 41924ea7d9..e85cc681e1 100644 --- a/src/codegen/generate-jssink.ts +++ b/src/codegen/generate-jssink.ts @@ -26,7 +26,7 @@ function header() { static constexpr SinkID Sink = SinkID::${name}; static constexpr unsigned StructureFlags = Base::StructureFlags; - static constexpr bool needsDestruction = false; + static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; DECLARE_EXPORT_INFO; template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)