From 27217df7df3b0da66c2bbdfb0fa871bccdfe0569 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 4 Jun 2026 21:45:01 +0000 Subject: [PATCH 01/20] Rename ZigGlobalObject to BunGlobalObject The class dates to when Bun's runtime was written in Zig and the "Zig" prefix meant "the global object that bridges to Zig code". The runtime has since been ported, the prefix is misleading, and the header carried a TODO asking for this rename since 2023. - Zig::GlobalObject and Zig::EvalGlobalObject move to namespace Bun - ZigGlobalObject.{h,cpp,lut.txt} become BunGlobalObject.{h,cpp,lut.txt} - extern "C" symbols Zig__GlobalObject__* become Bun__GlobalObject__*, ZigGlobalObject__* become BunGlobalObject__*, and Bun__ZigGlobalObject__uvLoop becomes Bun__GlobalObject__uvLoop - codegen templates, build scripts, leak suppressions and docs updated No behavior change. --- .../implementing-jsc-classes-cpp/SKILL.md | 8 +- CLAUDE.md | 2 +- scripts/build/codegen.ts | 2 +- scripts/build/unified.ts | 2 +- src/codegen/bundle-functions.ts | 12 +- src/codegen/cppbind.ts | 6 +- src/codegen/generate-classes.ts | 28 +-- src/codegen/generate-host-exports.ts | 2 +- src/codegen/generate-js2native.ts | 12 +- src/codegen/generate-jssink.ts | 16 +- src/codegen/shared-types.ts | 2 +- src/event_loop/README.md | 4 +- src/js/builtins/shell.ts | 2 +- src/js/node/worker_threads.ts | 2 +- src/jsc/DOMFormData.rs | 2 +- src/jsc/FetchHeaders.rs | 2 +- src/jsc/JSGlobalObject.rs | 56 ++--- src/jsc/JSGlobalObject.zig | 52 ++--- src/jsc/ModuleLoader.rs | 2 +- src/jsc/VM.rs | 2 +- src/jsc/VirtualMachine.rs | 26 +-- src/jsc/VirtualMachine.zig | 6 +- src/jsc/bindings/AsymmetricKeyValue.cpp | 2 +- src/jsc/bindings/AsyncContextFrame.cpp | 6 +- .../bindings/BakeAdditionsToGlobalObject.cpp | 16 +- .../bindings/BunAnalyzeTranspiledModule.cpp | 4 +- src/jsc/bindings/BunCPUProfiler.cpp | 2 +- src/jsc/bindings/BunClientData.cpp | 2 +- src/jsc/bindings/BunClientData.h | 5 +- src/jsc/bindings/BunCommonStrings.cpp | 16 +- src/jsc/bindings/BunDebugger.cpp | 28 +-- ...igGlobalObject.cpp => BunGlobalObject.cpp} | 204 +++++++++--------- .../{ZigGlobalObject.h => BunGlobalObject.h} | 51 ++--- ...Object.lut.txt => BunGlobalObject.lut.txt} | 4 +- src/jsc/bindings/BunGlobalScope.cpp | 2 +- src/jsc/bindings/BunHttp2CommonStrings.cpp | 2 +- src/jsc/bindings/BunMarkdownMeta.cpp | 8 +- src/jsc/bindings/BunMarkdownMeta.h | 2 +- src/jsc/bindings/BunMarkdownTagStrings.cpp | 4 +- src/jsc/bindings/BunObject.cpp | 32 +-- src/jsc/bindings/BunPlugin.cpp | 20 +- src/jsc/bindings/BunPlugin.h | 5 +- src/jsc/bindings/BunProcess.cpp | 86 ++++---- src/jsc/bindings/BunProcess.h | 6 +- .../BunProcessReportObjectWindows.cpp | 4 +- src/jsc/bindings/BunSecureContextCache.cpp | 6 +- src/jsc/bindings/BunSecureContextCache.h | 2 +- src/jsc/bindings/BunString.cpp | 4 +- src/jsc/bindings/BundlerMetafile.cpp | 2 +- src/jsc/bindings/CallSite.cpp | 2 +- src/jsc/bindings/CallSite.h | 2 +- src/jsc/bindings/DOMWrapperWorld.cpp | 2 +- src/jsc/bindings/DOMWrapperWorld.h | 6 +- src/jsc/bindings/ErrorCode.cpp | 14 +- src/jsc/bindings/ErrorCode.h | 10 +- src/jsc/bindings/ErrorStackTrace.h | 2 +- src/jsc/bindings/EventLoopTaskNoContext.h | 2 +- src/jsc/bindings/ExposeNodeModuleGlobals.cpp | 8 +- src/jsc/bindings/FormatStackTraceForJS.cpp | 30 +-- src/jsc/bindings/FormatStackTraceForJS.h | 9 +- src/jsc/bindings/FuzzilliREPRL.cpp | 4 +- src/jsc/bindings/HTMLEntryPoint.cpp | 4 +- src/jsc/bindings/IPC.cpp | 6 +- src/jsc/bindings/ImportMetaObject.cpp | 14 +- src/jsc/bindings/ImportMetaObject.h | 2 +- .../InspectorBunFrontendDevServerAgent.cpp | 2 +- src/jsc/bindings/InspectorHTTPServerAgent.cpp | 2 +- src/jsc/bindings/InspectorLifecycleAgent.cpp | 2 +- .../bindings/InspectorTestReporterAgent.cpp | 2 +- src/jsc/bindings/InternalForTesting.cpp | 2 +- src/jsc/bindings/InternalForTesting.h | 2 +- src/jsc/bindings/InternalModuleRegistry.cpp | 4 +- src/jsc/bindings/JS2Native.cpp | 4 +- src/jsc/bindings/JSBakeResponse.cpp | 16 +- src/jsc/bindings/JSBakeResponse.h | 2 +- src/jsc/bindings/JSBuffer.cpp | 4 +- src/jsc/bindings/JSBufferList.cpp | 10 +- src/jsc/bindings/JSBufferList.h | 4 +- src/jsc/bindings/JSBunRequest.cpp | 6 +- src/jsc/bindings/JSBunRequest.h | 2 +- src/jsc/bindings/JSBundlerPlugin.cpp | 4 +- src/jsc/bindings/JSCTestingHelpers.cpp | 4 +- src/jsc/bindings/JSCTestingHelpers.h | 2 +- src/jsc/bindings/JSCommonJSExtensions.cpp | 18 +- src/jsc/bindings/JSCommonJSModule.cpp | 46 ++-- src/jsc/bindings/JSCommonJSModule.h | 26 +-- src/jsc/bindings/JSDOMExceptionHandling.cpp | 2 +- src/jsc/bindings/JSDOMFile.cpp | 2 +- src/jsc/bindings/JSDOMGlobalObject.cpp | 6 +- src/jsc/bindings/JSDOMGlobalObject.h | 4 +- src/jsc/bindings/JSDOMWrapper.h | 4 +- src/jsc/bindings/JSDOMWrapperCache.cpp | 2 +- src/jsc/bindings/JSEnvironmentVariableMap.cpp | 4 +- src/jsc/bindings/JSEnvironmentVariableMap.h | 4 +- src/jsc/bindings/JSFFIFunction.cpp | 20 +- src/jsc/bindings/JSFFIFunction.h | 6 +- src/jsc/bindings/JSMockFunction.cpp | 38 ++-- .../JSNodePerformanceHooksHistogram.cpp | 2 +- ...dePerformanceHooksHistogramConstructor.cpp | 2 +- ...JSNodePerformanceHooksHistogramPrototype.h | 2 +- src/jsc/bindings/JSPropertyIterator.cpp | 2 +- src/jsc/bindings/JSReactElement.cpp | 4 +- src/jsc/bindings/JSReactElement.h | 2 +- src/jsc/bindings/JSS3File.cpp | 2 +- src/jsc/bindings/JSS3File.h | 2 +- src/jsc/bindings/JSSecrets.cpp | 2 +- src/jsc/bindings/JSSocketAddressDTO.cpp | 4 +- src/jsc/bindings/JSSocketAddressDTO.h | 4 +- src/jsc/bindings/JSStringDecoder.cpp | 6 +- src/jsc/bindings/JSWrappingFunction.cpp | 10 +- src/jsc/bindings/JSWrappingFunction.h | 4 +- src/jsc/bindings/JSX509Certificate.cpp | 2 +- src/jsc/bindings/JSX509Certificate.h | 2 +- .../bindings/JSX509CertificateConstructor.cpp | 2 +- .../bindings/JSX509CertificateConstructor.h | 2 +- .../bindings/JSX509CertificatePrototype.cpp | 2 +- src/jsc/bindings/ModuleLoader.cpp | 36 ++-- src/jsc/bindings/ModuleLoader.h | 14 +- src/jsc/bindings/NapiClass.cpp | 4 +- src/jsc/bindings/NativePromiseContext.cpp | 4 +- src/jsc/bindings/NodeAsyncHooks.cpp | 4 +- src/jsc/bindings/NodeAsyncHooks.h | 2 +- src/jsc/bindings/NodeDirent.cpp | 10 +- src/jsc/bindings/NodeFSStatBinding.cpp | 20 +- src/jsc/bindings/NodeFSStatFSBinding.cpp | 20 +- src/jsc/bindings/NodeFetch.cpp | 4 +- src/jsc/bindings/NodeFetch.h | 2 +- src/jsc/bindings/NodeHTTP.cpp | 10 +- src/jsc/bindings/NodeHTTP.h | 2 +- src/jsc/bindings/NodeTLS.cpp | 2 +- src/jsc/bindings/NodeTLS.h | 2 +- src/jsc/bindings/NodeTimerObject.cpp | 2 +- src/jsc/bindings/NodeURL.cpp | 2 +- src/jsc/bindings/NodeURL.h | 4 +- src/jsc/bindings/NodeVM.cpp | 12 +- src/jsc/bindings/NodeVM.h | 6 +- src/jsc/bindings/NodeValidator.cpp | 2 +- src/jsc/bindings/NodeValidator.h | 2 +- src/jsc/bindings/Path.cpp | 6 +- src/jsc/bindings/Path.h | 4 +- src/jsc/bindings/ProcessBindingFs.cpp | 2 +- src/jsc/bindings/ProcessBindingHTTPParser.cpp | 2 +- src/jsc/bindings/ProcessBindingTTYWrap.cpp | 6 +- src/jsc/bindings/ProcessBindingTTYWrap.h | 4 +- src/jsc/bindings/ProcessBindingUV.cpp | 2 +- src/jsc/bindings/SQLClient.cpp | 6 +- src/jsc/bindings/ScriptExecutionContext.cpp | 6 +- src/jsc/bindings/ServerRouteList.cpp | 16 +- src/jsc/bindings/ServerRouteList.h | 4 +- src/jsc/bindings/ShellBindings.cpp | 2 +- src/jsc/bindings/StrongRef.cpp | 2 +- src/jsc/bindings/Undici.cpp | 4 +- src/jsc/bindings/Undici.h | 2 +- src/jsc/bindings/UtilInspect.cpp | 6 +- src/jsc/bindings/ZigException.cpp | 2 +- src/jsc/bindings/ZigLazyStaticFunctions.h | 7 +- src/jsc/bindings/ZigSourceProvider.cpp | 4 +- src/jsc/bindings/ZigSourceProvider.h | 8 +- src/jsc/bindings/bindings.cpp | 38 ++-- src/jsc/bindings/headers-cpp.h | 14 +- src/jsc/bindings/headers.h | 18 +- src/jsc/bindings/helpers.h | 2 +- src/jsc/bindings/napi.cpp | 82 +++---- src/jsc/bindings/napi.h | 22 +- src/jsc/bindings/napi_handle_scope.cpp | 8 +- src/jsc/bindings/napi_handle_scope.h | 8 +- src/jsc/bindings/napi_type_tag.cpp | 2 +- .../bindings/node/JSNodeHTTPServerSocket.cpp | 12 +- .../bindings/node/JSNodeHTTPServerSocket.h | 2 +- .../node/JSNodeHTTPServerSocketPrototype.cpp | 2 +- src/jsc/bindings/node/crypto/CryptoUtil.cpp | 12 +- src/jsc/bindings/node/crypto/CryptoUtil.h | 6 +- src/jsc/bindings/node/crypto/JSCipher.cpp | 2 +- .../bindings/node/crypto/JSDiffieHellman.cpp | 2 +- .../node/crypto/JSDiffieHellmanGroup.cpp | 2 +- .../JSDiffieHellmanGroupConstructor.cpp | 4 +- src/jsc/bindings/node/crypto/JSECDH.cpp | 2 +- src/jsc/bindings/node/crypto/JSKeyObject.cpp | 2 +- .../node/crypto/JSKeyObjectConstructor.cpp | 2 +- .../node/crypto/JSPrivateKeyObject.cpp | 2 +- .../node/crypto/JSPublicKeyObject.cpp | 2 +- .../node/crypto/JSSecretKeyObject.cpp | 2 +- src/jsc/bindings/node/crypto/JSSign.cpp | 2 +- src/jsc/bindings/node/crypto/JSVerify.cpp | 2 +- src/jsc/bindings/node/crypto/KeyObject.cpp | 2 +- .../node/crypto/node_crypto_binding.cpp | 6 +- .../node/crypto/node_crypto_binding.h | 2 +- .../http/JSConnectionsListConstructor.cpp | 2 +- .../node/http/JSHTTPParserConstructor.cpp | 2 +- .../node/http/JSHTTPParserPrototype.cpp | 2 +- src/jsc/bindings/node/http/NodeHTTPParser.cpp | 2 +- src/jsc/bindings/root-pch.h | 4 +- src/jsc/bindings/sqlite/JSSQLStatement.cpp | 6 +- src/jsc/bindings/sqlite/JSSQLStatement.h | 4 +- src/jsc/bindings/v8/V8Array.cpp | 8 +- src/jsc/bindings/v8/V8Context.h | 12 +- src/jsc/bindings/v8/V8Function.cpp | 2 +- src/jsc/bindings/v8/V8Isolate.cpp | 2 +- src/jsc/bindings/v8/V8Isolate.h | 4 +- src/jsc/bindings/v8/V8Object.cpp | 12 +- src/jsc/bindings/v8/shim/FunctionTemplate.cpp | 4 +- src/jsc/bindings/v8/shim/GlobalInternals.cpp | 2 +- src/jsc/bindings/v8/shim/GlobalInternals.h | 6 +- src/jsc/bindings/v8/v8.h | 2 +- src/jsc/bindings/webcore/AbortController.h | 6 +- src/jsc/bindings/webcore/AbortSignal.h | 2 +- src/jsc/bindings/webcore/DOMIsoSubspaces.h | 2 +- src/jsc/bindings/webcore/JSCallbackData.cpp | 2 +- .../bindings/webcore/JSDOMConstructorBase.h | 2 +- src/jsc/bindings/webcore/JSDOMConvertBase.h | 2 +- .../webcore/JSDOMGlobalObjectInlines.h | 8 +- src/jsc/bindings/webcore/JSErrorEvent.cpp | 2 +- src/jsc/bindings/webcore/JSEventEmitter.cpp | 2 +- .../bindings/webcore/JSEventEmitterCustom.cpp | 4 +- src/jsc/bindings/webcore/JSEventListener.cpp | 2 +- .../bindings/webcore/JSEventTargetCustom.cpp | 2 +- src/jsc/bindings/webcore/JSMIMEBindings.cpp | 4 +- src/jsc/bindings/webcore/JSMIMEBindings.h | 4 +- src/jsc/bindings/webcore/JSMIMEParams.cpp | 4 +- src/jsc/bindings/webcore/JSMIMEParams.h | 2 +- src/jsc/bindings/webcore/JSMIMEType.cpp | 2 +- src/jsc/bindings/webcore/JSPerformance.cpp | 2 +- .../webcore/JSPerformanceObserverCallback.cpp | 2 +- src/jsc/bindings/webcore/JSReadableStream.cpp | 10 +- src/jsc/bindings/webcore/JSWebSocket.cpp | 4 +- src/jsc/bindings/webcore/JSWebSocket.h | 2 +- src/jsc/bindings/webcore/MessagePort.cpp | 2 +- src/jsc/bindings/webcore/PerformanceMark.cpp | 2 +- .../bindings/webcore/PerformanceObserver.cpp | 2 +- src/jsc/bindings/webcore/ReadableStream.cpp | 38 ++-- .../webcore/SerializedScriptValue.cpp | 2 +- src/jsc/bindings/webcore/WebSocket.cpp | 2 +- src/jsc/bindings/webcore/Worker.cpp | 24 +-- src/jsc/bindings/webcore/Worker.h | 8 +- src/jsc/bindings/xxhash3.cpp | 2 +- src/jsc/bindings/xxhash3_testing.cpp | 4 +- src/jsc/headergen/sizegen.cpp | 2 +- src/jsc/jsc.zig | 4 +- src/jsc/lib.rs | 4 +- src/jsc/modules/AbortControllerModuleModule.h | 2 +- src/jsc/modules/BunAppModule.h | 2 +- src/jsc/modules/BunJSCModule.h | 2 +- src/jsc/modules/BunTestModule.h | 2 +- src/jsc/modules/NodeBufferModule.h | 4 +- src/jsc/modules/NodeModuleModule.cpp | 40 ++-- src/jsc/modules/NodeModuleModule.h | 2 +- src/jsc/modules/NodeProcessModule.h | 2 +- src/jsc/modules/NodeStringDecoderModule.h | 2 +- src/jsc/modules/ObjectModule.cpp | 4 +- src/jsc/modules/ObjectModule.h | 2 +- src/jsc/modules/_NativeModule.h | 6 +- src/jsc/virtual_machine_exports.rs | 4 +- src/jsc/virtual_machine_exports.zig | 4 +- src/jsc/web_worker.rs | 2 +- src/runtime/bake/BakeGlobalObject.cpp | 14 +- src/runtime/bake/BakeGlobalObject.h | 8 +- src/runtime/bake/BakeSourceProvider.h | 2 +- src/runtime/bake/DevServerSourceProvider.h | 6 +- src/runtime/cli/repl_command.rs | 2 +- src/runtime/ffi_imports.rs | 2 +- src/runtime/hw_exports.rs | 4 +- src/runtime/jsc_hooks.rs | 2 +- src/runtime/server/RequestContext.rs | 2 +- src/runtime/socket/Listener.zig | 2 +- src/runtime/test_runner/bun_test.rs | 4 +- src/runtime/timer/mod.rs | 2 +- src/runtime/webcore/FileSink.rs | 2 +- src/runtime/webcore/ReadableStream.rs | 4 +- src/runtime/webcore/ReadableStream.zig | 4 +- src/runtime/webcore/wasm_streaming.rs | 4 +- src/runtime/webview/ChromeBackend.cpp | 14 +- src/runtime/webview/ChromeBackend.h | 8 +- src/runtime/webview/JSWebView.cpp | 2 +- src/runtime/webview/JSWebViewConstructor.cpp | 2 +- src/runtime/webview/JSWebViewPrototype.cpp | 2 +- src/runtime/webview/WebKitBackend.cpp | 14 +- src/runtime/webview/WebKitBackend.h | 6 +- test/leaksan.supp | 6 +- test/regression/issue/29519.test.ts | 8 +- test/regression/issue/30205.test.ts | 4 +- 280 files changed, 1097 insertions(+), 1086 deletions(-) rename src/jsc/bindings/{ZigGlobalObject.cpp => BunGlobalObject.cpp} (96%) rename src/jsc/bindings/{ZigGlobalObject.h => BunGlobalObject.h} (97%) rename src/jsc/bindings/{ZigGlobalObject.lut.txt => BunGlobalObject.lut.txt} (97%) diff --git a/.claude/skills/implementing-jsc-classes-cpp/SKILL.md b/.claude/skills/implementing-jsc-classes-cpp/SKILL.md index de5269026b6a..cb17e5881076 100644 --- a/.claude/skills/implementing-jsc-classes-cpp/SKILL.md +++ b/.claude/skills/implementing-jsc-classes-cpp/SKILL.md @@ -148,13 +148,13 @@ private: ## Structure Caching -Add to `ZigGlobalObject.h`: +Add to `BunGlobalObject.h`: ```cpp JSC::LazyClassStructure m_JSFooClassStructure; ``` -Initialize in `ZigGlobalObject.cpp`: +Initialize in `BunGlobalObject.cpp`: ```cpp m_JSFooClassStructure.initLater([](LazyClassStructure::Initializer& init) { @@ -171,11 +171,11 @@ m_JSFooClassStructure.visit(visitor); ## Expose to Zig ```cpp -extern "C" JSC::EncodedJSValue Bun__JSFooConstructor(Zig::GlobalObject* globalObject) { +extern "C" JSC::EncodedJSValue Bun__JSFooConstructor(Bun::GlobalObject* globalObject) { return JSValue::encode(globalObject->m_JSFooClassStructure.constructor(globalObject)); } -extern "C" EncodedJSValue Bun__Foo__toJS(Zig::GlobalObject* globalObject, Foo* foo) { +extern "C" EncodedJSValue Bun__Foo__toJS(Bun::GlobalObject* globalObject, Foo* foo) { auto* structure = globalObject->m_JSFooClassStructure.get(globalObject); return JSValue::encode(JSFoo::create(globalObject->vm(), structure, globalObject, WTFMove(foo))); } diff --git a/CLAUDE.md b/CLAUDE.md index b98eeaa0046d..f5aaa6d1158b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -221,7 +221,7 @@ When implementing JavaScript classes in C++: 2. Define properties using HashTableValue arrays 3. Add iso subspaces for classes with C++ fields -4. Cache structures in `ZigGlobalObject` +4. Cache structures in `BunGlobalObject` ### Code Generation diff --git a/scripts/build/codegen.ts b/scripts/build/codegen.ts index 83c5c0f91edf..d458c3624b57 100644 --- a/scripts/build/codegen.ts +++ b/scripts/build/codegen.ts @@ -993,7 +993,7 @@ function emitObjectLuts({ n, cfg, o, dirStamp }: Ctx): void { // GENERATED by emitGeneratedClasses, so it's in codegenDir not src/. const pairs: [src: string, out: string][] = [ [resolve(cfg.cwd, "src/jsc/bindings/BunObject.cpp"), resolve(cfg.codegenDir, "BunObject.lut.h")], - [resolve(cfg.cwd, "src/jsc/bindings/ZigGlobalObject.lut.txt"), resolve(cfg.codegenDir, "ZigGlobalObject.lut.h")], + [resolve(cfg.cwd, "src/jsc/bindings/BunGlobalObject.lut.txt"), resolve(cfg.codegenDir, "BunGlobalObject.lut.h")], [resolve(cfg.cwd, "src/jsc/bindings/JSBuffer.cpp"), resolve(cfg.codegenDir, "JSBuffer.lut.h")], [resolve(cfg.cwd, "src/jsc/bindings/BunProcess.cpp"), resolve(cfg.codegenDir, "BunProcess.lut.h")], [ diff --git a/scripts/build/unified.ts b/scripts/build/unified.ts index a631d606f504..16299c17b65e 100644 --- a/scripts/build/unified.ts +++ b/scripts/build/unified.ts @@ -50,7 +50,7 @@ import { slash } from "./shell.ts"; const noUnify: readonly string[] = [ // Heavy single-file TUs that already saturate a core. Bundling them with // siblings would serialize work that should run in parallel. - "src/jsc/bindings/ZigGlobalObject.cpp", + "src/jsc/bindings/BunGlobalObject.cpp", "src/jsc/bindings/BunObject.cpp", "src/jsc/bindings/bindings.cpp", "src/jsc/bindings/BunProcess.cpp", diff --git a/src/codegen/bundle-functions.ts b/src/codegen/bundle-functions.ts index 33f54f5943d5..0a864f5c580a 100644 --- a/src/codegen/bundle-functions.ts +++ b/src/codegen/bundle-functions.ts @@ -440,7 +440,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt // C++ codegen let bundledCPP = `// Generated by ${import.meta.path} - namespace Zig { class GlobalObject; } + namespace Bun { class GlobalObject; } #include "root.h" #include "config.h" #include "JSDOMGlobalObject.h" @@ -556,7 +556,7 @@ JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm) : m_vm(vm) } bundledCPP += ` - SUPPRESS_ASAN void JSBuiltinInternalFunctions::initialize(Zig::GlobalObject& globalObject) + SUPPRESS_ASAN void JSBuiltinInternalFunctions::initialize(Bun::GlobalObject& globalObject) { UNUSED_PARAM(globalObject); `; @@ -569,13 +569,13 @@ JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm) : m_vm(vm) bundledCPP += ` JSVMClientData& clientData = *static_cast(m_vm.clientData); - Zig::GlobalObject::GlobalPropertyInfo staticGlobals[] = { + Bun::GlobalObject::GlobalPropertyInfo staticGlobals[] = { `; for (const { basename, internal } of files) { if (internal) { bundledCPP += `#define DECLARE_GLOBAL_STATIC(name) \\ - Zig::GlobalObject::GlobalPropertyInfo( \\ + Bun::GlobalObject::GlobalPropertyInfo( \\ clientData.builtinFunctions().${low(basename)}Builtins().name##PrivateName(), ${low(basename)}().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly), WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC) #undef DECLARE_GLOBAL_STATIC @@ -596,7 +596,7 @@ JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm) : m_vm(vm) let bundledHeader = `// Generated by ${import.meta.path} // Do not edit by hand. #pragma once - namespace Zig { class GlobalObject; } + namespace Bun { class GlobalObject; } #include "root.h" #include #include @@ -768,7 +768,7 @@ JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm) : m_vm(vm) explicit JSBuiltinInternalFunctions(JSC::VM&); template void visit(Visitor&); - void initialize(Zig::GlobalObject&); + void initialize(Bun::GlobalObject&); `; for (const { basename, internal } of files) { diff --git a/src/codegen/cppbind.ts b/src/codegen/cppbind.ts index f5b3f479d780..a92afd4b0474 100644 --- a/src/codegen/cppbind.ts +++ b/src/codegen/cppbind.ts @@ -454,7 +454,7 @@ const rustSharedTypes: Record = { "JSC::EncodedJSValue": "crate::JSValue", "EncodedJSValue": "crate::JSValue", "JSC::JSGlobalObject": "crate::JSGlobalObject", - "Zig::GlobalObject": "crate::JSGlobalObject", + "Bun::GlobalObject": "crate::JSGlobalObject", "ZigException": "crate::zig_exception::ZigException", "ZigString": "bun_core::ZigString", "JSC::VM": "crate::VM", @@ -574,7 +574,7 @@ function isGlobalObjectPtr(t: CppType): boolean { return ( t.type === "pointer" && t.child.type === "named" && - (t.child.name === "JSC::JSGlobalObject" || t.child.name === "Zig::GlobalObject") + (t.child.name === "JSC::JSGlobalObject" || t.child.name === "Bun::GlobalObject") ); } @@ -586,7 +586,7 @@ function isGlobalObjectPtr(t: CppType): boolean { // `JSGlobalObject*` → `&JSGlobalObject` rule. const rustOpaqueHandles = new Set([ "JSC::JSGlobalObject", - "Zig::GlobalObject", + "Bun::GlobalObject", "JSC::VM", "JSC::JSPromise", "JSC::JSInternalPromise", diff --git a/src/codegen/generate-classes.ts b/src/codegen/generate-classes.ts index b659bb334bf0..cc22f8fa1c86 100644 --- a/src/codegen/generate-classes.ts +++ b/src/codegen/generate-classes.ts @@ -658,7 +658,7 @@ ${name}* ${name}::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::St JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${name}::call(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { - Zig::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); JSC::VM &vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -712,7 +712,7 @@ ${ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${name}::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { - Zig::GlobalObject *globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject *globalObject = defaultGlobalObject(lexicalGlobalObject); JSC::VM &vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSObject* newTarget = asObject(callFrame->newTarget()); @@ -770,7 +770,7 @@ const ClassInfo ${name}::s_info = { "Function"_s, &Base::s_info, nullptr, nullpt ${ !obj.noConstructor ? ` - extern JSC_CALLCONV JSC::EncodedJSValue ${typeName}__getConstructor(Zig::GlobalObject* globalObject) { + extern JSC_CALLCONV JSC::EncodedJSValue ${typeName}__getConstructor(Bun::GlobalObject* globalObject) { return JSValue::encode(globalObject->${className(typeName)}Constructor()); }` : "" @@ -1061,7 +1061,7 @@ JSC_DEFINE_CUSTOM_GETTER(js${typeName}Constructor, (JSGlobalObject * lexicalGlob { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); - auto* globalObject = reinterpret_cast(lexicalGlobalObject); + auto* globalObject = reinterpret_cast(lexicalGlobalObject); auto* prototype = dynamicDowncast<${prototypeName(typeName)}>(JSValue::decode(thisValue)); if (!prototype) [[unlikely]] { @@ -1084,7 +1084,7 @@ JSC_DEFINE_CUSTOM_GETTER(js${typeName}Constructor, (JSGlobalObject * lexicalGlob JSC_DEFINE_CUSTOM_GETTER(${symbolName(typeName, name)}GetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue encodedThisValue, PropertyName attributeName)) { auto& vm = JSC::getVM(lexicalGlobalObject); - Zig::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); ${ obj.forBind @@ -1181,7 +1181,7 @@ JSC_DEFINE_CUSTOM_GETTER(${symbolName(typeName, name)}GetterWrap, (JSGlobalObjec JSC_DEFINE_CUSTOM_GETTER(${symbolName(typeName, name)}GetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue encodedThisValue, PropertyName attributeName)) { auto& vm = JSC::getVM(lexicalGlobalObject); - Zig::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); ${className(typeName)}* thisObject = uncheckedDowncast<${className(typeName)}>(JSValue::decode(encodedThisValue)); JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); @@ -1203,7 +1203,7 @@ JSC_DEFINE_CUSTOM_GETTER(${symbolName(typeName, name)}GetterWrap, (JSGlobalObjec JSC_DEFINE_CUSTOM_GETTER(${symbolName(typeName, name)}GetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue encodedThisValue, PropertyName attributeName)) { auto& vm = JSC::getVM(lexicalGlobalObject); - Zig::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); ${className(typeName)}* thisObject = dynamicDowncast<${className(typeName)}>(JSValue::decode(encodedThisValue)); if (!thisObject) [[unlikely]] { @@ -1853,7 +1853,7 @@ extern JSC_CALLCONV void* JSC_HOST_CALL_ATTRIBUTES ${typeName}__fromJSDirect(JSC if (!object) return nullptr; - Zig::GlobalObject* globalObject = dynamicDowncast(object->globalObject()); + Bun::GlobalObject* globalObject = dynamicDowncast(object->globalObject()); if (globalObject == nullptr || cell->structureID() != globalObject->${className(typeName)}Structure()->id()) [[unlikely]] { return nullptr; @@ -1914,7 +1914,7 @@ JSObject* ${name}::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) return ${prototypeName(typeName)}::create(vm, globalObject, structure); } -extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__create(Zig::GlobalObject* globalObject, void* ptr) { +extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__create(Bun::GlobalObject* globalObject, void* ptr) { auto &vm = globalObject->vm(); JSC::Structure* structure = globalObject->${className(typeName)}Structure(); ${className(typeName)}* instance = ${className(typeName)}::create(vm, globalObject, structure, ptr); @@ -1930,7 +1930,7 @@ extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__cr ${ obj.valuesArray - ? `extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__createWithValues(Zig::GlobalObject* globalObject, void* ptr, void* markedArgumentBuffer) { + ? `extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__createWithValues(Bun::GlobalObject* globalObject, void* ptr, void* markedArgumentBuffer) { auto &vm = globalObject->vm(); JSC::Structure* structure = globalObject->${className(typeName)}Structure(); auto* args = static_cast(markedArgumentBuffer); @@ -1953,7 +1953,7 @@ ${ ${ obj.valuesArray && obj.values && obj.values.length > 0 - ? `extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__createWithInitialValues(Zig::GlobalObject* globalObject, void* ptr${obj.values.map(v => `, JSC::EncodedJSValue ${v}`).join("")}) { + ? `extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__createWithInitialValues(Bun::GlobalObject* globalObject, void* ptr${obj.values.map(v => `, JSC::EncodedJSValue ${v}`).join("")}) { auto &vm = globalObject->vm(); JSC::Structure* structure = globalObject->${className(typeName)}Structure(); ${className(typeName)}* instance = ${className(typeName)}::create(vm, globalObject, structure, ptr${obj.values.map(v => `, JSC::JSValue::decode(${v})`).join("")}); @@ -1971,7 +1971,7 @@ ${ ${ obj.valuesArray && obj.values && obj.values.length > 0 - ? `extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__createWithValuesAndInitialValues(Zig::GlobalObject* globalObject, void* ptr, void* markedArgumentBuffer${obj.values.map(v => `, JSC::EncodedJSValue ${v}`).join("")}) { + ? `extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${typeName}__createWithValuesAndInitialValues(Bun::GlobalObject* globalObject, void* ptr, void* markedArgumentBuffer${obj.values.map(v => `, JSC::EncodedJSValue ${v}`).join("")}) { auto &vm = globalObject->vm(); JSC::Structure* structure = globalObject->${className(typeName)}Structure(); auto* args = static_cast(markedArgumentBuffer); @@ -3209,7 +3209,7 @@ function generateLazyClassStructureImpl(typeName, { klass = {}, proto = {}, noCo return ` m_${className(typeName)}.initLater( [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::${className(typeName)}::createPrototype(init.vm, reinterpret_cast(init.global))); + init.setPrototype(WebCore::${className(typeName)}::createPrototype(init.vm, reinterpret_cast(init.global))); init.setStructure(WebCore::${className(typeName)}::createStructure(init.vm, init.global, init.prototype)); ${ noConstructor @@ -3259,7 +3259,7 @@ const GENERATED_CLASSES_IMPL_HEADER_PRE = ` #include "headers.h" #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include diff --git a/src/codegen/generate-host-exports.ts b/src/codegen/generate-host-exports.ts index 05cae8b8c8dd..fe45e275c89a 100644 --- a/src/codegen/generate-host-exports.ts +++ b/src/codegen/generate-host-exports.ts @@ -266,7 +266,7 @@ for (const { dir, crate } of scanRoots) { abi ??= "jsc"; } else if (params.length === 1 && /JSGlobalObject$/.test(params[0].ty) && isJsRet) { shape = "lazy"; - // Lazy property creators are direct C++ calls (e.g. ZigGlobalObject.cpp + // Lazy property creators are direct C++ calls (e.g. BunGlobalObject.cpp // declares `extern "C" JSC::EncodedJSValue BunObject__createBunStd*`), // NOT JSC trampoline dispatch — default to `c`. A SYSV_ABI lazy getter // (e.g. `BunObject_lazyPropCb_*`) must opt in with `, jsc` explicitly. diff --git a/src/codegen/generate-js2native.ts b/src/codegen/generate-js2native.ts index 86bfed725774..744a0544c9e9 100644 --- a/src/codegen/generate-js2native.ts +++ b/src/codegen/generate-js2native.ts @@ -134,9 +134,9 @@ export function getJS2NativeCPP() { .filter(x => x.type === "zig") .flatMap( call => ( - externs.push(`extern "C" SYSV_ABI JSC::EncodedJSValue ${symbol(call)}_workaround(Zig::GlobalObject*);` + "\n"), + externs.push(`extern "C" SYSV_ABI JSC::EncodedJSValue ${symbol(call)}_workaround(Bun::GlobalObject*);` + "\n"), [ - `static ALWAYS_INLINE JSC::JSValue ${symbol(call)}(Zig::GlobalObject* global) {`, + `static ALWAYS_INLINE JSC::JSValue ${symbol(call)}(Bun::GlobalObject* global) {`, ` return JSValue::decode(${symbol(call)}_workaround(global));`, `}` + "\n\n", ] @@ -155,7 +155,7 @@ export function getJS2NativeCPP() { })});`, ), "") || "", - `static ALWAYS_INLINE JSC::JSValue ${x.symbol_generated}(Zig::GlobalObject* globalObject) {`, + `static ALWAYS_INLINE JSC::JSValue ${x.symbol_generated}(Bun::GlobalObject* globalObject) {`, ` return JSC::JSFunction::create(globalObject->vm(), globalObject, ${x.call_length}, ${JSON.stringify( x.display_name, )}_s, ${symbol({ @@ -185,10 +185,10 @@ export function getJS2NativeCPP() { .filter(x => x.type === "bind") .map( x => - `extern "C" SYSV_ABI JSC::EncodedJSValue js2native_bindgen_${basename(x.filename.replace(/\.bind\.ts$/, ""))}_${x.symbol}(Zig::GlobalObject*);`, + `extern "C" SYSV_ABI JSC::EncodedJSValue js2native_bindgen_${basename(x.filename.replace(/\.bind\.ts$/, ""))}_${x.symbol}(Bun::GlobalObject*);`, ), - `typedef JSC::JSValue (*JS2NativeFunction)(Zig::GlobalObject*);`, - `static ALWAYS_INLINE JSC::JSValue callJS2Native(int32_t index, Zig::GlobalObject* global) {`, + `typedef JSC::JSValue (*JS2NativeFunction)(Bun::GlobalObject*);`, + `static ALWAYS_INLINE JSC::JSValue callJS2Native(int32_t index, Bun::GlobalObject* global) {`, ` switch(index) {`, ...nativeCalls.map( x => diff --git a/src/codegen/generate-jssink.ts b/src/codegen/generate-jssink.ts index c047c862e435..bfd13e468289 100644 --- a/src/codegen/generate-jssink.ts +++ b/src/codegen/generate-jssink.ts @@ -302,7 +302,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); JSC::JSValue readableStream = callFrame->argument(0); JSC::JSValue onPull = callFrame->argument(1); @@ -416,7 +416,7 @@ JSC_DEFINE_HOST_FUNCTION(${name}__unref, (JSC::JSGlobalObject * lexicalGlobalObj JSC_DEFINE_CUSTOM_GETTER(function${name}__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); return JSC::JSValue::encode(globalObject->${name}()); } @@ -449,7 +449,7 @@ JSC_DEFINE_HOST_FUNCTION(${controller}__close, (JSC::JSGlobalObject * lexicalGlo auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); WebCore::${controller}* controller = dynamicDowncast(callFrame->thisValue()); if (!controller) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected ${controller}"_s)); @@ -472,7 +472,7 @@ JSC_DEFINE_HOST_FUNCTION(${controller}__end, (JSC::JSGlobalObject * lexicalGloba { auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); WebCore::${controller}* controller = dynamicDowncast(callFrame->thisValue()); if (!controller) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected ${controller}"_s)); @@ -497,7 +497,7 @@ JSC_DEFINE_HOST_FUNCTION(${name}__getFd, (JSC::JSGlobalObject * lexicalGlobalObj { auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); WebCore::${className}* sink = dynamicDowncast(callFrame->thisValue()); if (!sink) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected ${name}"_s)); @@ -518,7 +518,7 @@ JSC_DEFINE_HOST_FUNCTION(${name}__doClose, (JSC::JSGlobalObject * lexicalGlobalO auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); WebCore::${className}* sink = dynamicDowncast(callFrame->thisValue()); if (!sink) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected ${name}"_s)); @@ -938,7 +938,7 @@ default: extern "C" JSC::EncodedJSValue ${name}__createObject(JSC::JSGlobalObject* arg0, void* sinkPtr, uintptr_t destructor) { auto& vm = arg0->vm(); - Zig::GlobalObject* globalObject = reinterpret_cast(arg0); + Bun::GlobalObject* globalObject = reinterpret_cast(arg0); JSC::Structure* structure = globalObject->${name}Structure(); return JSC::JSValue::encode(WebCore::JS${name}::create(vm, globalObject, structure, sinkPtr, destructor)); } @@ -971,7 +971,7 @@ extern "C" void ${name}__detachPtr(JSC::EncodedJSValue JSValue0) extern "C" JSC::EncodedJSValue ${name}__assignToStream(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue stream, void* sinkPtr, void **controllerValue) { auto& vm = arg0->vm(); - Zig::GlobalObject* globalObject = reinterpret_cast(arg0); + Bun::GlobalObject* globalObject = reinterpret_cast(arg0); JSC::Structure* structure = WebCore::getDOMStructure(vm, *globalObject); WebCore::${controller} *controller = WebCore::${controller}::create(vm, globalObject, structure, sinkPtr, 0); diff --git a/src/codegen/shared-types.ts b/src/codegen/shared-types.ts index e998b7f3e255..0b8753e07c64 100644 --- a/src/codegen/shared-types.ts +++ b/src/codegen/shared-types.ts @@ -45,7 +45,7 @@ export const sharedTypes: Record = { "HotReloadId": "HTTPServerAgent.HotReloadId", "ServerId": "HTTPServerAgent.ServerId", "Route": "HTTPServerAgent.Route", - "Zig::GlobalObject": "jsc.JSGlobalObject", + "Bun::GlobalObject": "jsc.JSGlobalObject", "JSC::VM": "jsc.VM", "WTF::StringImpl": "bun.WTF._StringImplStruct", "WebCore::DOMURL": "bun.DOMURL", diff --git a/src/event_loop/README.md b/src/event_loop/README.md index 7aad09dddb76..c76889382e60 100644 --- a/src/event_loop/README.md +++ b/src/event_loop/README.md @@ -130,7 +130,7 @@ For each task dequeued from the task queue: │ │ └─> VM.releaseWeakRefs() │ │ │ │ │ ├─> CALL JSC__JSGlobalObject__drainMicrotasks() │ -│ │ (ZigGlobalObject.cpp:2793-2840) │ +│ │ (BunGlobalObject.cpp:2793-2840) │ │ │ │ │ │ │ ├─> IF nextTick queue exists and not empty: │ │ │ │ └─> Call processTicksAndRejections() │ @@ -156,7 +156,7 @@ For each task dequeued from the task queue: ### Key Points -#### Process.nextTick Ordering (`ZigGlobalObject.cpp:2818-2829`) +#### Process.nextTick Ordering (`BunGlobalObject.cpp:2818-2829`) The process.nextTick queue is special: diff --git a/src/js/builtins/shell.ts b/src/js/builtins/shell.ts index f1d19bb84acd..885f42ba161d 100644 --- a/src/js/builtins/shell.ts +++ b/src/js/builtins/shell.ts @@ -114,7 +114,7 @@ export function createBunShellTemplateFunction(createShellInterpreter_, createPa // Create the error immediately so it captures the stacktrace at the point // of the shell script's invocation. Just creating the error should be // relatively cheap, the costly work is actually computing the stacktrace - // (`computeErrorInfo()` in ZigGlobalObject.cpp) + // (`computeErrorInfo()` in BunGlobalObject.cpp) let potentialError: ShellError | undefined = new ShellError(); let resolve, reject; diff --git a/src/js/node/worker_threads.ts b/src/js/node/worker_threads.ts index c6d0633dde98..a3847cff1b9c 100644 --- a/src/js/node/worker_threads.ts +++ b/src/js/node/worker_threads.ts @@ -148,7 +148,7 @@ function fakeParentPort() { }, }); - const postMessage = $newCppFunction("ZigGlobalObject.cpp", "jsFunctionPostMessage", 1); + const postMessage = $newCppFunction("BunGlobalObject.cpp", "jsFunctionPostMessage", 1); Object.defineProperty(fake, "postMessage", { value(...args: [any, any]) { return postMessage.$apply(null, args); diff --git a/src/jsc/DOMFormData.rs b/src/jsc/DOMFormData.rs index bc406d3bb3a5..a06a84f7dbcd 100644 --- a/src/jsc/DOMFormData.rs +++ b/src/jsc/DOMFormData.rs @@ -32,7 +32,7 @@ unsafe extern "C" { // handles; `&ZigString` is ABI-identical to non-null `*const ZigString` and // C++ only reads the named struct via `toStringCopy`. `arg3` is an opaque // `*Blob` C++ owns (never dereferenced as Rust data) — same round-trip - // contract as `Zig__GlobalObject__resetModuleRegistryMap`'s `map` param. + // contract as `Bun__GlobalObject__resetModuleRegistryMap`'s `map` param. safe fn WebCore__DOMFormData__appendBlob( arg0: &mut DOMFormData, arg1: &JSGlobalObject, diff --git a/src/jsc/FetchHeaders.rs b/src/jsc/FetchHeaders.rs index 774149329f95..6c2ade584869 100644 --- a/src/jsc/FetchHeaders.rs +++ b/src/jsc/FetchHeaders.rs @@ -42,7 +42,7 @@ unsafe extern "C" { safe fn WebCore__FetchHeaders__createEmpty() -> *mut FetchHeaders; // safe: `arg0`/`arg1` are opaque handles to C++-owned request structs // (PicoHeaders / uWS HttpRequest); never dereferenced as Rust data — same - // round-trip contract as `Zig__GlobalObject__resetModuleRegistryMap`. + // round-trip contract as `Bun__GlobalObject__resetModuleRegistryMap`. safe fn WebCore__FetchHeaders__createFromPicoHeaders_(arg0: *const c_void) -> *mut FetchHeaders; safe fn WebCore__FetchHeaders__createFromUWS(arg1: *mut c_void) -> *mut FetchHeaders; diff --git a/src/jsc/JSGlobalObject.rs b/src/jsc/JSGlobalObject.rs index a8772dff0074..8fcc89cc4e2d 100644 --- a/src/jsc/JSGlobalObject.rs +++ b/src/jsc/JSGlobalObject.rs @@ -1147,27 +1147,27 @@ impl JSGlobalObject { } pub fn readable_stream_to_array_buffer(&self, value: JSValue) -> JSValue { - ZigGlobalObject__readableStreamToArrayBuffer(self, value) + BunGlobalObject__readableStreamToArrayBuffer(self, value) } pub fn readable_stream_to_bytes(&self, value: JSValue) -> JSValue { - ZigGlobalObject__readableStreamToBytes(self, value) + BunGlobalObject__readableStreamToBytes(self, value) } pub fn readable_stream_to_text(&self, value: JSValue) -> JSValue { - ZigGlobalObject__readableStreamToText(self, value) + BunGlobalObject__readableStreamToText(self, value) } pub fn readable_stream_to_json(&self, value: JSValue) -> JSValue { - ZigGlobalObject__readableStreamToJSON(self, value) + BunGlobalObject__readableStreamToJSON(self, value) } pub fn readable_stream_to_blob(&self, value: JSValue) -> JSValue { - ZigGlobalObject__readableStreamToBlob(self, value) + BunGlobalObject__readableStreamToBlob(self, value) } pub fn readable_stream_to_form_data(&self, value: JSValue, content_type: JSValue) -> JSValue { - ZigGlobalObject__readableStreamToFormData(self, value, content_type) + BunGlobalObject__readableStreamToFormData(self, value, content_type) } /// Returns a freshly-created `napi_env` owned by this global, for use by @@ -1175,7 +1175,7 @@ impl JSGlobalObject { /// (which depends on `bun_jsc`), so this returns the raw pointer untyped; /// callers in `bun_runtime` cast to `*mut NapiEnv`. pub fn make_napi_env_for_ffi(&self) -> *mut c_void { - ZigGlobalObject__makeNapiEnvForFFI(self) + BunGlobalObject__makeNapiEnvForFFI(self) } #[inline] @@ -1394,7 +1394,7 @@ impl JSGlobalObject { v.event_loop_mut().ensure_waker(); // C++ creates and returns a non-null global object; `console`/`worker_ptr` // are opaque round-trip pointers C++ stores into the new global. - let global = Zig__GlobalObject__create( + let global = Bun__GlobalObject__create( console, context_id, mini_mode, @@ -1412,17 +1412,17 @@ impl JSGlobalObject { old_global: &JSGlobalObject, console: *mut c_void, ) -> *mut JSGlobalObject { - Zig__GlobalObject__createForTestIsolation(old_global, console) + Bun__GlobalObject__createForTestIsolation(old_global, console) } pub fn get_module_registry_map(global: &JSGlobalObject) -> *mut c_void { - Zig__GlobalObject__getModuleRegistryMap(global) + Bun__GlobalObject__getModuleRegistryMap(global) } pub fn reset_module_registry_map(global: &JSGlobalObject, map: *mut c_void) -> bool { // `map` is an opaque round-trip pointer previously returned by // `get_module_registry_map` (C++ owns it; never dereferenced as Rust data). - Zig__GlobalObject__resetModuleRegistryMap(global, map) + Bun__GlobalObject__resetModuleRegistryMap(global, map) } pub fn report_uncaught_exception_from_error(&self, proof: JsError) { @@ -1534,7 +1534,7 @@ use bun_core::fmt::VecWriter as WriteVec; // ────────────────────────────────────────────────────────────────────────────── #[unsafe(no_mangle)] -pub(crate) unsafe extern "C" fn Zig__GlobalObject__resolve( +pub(crate) unsafe extern "C" fn Bun__GlobalObject__resolve( res: *mut ErrorableString, global: *const JSGlobalObject, specifier: *mut BunString, @@ -1557,7 +1557,7 @@ pub(crate) unsafe extern "C" fn Zig__GlobalObject__resolve( } #[unsafe(no_mangle)] -pub(crate) unsafe extern "C" fn Zig__GlobalObject__reportUncaughtException( +pub(crate) unsafe extern "C" fn Bun__GlobalObject__reportUncaughtException( global: *const JSGlobalObject, exception: *mut Exception, ) -> JSValue { @@ -1574,7 +1574,7 @@ pub(crate) fn report_uncaught_exception(global: &JSGlobalObject, exception: &Exc } #[unsafe(no_mangle)] -pub(crate) extern "C" fn Zig__GlobalObject__onCrash() { +pub(crate) extern "C" fn Bun__GlobalObject__onCrash() { crate::mark_binding(); Output::flush(); panic!("A C++ exception occurred"); @@ -1583,7 +1583,7 @@ pub(crate) extern "C" fn Zig__GlobalObject__onCrash() { // LAYERING: `getBodyStreamOrBytesForWasmStreaming` deals entirely // in `webcore` types (`Response`, `Body.Value`, `Blob`, `ReadableStream`) // which live in `bun_runtime`. The exported `extern "C"` symbol -// `Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming` is therefore +// `Bun__GlobalObject__getBodyStreamOrBytesForWasmStreaming` is therefore // defined in `bun_runtime::webcore::wasm_streaming` rather than here, to // avoid a forward dep cycle. See `src/runtime/webcore/wasm_streaming.rs`. @@ -1664,27 +1664,27 @@ unsafe extern "C" { safe fn JSC__JSGlobalObject__handleRejectedPromises(this: &JSGlobalObject); - safe fn ZigGlobalObject__readableStreamToArrayBuffer( + safe fn BunGlobalObject__readableStreamToArrayBuffer( this: &JSGlobalObject, value: JSValue, ) -> JSValue; - safe fn ZigGlobalObject__readableStreamToBytes( + safe fn BunGlobalObject__readableStreamToBytes( this: &JSGlobalObject, value: JSValue, ) -> JSValue; - safe fn ZigGlobalObject__readableStreamToText(this: &JSGlobalObject, value: JSValue) + safe fn BunGlobalObject__readableStreamToText(this: &JSGlobalObject, value: JSValue) -> JSValue; - safe fn ZigGlobalObject__readableStreamToJSON(this: &JSGlobalObject, value: JSValue) + safe fn BunGlobalObject__readableStreamToJSON(this: &JSGlobalObject, value: JSValue) -> JSValue; - safe fn ZigGlobalObject__readableStreamToFormData( + safe fn BunGlobalObject__readableStreamToFormData( this: &JSGlobalObject, value: JSValue, content_type: JSValue, ) -> JSValue; - safe fn ZigGlobalObject__readableStreamToBlob(this: &JSGlobalObject, value: JSValue) + safe fn BunGlobalObject__readableStreamToBlob(this: &JSGlobalObject, value: JSValue) -> JSValue; - safe fn ZigGlobalObject__makeNapiEnvForFFI(this: &JSGlobalObject) -> *mut c_void; + safe fn BunGlobalObject__makeNapiEnvForFFI(this: &JSGlobalObject) -> *mut c_void; safe fn JSC__JSGlobalObject__bunVM(this: &JSGlobalObject) -> *mut c_void; safe fn JSC__JSGlobalObject__vm(this: &JSGlobalObject) -> *mut VM; @@ -1701,10 +1701,10 @@ unsafe extern "C" { safe fn JSGlobalObject__requestTermination(this: &JSGlobalObject); // safe: `console`/`worker_ptr` are opaque round-trip pointers C++ stores into - // the new ZigGlobalObject (never dereferenced as Rust data here — same - // contract as `Zig__GlobalObject__createForTestIsolation` below); remaining + // the new BunGlobalObject (never dereferenced as Rust data here — same + // contract as `Bun__GlobalObject__createForTestIsolation` below); remaining // args are by-value scalars. - safe fn Zig__GlobalObject__create( + safe fn Bun__GlobalObject__create( console: *mut c_void, context_id: i32, mini_mode: bool, @@ -1715,15 +1715,15 @@ unsafe extern "C" { // safe: `JSGlobalObject` is an opaque `UnsafeCell`-backed ZST handle (`&` is // ABI-identical to non-null `*const`); `console` is an opaque pointer C++ // stores into the new global (never dereferenced as Rust data here). - safe fn Zig__GlobalObject__createForTestIsolation( + safe fn Bun__GlobalObject__createForTestIsolation( old_global: &JSGlobalObject, console: *mut c_void, ) -> *mut JSGlobalObject; - safe fn Zig__GlobalObject__getModuleRegistryMap(global: &JSGlobalObject) -> *mut c_void; + safe fn Bun__GlobalObject__getModuleRegistryMap(global: &JSGlobalObject) -> *mut c_void; // safe: `map` is the opaque round-trip pointer returned by // `getModuleRegistryMap` (C++ owns it; never dereferenced as Rust data). - safe fn Zig__GlobalObject__resetModuleRegistryMap( + safe fn Bun__GlobalObject__resetModuleRegistryMap( global: &JSGlobalObject, map: *mut c_void, ) -> bool; diff --git a/src/jsc/JSGlobalObject.zig b/src/jsc/JSGlobalObject.zig index 5d117d97d32c..47f505637887 100644 --- a/src/jsc/JSGlobalObject.zig +++ b/src/jsc/JSGlobalObject.zig @@ -665,41 +665,41 @@ pub const JSGlobalObject = opaque { return bun.jsc.fromJSHostCallGeneric(this, @src(), JSC__JSGlobalObject__handleRejectedPromises, .{this}) catch return; } - extern fn ZigGlobalObject__readableStreamToArrayBuffer(*JSGlobalObject, JSValue) JSValue; - extern fn ZigGlobalObject__readableStreamToBytes(*JSGlobalObject, JSValue) JSValue; - extern fn ZigGlobalObject__readableStreamToText(*JSGlobalObject, JSValue) JSValue; - extern fn ZigGlobalObject__readableStreamToJSON(*JSGlobalObject, JSValue) JSValue; - extern fn ZigGlobalObject__readableStreamToFormData(*JSGlobalObject, JSValue, JSValue) JSValue; - extern fn ZigGlobalObject__readableStreamToBlob(*JSGlobalObject, JSValue) JSValue; + extern fn BunGlobalObject__readableStreamToArrayBuffer(*JSGlobalObject, JSValue) JSValue; + extern fn BunGlobalObject__readableStreamToBytes(*JSGlobalObject, JSValue) JSValue; + extern fn BunGlobalObject__readableStreamToText(*JSGlobalObject, JSValue) JSValue; + extern fn BunGlobalObject__readableStreamToJSON(*JSGlobalObject, JSValue) JSValue; + extern fn BunGlobalObject__readableStreamToFormData(*JSGlobalObject, JSValue, JSValue) JSValue; + extern fn BunGlobalObject__readableStreamToBlob(*JSGlobalObject, JSValue) JSValue; pub fn readableStreamToArrayBuffer(this: *JSGlobalObject, value: JSValue) JSValue { - return ZigGlobalObject__readableStreamToArrayBuffer(this, value); + return BunGlobalObject__readableStreamToArrayBuffer(this, value); } pub fn readableStreamToBytes(this: *JSGlobalObject, value: JSValue) JSValue { - return ZigGlobalObject__readableStreamToBytes(this, value); + return BunGlobalObject__readableStreamToBytes(this, value); } pub fn readableStreamToText(this: *JSGlobalObject, value: JSValue) JSValue { - return ZigGlobalObject__readableStreamToText(this, value); + return BunGlobalObject__readableStreamToText(this, value); } pub fn readableStreamToJSON(this: *JSGlobalObject, value: JSValue) JSValue { - return ZigGlobalObject__readableStreamToJSON(this, value); + return BunGlobalObject__readableStreamToJSON(this, value); } pub fn readableStreamToBlob(this: *JSGlobalObject, value: JSValue) JSValue { - return ZigGlobalObject__readableStreamToBlob(this, value); + return BunGlobalObject__readableStreamToBlob(this, value); } pub fn readableStreamToFormData(this: *JSGlobalObject, value: JSValue, content_type: JSValue) JSValue { - return ZigGlobalObject__readableStreamToFormData(this, value, content_type); + return BunGlobalObject__readableStreamToFormData(this, value, content_type); } - extern fn ZigGlobalObject__makeNapiEnvForFFI(*JSGlobalObject) *napi.NapiEnv; + extern fn BunGlobalObject__makeNapiEnvForFFI(*JSGlobalObject) *napi.NapiEnv; pub fn makeNapiEnvForFFI(this: *JSGlobalObject) *napi.NapiEnv { - return ZigGlobalObject__makeNapiEnvForFFI(this); + return BunGlobalObject__makeNapiEnvForFFI(this); } pub inline fn assertOnJSThread(this: *JSGlobalObject) void { @@ -860,7 +860,7 @@ pub const JSGlobalObject = opaque { extern fn JSGlobalObject__tryTakeException(*JSGlobalObject) JSValue; extern fn JSGlobalObject__requestTermination(this: *JSGlobalObject) void; - extern fn Zig__GlobalObject__create(*anyopaque, i32, bool, bool, ?*anyopaque) *JSGlobalObject; + extern fn Bun__GlobalObject__create(*anyopaque, i32, bool, bool, ?*anyopaque) *JSGlobalObject; pub fn create( v: *jsc.VirtualMachine, console: *anyopaque, @@ -873,7 +873,7 @@ pub const JSGlobalObject = opaque { defer trace.end(); v.eventLoop().ensureWaker(); - const global = Zig__GlobalObject__create(console, context_id, mini_mode, eval_mode, worker_ptr); + const global = Bun__GlobalObject__create(console, context_id, mini_mode, eval_mode, worker_ptr); // JSC might mess with the stack size. bun.StackCheck.configureThread(); @@ -881,19 +881,19 @@ pub const JSGlobalObject = opaque { return global; } - extern fn Zig__GlobalObject__createForTestIsolation(old_global: *JSGlobalObject, console: *anyopaque) *JSGlobalObject; + extern fn Bun__GlobalObject__createForTestIsolation(old_global: *JSGlobalObject, console: *anyopaque) *JSGlobalObject; pub fn createForTestIsolation(old_global: *JSGlobalObject, console: *anyopaque) *JSGlobalObject { - return Zig__GlobalObject__createForTestIsolation(old_global, console); + return Bun__GlobalObject__createForTestIsolation(old_global, console); } - extern fn Zig__GlobalObject__getModuleRegistryMap(*JSGlobalObject) *anyopaque; + extern fn Bun__GlobalObject__getModuleRegistryMap(*JSGlobalObject) *anyopaque; pub fn getModuleRegistryMap(global: *JSGlobalObject) *anyopaque { - return Zig__GlobalObject__getModuleRegistryMap(global); + return Bun__GlobalObject__getModuleRegistryMap(global); } - extern fn Zig__GlobalObject__resetModuleRegistryMap(*JSGlobalObject, *anyopaque) bool; + extern fn Bun__GlobalObject__resetModuleRegistryMap(*JSGlobalObject, *anyopaque) bool; pub fn resetModuleRegistryMap(global: *JSGlobalObject, map: *anyopaque) bool { - return Zig__GlobalObject__resetModuleRegistryMap(global, map); + return Bun__GlobalObject__resetModuleRegistryMap(global, map); } pub fn resolve(res: *ErrorableString, global: *JSGlobalObject, specifier: *bun.String, source: *bun.String, query: *bun.String) callconv(.c) void { @@ -1045,10 +1045,10 @@ pub const JSGlobalObject = opaque { pub const Extern = [_][]const u8{ "create", "getModuleRegistryMap", "resetModuleRegistryMap" }; comptime { - @export(&resolve, .{ .name = "Zig__GlobalObject__resolve" }); - @export(&reportUncaughtException, .{ .name = "Zig__GlobalObject__reportUncaughtException" }); - @export(&onCrash, .{ .name = "Zig__GlobalObject__onCrash" }); - @export(&jsc.host_fn.wrap3(getBodyStreamOrBytesForWasmStreaming), .{ .name = "Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming" }); + @export(&resolve, .{ .name = "Bun__GlobalObject__resolve" }); + @export(&reportUncaughtException, .{ .name = "Bun__GlobalObject__reportUncaughtException" }); + @export(&onCrash, .{ .name = "Bun__GlobalObject__onCrash" }); + @export(&jsc.host_fn.wrap3(getBodyStreamOrBytesForWasmStreaming), .{ .name = "Bun__GlobalObject__getBodyStreamOrBytesForWasmStreaming" }); } }; diff --git a/src/jsc/ModuleLoader.rs b/src/jsc/ModuleLoader.rs index b9ca2912ad27..eeff17199d9d 100644 --- a/src/jsc/ModuleLoader.rs +++ b/src/jsc/ModuleLoader.rs @@ -220,7 +220,7 @@ pub struct LoaderHooks { /// `VirtualMachine.resolveMaybeNeedsTrailingSlash(res, global, specifier, /// source, query_string?, is_esm, is_a_file_path, is_user_require_resolve)` /// — the resolution path behind - /// `Bun__resolveSync` / `Zig__GlobalObject__resolve` / `import.meta.resolve`. + /// `Bun__resolveSync` / `Bun__GlobalObject__resolve` / `import.meta.resolve`. /// Body reaches into `transpiler.resolver.resolveAndAutoInstall`, the /// `PluginRunner`, `ObjectURLRegistry`, and `ServerEntryPoint` (all /// `bun_runtime` types), so the low tier owns the symbol and dispatches. diff --git a/src/jsc/VM.rs b/src/jsc/VM.rs index bfe379e7e722..eec22756d06b 100644 --- a/src/jsc/VM.rs +++ b/src/jsc/VM.rs @@ -63,7 +63,7 @@ pub enum HeapType { impl VM { // Note: `JSC__VM__create` was removed from bindings.cpp (Bun creates - // its VM via `Zig::GlobalObject::create` → `WebWorker__createVM` instead). + // its VM via `Bun::GlobalObject::create` → `WebWorker__createVM` instead). // Note: not `impl Drop` — takes a `global_object` param and `VM` is an opaque FFI handle. pub fn deinit(&self, global_object: &JSGlobalObject) { diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index e847b6a66271..a3c604750c4b 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -102,7 +102,7 @@ pub struct InitOptions { pub smol: bool, pub eval_mode: bool, pub is_main_thread: bool, - /// Forwarded to `Zig__GlobalObject__create` so the C++ ZigGlobalObject is + /// Forwarded to `Bun__GlobalObject__create` so the C++ BunGlobalObject is /// created with its `WebCore::Worker*` already wired. `null` for the /// main-thread / bake paths. pub worker_ptr: *mut c_void, @@ -110,7 +110,7 @@ pub struct InitOptions { /// `WebWorker::execution_context_id`; `None` lets [`init`] derive it from /// `is_main_thread` (matches the previous behaviour for non-worker init). pub context_id: Option, - /// Forwarded as `mini_mode` to `Zig__GlobalObject__create`. For the + /// Forwarded as `mini_mode` to `Bun__GlobalObject__create`. For the /// main-thread path this is `smol`; for workers it is `WebWorker::mini`. pub mini_mode: bool, } @@ -212,7 +212,7 @@ pub struct VirtualMachine { /// Set once `on_exit()` has finished draining `RareData::cleanup_hooks`. /// After this point the cleanup-hook list is never iterated again, so /// pushing to it (e.g. from a deferred N-API finalizer scheduled during - /// the final `collectNow()` in `Zig__GlobalObject__destructOnExit`) would + /// the final `collectNow()` in `Bun__GlobalObject__destructOnExit`) would /// only leak the hook's `ctx` allocation. pub has_run_cleanup_hooks: bool, pub plugin_runner: Option, @@ -371,7 +371,7 @@ unsafe extern "C" { safe fn Process__dispatchOnExit(global: &JSGlobalObject, code: u8); safe fn Bun__closeAllSQLiteDatabasesForTermination(); safe fn Bun__WebView__closeAllForTermination(); - safe fn Zig__GlobalObject__destructOnExit(global: &JSGlobalObject); + safe fn Bun__GlobalObject__destructOnExit(global: &JSGlobalObject); } pub const HOT_RELOAD_HOT: u8 = 1; @@ -1578,7 +1578,7 @@ impl VirtualMachine { // JSC `Strong`/`Weak` handles against a live HandleSet. self.event_loop_mut().release_queued_tasks_for_shutdown(); - Zig__GlobalObject__destructOnExit(self.global()); + Bun__GlobalObject__destructOnExit(self.global()); // lastChanceToFinalize() above runs Listener/Server finalize → // their own embedded group.closeAll() → sockets land in @@ -1930,9 +1930,9 @@ pub fn runtime_hooks() -> Option<&'static RuntimeHooks> { #[allow(improper_ctypes)] // VirtualMachine is opaque to C++; passed as `void*` unsafe extern "C" { // safe: `console`/`worker_ptr` are opaque round-trip pointers C++ stores - // into the new ZigGlobalObject (never dereferenced as Rust data); remaining + // into the new BunGlobalObject (never dereferenced as Rust data); remaining // args are by-value scalars. - safe fn Zig__GlobalObject__create( + safe fn Bun__GlobalObject__create( console: *mut c_void, context_id: i32, mini_mode: bool, @@ -2125,7 +2125,7 @@ impl VirtualMachine { // High-tier per-VM state — Transpiler / Timer::All / entry_point. // Note (init order): the transpiler and per-VM timer state must be // built BEFORE `JSGlobalObject` creation. The C++ body - // of `Zig__GlobalObject__create` re-enters via `WTFTimer__create`/ + // of `Bun__GlobalObject__create` re-enters via `WTFTimer__create`/ // `WTFTimer__update` (JSC's GC scheduler), which dereferences // `runtime_state().timer` — so this hook MUST run first or that path // null-derefs. The post-global tail (`configureDebugger`, @@ -2149,12 +2149,12 @@ impl VirtualMachine { // JSGlobalObject creation. `ensure_waker()` must run before the FFI. // SAFETY: `vm` is the unique live VM on this thread; raw-ptr deref so // no `&mut` is held across the FFI re-entry (`Bun__getVM()` — - // ZigGlobalObject.cpp:473/961). + // BunGlobalObject.cpp:473/961). unsafe { (*vm).regular_event_loop.ensure_waker() }; // `console`/`worker_ptr` are opaque round-trip pointers C++ stores into // the new global. `worker_ptr` is the C++ `WebCore::Worker*` (or null on // the main thread). - let global = Zig__GlobalObject__create( + let global = Bun__GlobalObject__create( console.cast(), context_id, opts.mini_mode, @@ -3053,7 +3053,7 @@ crate::jsc_abi_extern! { // `JSGlobalObject` / `VM` are opaque `UnsafeCell`-backed ZST handles, so // `&T` is ABI-identical to a non-null `T*`. `BakeCreateProdGlobal`'s // `console_ptr` is an opaque round-trip pointer C++ stores into the new global -// (never dereferenced as Rust data) — same contract as `Zig__GlobalObject__create`. +// (never dereferenced as Rust data) — same contract as `Bun__GlobalObject__create`. #[allow(improper_ctypes)] unsafe extern "C" { safe fn Bun__promises__isErrorLike(global: &JSGlobalObject, reason: JSValue) -> bool; @@ -3655,7 +3655,7 @@ impl VirtualMachine { is_main_thread: false, // The global is created // with `worker.cpp_worker`, `worker.execution_context_id`, - // and `worker.mini` so the C++ ZigGlobalObject is born with its + // and `worker.mini` so the C++ BunGlobalObject is born with its // WorkerGlobalScope + debugger context id wired. worker_ptr: worker.cpp_worker(), context_id: Some(worker.execution_context_id() as i32), @@ -3703,7 +3703,7 @@ impl VirtualMachine { }; // Note: shares the console / log / event-loop wiring with `init`; // the only delta is the global is created via `BakeCreateProdGlobal` - // instead of `ZigGlobalObject__create`. Route through `init` then + // instead of `BunGlobalObject__create`. Route through `init` then // swap the global. let vm = Self::init(init_opts)?; // SAFETY: `vm` is the unique live VM on this thread. diff --git a/src/jsc/VirtualMachine.zig b/src/jsc/VirtualMachine.zig index 461906c6b3aa..cde14896e70c 100644 --- a/src/jsc/VirtualMachine.zig +++ b/src/jsc/VirtualMachine.zig @@ -955,7 +955,7 @@ pub fn onExit(this: *VirtualMachine) void { } } -extern fn Zig__GlobalObject__destructOnExit(*JSGlobalObject) void; +extern fn Bun__GlobalObject__destructOnExit(*JSGlobalObject) void; pub fn globalExit(this: *VirtualMachine) noreturn { bun.assert(this.isShuttingDown()); @@ -979,7 +979,7 @@ pub fn globalExit(this: *VirtualMachine) noreturn { // / postgres / etc. socket is an LSAN leak under // BUN_DESTRUCT_VM_ON_EXIT. if (this.rare_data) |rare| rare.closeAllSocketGroups(this); - Zig__GlobalObject__destructOnExit(this.global); + Bun__GlobalObject__destructOnExit(this.global); // lastChanceToFinalize() above runs Listener/Server finalize → their // own embedded group.closeAll() → sockets land in loop.closed_head. // The pre-JSC drain in closeAllSocketGroups() can't see those (the @@ -2499,7 +2499,7 @@ pub fn removeListeningSocketForWatchMode(this: *VirtualMachine, socket: bun.FD) } /// `bun test --isolate`: tear down per-file OS resources, bump the generation -/// so stale callbacks self-cancel, then create a fresh `ZigGlobalObject` on +/// so stale callbacks self-cancel, then create a fresh `BunGlobalObject` on /// the same `JSC::VM` and point `this.global` at it. The old global is /// gcUnprotect'd; its module graph becomes collectable on the next GC. pub fn swapGlobalForTestIsolation(this: *VirtualMachine) void { diff --git a/src/jsc/bindings/AsymmetricKeyValue.cpp b/src/jsc/bindings/AsymmetricKeyValue.cpp index d72f9abce0b6..604f439d9825 100644 --- a/src/jsc/bindings/AsymmetricKeyValue.cpp +++ b/src/jsc/bindings/AsymmetricKeyValue.cpp @@ -27,7 +27,7 @@ #include "JavaScriptCore/JSArrayBufferView.h" #include "JavaScriptCore/JSCJSValue.h" #include "JavaScriptCore/JSCast.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "webcrypto/JSCryptoKey.h" #include "webcrypto/JSSubtleCrypto.h" #include "webcrypto/CryptoKeyOKP.h" diff --git a/src/jsc/bindings/AsyncContextFrame.cpp b/src/jsc/bindings/AsyncContextFrame.cpp index 06e9f3827c01..d159773c499c 100644 --- a/src/jsc/bindings/AsyncContextFrame.cpp +++ b/src/jsc/bindings/AsyncContextFrame.cpp @@ -1,5 +1,5 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "AsyncContextFrame.h" #include @@ -23,7 +23,7 @@ AsyncContextFrame* AsyncContextFrame::create(JSGlobalObject* global, JSValue cal { auto& vm = global->vm(); ASSERT(callback.isCallable()); - auto* structure = uncheckedDowncast(global)->AsyncContextFrameStructure(); + auto* structure = uncheckedDowncast(global)->AsyncContextFrameStructure(); AsyncContextFrame* asyncContextData = new (NotNull, allocateCell(vm)) AsyncContextFrame(vm, structure, callback, context); asyncContextData->finishCreation(vm); return asyncContextData; @@ -52,7 +52,7 @@ JSValue AsyncContextFrame::withAsyncContextIfNeeded(JSGlobalObject* globalObject auto& vm = JSC::getVM(globalObject); return AsyncContextFrame::create( vm, - uncheckedDowncast(globalObject)->AsyncContextFrameStructure(), + uncheckedDowncast(globalObject)->AsyncContextFrameStructure(), callback, context); } diff --git a/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp b/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp index c8c5b87b71e1..acf8a72031a0 100644 --- a/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp +++ b/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp @@ -38,7 +38,7 @@ extern "C" SYSV_ABI EncodedJSValue Bake__createDevServerFrameworkRequestArgsObje auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); auto& vm = globalObject->vm(); - auto* zig = uncheckedDowncast(globalObject); + auto* zig = uncheckedDowncast(globalObject); auto* object = JSFinalObject::create(vm, zig->bakeAdditions().m_DevServerFrameworkRequestArgsClassStructure.get(zig)); RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); @@ -58,33 +58,33 @@ extern "C" SYSV_ABI EncodedJSValue Bake__createDevServerFrameworkRequestArgsObje extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getAsyncLocalStorage(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); auto value = zig->bakeAdditions().getAsyncLocalStorage(zig); return JSValue::encode(value); } extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getEnsureAsyncLocalStorageInstanceJSFunction(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); return JSValue::encode(zig->bakeAdditions().ensureAsyncLocalStorageInstanceJSFunction(globalObject)); } extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getSSRResponseConstructor(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); return JSValue::encode(zig->bakeAdditions().JSBakeResponseConstructor(globalObject)); } BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeGetAsyncLocalStorage, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); return JSValue::encode(zig->bakeAdditions().getAsyncLocalStorage(zig)); } BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeEnsureAsyncLocalStorage, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); if (callframe->argumentCount() < 1) { Bun::throwError(globalObject, scope, ErrorCode::ERR_MISSING_ARGS, "bakeEnsureAsyncLocalStorage requires at least one argument"_s); return JSValue::encode(jsUndefined()); @@ -96,7 +96,7 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeEnsureAsyncLocalStorage, (JSC::JSGlobalOb extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getBundleNewRouteJSFunction(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); auto value = zig->bakeAdditions().getBundleNewRouteJSFunction(zig); return JSValue::encode(value); } @@ -136,7 +136,7 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeGetBundleNewRouteJSFunction, (JSC::JSGlob extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getNewRouteParamsJSFunction(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); auto value = zig->bakeAdditions().getNewRouteParamsJSFunction(zig); return JSValue::encode(value); } diff --git a/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp b/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp index baa7ad395ac6..5cbad52e3bf8 100644 --- a/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp +++ b/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp @@ -11,7 +11,7 @@ #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/ExceptionScope.h" #include "ZigSourceProvider.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "headers-handwritten.h" #include "IsolatedModuleCache.h" #include "BunAnalyzeTranspiledModule.h" @@ -188,7 +188,7 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj // Under --isolate the same SourceProvider is reused across globals via the // IsolatedModuleCache, so module_info must remain alive on the provider; // ~SourceProvider frees it. Otherwise, free now. - if (!Bun::IsolatedModuleCache::canUse(vm, uncheckedDowncast(globalObject)->bunVM())) { + if (!Bun::IsolatedModuleCache::canUse(vm, uncheckedDowncast(globalObject)->bunVM())) { zig__ModuleInfoDeserialized__deinit(moduleInfo); provider->m_resolvedSource.module_info = nullptr; } diff --git a/src/jsc/bindings/BunCPUProfiler.cpp b/src/jsc/bindings/BunCPUProfiler.cpp index 3166d2ed9a8e..084db2584f4e 100644 --- a/src/jsc/bindings/BunCPUProfiler.cpp +++ b/src/jsc/bindings/BunCPUProfiler.cpp @@ -1,6 +1,6 @@ #include "root.h" #include "BunCPUProfiler.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "helpers.h" #include "BunString.h" #include diff --git a/src/jsc/bindings/BunClientData.cpp b/src/jsc/bindings/BunClientData.cpp index a80a81f2e9dd..20e5bdb80abf 100644 --- a/src/jsc/bindings/BunClientData.cpp +++ b/src/jsc/bindings/BunClientData.cpp @@ -34,7 +34,7 @@ using namespace JSC; RefPtr createBuiltinsSourceProvider(); JSHeapData::JSHeapData(Heap& heap) - : m_heapCellTypeForJSWorkerGlobalScope(JSC::IsoHeapCellType::Args()) + : m_heapCellTypeForJSWorkerGlobalScope(JSC::IsoHeapCellType::Args()) , m_heapCellTypeForNodeVMGlobalObject(JSC::IsoHeapCellType::Args()) , m_heapCellTypeForBakeGlobalObject(JSC::IsoHeapCellType::Args()) , m_heapCellTypeForNapiHandleScopeImpl(JSC::IsoHeapCellType::Args()) diff --git a/src/jsc/bindings/BunClientData.h b/src/jsc/bindings/BunClientData.h index 39830bb53845..3e0356eb5843 100644 --- a/src/jsc/bindings/BunClientData.h +++ b/src/jsc/bindings/BunClientData.h @@ -26,10 +26,13 @@ class DOMWrapperWorld; #include #include "JSCTaskScheduler.h" #include "HTTPHeaderIdentifiers.h" -namespace Zig { +namespace Bun { class GlobalObject; } +namespace Zig { +} + namespace WebCore { using namespace JSC; using namespace Zig; diff --git a/src/jsc/bindings/BunCommonStrings.cpp b/src/jsc/bindings/BunCommonStrings.cpp index 42e51363445a..27cbc72e19eb 100644 --- a/src/jsc/bindings/BunCommonStrings.cpp +++ b/src/jsc/bindings/BunCommonStrings.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -86,7 +86,7 @@ enum class HTTPMethod : uint8_t { httpUNSUBSCRIBE = 35, }; -static JSC::JSValue toJS(Zig::GlobalObject* globalObject, HTTPMethod method) +static JSC::JSValue toJS(Bun::GlobalObject* globalObject, HTTPMethod method) { #define FOR_EACH_METHOD(method) \ case HTTPMethod::http##method: \ @@ -138,7 +138,7 @@ static JSC::JSValue toJS(Zig::GlobalObject* globalObject, HTTPMethod method) #undef FOR_EACH_METHOD } -extern "C" JSC::EncodedJSValue Bun__HTTPMethod__toJS(HTTPMethod method, Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__HTTPMethod__toJS(HTTPMethod method, Bun::GlobalObject* globalObject) { return JSValue::encode(toJS(globalObject, method)); } @@ -159,7 +159,7 @@ enum class CommonStringsForZig : uint8_t { binaryTypeUint8Array = 12, }; -static JSC::JSValue toJS(Zig::GlobalObject* globalObject, CommonStringsForZig commonString) +static JSC::JSValue toJS(Bun::GlobalObject* globalObject, CommonStringsForZig commonString) { auto& commonStrings = globalObject->commonStrings(); switch (commonString) { @@ -196,7 +196,7 @@ static JSC::JSValue toJS(Zig::GlobalObject* globalObject, CommonStringsForZig co } } -extern "C" JSC::EncodedJSValue Bun__CommonStringsForZig__toJS(CommonStringsForZig commonString, Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__CommonStringsForZig__toJS(CommonStringsForZig commonString, Bun::GlobalObject* globalObject) { return JSValue::encode(toJS(globalObject, commonString)); } @@ -211,7 +211,7 @@ enum class FetchCacheMode : uint8_t { OnlyIfCached = 5, }; -extern "C" JSC::EncodedJSValue Bun__FetchCacheMode__toJS(FetchCacheMode mode, Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__FetchCacheMode__toJS(FetchCacheMode mode, Bun::GlobalObject* globalObject) { auto& commonStrings = globalObject->commonStrings(); switch (mode) { @@ -241,7 +241,7 @@ enum class FetchRedirect : uint8_t { Error = 2, }; -extern "C" JSC::EncodedJSValue Bun__FetchRedirect__toJS(FetchRedirect redirect, Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__FetchRedirect__toJS(FetchRedirect redirect, Bun::GlobalObject* globalObject) { auto& commonStrings = globalObject->commonStrings(); switch (redirect) { @@ -266,7 +266,7 @@ enum class FetchRequestMode : uint8_t { Navigate = 3, }; -extern "C" JSC::EncodedJSValue Bun__FetchRequestMode__toJS(FetchRequestMode mode, Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__FetchRequestMode__toJS(FetchRequestMode mode, Bun::GlobalObject* globalObject) { auto& commonStrings = globalObject->commonStrings(); switch (mode) { diff --git a/src/jsc/bindings/BunDebugger.cpp b/src/jsc/bindings/BunDebugger.cpp index 07de46c89962..492df1302629 100644 --- a/src/jsc/bindings/BunDebugger.cpp +++ b/src/jsc/bindings/BunDebugger.cpp @@ -1,6 +1,6 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -116,7 +116,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { this->status = ConnectionStatus::Connected; auto* globalObject = context.jsGlobalObject(); if (this->unrefOnDisconnect) { - Bun__eventLoop__incrementRefConcurrently(static_cast(globalObject)->bunVM(), 1); + Bun__eventLoop__incrementRefConcurrently(static_cast(globalObject)->bunVM(), 1); } globalObject->setInspectable(true); auto& inspector = globalObject->inspectorDebuggable(); @@ -146,7 +146,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { }; } - this->receiveMessagesOnInspectorThread(context, static_cast(globalObject), false); + this->receiveMessagesOnInspectorThread(context, static_cast(globalObject), false); } void connect() @@ -202,7 +202,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { if (connection->unrefOnDisconnect) { connection->unrefOnDisconnect = false; - Bun__eventLoop__incrementRefConcurrently(static_cast(context.jsGlobalObject())->bunVM(), -1); + Bun__eventLoop__incrementRefConcurrently(static_cast(context.jsGlobalObject())->bunVM(), -1); } }); } @@ -222,7 +222,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { static void runWhilePaused(JSGlobalObject& globalObject, bool& isDoneProcessingEvents) { - Zig::GlobalObject* global = static_cast(&globalObject); + Bun::GlobalObject* global = static_cast(&globalObject); Vector connections; { Locker locker(inspectorConnectionsLock); @@ -309,7 +309,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { wait.condition.notifyAll(); } - void receiveMessagesOnInspectorThread(ScriptExecutionContext& context, Zig::GlobalObject* globalObject, bool connectIfNeeded) + void receiveMessagesOnInspectorThread(ScriptExecutionContext& context, Bun::GlobalObject* globalObject, bool connectIfNeeded) { this->jsThreadMessageScheduledCount.store(0); WTF::Vector messages; @@ -349,7 +349,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { messages.clear(); } - void receiveMessagesOnDebuggerThread(ScriptExecutionContext& context, Zig::GlobalObject* debuggerGlobalObject) + void receiveMessagesOnDebuggerThread(ScriptExecutionContext& context, Bun::GlobalObject* debuggerGlobalObject) { debuggerThreadMessageScheduledCount.store(0); WTF::Vector messages; @@ -382,7 +382,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { if (this->debuggerThreadMessageScheduledCount++ == 0) { debuggerScriptExecutionContext->postTaskConcurrently([connection = this](ScriptExecutionContext& context) { - connection->receiveMessagesOnDebuggerThread(context, static_cast(context.jsGlobalObject())); + connection->receiveMessagesOnDebuggerThread(context, static_cast(context.jsGlobalObject())); }); } } @@ -398,7 +398,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { if (this->jsThreadMessageScheduledCount++ == 0) { ScriptExecutionContext::postTaskTo(scriptExecutionContextIdentifier, [connection = this](ScriptExecutionContext& context) { - connection->receiveMessagesOnInspectorThread(context, static_cast(context.jsGlobalObject()), true); + connection->receiveMessagesOnInspectorThread(context, static_cast(context.jsGlobalObject()), true); }); } } @@ -414,7 +414,7 @@ class BunInspectorConnection : public Inspector::FrontendChannel { if (this->jsThreadMessageScheduledCount++ == 0) { ScriptExecutionContext::postTaskTo(scriptExecutionContextIdentifier, [connection = this](ScriptExecutionContext& context) { - connection->receiveMessagesOnInspectorThread(context, static_cast(context.jsGlobalObject()), true); + connection->receiveMessagesOnInspectorThread(context, static_cast(context.jsGlobalObject()), true); }); } } @@ -533,7 +533,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionDisconnect, (JSC::JSGlobalObject * globalObje const JSC::ClassInfo JSBunInspectorConnection::s_info = { "BunInspectorConnection"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBunInspectorConnection) }; -extern "C" unsigned int Bun__createJSDebugger(Zig::GlobalObject* globalObject) +extern "C" unsigned int Bun__createJSDebugger(Bun::GlobalObject* globalObject) { { Locker locker(inspectorConnectionsLock); @@ -590,7 +590,7 @@ extern "C" void BunDebugger__willHotReload() JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateConnection, (JSGlobalObject * globalObject, CallFrame* callFrame)) { - auto* debuggerGlobalObject = dynamicDowncast(globalObject); + auto* debuggerGlobalObject = dynamicDowncast(globalObject); if (!debuggerGlobalObject) return JSValue::encode(jsUndefined()); @@ -618,7 +618,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateConnection, (JSGlobalObject * globalObj return JSValue::encode(JSBunInspectorConnection::create(vm, JSBunInspectorConnection::createStructure(vm, globalObject, globalObject->objectPrototype()), connection)); } -extern "C" void Bun__startJSDebuggerThread(Zig::GlobalObject* debuggerGlobalObject, ScriptExecutionContextIdentifier scriptId, BunString* portOrPathString, int isAutomatic, bool isUrlServer) +extern "C" void Bun__startJSDebuggerThread(Bun::GlobalObject* debuggerGlobalObject, ScriptExecutionContextIdentifier scriptId, BunString* portOrPathString, int isAutomatic, bool isUrlServer) { if (!debuggerScriptExecutionContext) debuggerScriptExecutionContext = debuggerGlobalObject->scriptExecutionContext(); @@ -709,7 +709,7 @@ extern "C" void Debugger__willDispatchAsyncCall(JSGlobalObject* globalObject, As agent->willDispatchAsyncCall(getCallType(callType), callbackId); } -extern "C" void Bun__InspectorConnection__disconnectAllOnExit(Zig::GlobalObject* globalObject) +extern "C" void Bun__InspectorConnection__disconnectAllOnExit(Bun::GlobalObject* globalObject) { // Snapshot under the lock, release before calling into the inspector — // `willDestroyFrontendAndBackend` must not run with `inspectorConnectionsLock` held. diff --git a/src/jsc/bindings/ZigGlobalObject.cpp b/src/jsc/bindings/BunGlobalObject.cpp similarity index 96% rename from src/jsc/bindings/ZigGlobalObject.cpp rename to src/jsc/bindings/BunGlobalObject.cpp index 456898e72aaf..763b27878def 100644 --- a/src/jsc/bindings/ZigGlobalObject.cpp +++ b/src/jsc/bindings/BunGlobalObject.cpp @@ -1,6 +1,6 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "helpers.h" #include "JavaScriptCore/ArgList.h" #include "JavaScriptCore/JSCellButterfly.h" @@ -268,7 +268,7 @@ extern "C" unsigned getJSCBytecodeCacheVersion() // Declare fuzzilli function registration from FuzzilliREPRL.cpp #ifdef FUZZILLI_ENABLED -extern "C" void Bun__REPRL__registerFuzzilliFunctions(Zig::GlobalObject*); +extern "C" void Bun__REPRL__registerFuzzilliFunctions(Bun::GlobalObject*); #endif extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(const char* ptr, size_t length), bool evalMode, bool oneShotStartup) @@ -278,7 +278,7 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c std::call_once(jsc_init_flag, [evalMode, oneShotStartup, envp, envc, onCrash]() { JSC::Config::enableRestrictedOptions(); - std::set_terminate([]() { Zig__GlobalObject__onCrash(); }); + std::set_terminate([]() { Bun__GlobalObject__onCrash(); }); WTF::initializeMainThread(); // Use JSC::initialize with a callback to set Options during initialization. @@ -353,7 +353,7 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c extern "C" void* Bun__getVM(); -extern "C" void Bun__setDefaultGlobalObject(Zig::GlobalObject* globalObject); +extern "C" void Bun__setDefaultGlobalObject(Bun::GlobalObject* globalObject); // Declare the native functions for LazyProperty initializers extern "C" JSC::EncodedJSValue BunObject__createBunStdin(JSC::JSGlobalObject*); @@ -417,7 +417,7 @@ JSC::Structure* GlobalObject::createStructure(JSC::VM& vm) return structure; } -void Zig::GlobalObject::resetOnEachMicrotaskTick() +void Bun::GlobalObject::resetOnEachMicrotaskTick() { auto& vm = this->vm(); if (this->asyncHooksNeedsCleanup) { @@ -436,7 +436,7 @@ extern "C" size_t Bun__reported_memory_size; // executionContextId: -1 for main thread // executionContextId: maxInt32 for macros // executionContextId: >-1 for workers -extern "C" JSC::JSGlobalObject* Zig__GlobalObject__create(void* console_client, int32_t executionContextId, bool miniMode, bool evalMode, void* worker_ptr) +extern "C" JSC::JSGlobalObject* Bun__GlobalObject__create(void* console_client, int32_t executionContextId, bool miniMode, bool evalMode, void* worker_ptr) { auto heapSize = miniMode ? JSC::HeapType::Small : JSC::HeapType::Large; RefPtr vmPtr = JSC::VM::tryCreate(heapSize); @@ -481,32 +481,32 @@ extern "C" JSC::JSGlobalObject* Zig__GlobalObject__create(void* console_client, WebCore::JSVMClientData::create(&vm, Bun__getVM()); - const auto createGlobalObject = [&]() -> Zig::GlobalObject* { + const auto createGlobalObject = [&]() -> Bun::GlobalObject* { if (executionContextId == std::numeric_limits::max() || executionContextId > 1) [[unlikely]] { - auto* structure = Zig::GlobalObject::createStructure(vm); + auto* structure = Bun::GlobalObject::createStructure(vm); if (!structure) [[unlikely]] { return nullptr; } - return Zig::GlobalObject::create( + return Bun::GlobalObject::create( vm, structure, static_cast(executionContextId)); } else if (evalMode) { - auto* structure = Zig::EvalGlobalObject::createStructure(vm); + auto* structure = Bun::EvalGlobalObject::createStructure(vm); if (!structure) [[unlikely]] { return nullptr; } - return Zig::EvalGlobalObject::create( + return Bun::EvalGlobalObject::create( vm, structure, - &Zig::EvalGlobalObject::globalObjectMethodTable()); + &Bun::EvalGlobalObject::globalObjectMethodTable()); } else { - auto* structure = Zig::GlobalObject::createStructure(vm); + auto* structure = Bun::GlobalObject::createStructure(vm); if (!structure) [[unlikely]] { return nullptr; } - return Zig::GlobalObject::create( + return Bun::GlobalObject::create( vm, structure); } @@ -524,7 +524,7 @@ extern "C" JSC::JSGlobalObject* Zig__GlobalObject__create(void* console_client, JSC::gcProtect(globalObject); #ifdef FUZZILLI_ENABLED - Bun__REPRL__registerFuzzilliFunctions(static_cast(globalObject)); + Bun__REPRL__registerFuzzilliFunctions(static_cast(globalObject)); #endif vm.setOnComputeErrorInfo(computeErrorInfoWrapperToString); @@ -583,10 +583,10 @@ extern "C" JSC::JSGlobalObject* Zig__GlobalObject__create(void* console_client, return globalObject; } -// Create a fresh Zig::GlobalObject on the *same* JSC::VM as `oldGlobal`, then unprotect +// Create a fresh Bun::GlobalObject on the *same* JSC::VM as `oldGlobal`, then unprotect // the old one so GC can reclaim its module graph. Used by `bun test --isolate` to give // each test file a clean global without paying for a new JSC::VM. -extern "C" JSC::JSGlobalObject* Zig__GlobalObject__createForTestIsolation(Zig::GlobalObject* oldGlobal, void* console_client) +extern "C" JSC::JSGlobalObject* Bun__GlobalObject__createForTestIsolation(Bun::GlobalObject* oldGlobal, void* console_client) { JSC::VM& vm = oldGlobal->vm(); JSC::JSLockHolder locker(vm); @@ -611,11 +611,11 @@ extern "C" JSC::JSGlobalObject* Zig__GlobalObject__createForTestIsolation(Zig::G oldContext->removeFromContextsMap(); oldContext->regenerateIdentifier(); - auto* structure = Zig::GlobalObject::createStructure(vm); + auto* structure = Bun::GlobalObject::createStructure(vm); if (!structure) [[unlikely]] { BUN_PANIC("Failed to allocate global object structure for test isolation"); } - auto* globalObject = Zig::GlobalObject::create(vm, structure, inheritedId); + auto* globalObject = Bun::GlobalObject::create(vm, structure, inheritedId); if (!globalObject) [[unlikely]] { BUN_PANIC("Failed to allocate global object for test isolation"); } @@ -626,7 +626,7 @@ extern "C" JSC::JSGlobalObject* Zig__GlobalObject__createForTestIsolation(Zig::G Bun__setDefaultGlobalObject(globalObject); JSC::gcProtect(globalObject); - // NapiEnv holds a raw Zig::GlobalObject*; deferred napi finalizers for + // NapiEnv holds a raw Bun::GlobalObject*; deferred napi finalizers for // the old global's objects run on the next event-loop tick — after this // function returns and the old global is collectable — and would write // into the dead cell via NapiHandleScope::open. Point those envs at the @@ -645,7 +645,7 @@ extern "C" JSC::JSGlobalObject* Zig__GlobalObject__createForTestIsolation(Zig::G JSC_DEFINE_HOST_FUNCTION(functionFulfillModuleSync, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -749,7 +749,7 @@ JSC_DEFINE_HOST_FUNCTION(functionEsmRegistryEvaluatedKeys, (JSC::JSGlobalObject JSC_DEFINE_HOST_FUNCTION(functionEsmLoadSync, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); JSValue keyValue = callFrame->argument(0); @@ -838,7 +838,7 @@ JSC_DEFINE_HOST_FUNCTION(functionEsmLoadSync, (JSC::JSGlobalObject * lexicalGlob return JSValue::encode(ns); } -extern "C" void* Zig__GlobalObject__getModuleRegistryMap(JSC::JSGlobalObject*) +extern "C" void* Bun__GlobalObject__getModuleRegistryMap(JSC::JSGlobalObject*) { // The JSC module loader registry is no longer a JS Map; snapshot/restore // is no longer supported. This symbol has no callers, so this is dead @@ -846,22 +846,22 @@ extern "C" void* Zig__GlobalObject__getModuleRegistryMap(JSC::JSGlobalObject*) return nullptr; } -extern "C" bool Zig__GlobalObject__resetModuleRegistryMap(JSC::JSGlobalObject*, void*) +extern "C" bool Bun__GlobalObject__resetModuleRegistryMap(JSC::JSGlobalObject*, void*) { - // See Zig__GlobalObject__getModuleRegistryMap above. + // See Bun__GlobalObject__getModuleRegistryMap above. return false; } #define WEBCORE_GENERATED_CONSTRUCTOR_GETTER(ConstructorName) \ JSValue ConstructorName##ConstructorCallback(VM& vm, JSObject* lexicalGlobalObject) \ { \ - return WebCore::JS##ConstructorName::getConstructor(vm, uncheckedDowncast(lexicalGlobalObject)); \ + return WebCore::JS##ConstructorName::getConstructor(vm, uncheckedDowncast(lexicalGlobalObject)); \ } \ JSC_DEFINE_CUSTOM_GETTER(ConstructorName##_getter, \ (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, \ JSC::PropertyName)) \ { \ - return JSC::JSValue::encode(WebCore::JS##ConstructorName::getConstructor(lexicalGlobalObject->vm(), uncheckedDowncast(lexicalGlobalObject))); \ + return JSC::JSValue::encode(WebCore::JS##ConstructorName::getConstructor(lexicalGlobalObject->vm(), uncheckedDowncast(lexicalGlobalObject))); \ } String GlobalObject::defaultAgentClusterID() @@ -877,20 +877,20 @@ String GlobalObject::agentClusterID() const return defaultAgentClusterID(); } -namespace Zig { +namespace Bun { using namespace WebCore; static JSGlobalObject* deriveShadowRealmGlobalObject(JSGlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); - // Same reasoning as Zig__GlobalObject__createForTestIsolation: keep the + // Same reasoning as Bun__GlobalObject__createForTestIsolation: keep the // concurrent marker from walking the new global while finishCreation/init // is still populating it. JSC::DeferGC deferGC(vm); - Zig::GlobalObject* shadow = Zig::GlobalObject::create( + Bun::GlobalObject* shadow = Bun::GlobalObject::create( vm, - Zig::GlobalObject::createStructure(vm), + Bun::GlobalObject::createStructure(vm), ScriptExecutionContext::generateIdentifier()); shadow->setConsole(shadow); @@ -898,9 +898,9 @@ static JSGlobalObject* deriveShadowRealmGlobalObject(JSGlobalObject* globalObjec } extern "C" int Bun__VM__scriptExecutionStatus(void*); -JSC::ScriptExecutionStatus Zig::GlobalObject::scriptExecutionStatus(JSC::JSGlobalObject* globalObject, JSC::JSObject*) +JSC::ScriptExecutionStatus Bun::GlobalObject::scriptExecutionStatus(JSC::JSGlobalObject* globalObject, JSC::JSObject*) { - switch (Bun__VM__scriptExecutionStatus(uncheckedDowncast(globalObject)->bunVM())) { + switch (Bun__VM__scriptExecutionStatus(uncheckedDowncast(globalObject)->bunVM())) { case 0: return JSC::ScriptExecutionStatus::Running; case 1: @@ -913,7 +913,7 @@ JSC::ScriptExecutionStatus Zig::GlobalObject::scriptExecutionStatus(JSC::JSGloba } } -void unsafeEvalNoop(JSGlobalObject*, const WTF::String&) {} +static void unsafeEvalNoop(JSGlobalObject*, const WTF::String&) {} const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable() { @@ -935,7 +935,7 @@ const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable() nullptr, // defaultLanguage &compileStreaming, &instantiateStreaming, - &Zig::deriveShadowRealmGlobalObject, + &Bun::deriveShadowRealmGlobalObject, &codeForEval, // codeForEval &canCompileStrings, // canCompileStrings &trustedScriptStructure, // trustedScriptStructure @@ -963,7 +963,7 @@ const JSC::GlobalObjectMethodTable& EvalGlobalObject::globalObjectMethodTable() nullptr, // defaultLanguage &compileStreaming, &instantiateStreaming, - &Zig::deriveShadowRealmGlobalObject, + &Bun::deriveShadowRealmGlobalObject, &codeForEval, // codeForEval &canCompileStrings, // canCompileStrings &trustedScriptStructure, // trustedScriptStructure @@ -1037,7 +1037,7 @@ void GlobalObject::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObje Bun__reportUnhandledError(globalObject, JSValue::encode(JSValue(exception))); } -extern "C" void Bun__handleHandledPromise(Zig::GlobalObject* JSGlobalObject, JSC::JSPromise* promise); +extern "C" void Bun__handleHandledPromise(Bun::GlobalObject* JSGlobalObject, JSC::JSPromise* promise); void GlobalObject::promiseRejectionTracker(JSGlobalObject* obj, JSC::JSPromise* promise, JSC::JSPromiseRejectionOperation operation) @@ -1068,7 +1068,7 @@ JSC_DEFINE_CUSTOM_GETTER(errorConstructorPrepareStackTraceGetter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - Zig::GlobalObject* thisObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* thisObject = uncheckedDowncast(lexicalGlobalObject); if (thisObject->m_errorConstructorPrepareStackTraceValue) { return JSValue::encode(thisObject->m_errorConstructorPrepareStackTraceValue.get()); } @@ -1081,7 +1081,7 @@ JSC_DEFINE_CUSTOM_SETTER(errorConstructorPrepareStackTraceSetter, JSC::EncodedJSValue encodedValue, JSC::PropertyName property)) { auto& vm = JSC::getVM(lexicalGlobalObject); - Zig::GlobalObject* thisObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* thisObject = uncheckedDowncast(lexicalGlobalObject); JSValue value = JSValue::decode(encodedValue); if (value == thisObject->m_errorConstructorPrepareStackTraceInternalValue.get(thisObject)) { thisObject->m_errorConstructorPrepareStackTraceValue.clear(); @@ -1098,7 +1098,7 @@ JSC_DEFINE_CUSTOM_GETTER(globalOnMessage, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - Zig::GlobalObject* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); + Bun::GlobalObject* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); return JSValue::encode(eventHandlerAttribute(thisObject->eventTarget(), eventNames().messageEvent, thisObject->world())); } @@ -1106,7 +1106,7 @@ JSC_DEFINE_CUSTOM_GETTER(globalOnError, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - Zig::GlobalObject* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); + Bun::GlobalObject* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); return JSValue::encode(eventHandlerAttribute(thisObject->eventTarget(), eventNames().errorEvent, thisObject->world())); } @@ -1116,7 +1116,7 @@ JSC_DEFINE_CUSTOM_SETTER(setGlobalOnMessage, { auto& vm = JSC::getVM(lexicalGlobalObject); JSValue value = JSValue::decode(encodedValue); - auto* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); + auto* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); setEventHandlerAttribute(thisObject->eventTarget(), eventNames().messageEvent, value, *thisObject); vm.writeBarrier(thisObject, value); ensureStillAliveHere(value); @@ -1129,7 +1129,7 @@ JSC_DEFINE_CUSTOM_SETTER(setGlobalOnError, { auto& vm = JSC::getVM(lexicalGlobalObject); JSValue value = JSValue::decode(encodedValue); - auto* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); + auto* thisObject = uncheckedDowncast(JSValue::decode(thisValue)); setEventHandlerAttribute(thisObject->eventTarget(), eventNames().errorEvent, value, *thisObject); vm.writeBarrier(thisObject, value); ensureStillAliveHere(value); @@ -1145,7 +1145,7 @@ JSC_DEFINE_CUSTOM_GETTER(functionLazyLoadStreamPrototypeMap_getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - Zig::GlobalObject* thisObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* thisObject = uncheckedDowncast(lexicalGlobalObject); return JSC::JSValue::encode( thisObject->readableStreamNativeMap()); } @@ -1154,10 +1154,10 @@ JSC_DEFINE_CUSTOM_GETTER(JSBuffer_getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - return JSC::JSValue::encode(uncheckedDowncast(lexicalGlobalObject)->JSBufferConstructor()); + return JSC::JSValue::encode(uncheckedDowncast(lexicalGlobalObject)->JSBufferConstructor()); } -// This macro defines the getter needed for ZigGlobalObject.lut.h +// This macro defines the getter needed for BunGlobalObject.lut.h // "ConstructorCallback" is a PropertyCallback // it also defines "_getter" which is the getter for a JSC::CustomGetterSetter WEBCORE_GENERATED_CONSTRUCTOR_GETTER(AbortController); @@ -1447,7 +1447,7 @@ extern "C" JSC::EncodedJSValue Bun__createUint8ArrayForCopy(JSC::JSGlobalObject* VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - auto* subclassStructure = isBuffer ? static_cast(globalObject)->JSBufferSubclassStructure() : globalObject->typedArrayStructureWithTypedArrayType(); + auto* subclassStructure = isBuffer ? static_cast(globalObject)->JSBufferSubclassStructure() : globalObject->typedArrayStructureWithTypedArrayType(); JSC::JSUint8Array* array = JSC::JSUint8Array::createUninitialized(globalObject, subclassStructure, len); RETURN_IF_EXCEPTION(scope, {}); @@ -1520,7 +1520,7 @@ JSC_DEFINE_HOST_FUNCTION(functionCreateUninitializedArrayBuffer, RELEASE_AND_RETURN(scope, JSValue::encode(JSC::JSArrayBuffer::create(globalObject->vm(), globalObject->arrayBufferStructure(JSC::ArrayBufferSharingMode::Default), WTF::move(arrayBuffer)))); } -static inline JSC::EncodedJSValue jsFunctionAddEventListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, Zig::GlobalObject* castedThis) +static inline JSC::EncodedJSValue jsFunctionAddEventListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, Bun::GlobalObject* castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -1546,10 +1546,10 @@ static inline JSC::EncodedJSValue jsFunctionAddEventListenerBody(JSC::JSGlobalOb JSC_DEFINE_HOST_FUNCTION(jsFunctionAddEventListener, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return jsFunctionAddEventListenerBody(lexicalGlobalObject, callFrame, dynamicDowncast(lexicalGlobalObject)); + return jsFunctionAddEventListenerBody(lexicalGlobalObject, callFrame, dynamicDowncast(lexicalGlobalObject)); } -static inline JSC::EncodedJSValue jsFunctionRemoveEventListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, Zig::GlobalObject* castedThis) +static inline JSC::EncodedJSValue jsFunctionRemoveEventListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, Bun::GlobalObject* castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -1575,10 +1575,10 @@ static inline JSC::EncodedJSValue jsFunctionRemoveEventListenerBody(JSC::JSGloba JSC_DEFINE_HOST_FUNCTION(jsFunctionRemoveEventListener, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return jsFunctionRemoveEventListenerBody(lexicalGlobalObject, callFrame, dynamicDowncast(lexicalGlobalObject)); + return jsFunctionRemoveEventListenerBody(lexicalGlobalObject, callFrame, dynamicDowncast(lexicalGlobalObject)); } -static inline JSC::EncodedJSValue jsFunctionDispatchEventBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, Zig::GlobalObject* castedThis) +static inline JSC::EncodedJSValue jsFunctionDispatchEventBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, Bun::GlobalObject* castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -1595,12 +1595,12 @@ static inline JSC::EncodedJSValue jsFunctionDispatchEventBody(JSC::JSGlobalObjec JSC_DEFINE_HOST_FUNCTION(jsFunctionDispatchEvent, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return jsFunctionDispatchEventBody(lexicalGlobalObject, callFrame, dynamicDowncast(lexicalGlobalObject)); + return jsFunctionDispatchEventBody(lexicalGlobalObject, callFrame, dynamicDowncast(lexicalGlobalObject)); } JSC_DEFINE_CUSTOM_GETTER(getterSubtleCrypto, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { - return JSValue::encode(static_cast(lexicalGlobalObject)->subtleCrypto()); + return JSValue::encode(static_cast(lexicalGlobalObject)->subtleCrypto()); } extern "C" JSC::EncodedJSValue ExpectMatcherUtils_createSigleton(JSC::JSGlobalObject* lexicalGlobalObject); @@ -1762,7 +1762,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBunPokePromiseAsHandled, (JSGlobalObject*, CallFrame* } extern "C" JSC::EncodedJSValue Bun__Jest__createTestModuleObject(JSC::JSGlobalObject*); -extern "C" JSC::EncodedJSValue Bun__Jest__testModuleObject(Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__Jest__testModuleObject(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1771,7 +1771,7 @@ extern "C" JSC::EncodedJSValue Bun__Jest__testModuleObject(Zig::GlobalObject* gl return JSValue::encode(object); } -extern "C" napi_env ZigGlobalObject__makeNapiEnvForFFI(Zig::GlobalObject* globalObject) +extern "C" napi_env BunGlobalObject__makeNapiEnvForFFI(Bun::GlobalObject* globalObject) { return globalObject->makeNapiEnvForFFI(); } @@ -2026,7 +2026,7 @@ void GlobalObject::finishCreation(VM& vm) m_commonJSModuleObjectStructure.initLater( [](const Initializer& init) { - init.set(Bun::createCommonJSModuleStructure(static_cast(init.owner))); + init.set(Bun::createCommonJSModuleStructure(static_cast(init.owner))); }); m_JSSocketAddressDTOStructure.initLater( @@ -2067,7 +2067,7 @@ void GlobalObject::finishCreation(VM& vm) v8::shim::GlobalInternals::create( init.vm, v8::shim::GlobalInternals::createStructure(init.vm, init.owner), - dynamicDowncast(init.owner))); + dynamicDowncast(init.owner))); }); m_JSStatsClassStructure.initLater( @@ -2094,7 +2094,7 @@ void GlobalObject::finishCreation(VM& vm) [](const JSC::LazyProperty::Initializer& init) { init.set( createMemoryFootprintStructure( - init.vm, static_cast(init.owner))); + init.vm, static_cast(init.owner))); }); m_errorConstructorPrepareStackTraceInternalValue.initLater( @@ -2118,7 +2118,7 @@ void GlobalObject::finishCreation(VM& vm) m_JSBufferSubclassStructure.initLater( [](const Initializer& init) { auto scope = DECLARE_TOP_EXCEPTION_SCOPE(init.vm); - auto* globalObject = static_cast(init.owner); + auto* globalObject = static_cast(init.owner); auto* baseStructure = globalObject->typedArrayStructureWithTypedArrayType(); JSC::Structure* subclassStructure = JSC::InternalFunction::createSubclassStructure(globalObject, globalObject->JSBufferConstructor(), baseStructure); scope.assertNoExceptionExceptTermination(); @@ -2127,7 +2127,7 @@ void GlobalObject::finishCreation(VM& vm) m_JSResizableOrGrowableSharedBufferSubclassStructure.initLater( [](const Initializer& init) { auto scope = DECLARE_TOP_EXCEPTION_SCOPE(init.vm); - auto* globalObject = static_cast(init.owner); + auto* globalObject = static_cast(init.owner); auto* baseStructure = globalObject->resizableOrGrowableSharedTypedArrayStructureWithTypedArrayType(); JSC::Structure* subclassStructure = JSC::InternalFunction::createSubclassStructure(globalObject, globalObject->JSBufferConstructor(), baseStructure); scope.assertNoExceptionExceptTermination(); @@ -2141,7 +2141,7 @@ void GlobalObject::finishCreation(VM& vm) m_utilInspectFunction.initLater( [](const Initializer& init) { auto scope = DECLARE_THROW_SCOPE(init.vm); - JSValue nodeUtilValue = uncheckedDowncast(init.owner)->internalModuleRegistry()->requireId(init.owner, init.vm, Bun::InternalModuleRegistry::Field::NodeUtil); + JSValue nodeUtilValue = uncheckedDowncast(init.owner)->internalModuleRegistry()->requireId(init.owner, init.vm, Bun::InternalModuleRegistry::Field::NodeUtil); RETURN_IF_EXCEPTION(scope, ); RELEASE_ASSERT(nodeUtilValue.isObject()); auto prop = nodeUtilValue.getObject()->getIfPropertyExists(init.owner, Identifier::fromString(init.vm, "inspect"_s)); @@ -2168,7 +2168,7 @@ void GlobalObject::finishCreation(VM& vm) [](const Initializer& init) { auto scope = DECLARE_THROW_SCOPE(init.vm); JSC::MarkedArgumentBuffer args; - args.append(uncheckedDowncast(init.owner)->utilInspectFunction()); + args.append(uncheckedDowncast(init.owner)->utilInspectFunction()); RETURN_IF_EXCEPTION(scope, ); JSC::JSFunction* getStylize = JSC::JSFunction::create(init.vm, init.owner, utilInspectGetStylizeWithColorCodeGenerator(init.vm), init.owner); @@ -2294,17 +2294,17 @@ void GlobalObject::finishCreation(VM& vm) m_ServerRouteListStructure.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(Bun::createServerRouteListStructure(init.vm, static_cast(init.owner))); + init.set(Bun::createServerRouteListStructure(init.vm, static_cast(init.owner))); }); m_JSBunRequestParamsPrototype.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(Bun::createJSBunRequestParamsPrototype(init.vm, static_cast(init.owner))); + init.set(Bun::createJSBunRequestParamsPrototype(init.vm, static_cast(init.owner))); }); m_JSBunRequestStructure.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(Bun::createJSBunRequestStructure(init.vm, static_cast(init.owner))); + init.set(Bun::createJSBunRequestStructure(init.vm, static_cast(init.owner))); }); m_NapiHandleScopeImplStructure.initLater([](const JSC::LazyProperty::Initializer& init) { @@ -2331,7 +2331,7 @@ void GlobalObject::finishCreation(VM& vm) m_subtleCryptoObject.initLater( [](const JSC::LazyProperty::Initializer& init) { - auto& global = *static_cast(init.owner); + auto& global = *static_cast(init.owner); if (!global.m_subtleCrypto) { global.m_subtleCrypto = &WebCore::SubtleCrypto::create(global.scriptExecutionContext()).leakRef(); @@ -2377,13 +2377,13 @@ void GlobalObject::finishCreation(VM& vm) m_performanceObject.initLater( [](const JSC::LazyProperty::Initializer& init) { - auto* globalObject = static_cast(init.owner); + auto* globalObject = static_cast(init.owner); init.set(toJS(init.owner, globalObject, globalObject->performance().get()).getObject()); }); m_processEnvObject.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(Bun::createEnvironmentVariablesMap(static_cast(init.owner)).getObject()); + init.set(Bun::createEnvironmentVariablesMap(static_cast(init.owner)).getObject()); }); m_processObject.initLater( @@ -2555,7 +2555,7 @@ void GlobalObject::finishCreation(VM& vm) m_JSCryptoKey.initLater( [](const JSC::LazyProperty::Initializer& init) { - Zig::GlobalObject* globalObject = static_cast(init.owner); + Bun::GlobalObject* globalObject = static_cast(init.owner); auto* prototype = JSCryptoKey::createPrototype(init.vm, *globalObject); auto* structure = JSCryptoKey::createStructure(init.vm, init.owner, JSValue(prototype)); init.set(structure); @@ -2632,7 +2632,7 @@ void GlobalObject::finishCreation(VM& vm) JSC_DEFINE_CUSTOM_GETTER(JSDOMFileConstructor_getter, (JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, PropertyName)) { - Zig::GlobalObject* bunGlobalObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* bunGlobalObject = uncheckedDowncast(globalObject); return JSValue::encode( bunGlobalObject->JSDOMFileConstructor()); } @@ -2675,7 +2675,7 @@ JSC_DEFINE_CUSTOM_GETTER(getConsoleStdout, (JSGlobalObject * globalObject, Encod { auto& vm = JSC::getVM(globalObject); auto console = JSValue::decode(thisValue).getObject(); - auto global = uncheckedDowncast(globalObject); + auto global = uncheckedDowncast(globalObject); // instead of calling the constructor builtin, go through the process.stdout getter to ensure it's only created once. auto stdoutValue = global->processObject()->get(globalObject, Identifier::fromString(vm, "stdout"_s)); @@ -2690,7 +2690,7 @@ JSC_DEFINE_CUSTOM_GETTER(getConsoleStderr, (JSGlobalObject * globalObject, Encod { auto& vm = JSC::getVM(globalObject); auto console = JSValue::decode(thisValue).getObject(); - auto global = uncheckedDowncast(globalObject); + auto global = uncheckedDowncast(globalObject); // instead of calling the constructor builtin, go through the process.stdout getter to ensure it's only created once. auto stderrValue = global->processObject()->get(globalObject, Identifier::fromString(vm, "stderr"_s)); @@ -2716,7 +2716,7 @@ JSC_DEFINE_CUSTOM_GETTER(getConsoleStderr, (JSGlobalObject * globalObject, Encod JSC_DEFINE_CUSTOM_GETTER(getterName, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue, PropertyName name)) \ { \ auto& vm = JSC::getVM(lexicalGlobalObject); \ - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); \ + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); \ JSC::JSFunction* fn = globalObject->putDirectBuiltinFunction(vm, globalObject, name, codeGenerator(vm), (attributes)); \ return JSValue::encode(fn); \ } @@ -2796,7 +2796,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionCheckBufferRead, (JSC::JSGlobalObject * globa } extern "C" EncodedJSValue Bun__assignStreamIntoResumableSink(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue stream, JSC::EncodedJSValue sink) { - Zig::GlobalObject* globalThis = static_cast(globalObject); + Bun::GlobalObject* globalThis = static_cast(globalObject); return globalThis->assignStreamToResumableSink(JSValue::decode(stream), JSValue::decode(sink)); } EncodedJSValue GlobalObject::assignStreamToResumableSink(JSValue stream, JSValue sink) @@ -2856,7 +2856,7 @@ JSC_DEFINE_CUSTOM_GETTER(functionLazyNavigatorGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - return JSC::JSValue::encode(static_cast(globalObject)->navigatorObject()); + return JSC::JSValue::encode(static_cast(globalObject)->navigatorObject()); } JSC::GCClient::IsoSubspace* GlobalObject::subspaceForImpl(JSC::VM& vm) @@ -2876,12 +2876,12 @@ BUN_DECLARE_HOST_FUNCTION(WebCore__confirm); JSValue GlobalObject_getPerformanceObject(VM& vm, JSObject* globalObject) { - return uncheckedDowncast(globalObject)->performanceObject(); + return uncheckedDowncast(globalObject)->performanceObject(); } JSValue GlobalObject_getGlobalThis(VM& vm, JSObject* globalObject) { - return uncheckedDowncast(globalObject)->globalThis(); + return uncheckedDowncast(globalObject)->globalThis(); } // This is like `putDirectBuiltinFunction` but for the global static list. @@ -3039,7 +3039,7 @@ extern "C" size_t Bun__gc(void* vm, bool sync); JSC_DEFINE_HOST_FUNCTION(functionJsGc, (JSC::JSGlobalObject * global, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = defaultGlobalObject(global); + Bun::GlobalObject* globalObject = defaultGlobalObject(global); Bun__gc(globalObject->bunVM(), true); return JSValue::encode(jsUndefined()); } @@ -3100,12 +3100,12 @@ uint8_t GlobalObject::drainMicrotasks() return 0; } -extern "C" uint8_t JSC__JSGlobalObject__drainMicrotasks(Zig::GlobalObject* globalObject) +extern "C" uint8_t JSC__JSGlobalObject__drainMicrotasks(Bun::GlobalObject* globalObject) { return globalObject->drainMicrotasks(); } -extern "C" EncodedJSValue JSC__JSGlobalObject__getHTTP2CommonString(Zig::GlobalObject* globalObject, uint32_t hpack_index) +extern "C" EncodedJSValue JSC__JSGlobalObject__getHTTP2CommonString(Bun::GlobalObject* globalObject, uint32_t hpack_index) { auto value = globalObject->http2CommonStrings().getStringFromHPackIndex(hpack_index, globalObject); if (value != nullptr) { @@ -3129,7 +3129,7 @@ template static void visitGlobalObjectMember(Visitor& vi // The two unique_ptr members (m_builtinInternalFunctions, m_constructors) are // populated in the constructor initializer list, so in steady state this is // never null. The guard exists because the concurrent marker can visit a - // Zig::GlobalObject picked up via conservative stack scan while its own + // Bun::GlobalObject picked up via conservative stack scan while its own // IsoSubspace slot is being recycled from a previously-destroyed global whose // unique_ptr members were reset to null by ~unique_ptr(); until placement-new // re-initializes them there is a brief window where the pointer reads as null. @@ -3208,7 +3208,7 @@ extern "C" void JSGlobalObject__clearTerminationException(JSC::JSGlobalObject* g extern "C" void Bun__queueTask(JSC::JSGlobalObject*, WebCore::EventLoopTask* task); extern "C" void Bun__queueTaskConcurrently(JSC::JSGlobalObject*, WebCore::EventLoopTask* task); -extern "C" [[ZIG_EXPORT(check_slow)]] void Bun__performTask(Zig::GlobalObject* globalObject, WebCore::EventLoopTask* task) +extern "C" [[ZIG_EXPORT(check_slow)]] void Bun__performTask(Bun::GlobalObject* globalObject, WebCore::EventLoopTask* task) { task->performTask(*globalObject->scriptExecutionContext()); } @@ -3243,7 +3243,7 @@ void GlobalObject::queueTaskConcurrently(WebCore::EventLoopTask* task) Bun__queueTaskConcurrently(this, task); } -extern "C" void Bun__handleRejectedPromise(Zig::GlobalObject* JSGlobalObject, JSC::JSPromise* promise); +extern "C" void Bun__handleRejectedPromise(Bun::GlobalObject* JSGlobalObject, JSC::JSPromise* promise); void GlobalObject::handleRejectedPromises() { @@ -3293,13 +3293,13 @@ template void GlobalObject::visitOutputConstraints(JSCell*, SlotVisitor&); // void GlobalObject::destroy(JSCell* cell) // { -// uncheckedDowncast(cell)->Zig::GlobalObject::~Zig::GlobalObject(); +// uncheckedDowncast(cell)->Bun::GlobalObject::~Bun::GlobalObject(); // } // template // void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) // { -// Zig::GlobalObject* thisObject = uncheckedDowncast(cell); +// Bun::GlobalObject* thisObject = uncheckedDowncast(cell); // ASSERT_GC_OBJECT_INHERITS(thisObject, info()); // Base::visitChildren(thisObject, visitor); @@ -3320,7 +3320,7 @@ template void GlobalObject::visitOutputConstraints(JSCell*, SlotVisitor&); // thisObject->m_builtinInternalFunctions.visit(visitor); // } -// DEFINE_VISIT_CHILDREN(Zig::GlobalObject); +// DEFINE_VISIT_CHILDREN(Bun::GlobalObject); void GlobalObject::reload() { @@ -3343,11 +3343,11 @@ void GlobalObject::reload() extern "C" [[ZIG_EXPORT(check_slow)]] void JSC__JSGlobalObject__reload(JSC::JSGlobalObject* arg0) { - Zig::GlobalObject* globalObject = static_cast(arg0); + Bun::GlobalObject* globalObject = static_cast(arg0); globalObject->reload(); } -extern "C" void JSC__JSGlobalObject__queueMicrotaskCallback(Zig::GlobalObject* globalObject, void* ptr, MicrotaskCallback callback) +extern "C" void JSC__JSGlobalObject__queueMicrotaskCallback(Bun::GlobalObject* globalObject, void* ptr, MicrotaskCallback callback) { JSFunction* function = globalObject->nativeMicrotaskTrampoline(); @@ -3367,7 +3367,7 @@ JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject* jsGlobalObject JSModuleLoader* loader, JSValue key, JSValue referrer, RefPtr, bool) { - Zig::GlobalObject* globalObject = static_cast(jsGlobalObject); + Bun::GlobalObject* globalObject = static_cast(jsGlobalObject); ErrorableString res; res.success = false; @@ -3426,7 +3426,7 @@ JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject* jsGlobalObject } BunString queryString = { BunStringTag::Empty, nullptr }; - Zig__GlobalObject__resolve(&res, globalObject, &keyZ, &referrerZ, &queryString); + Bun__GlobalObject__resolve(&res, globalObject, &keyZ, &referrerZ, &queryString); keyZ.deref(); referrerZ.deref(); @@ -3456,7 +3456,7 @@ JSC::JSPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* jsGlobalO bool deferred) { UNUSED_PARAM(deferred); - auto* globalObject = static_cast(jsGlobalObject); + auto* globalObject = static_cast(jsGlobalObject); VM& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -3520,7 +3520,7 @@ JSC::JSPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* jsGlobalO auto sourceOriginZ = Bun::toStringRef(sourceOriginStringHolder); - Zig__GlobalObject__resolve(&resolved, globalObject, &moduleNameZ, &sourceOriginZ, &queryString); + Bun__GlobalObject__resolve(&resolved, globalObject, &moduleNameZ, &sourceOriginZ, &queryString); // If resolution failed, make sure it becomes a pending exception if (!resolved.success && !scope.exception()) [[unlikely]] { @@ -3623,7 +3623,7 @@ JSC::JSPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, // JSModuleLoader::loadModuleSync / VM::m_synchronousModuleQueue). if (vm.m_synchronousModuleQueue) { JSValue result = Bun::fetchESMSourceCodeSync( - static_cast(globalObject), + static_cast(globalObject), moduleKeyJS, &res, &moduleKeyBun, @@ -3638,7 +3638,7 @@ JSC::JSPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, } JSValue result = Bun::fetchESMSourceCodeAsync( - static_cast(globalObject), + static_cast(globalObject), moduleKeyJS, &res, &moduleKeyBun, @@ -3679,7 +3679,7 @@ JSC::JSValue EvalGlobalObject::moduleLoaderEvaluate(JSGlobalObject* lexicalGloba JSValue moduleRecordValue, RefPtr scriptFetcher, JSValue sentValue, JSValue resumeMode) { - Zig::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -3719,7 +3719,7 @@ JSC::JSValue EvalGlobalObject::moduleLoaderEvaluate(JSGlobalObject* lexicalGloba return result; } -extern "C" JSC::EncodedJSValue Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming(JSGlobalObject*, EncodedJSValue response, JSC::Wasm::StreamingCompiler* compiler); +extern "C" JSC::EncodedJSValue Bun__GlobalObject__getBodyStreamOrBytesForWasmStreaming(JSGlobalObject*, EncodedJSValue response, JSC::Wasm::StreamingCompiler* compiler); extern "C" void JSC__Wasm__StreamingCompiler__addBytes(JSC::Wasm::StreamingCompiler* compiler, const uint8_t* spanPtr, size_t spanSize) { @@ -3745,7 +3745,7 @@ static void handleResponseOnStreamingAction(JSGlobalObject* lexicalGlobalObject, // and the awaiting test hangs. Convert any thrown exception into a // rejection here. - auto readableStreamMaybe = JSC::JSValue::decode(Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming( + auto readableStreamMaybe = JSC::JSValue::decode(Bun__GlobalObject__getBodyStreamOrBytesForWasmStreaming( globalObject, JSC::JSValue::encode(source), compiler.ptr())); if (scope.exception()) [[unlikely]] { @@ -3933,9 +3933,9 @@ void GlobalObject::adoptNapiEnvsForTestIsolation(GlobalObject* oldGlobal) void GlobalObject::setNodeWorkerEnvironmentData(JSMap* data) { m_nodeWorkerEnvironmentData.set(vm(), this, data); } -extern "C" void Bun__InspectorConnection__disconnectAllOnExit(Zig::GlobalObject*); +extern "C" void Bun__InspectorConnection__disconnectAllOnExit(Bun::GlobalObject*); -extern "C" void Zig__GlobalObject__destructOnExit(Zig::GlobalObject* globalObject) +extern "C" void Bun__GlobalObject__destructOnExit(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); if (vm.entryScope) { @@ -3970,12 +3970,12 @@ extern "C" void Zig__GlobalObject__destructOnExit(Zig::GlobalObject* globalObjec } #include "ZigGeneratedClasses+lazyStructureImpl.h" -#include "ZigGlobalObject.lut.h" +#include "BunGlobalObject.lut.h" const JSC::ClassInfo GlobalObject::s_info = { "GlobalObject"_s, &Base::s_info, &bunGlobalObjectTable, nullptr, CREATE_METHOD_TABLE(GlobalObject) }; -} // namespace Zig +} // namespace Bun JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplemented, (JSGlobalObject * leixcalGlobalObject, CallFrame* callFrame)) { diff --git a/src/jsc/bindings/ZigGlobalObject.h b/src/jsc/bindings/BunGlobalObject.h similarity index 97% rename from src/jsc/bindings/ZigGlobalObject.h rename to src/jsc/bindings/BunGlobalObject.h index eae5d1cc5a6f..c52dad7af872 100644 --- a/src/jsc/bindings/ZigGlobalObject.h +++ b/src/jsc/bindings/BunGlobalObject.h @@ -3,11 +3,10 @@ // Be very cautious of sticking your #include in this file // or adding anything into this file other than LazyClassStructure or LazyProperty // ** WARNING ** -// TODO: rename this to BunGlobalObject #pragma once -#ifndef ZIG_GLOBAL_OBJECT -#define ZIG_GLOBAL_OBJECT +#ifndef BUN_GLOBAL_OBJECT +#define BUN_GLOBAL_OBJECT namespace JSC { class Structure; @@ -89,17 +88,19 @@ extern "C" bool Bun__VirtualMachine__isShuttingDown(void* /* BunVM */); #if OS(WINDOWS) #include -extern "C" uv_loop_t* Bun__ZigGlobalObject__uvLoop(void* /* BunVM */); +extern "C" uv_loop_t* Bun__GlobalObject__uvLoop(void* /* BunVM */); #endif namespace Zig { - class JSCStackTrace; +} // namespace Zig + +namespace Bun { using JSDOMStructureMap = UncheckedKeyHashMap>; using DOMGuardedObjectSet = UncheckedKeyHashSet; -#define ZIG_GLOBAL_OBJECT_DEFINED +#define BUN_GLOBAL_OBJECT_DEFINED class GlobalObject : public Bun::GlobalScope { using Base = Bun::GlobalScope; @@ -353,7 +354,7 @@ class GlobalObject : public Bun::GlobalScope { #if OS(WINDOWS) uv_loop_t* uvLoop() const { - return Bun__ZigGlobalObject__uvLoop(m_bunVM); + return Bun__GlobalObject__uvLoop(m_bunVM); } #endif bool isThreadLocalDefaultGlobalObject = false; @@ -466,7 +467,7 @@ class GlobalObject : public Bun::GlobalScope { // - Make sure the type can be written with no commas in its name. This is because a type with // commas will count as two macro parameters instead of one. You can add a `using` declaration // like above to create an alias for a complex template type without a comma. - // - Make sure `visitGlobalObjectMember` in `ZigGlobalObject.cpp` can handle your type. + // - Make sure `visitGlobalObjectMember` in `BunGlobalObject.cpp` can handle your type. // Currently it has overloads to handle: // // - any class with a `visit` method (this covers LazyProperty and LazyClassStructure) @@ -718,8 +719,8 @@ class GlobalObject : public Bun::GlobalScope { String agentClusterID() const; static String defaultAgentClusterID(); - BunPlugin::OnLoad onLoadPlugins {}; - BunPlugin::OnResolve onResolvePlugins {}; + Zig::BunPlugin::OnLoad onLoadPlugins {}; + Zig::BunPlugin::OnResolve onResolvePlugins {}; // This increases the cache hit rate for JSC::VM's SourceProvider cache // It also avoids an extra allocation for the SourceProvider @@ -799,11 +800,11 @@ class EvalGlobalObject : public GlobalObject { } }; -} // namespace Zig +} // namespace Bun namespace Bun { -ALWAYS_INLINE void* vm(Zig::GlobalObject* globalObject) +ALWAYS_INLINE void* vm(Bun::GlobalObject* globalObject) { return globalObject->bunVM(); } @@ -823,42 +824,42 @@ ALWAYS_INLINE void* vm(JSC::JSGlobalObject* lexicalGlobalObject) #ifndef RENAMED_JSDOM_GLOBAL_OBJECT #define RENAMED_JSDOM_GLOBAL_OBJECT namespace WebCore { -using JSDOMGlobalObject = Zig::GlobalObject; +using JSDOMGlobalObject = Bun::GlobalObject; } #endif // Do not use this directly. namespace ___private___ { -extern "C" Zig::GlobalObject* Bun__getDefaultGlobalObject(); -inline Zig::GlobalObject* getDefaultGlobalObject() +extern "C" Bun::GlobalObject* Bun__getDefaultGlobalObject(); +inline Bun::GlobalObject* getDefaultGlobalObject() { return Bun__getDefaultGlobalObject(); } } -inline Zig::GlobalObject* defaultGlobalObject(JSC::JSGlobalObject* lexicalGlobalObject) +inline Bun::GlobalObject* defaultGlobalObject(JSC::JSGlobalObject* lexicalGlobalObject) { - auto* globalObject = dynamicDowncast(lexicalGlobalObject); + auto* globalObject = dynamicDowncast(lexicalGlobalObject); if (!globalObject) { return ___private___::getDefaultGlobalObject(); } return globalObject; } -inline Zig::GlobalObject* defaultGlobalObject() +inline Bun::GlobalObject* defaultGlobalObject() { return ___private___::getDefaultGlobalObject(); } inline void* bunVM(JSC::JSGlobalObject* lexicalGlobalObject) { - if (auto* globalObject = dynamicDowncast(lexicalGlobalObject)) { + if (auto* globalObject = dynamicDowncast(lexicalGlobalObject)) { return globalObject->bunVM(); } return WebCore::clientData(lexicalGlobalObject->vm())->bunVM; } -inline void* bunVM(Zig::GlobalObject* globalObject) +inline void* bunVM(Bun::GlobalObject* globalObject) { return globalObject->bunVM(); } @@ -866,10 +867,10 @@ inline void* bunVM(Zig::GlobalObject* globalObject) JSC_DECLARE_HOST_FUNCTION(jsFunctionNotImplemented); JSC_DECLARE_HOST_FUNCTION(jsFunctionCreateFunctionThatMasqueradesAsUndefined); -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToText(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBytes(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToJSON(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBlob(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToText(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToArrayBuffer(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToBytes(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToJSON(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToBlob(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue); #endif diff --git a/src/jsc/bindings/ZigGlobalObject.lut.txt b/src/jsc/bindings/BunGlobalObject.lut.txt similarity index 97% rename from src/jsc/bindings/ZigGlobalObject.lut.txt rename to src/jsc/bindings/BunGlobalObject.lut.txt index 9ccc124f252c..fe6057f0471e 100644 --- a/src/jsc/bindings/ZigGlobalObject.lut.txt +++ b/src/jsc/bindings/BunGlobalObject.lut.txt @@ -1,6 +1,6 @@ -// In a separate file because processing ZigGlobalObject.cpp takes 15+ seconds +// In a separate file because processing BunGlobalObject.cpp takes 15+ seconds -/* Source for ZigGlobalObject.lut.h +/* Source for BunGlobalObject.lut.h @begin bunGlobalObjectTable addEventListener jsFunctionAddEventListener Function 2 alert WebCore__alert Function 1 diff --git a/src/jsc/bindings/BunGlobalScope.cpp b/src/jsc/bindings/BunGlobalScope.cpp index 694e720fe5f2..576937f87186 100644 --- a/src/jsc/bindings/BunGlobalScope.cpp +++ b/src/jsc/bindings/BunGlobalScope.cpp @@ -1,6 +1,6 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "BunGlobalScope.h" #include "JavaScriptCore/VM.h" #include "JavaScriptCore/VMTraps.h" diff --git a/src/jsc/bindings/BunHttp2CommonStrings.cpp b/src/jsc/bindings/BunHttp2CommonStrings.cpp index e1eba23d6aa1..02803a106dca 100644 --- a/src/jsc/bindings/BunHttp2CommonStrings.cpp +++ b/src/jsc/bindings/BunHttp2CommonStrings.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include diff --git a/src/jsc/bindings/BunMarkdownMeta.cpp b/src/jsc/bindings/BunMarkdownMeta.cpp index a125099b65ee..bf726a9959f4 100644 --- a/src/jsc/bindings/BunMarkdownMeta.cpp +++ b/src/jsc/bindings/BunMarkdownMeta.cpp @@ -64,7 +64,7 @@ extern "C" JSC::EncodedJSValue BunMarkdownMeta__createListItem( EncodedJSValue start, EncodedJSValue checked) { - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); VM& vm = global->vm(); JSObject* obj = constructEmptyObject(vm, global->JSMarkdownListItemMetaStructure()); @@ -83,7 +83,7 @@ extern "C" JSC::EncodedJSValue BunMarkdownMeta__createList( EncodedJSValue start, uint32_t depth) { - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); VM& vm = global->vm(); JSObject* obj = constructEmptyObject(vm, global->JSMarkdownListMetaStructure()); @@ -98,7 +98,7 @@ extern "C" JSC::EncodedJSValue BunMarkdownMeta__createCell( JSGlobalObject* globalObject, EncodedJSValue align) { - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); VM& vm = global->vm(); JSObject* obj = constructEmptyObject(vm, global->JSMarkdownCellMetaStructure()); @@ -112,7 +112,7 @@ extern "C" JSC::EncodedJSValue BunMarkdownMeta__createLink( EncodedJSValue href, EncodedJSValue title) { - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); VM& vm = global->vm(); JSObject* obj = constructEmptyObject(vm, global->JSMarkdownLinkMetaStructure()); diff --git a/src/jsc/bindings/BunMarkdownMeta.h b/src/jsc/bindings/BunMarkdownMeta.h index 8d24e9d04478..056bc4dd2a08 100644 --- a/src/jsc/bindings/BunMarkdownMeta.h +++ b/src/jsc/bindings/BunMarkdownMeta.h @@ -2,7 +2,7 @@ #include "root.h" #include "headers.h" #include "JavaScriptCore/JSObjectInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" using namespace JSC; diff --git a/src/jsc/bindings/BunMarkdownTagStrings.cpp b/src/jsc/bindings/BunMarkdownTagStrings.cpp index 299f3cbc7271..714aebc670d5 100644 --- a/src/jsc/bindings/BunMarkdownTagStrings.cpp +++ b/src/jsc/bindings/BunMarkdownTagStrings.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -37,7 +37,7 @@ template void MarkdownTagStrings::visit(JSC::SlotVisitor&); } // namespace Bun // C API for the Rust bindings -extern "C" JSC::EncodedJSValue BunMarkdownTagStrings__getTagString(Zig::GlobalObject* globalObject, uint8_t tagIndex) +extern "C" JSC::EncodedJSValue BunMarkdownTagStrings__getTagString(Bun::GlobalObject* globalObject, uint8_t tagIndex) { if (tagIndex >= MARKDOWN_TAG_STRINGS_COUNT) return JSC::JSValue::encode(JSC::jsUndefined()); diff --git a/src/jsc/bindings/BunObject.cpp b/src/jsc/bindings/BunObject.cpp index 23554a77f449..67c4b0e76424 100644 --- a/src/jsc/bindings/BunObject.cpp +++ b/src/jsc/bindings/BunObject.cpp @@ -2,7 +2,7 @@ #include "JavaScriptCore/HeapProfiler.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/ArgList.h" #include "JSDOMURL.h" #include "helpers.h" @@ -96,7 +96,7 @@ extern "C" bool has_bun_garbage_collector_flag_enabled; static JSValue BunObject_lazyPropCb_wrap_ArrayBufferSink(VM& vm, JSObject* bunObject) { - return uncheckedDowncast(bunObject->globalObject())->ArrayBufferSink(); + return uncheckedDowncast(bunObject->globalObject())->ArrayBufferSink(); } static JSValue constructCookieObject(VM& vm, JSObject* bunObject); @@ -106,7 +106,7 @@ static JSValue constructWebViewObject(VM& vm, JSObject* bunObject); static JSValue constructEnvObject(VM& vm, JSObject* object) { - return uncheckedDowncast(object->globalObject())->processEnvObject(); + return uncheckedDowncast(object->globalObject())->processEnvObject(); } static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Array(JSGlobalObject* lexicalGlobalObject, JSValue arrayValue, size_t maxLength, bool asUint8Array) @@ -300,7 +300,7 @@ static JSValue constructBunVersionWithSha(VM& vm, JSObject*) static JSValue constructIsMainThread(VM&, JSObject* object) { - return jsBoolean(uncheckedDowncast(object->globalObject())->scriptExecutionContext()->isMainThread()); + return jsBoolean(uncheckedDowncast(object->globalObject())->scriptExecutionContext()->isMainThread()); } static JSValue constructPluginObject(VM& vm, JSObject* bunObject) @@ -349,7 +349,7 @@ JSValue constructBunFetchObject(VM& vm, JSObject* bunObject) { JSFunction* fetchFn = JSFunction::create(vm, bunObject->globalObject(), 1, "fetch"_s, Bun__fetch, ImplementationVisibility::Public, NoIntrinsic); - auto* globalObject = uncheckedDowncast(bunObject->globalObject()); + auto* globalObject = uncheckedDowncast(bunObject->globalObject()); fetchFn->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "preconnect"_s), 1, Bun__fetchPreconnect, ImplementationVisibility::Public, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0); @@ -358,7 +358,7 @@ JSValue constructBunFetchObject(VM& vm, JSObject* bunObject) static JSValue constructBunShell(VM& vm, JSObject* bunObject) { - auto* globalObject = uncheckedDowncast(bunObject->globalObject()); + auto* globalObject = uncheckedDowncast(bunObject->globalObject()); JSFunction* createParsedShellScript = JSFunction::create(vm, bunObject->globalObject(), 2, "createParsedShellScript"_s, BunObject_callback_createParsedShellScript, ImplementationVisibility::Private, NoIntrinsic); JSFunction* createShellInterpreterFunction = JSFunction::create(vm, bunObject->globalObject(), 1, "createShellInterpreter"_s, BunObject_callback_createShellInterpreter, ImplementationVisibility::Private, NoIntrinsic); JSC::JSFunction* createShellFn = JSC::JSFunction::create(vm, globalObject, shellCreateBunShellTemplateFunctionCodeGenerator(vm), globalObject); @@ -620,7 +620,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionJSONLParseChunk, (JSGlobalObject * globalObje errorValue = createSyntaxError(globalObject, "Failed to parse JSONL"_s); } - auto* zigGlobalObject = uncheckedDowncast(globalObject); + auto* zigGlobalObject = uncheckedDowncast(globalObject); JSObject* resultObj = constructEmptyObject(vm, zigGlobalObject->jsonlParseResultStructure()); resultObj->putDirectOffset(vm, 0, array); resultObj->putDirectOffset(vm, 1, jsNumber(readBytes)); @@ -1098,19 +1098,19 @@ static JSC_DEFINE_CUSTOM_SETTER(setBunObjectMain, (JSC::JSGlobalObject * globalO // LazyProperty wrappers for stdin/stderr/stdout static JSValue BunObject_lazyPropCb_wrap_stdin(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); + auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); return zigGlobalObject->m_bunStdin.getInitializedOnMainThread(zigGlobalObject); } static JSValue BunObject_lazyPropCb_wrap_stderr(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); + auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); return zigGlobalObject->m_bunStderr.getInitializedOnMainThread(zigGlobalObject); } static JSValue BunObject_lazyPropCb_wrap_stdout(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); + auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); return zigGlobalObject->m_bunStdout.getInitializedOnMainThread(zigGlobalObject); } @@ -1128,31 +1128,31 @@ const JSC::ClassInfo JSBunObject::s_info = { "Bun"_s, &Base::s_info, &bunObjectT static JSValue constructCookieObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); + auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); return WebCore::JSCookie::getConstructor(vm, zigGlobalObject); } static JSValue constructCookieMapObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); + auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); return WebCore::JSCookieMap::getConstructor(vm, zigGlobalObject); } static JSValue constructSecretsObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); + auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); return Bun::createSecretsObject(vm, zigGlobalObject); } static JSValue constructWebViewObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); + auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); return zigGlobalObject->m_JSWebViewClassStructure.constructor(zigGlobalObject); } JSC::JSObject* createBunObject(VM& vm, JSObject* globalObject) { - return JSBunObject::create(vm, uncheckedDowncast(globalObject)); + return JSBunObject::create(vm, uncheckedDowncast(globalObject)); } static void exportBunObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* object, Vector& exportNames, JSC::MarkedArgumentBuffer& exportValues) @@ -1192,7 +1192,7 @@ void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject, JSC::MarkedArgumentBuffer& exportValues) { auto& vm = JSC::getVM(lexicalGlobalObject); - Zig::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); auto* object = globalObject->bunObject(); diff --git a/src/jsc/bindings/BunPlugin.cpp b/src/jsc/bindings/BunPlugin.cpp index f5526c59a007..41bc06c10266 100644 --- a/src/jsc/bindings/BunPlugin.cpp +++ b/src/jsc/bindings/BunPlugin.cpp @@ -5,7 +5,7 @@ #include "JavaScriptCore/JSCast.h" #include "headers-handwritten.h" #include "helpers.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -143,7 +143,7 @@ static EncodedJSValue jsFunctionAppendVirtualModulePluginBody(JSC::JSGlobalObjec return {}; } - Zig::GlobalObject* global = defaultGlobalObject(globalObject); + Bun::GlobalObject* global = defaultGlobalObject(globalObject); if (global->onLoadPlugins.virtualModules == nullptr) { global->onLoadPlugins.virtualModules = new BunPlugin::VirtualModuleMap; @@ -228,7 +228,7 @@ static JSC::EncodedJSValue jsFunctionAppendOnResolvePluginBody(JSC::JSGlobalObje static JSC::EncodedJSValue jsFunctionAppendOnResolvePluginGlobal(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe, BunPluginTarget target) { - Zig::GlobalObject* global = defaultGlobalObject(globalObject); + Bun::GlobalObject* global = defaultGlobalObject(globalObject); auto& plugins = global->onResolvePlugins; auto callback = Bun__onDidAppendPlugin; @@ -237,7 +237,7 @@ static JSC::EncodedJSValue jsFunctionAppendOnResolvePluginGlobal(JSC::JSGlobalOb static JSC::EncodedJSValue jsFunctionAppendOnLoadPluginGlobal(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe, BunPluginTarget target) { - Zig::GlobalObject* global = defaultGlobalObject(globalObject); + Bun::GlobalObject* global = defaultGlobalObject(globalObject); auto& plugins = global->onLoadPlugins; auto callback = Bun__onDidAppendPlugin; @@ -397,7 +397,7 @@ JSC::JSObject* BunPlugin::Group::find(JSC::JSGlobalObject* globalObject, String& void BunPlugin::OnLoad::addModuleMock(JSC::VM& vm, const String& path, JSC::JSObject* mockObject) { - Zig::GlobalObject* globalObject = defaultGlobalObject(mockObject->globalObject()); + Bun::GlobalObject* globalObject = defaultGlobalObject(mockObject->globalObject()); if (globalObject->onLoadPlugins.virtualModules == nullptr) { globalObject->onLoadPlugins.virtualModules = new BunPlugin::VirtualModuleMap; @@ -506,7 +506,7 @@ BUN_DECLARE_HOST_FUNCTION(JSMock__jsModuleMock); extern "C" JSC_DEFINE_HOST_FUNCTION(JSMock__jsModuleMock, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callframe)) { auto& vm = JSC::getVM(lexicalGlobalObject); - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); if (!globalObject) [[unlikely]] { scope.throwException(lexicalGlobalObject, JSC::createTypeError(lexicalGlobalObject, "Cannot run mock from a different global context"_s)); @@ -883,12 +883,12 @@ EncodedJSValue BunPlugin::OnResolve::run(JSC::JSGlobalObject* globalObject, BunS } // namespace Zig -extern "C" JSC::EncodedJSValue Bun__runOnResolvePlugins(Zig::GlobalObject* globalObject, BunString* namespaceString, BunString* path, BunString* from, BunPluginTarget target) +extern "C" JSC::EncodedJSValue Bun__runOnResolvePlugins(Bun::GlobalObject* globalObject, BunString* namespaceString, BunString* path, BunString* from, BunPluginTarget target) { return globalObject->onResolvePlugins.run(globalObject, namespaceString, path, from); } -extern "C" JSC::EncodedJSValue Bun__runOnLoadPlugins(Zig::GlobalObject* globalObject, BunString* namespaceString, BunString* path, BunPluginTarget target) +extern "C" JSC::EncodedJSValue Bun__runOnLoadPlugins(Bun::GlobalObject* globalObject, BunString* namespaceString, BunString* path, BunPluginTarget target) { return globalObject->onLoadPlugins.run(globalObject, namespaceString, path); } @@ -900,7 +900,7 @@ Structure* createModuleMockStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObj return Zig::JSModuleMock::createStructure(vm, globalObject, prototype); } -JSC::JSValue runVirtualModule(Zig::GlobalObject* globalObject, BunString* specifier, bool& wasModuleMock) +JSC::JSValue runVirtualModule(Bun::GlobalObject* globalObject, BunString* specifier, bool& wasModuleMock) { auto fallback = [&]() -> JSC::JSValue { return JSValue::decode(Bun__runVirtualModule(globalObject, specifier)); @@ -962,7 +962,7 @@ JSC::JSValue runVirtualModule(Zig::GlobalObject* globalObject, BunString* specif BUN_DEFINE_HOST_FUNCTION(jsFunctionBunPluginClear, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { - Zig::GlobalObject* global = static_cast(globalObject); + Bun::GlobalObject* global = static_cast(globalObject); global->onLoadPlugins.fileNamespace.clear(); global->onResolvePlugins.fileNamespace.clear(); global->onLoadPlugins.groups.clear(); diff --git a/src/jsc/bindings/BunPlugin.h b/src/jsc/bindings/BunPlugin.h index 458138325420..b24823d5986a 100644 --- a/src/jsc/bindings/BunPlugin.h +++ b/src/jsc/bindings/BunPlugin.h @@ -99,11 +99,10 @@ class BunPlugin { }; }; -class GlobalObject; - } // namespace Zig namespace Bun { -JSC::JSValue runVirtualModule(Zig::GlobalObject*, BunString* specifier, bool& wasModuleMock); +class GlobalObject; +JSC::JSValue runVirtualModule(Bun::GlobalObject*, BunString* specifier, bool& wasModuleMock); JSC::Structure* createModuleMockStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype); } diff --git a/src/jsc/bindings/BunProcess.cpp b/src/jsc/bindings/BunProcess.cpp index 86a9622c33ac..c4242dbe2a18 100644 --- a/src/jsc/bindings/BunProcess.cpp +++ b/src/jsc/bindings/BunProcess.cpp @@ -29,7 +29,7 @@ #include "JavaScriptCore/PutPropertySlot.h" #include "ScriptExecutionContext.h" #include "headers-handwritten.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "FormatStackTraceForJS.h" #include "headers.h" #include "JSEnvironmentVariableMap.h" @@ -169,8 +169,8 @@ extern "C" bool Bun__ensureProcessIPCInitialized(JSGlobalObject*); extern "C" const char* Bun__githubURL; BUN_DECLARE_HOST_FUNCTION(Bun__Process__send); -extern "C" void Process__emitDisconnectEvent(Zig::GlobalObject* global); -extern "C" void Process__emitErrorEvent(Zig::GlobalObject* global, EncodedJSValue value); +extern "C" void Process__emitDisconnectEvent(Bun::GlobalObject* global); +extern "C" void Process__emitErrorEvent(Bun::GlobalObject* global, EncodedJSValue value); extern "C" void Bun__suppressCrashOnProcessKillSelfIfDesired(); @@ -388,7 +388,7 @@ extern "C" bool Bun__VM__allowAddons(void* vm); JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, (JSC::JSGlobalObject * globalObject_, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = static_cast(globalObject_); + Bun::GlobalObject* globalObject = static_cast(globalObject_); auto callCountAtStart = globalObject->napiModuleRegisterCallCount; auto scope = DECLARE_THROW_SCOPE(JSC::getVM(globalObject)); auto& vm = JSC::getVM(globalObject); @@ -820,7 +820,7 @@ extern "C" double Bun__readOriginTimerStart(void*); extern "C" void Bun__VirtualMachine__exitDuringUncaughtException(void*); // https://github.com/nodejs/node/blob/1936160c31afc9780e4365de033789f39b7cbc0c/src/api/hooks.cc#L49 -extern "C" void Process__dispatchOnBeforeExit(Zig::GlobalObject* globalObject, uint8_t exitCode) +extern "C" void Process__dispatchOnBeforeExit(Bun::GlobalObject* globalObject, uint8_t exitCode) { if (!globalObject->hasProcessObject()) { return; @@ -839,7 +839,7 @@ extern "C" void Process__dispatchOnBeforeExit(Zig::GlobalObject* globalObject, u } } -extern "C" void Process__dispatchOnExit(Zig::GlobalObject* globalObject, uint8_t exitCode) +extern "C" void Process__dispatchOnExit(Bun::GlobalObject* globalObject, uint8_t exitCode) { if (!globalObject->hasProcessObject()) { return; @@ -886,7 +886,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionExit, (JSC::JSGlobalObject * globalObje JSC_DEFINE_HOST_FUNCTION(Process_setUncaughtExceptionCaptureCallback, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - auto* globalObject = static_cast(lexicalGlobalObject); + auto* globalObject = static_cast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); auto arg0 = callFrame->argument(0); @@ -924,7 +924,7 @@ extern "C" uint64_t Bun__readOriginTimer(void*); JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, (JSC::JSGlobalObject * globalObject_, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = static_cast(globalObject_); + Bun::GlobalObject* globalObject = static_cast(globalObject_); auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -978,7 +978,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, (JSC::JSGlobalObject * globalOb JSC_DEFINE_HOST_FUNCTION(Process_functionHRTimeBigInt, (JSC::JSGlobalObject * globalObject_, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = static_cast(globalObject_); + Bun::GlobalObject* globalObject = static_cast(globalObject_); return JSC::JSValue::encode(JSValue(JSC::JSBigInt::createFrom(globalObject, Bun__readOriginTimer(globalObject->bunVM())))); } @@ -1158,7 +1158,7 @@ bool isSignalName(WTF::String input) return signalNameToNumberMap->contains(input); } -extern "C" void Bun__onSignalForJS(int signalNumber, Zig::GlobalObject* globalObject) +extern "C" void Bun__onSignalForJS(int signalNumber, Bun::GlobalObject* globalObject) { Process* process = globalObject->processObject(); @@ -1192,7 +1192,7 @@ void signalHandler(uv_signal_t* signal, int signalNumber) // uv_signal_t callbacks fire on the uv_run thread (JS thread), but defer to avoid // re-entering JS from inside the libuv poll loop context->postTaskConcurrently([signalNumber](ScriptExecutionContext& context) { - Bun__onSignalForJS(signalNumber, uncheckedDowncast(context.jsGlobalObject())); + Bun__onSignalForJS(signalNumber, uncheckedDowncast(context.jsGlobalObject())); }); #else @@ -1203,9 +1203,9 @@ extern "C" void Bun__logUnhandledException(JSC::EncodedJSValue exception); extern "C" int Bun__handleUncaughtException(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue exception, int isRejection) { - if (!lexicalGlobalObject->inherits(Zig::GlobalObject::info())) + if (!lexicalGlobalObject->inherits(Bun::GlobalObject::info())) return false; - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto* process = globalObject->processObject(); auto& wrapped = process->wrapped(); auto& vm = JSC::getVM(globalObject); @@ -1322,9 +1322,9 @@ extern "C" void Bun__promises__emitUnhandledRejectionWarning(JSC::JSGlobalObject extern "C" int Bun__handleUnhandledRejection(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue reason, JSC::JSValue promise) { - if (!lexicalGlobalObject->inherits(Zig::GlobalObject::info())) + if (!lexicalGlobalObject->inherits(Bun::GlobalObject::info())) return false; - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto* process = globalObject->processObject(); auto eventType = Identifier::fromString(JSC::getVM(globalObject), "unhandledRejection"_s); @@ -1345,9 +1345,9 @@ extern "C" bool Bun__VM__allowRejectionHandledWarning(void* vm); extern "C" bool Bun__emitHandledPromiseEvent(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue promise) { auto scope = DECLARE_TOP_EXCEPTION_SCOPE(JSC::getVM(lexicalGlobalObject)); - if (!lexicalGlobalObject->inherits(Zig::GlobalObject::info())) + if (!lexicalGlobalObject->inherits(Bun::GlobalObject::info())) return false; - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto* process = globalObject->processObject(); auto eventType = Identifier::fromString(JSC::getVM(globalObject), "rejectionHandled"_s); @@ -1630,7 +1630,7 @@ static int persistStandardStream(int fd) JSC_DEFINE_HOST_FUNCTION(Process_functionExecve, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1849,7 +1849,7 @@ static bool isJSValueEqualToASCIILiteral(JSC::JSGlobalObject* globalObject, JSC: return view == literal; } -extern "C" void Bun__Process__emitWarning(Zig::GlobalObject* globalObject, EncodedJSValue warning, EncodedJSValue type, EncodedJSValue code, EncodedJSValue ctor) +extern "C" void Bun__Process__emitWarning(Bun::GlobalObject* globalObject, EncodedJSValue warning, EncodedJSValue type, EncodedJSValue code, EncodedJSValue ctor) { // ignoring return value -- emitWarning only ever returns undefined or throws (void)Process::emitWarning( @@ -1862,7 +1862,7 @@ extern "C" void Bun__Process__emitWarning(Zig::GlobalObject* globalObject, Encod JSValue Process::emitWarningErrorInstance(JSC::JSGlobalObject* lexicalGlobalObject, JSValue errorInstance) { - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); VM& vm = getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); auto* process = globalObject->processObject(); @@ -1893,7 +1893,7 @@ JSValue Process::emitWarningErrorInstance(JSC::JSGlobalObject* lexicalGlobalObje } JSValue Process::emitWarning(JSC::JSGlobalObject* lexicalGlobalObject, JSValue warning, JSValue type, JSValue code, JSValue ctor) { - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); VM& vm = getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); JSValue detail = jsUndefined(); @@ -1961,7 +1961,7 @@ JSValue Process::emitWarning(JSC::JSGlobalObject* lexicalGlobalObject, JSValue w if (ctor.toBoolean(globalObject)) { caller = ctor; } else { - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto* process = globalObject->processObject(); caller = process->get(globalObject, Identifier::fromString(vm, String("emitWarning"_s))); RETURN_IF_EXCEPTION(scope, {}); @@ -1975,7 +1975,7 @@ JSValue Process::emitWarning(JSC::JSGlobalObject* lexicalGlobalObject, JSValue w JSC_DEFINE_HOST_FUNCTION(Process_emitWarning, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); auto warning = callFrame->argument(0); auto type = callFrame->argument(1); auto code = callFrame->argument(2); @@ -2044,7 +2044,7 @@ JSC_DEFINE_CUSTOM_SETTER(setProcessConnected, (JSC::JSGlobalObject * lexicalGlob return false; } -static JSValue constructReportObjectComplete(VM& vm, Zig::GlobalObject* globalObject, const String& fileName) +static JSValue constructReportObjectComplete(VM& vm, Bun::GlobalObject* globalObject, const String& fileName) { auto scope = DECLARE_THROW_SCOPE(vm); #if !OS(WINDOWS) @@ -2422,7 +2422,7 @@ static JSValue constructReportObjectComplete(VM& vm, Zig::GlobalObject* globalOb } #else // OS(WINDOWS) // Forward declaration - implemented in BunProcessReportObjectWindows.cpp - JSValue constructReportObjectWindows(VM & vm, Zig::GlobalObject * globalObject, Process * process); + JSValue constructReportObjectWindows(VM & vm, Bun::GlobalObject * globalObject, Process * process); // Get the Process object - needed for accessing report settings Process* process = globalObject->processObject(); @@ -2435,7 +2435,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionGetReport, (JSGlobalObject * globalObje { auto& vm = JSC::getVM(globalObject); // TODO: node:vm - return JSValue::encode(constructReportObjectComplete(vm, uncheckedDowncast(globalObject), String())); + return JSValue::encode(constructReportObjectComplete(vm, uncheckedDowncast(globalObject), String())); } JSC_DEFINE_HOST_FUNCTION(Process_functionWriteReport, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) @@ -2606,7 +2606,7 @@ static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, JSC: auto result = JSC::profiledCall(globalObject, ProfilingReason::API, getStdioWriteStream, callData, globalObject->globalThis(), args); if (auto* exception = scope.exception()) { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return jsUndefined(); } @@ -2667,7 +2667,7 @@ static JSValue constructStdin(VM& vm, JSObject* processObject) auto result = JSC::profiledCall(globalObject, ProfilingReason::API, getStdinStream, callData, globalObject, args); if (auto* exception = scope.exception()) { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return jsUndefined(); } return result; @@ -2921,7 +2921,7 @@ static JSValue constructRevision(VM& vm, JSObject* processObject) static JSValue constructEnv(VM& vm, JSObject* processObject) { - auto* globalObject = uncheckedDowncast(processObject->globalObject()); + auto* globalObject = uncheckedDowncast(processObject->globalObject()); return globalObject->processEnvObject(); } @@ -3162,12 +3162,12 @@ JSC_DEFINE_HOST_FUNCTION(Process_availableMemory, (JSGlobalObject * globalObject return JSValue::encode(JSValue {}); \ } -inline JSValue processBindingUtil(Zig::GlobalObject* globalObject, JSC::VM& vm) +inline JSValue processBindingUtil(Bun::GlobalObject* globalObject, JSC::VM& vm) { return globalObject->internalModuleRegistry()->requireId(globalObject, vm, InternalModuleRegistry::NodeUtilTypes); } -inline JSValue processBindingConfig(Zig::GlobalObject* globalObject, JSC::VM& vm) +inline JSValue processBindingConfig(Bun::GlobalObject* globalObject, JSC::VM& vm) { auto config = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 9); #ifdef BUN_DEBUG @@ -3198,7 +3198,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionBinding, (JSGlobalObject * jsGlobalObje { auto& vm = JSC::getVM(jsGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); - auto globalObject = uncheckedDowncast(jsGlobalObject); + auto globalObject = uncheckedDowncast(jsGlobalObject); auto process = globalObject->processObject(); auto moduleName = callFrame->argument(0).toWTFString(globalObject); RETURN_IF_EXCEPTION(throwScope, {}); @@ -3347,7 +3347,7 @@ static Process* getProcessObject(JSC::JSGlobalObject* lexicalGlobalObject, JSVal // Handle "var memoryUsage = process.memoryUsage; memoryUsage()" if (!process) [[unlikely]] { // Handle calling this function from inside a node:vm - Zig::GlobalObject* zigGlobalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(lexicalGlobalObject); return zigGlobalObject->processObject(); } @@ -3650,7 +3650,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsageRSS, (JSC::JSGlobalObject * JSC_DEFINE_HOST_FUNCTION(Process_functionOpenStdin, (JSGlobalObject * globalObject, CallFrame* callFrame)) { auto& vm = JSC::getVM(globalObject); - Zig::GlobalObject* global = defaultGlobalObject(globalObject); + Bun::GlobalObject* global = defaultGlobalObject(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); auto stdinValue = global->processObject()->getIfPropertyExists(globalObject, Identifier::fromString(vm, "stdin"_s)); @@ -3750,7 +3750,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_stubEmptyFunction, (JSGlobalObject * globalObje JSC_DEFINE_HOST_FUNCTION(Process_setSourceMapsEnabled, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -3866,7 +3866,7 @@ void Process::queueNextTick(JSC::JSGlobalObject* globalObject, JSValue func, con this->queueNextTick(globalObject, argsBuffer); } -void Process::emitOnNextTick(Zig::GlobalObject* globalObject, ASCIILiteral eventName, JSValue event) +void Process::emitOnNextTick(Bun::GlobalObject* globalObject, ASCIILiteral eventName, JSValue event) { auto& vm = getVM(globalObject); auto* function = m_emitHelperFunction.getInitializedOnMainThread(this); @@ -3907,7 +3907,7 @@ static JSValue constructMainModuleProperty(VM& vm, JSObject* processObject) return mainModule; } -JSValue Process::constructNextTickFn(JSC::VM& vm, Zig::GlobalObject* globalObject) +JSValue Process::constructNextTickFn(JSC::VM& vm, Bun::GlobalObject* globalObject) { JSNextTickQueue* nextTickQueueObject; if (!globalObject->m_nextTickQueue) { @@ -3936,7 +3936,7 @@ JSValue Process::constructNextTickFn(JSC::VM& vm, Zig::GlobalObject* globalObjec static JSValue constructProcessNextTickFn(VM& vm, JSObject* processObject) { JSGlobalObject* lexicalGlobalObject = processObject->globalObject(); - Zig::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); return uncheckedDowncast(processObject)->constructNextTickFn(JSC::getVM(globalObject), globalObject); } @@ -4152,7 +4152,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionKill, (JSC::JSGlobalObject * globalObje return Bun::ERR::INVALID_ARG_TYPE(scope, globalObject, "signal"_s, "string or number"_s, signalValue); } - auto global = uncheckedDowncast(globalObject); + auto global = uncheckedDowncast(globalObject); auto& vm = JSC::getVM(global); JSValue _killFn = global->processObject()->get(globalObject, Identifier::fromString(vm, "_kill"_s)); RETURN_IF_EXCEPTION(scope, {}); @@ -4181,7 +4181,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionKill, (JSC::JSGlobalObject * globalObje JSC_DEFINE_HOST_FUNCTION(Process_functionLoadBuiltinModule, (JSGlobalObject * globalObject, CallFrame* callFrame)) { - auto* zigGlobalObject = uncheckedDowncast(globalObject); + auto* zigGlobalObject = uncheckedDowncast(globalObject); VM& vm = zigGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -4220,7 +4220,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionEmitHelper, (JSGlobalObject * globalObj return JSValue::encode(ret); } -extern "C" void Process__emitMessageEvent(Zig::GlobalObject* global, EncodedJSValue value, EncodedJSValue handle) +extern "C" void Process__emitMessageEvent(Bun::GlobalObject* global, EncodedJSValue value, EncodedJSValue handle) { auto* process = global->processObject(); auto& vm = JSC::getVM(global); @@ -4234,7 +4234,7 @@ extern "C" void Process__emitMessageEvent(Zig::GlobalObject* global, EncodedJSVa } } -extern "C" void Process__emitDisconnectEvent(Zig::GlobalObject* global) +extern "C" void Process__emitDisconnectEvent(Bun::GlobalObject* global) { auto* process = global->processObject(); auto& vm = JSC::getVM(global); @@ -4245,7 +4245,7 @@ extern "C" void Process__emitDisconnectEvent(Zig::GlobalObject* global) } } -extern "C" void Process__emitErrorEvent(Zig::GlobalObject* global, EncodedJSValue value) +extern "C" void Process__emitErrorEvent(Bun::GlobalObject* global, EncodedJSValue value) { auto* process = global->processObject(); auto& vm = JSC::getVM(global); diff --git a/src/jsc/bindings/BunProcess.h b/src/jsc/bindings/BunProcess.h index 02b049ebf1e5..87cf91ae1093 100644 --- a/src/jsc/bindings/BunProcess.h +++ b/src/jsc/bindings/BunProcess.h @@ -6,7 +6,7 @@ #include "BunClientData.h" #include "JSEventEmitter.h" -namespace Zig { +namespace Bun { class GlobalObject; } @@ -54,7 +54,7 @@ class Process : public WebCore::JSEventEmitter { static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable; - JSValue constructNextTickFn(JSC::VM& vm, Zig::GlobalObject* globalObject); + JSValue constructNextTickFn(JSC::VM& vm, Bun::GlobalObject* globalObject); void queueNextTick(JSC::JSGlobalObject* globalObject, const ArgList& args); void queueNextTick(JSC::JSGlobalObject* globalObject, JSValue); void queueNextTick(JSC::JSGlobalObject* globalObject, JSValue, JSValue); @@ -64,7 +64,7 @@ class Process : public WebCore::JSEventEmitter { // Some Node.js events want to be emitted on the next tick rather than synchronously. // This is equivalent to `process.nextTick(() => process.emit(eventName, event))` from JavaScript. - void emitOnNextTick(Zig::GlobalObject* globalObject, ASCIILiteral eventName, JSValue event); + void emitOnNextTick(Bun::GlobalObject* globalObject, ASCIILiteral eventName, JSValue event); static JSValue emitWarningErrorInstance(JSC::JSGlobalObject* lexicalGlobalObject, JSValue errorInstance); static JSValue emitWarning(JSC::JSGlobalObject* lexicalGlobalObject, JSValue warning, JSValue type, JSValue code, JSValue ctor); diff --git a/src/jsc/bindings/BunProcessReportObjectWindows.cpp b/src/jsc/bindings/BunProcessReportObjectWindows.cpp index 48e24d14b64d..f937ff6b1ac2 100644 --- a/src/jsc/bindings/BunProcessReportObjectWindows.cpp +++ b/src/jsc/bindings/BunProcessReportObjectWindows.cpp @@ -3,7 +3,7 @@ #if OS(WINDOWS) #include "BunProcess.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "FormatStackTraceForJS.h" #include "headers.h" // For Bun__Process__createExecArgv and other exports #include "JavaScriptCore/JSCJSValue.h" @@ -38,7 +38,7 @@ using namespace JSC; // External functions extern "C" EncodedJSValue Bun__Process__createExecArgv(JSGlobalObject*); -JSValue constructReportObjectWindows(VM& vm, Zig::GlobalObject* globalObject, Process* process) +JSValue constructReportObjectWindows(VM& vm, Bun::GlobalObject* globalObject, Process* process) { auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/BunSecureContextCache.cpp b/src/jsc/bindings/BunSecureContextCache.cpp index 447413c4e569..c07473c07340 100644 --- a/src/jsc/bindings/BunSecureContextCache.cpp +++ b/src/jsc/bindings/BunSecureContextCache.cpp @@ -1,6 +1,6 @@ #include "root.h" #include "BunSecureContextCache.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include using namespace JSC; @@ -9,7 +9,7 @@ using namespace JSC; // for `key` (low 64 bits of the config digest) or jsEmpty() if none / GC'd. // The full 32-byte digest lives on the Rust SecureContext, so the caller does // a content-equality check on hit to handle the (~2⁻⁶⁴) key-collision case. -extern "C" JSC::EncodedJSValue Bun__SecureContextCache__get(Zig::GlobalObject* global, uint64_t key) +extern "C" JSC::EncodedJSValue Bun__SecureContextCache__get(Bun::GlobalObject* global, uint64_t key) { auto& slot = global->m_secureContextCache; if (!slot) return JSValue::encode(JSValue()); @@ -17,7 +17,7 @@ extern "C" JSC::EncodedJSValue Bun__SecureContextCache__get(Zig::GlobalObject* g return JSValue::encode(obj ? JSValue(obj) : JSValue()); } -extern "C" void Bun__SecureContextCache__set(Zig::GlobalObject* global, uint64_t key, JSC::EncodedJSValue value) +extern "C" void Bun__SecureContextCache__set(Bun::GlobalObject* global, uint64_t key, JSC::EncodedJSValue value) { auto& slot = global->m_secureContextCache; if (!slot) slot = makeUnique(global->vm()); diff --git a/src/jsc/bindings/BunSecureContextCache.h b/src/jsc/bindings/BunSecureContextCache.h index 5db7d4ca9aa5..eca63f9df032 100644 --- a/src/jsc/bindings/BunSecureContextCache.h +++ b/src/jsc/bindings/BunSecureContextCache.h @@ -1,6 +1,6 @@ #pragma once -// Thin wrapper around `WeakGCMap` so ZigGlobalObject.h +// Thin wrapper around `WeakGCMap` so BunGlobalObject.h // can hold a `std::unique_ptr` without pulling in // WeakGCMap.h (this header is included from one .cpp file only). // diff --git a/src/jsc/bindings/BunString.cpp b/src/jsc/bindings/BunString.cpp index 1d10870009dd..836fa35a6aab 100644 --- a/src/jsc/bindings/BunString.cpp +++ b/src/jsc/bindings/BunString.cpp @@ -12,7 +12,7 @@ #include "wtf/SIMDUTF.h" #include "JSDOMURL.h" #include "DOMURL.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "IDLTypes.h" #include "MimallocWTFMalloc.h" @@ -584,7 +584,7 @@ extern "C" size_t URL__originLength(const char* latin1_slice, size_t len) extern "C" JSC::EncodedJSValue BunString__toJSDOMURL(JSC::JSGlobalObject* lexicalGlobalObject, BunString* bunString) { - auto& globalObject = *uncheckedDowncast(lexicalGlobalObject); + auto& globalObject = *uncheckedDowncast(lexicalGlobalObject); auto& vm = globalObject.vm(); auto throwScope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/BundlerMetafile.cpp b/src/jsc/bindings/BundlerMetafile.cpp index c21e641a3665..dcc2f4e194d1 100644 --- a/src/jsc/bindings/BundlerMetafile.cpp +++ b/src/jsc/bindings/BundlerMetafile.cpp @@ -8,7 +8,7 @@ #include "root.h" #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include diff --git a/src/jsc/bindings/CallSite.cpp b/src/jsc/bindings/CallSite.cpp index ffaaa5323cbc..fbae0b2099af 100644 --- a/src/jsc/bindings/CallSite.cpp +++ b/src/jsc/bindings/CallSite.cpp @@ -97,7 +97,7 @@ JSC_DEFINE_HOST_FUNCTION(nativeFrameForTesting, (JSC::JSGlobalObject * globalObj return JSValue::encode(JSC::call(globalObject, function, JSC::ArgList(), "nativeFrameForTesting"_s)); } -JSValue createNativeFrameForTesting(Zig::GlobalObject* globalObject) +JSValue createNativeFrameForTesting(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); diff --git a/src/jsc/bindings/CallSite.h b/src/jsc/bindings/CallSite.h index 4d63a3b167b3..aa3345514c3d 100644 --- a/src/jsc/bindings/CallSite.h +++ b/src/jsc/bindings/CallSite.h @@ -102,5 +102,5 @@ class CallSite final : public JSC::JSNonFinalObject { DECLARE_VISIT_CHILDREN; }; -JSValue createNativeFrameForTesting(Zig::GlobalObject* globalObject); +JSValue createNativeFrameForTesting(Bun::GlobalObject* globalObject); } diff --git a/src/jsc/bindings/DOMWrapperWorld.cpp b/src/jsc/bindings/DOMWrapperWorld.cpp index b09b35e849a6..5b124d282706 100644 --- a/src/jsc/bindings/DOMWrapperWorld.cpp +++ b/src/jsc/bindings/DOMWrapperWorld.cpp @@ -25,7 +25,7 @@ // #include "JSDOMWindow.h" #include "WebCoreJSClientData.h" // #include "WindowProxy.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include namespace WebCore { diff --git a/src/jsc/bindings/DOMWrapperWorld.h b/src/jsc/bindings/DOMWrapperWorld.h index a619c28e200e..3c9351fbb657 100644 --- a/src/jsc/bindings/DOMWrapperWorld.h +++ b/src/jsc/bindings/DOMWrapperWorld.h @@ -23,7 +23,7 @@ #include "root.h" #include "DOMWrapperWorld-class.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace WebCore { @@ -50,10 +50,10 @@ inline bool isWorldCompatible(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSV inline DOMWrapperWorld& currentWorld(JSC::JSGlobalObject& lexicalGlobalObject) { - return uncheckedDowncast(&lexicalGlobalObject)->world(); + return uncheckedDowncast(&lexicalGlobalObject)->world(); } inline DOMWrapperWorld& worldForDOMObject(JSC::JSObject& object) { - return uncheckedDowncast(object.globalObject())->world(); + return uncheckedDowncast(object.globalObject())->world(); }; } diff --git a/src/jsc/bindings/ErrorCode.cpp b/src/jsc/bindings/ErrorCode.cpp index 8aef2ccca1b1..e9c12541a77d 100644 --- a/src/jsc/bindings/ErrorCode.cpp +++ b/src/jsc/bindings/ErrorCode.cpp @@ -1,7 +1,7 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "DOMException.h" #include "JavaScriptCore/Error.h" #include "JavaScriptCore/ErrorType.h" @@ -183,7 +183,7 @@ void ErrorCodeCache::finishCreation(VM& vm) } } -static ErrorCodeCache* errorCache(Zig::GlobalObject* globalObject) +static ErrorCodeCache* errorCache(Bun::GlobalObject* globalObject) { return static_cast(globalObject->nodeErrorCache()); } @@ -195,7 +195,7 @@ static Structure* createErrorStructure(JSC::VM& vm, JSGlobalObject* globalObject return ErrorInstance::createStructure(vm, globalObject, prototype); } -JSObject* ErrorCodeCache::createError(VM& vm, Zig::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options) +JSObject* ErrorCodeCache::createError(VM& vm, Bun::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options) { auto scope = DECLARE_TOP_EXCEPTION_SCOPE(vm); auto* cache = errorCache(globalObject); @@ -217,12 +217,12 @@ JSObject* ErrorCodeCache::createError(VM& vm, Zig::GlobalObject* globalObject, E return created_error; } -JSObject* createError(VM& vm, Zig::GlobalObject* globalObject, ErrorCode code, const String& message) +JSObject* createError(VM& vm, Bun::GlobalObject* globalObject, ErrorCode code, const String& message) { return errorCache(globalObject)->createError(vm, globalObject, code, jsString(vm, message), jsUndefined()); } -JSObject* createError(Zig::GlobalObject* globalObject, ErrorCode code, const String& message) +JSObject* createError(Bun::GlobalObject* globalObject, ErrorCode code, const String& message) { return createError(globalObject->vm(), globalObject, code, message); } @@ -234,14 +234,14 @@ JSObject* createError(VM& vm, JSC::JSGlobalObject* globalObject, ErrorCode code, JSObject* createError(VM& vm, JSC::JSGlobalObject* globalObject, ErrorCode code, JSValue message) { - if (auto* zigGlobalObject = dynamicDowncast(globalObject)) + if (auto* zigGlobalObject = dynamicDowncast(globalObject)) return createError(vm, zigGlobalObject, code, message, jsUndefined()); auto* structure = createErrorStructure(vm, globalObject, errors[static_cast(code)].type, errors[static_cast(code)].name, errors[static_cast(code)].code); return JSC::ErrorInstance::create(globalObject, structure, message, jsUndefined(), nullptr, JSC::RuntimeType::TypeNothing, errors[static_cast(code)].type, true); } -JSC::JSObject* createError(VM& vm, Zig::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options) +JSC::JSObject* createError(VM& vm, Bun::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options) { return errorCache(globalObject)->createError(vm, globalObject, code, message, options); } diff --git a/src/jsc/bindings/ErrorCode.h b/src/jsc/bindings/ErrorCode.h index c17dbf5d4b15..ae8fb6fbec56 100644 --- a/src/jsc/bindings/ErrorCode.h +++ b/src/jsc/bindings/ErrorCode.h @@ -1,7 +1,7 @@ // To add a new error code, put it in ErrorCode.ts #pragma once -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "root.h" #include #include @@ -52,7 +52,7 @@ class ErrorCodeCache : public JSC::JSInternalFieldObjectImpl { static ErrorCodeCache* create(VM& vm, Structure* structure); static Structure* createStructure(VM& vm, JSGlobalObject* globalObject); - JSObject* createError(VM& vm, Zig::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options); + JSObject* createError(VM& vm, Bun::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options); private: JS_EXPORT_PRIVATE ErrorCodeCache(VM&, Structure*); @@ -61,10 +61,10 @@ class ErrorCodeCache : public JSC::JSInternalFieldObjectImpl { }; JSC::EncodedJSValue throwError(JSC::JSGlobalObject* globalObject, JSC::ThrowScope& scope, ErrorCode code, const WTF::String& message); -JSC::JSObject* createError(Zig::GlobalObject* globalObject, ErrorCode code, const WTF::String& message); +JSC::JSObject* createError(Bun::GlobalObject* globalObject, ErrorCode code, const WTF::String& message); JSC::JSObject* createError(JSC::JSGlobalObject* globalObject, ErrorCode code, const WTF::String& message); -JSC::JSObject* createError(Zig::GlobalObject* globalObject, ErrorCode code, JSC::JSValue message); -JSC::JSObject* createError(VM& vm, Zig::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options); +JSC::JSObject* createError(Bun::GlobalObject* globalObject, ErrorCode code, JSC::JSValue message); +JSC::JSObject* createError(VM& vm, Bun::GlobalObject* globalObject, ErrorCode code, JSValue message, JSValue options); JSC::JSValue toJS(JSC::JSGlobalObject*, ErrorCode); JSObject* createInvalidThisError(JSGlobalObject* globalObject, JSValue thisValue, const ASCIILiteral typeName); JSObject* createInvalidThisError(JSGlobalObject* globalObject, const String& message); diff --git a/src/jsc/bindings/ErrorStackTrace.h b/src/jsc/bindings/ErrorStackTrace.h index 17c9dc6822ea..0a7894244092 100644 --- a/src/jsc/bindings/ErrorStackTrace.h +++ b/src/jsc/bindings/ErrorStackTrace.h @@ -9,7 +9,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" using namespace JSC; using namespace WebCore; diff --git a/src/jsc/bindings/EventLoopTaskNoContext.h b/src/jsc/bindings/EventLoopTaskNoContext.h index fede33f2603c..9f920a8f55e0 100644 --- a/src/jsc/bindings/EventLoopTaskNoContext.h +++ b/src/jsc/bindings/EventLoopTaskNoContext.h @@ -1,6 +1,6 @@ #pragma once -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "root.h" namespace Bun { diff --git a/src/jsc/bindings/ExposeNodeModuleGlobals.cpp b/src/jsc/bindings/ExposeNodeModuleGlobals.cpp index c00614bdde78..274db0c23448 100644 --- a/src/jsc/bindings/ExposeNodeModuleGlobals.cpp +++ b/src/jsc/bindings/ExposeNodeModuleGlobals.cpp @@ -11,7 +11,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "InternalModuleRegistry.h" #pragma push_macro("assert") @@ -64,7 +64,7 @@ namespace ExposeNodeModuleGlobalGetters { #define DECL_GETTER(id, field) \ JSC_DEFINE_CUSTOM_GETTER(id, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) \ { \ - Zig::GlobalObject* thisObject = defaultGlobalObject(lexicalGlobalObject); \ + Bun::GlobalObject* thisObject = defaultGlobalObject(lexicalGlobalObject); \ JSC::VM& vm = thisObject->vm(); \ return JSC::JSValue::encode(thisObject->internalModuleRegistry()->requireId(thisObject, vm, field)); \ } @@ -73,7 +73,7 @@ FOREACH_EXPOSED_BUILTIN_IMR(DECL_GETTER) } // namespace ExposeNodeModuleGlobalGetters -extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__ExposeNodeModuleGlobals(Zig::GlobalObject* globalObject) +extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__ExposeNodeModuleGlobals(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); @@ -95,7 +95,7 @@ extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__ExposeNodeModuleGlobals(Zig::Global // Set up require(), module, __filename, __dirname on globalThis for the REPL. // Creates a CommonJS module object rooted at the given directory so require() resolves correctly. extern "C" [[ZIG_EXPORT(check_slow)]] void Bun__REPL__setupGlobalRequire( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const unsigned char* cwdPtr, size_t cwdLen) { diff --git a/src/jsc/bindings/FormatStackTraceForJS.cpp b/src/jsc/bindings/FormatStackTraceForJS.cpp index b28d99e53704..f2c1b4e149fd 100644 --- a/src/jsc/bindings/FormatStackTraceForJS.cpp +++ b/src/jsc/bindings/FormatStackTraceForJS.cpp @@ -1,7 +1,7 @@ #include "root.h" #include "FormatStackTraceForJS.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "helpers.h" #include "JavaScriptCore/ArgList.h" @@ -29,7 +29,7 @@ using namespace WebCore; namespace Bun { -static JSValue formatStackTraceToJSValue(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites) +static JSValue formatStackTraceToJSValue(JSC::VM& vm, Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites) { auto scope = DECLARE_THROW_SCOPE(vm); @@ -78,7 +78,7 @@ static JSValue formatStackTraceToJSValue(JSC::VM& vm, Zig::GlobalObject* globalO return jsString(vm, sb.toString()); } -static JSValue formatStackTraceToJSValue(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites, JSValue prepareStackTrace) +static JSValue formatStackTraceToJSValue(JSC::VM& vm, Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites, JSValue prepareStackTrace) { auto scope = DECLARE_THROW_SCOPE(vm); auto stackStringValue = formatStackTraceToJSValue(vm, globalObject, lexicalGlobalObject, errorObject, callSites); @@ -117,10 +117,10 @@ static JSValue formatStackTraceToJSValue(JSC::VM& vm, Zig::GlobalObject* globalO return stackStringValue; } -static JSValue formatStackTraceToJSValueWithoutPrepareStackTrace(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites) +static JSValue formatStackTraceToJSValueWithoutPrepareStackTrace(JSC::VM& vm, Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites) { JSValue prepareStackTrace = {}; - if (lexicalGlobalObject->inherits()) { + if (lexicalGlobalObject->inherits()) { if (auto prepare = globalObject->m_errorConstructorPrepareStackTraceValue.get()) { prepareStackTrace = prepare; } @@ -137,7 +137,7 @@ static JSValue formatStackTraceToJSValueWithoutPrepareStackTrace(JSC::VM& vm, Zi WTF::String formatStackTrace( JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, const WTF::String& name, const WTF::String& message, @@ -189,7 +189,7 @@ WTF::String formatStackTrace( String sourceURLForFrame = err->sourceURL(); - // If it's not a Zig::GlobalObject, don't bother source-mapping it. + // If it's not a Bun::GlobalObject, don't bother source-mapping it. if (globalObject && !sourceURLForFrame.isEmpty()) { // https://github.com/oven-sh/bun/issues/3595 if (!sourceURLForFrame.isEmpty()) { @@ -393,7 +393,7 @@ WTF::String formatStackTrace( // error.stack calls this function static String computeErrorInfoWithoutPrepareStackTrace( JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, Vector& stackTrace, OrdinalNumber& line, @@ -425,7 +425,7 @@ static String computeErrorInfoWithoutPrepareStackTrace( return Bun::formatStackTrace(vm, globalObject, lexicalGlobalObject, name, message, line, column, sourceURL, stackTrace, errorInstance); } -static JSValue computeErrorInfoWithPrepareStackTrace(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, Vector& stackFrames, OrdinalNumber& line, OrdinalNumber& column, String& sourceURL, JSObject* errorObject, JSObject* prepareStackTrace) +static JSValue computeErrorInfoWithPrepareStackTrace(JSC::VM& vm, Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, Vector& stackFrames, OrdinalNumber& line, OrdinalNumber& column, String& sourceURL, JSObject* errorObject, JSObject* prepareStackTrace) { auto scope = DECLARE_THROW_SCOPE(vm); @@ -516,7 +516,7 @@ static JSValue computeErrorInfoWithPrepareStackTrace(JSC::VM& vm, Zig::GlobalObj static String computeErrorInfoToString(JSC::VM& vm, Vector& stackTrace, OrdinalNumber& line, OrdinalNumber& column, String& sourceURL) { - Zig::GlobalObject* globalObject = nullptr; + Bun::GlobalObject* globalObject = nullptr; JSC::JSGlobalObject* lexicalGlobalObject = nullptr; return computeErrorInfoWithoutPrepareStackTrace(vm, globalObject, lexicalGlobalObject, stackTrace, line, column, sourceURL, nullptr); @@ -526,10 +526,10 @@ static JSValue computeErrorInfoToJSValueWithoutSkipping(JSC::VM& vm, VectorglobalObject(); - globalObject = dynamicDowncast(lexicalGlobalObject); + globalObject = dynamicDowncast(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); // Error.prepareStackTrace - https://v8.dev/docs/stack-trace-api#customizing-stack-traces @@ -633,7 +633,7 @@ JSC::JSValue computeErrorInfoWrapperToJSValue(JSC::VM& vm, Vector& s JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncAppendStackTrace, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = static_cast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -735,7 +735,7 @@ JSC_DEFINE_CUSTOM_SETTER(errorInstanceLazyStackCustomSetter, (JSGlobalObject * g JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = static_cast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -798,7 +798,7 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb namespace Zig { -void createCallSitesFromFrames(Zig::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSCStackTrace& stackTrace, MarkedArgumentBuffer& callSites) +void createCallSitesFromFrames(Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSCStackTrace& stackTrace, MarkedArgumentBuffer& callSites) { /* From v8's "Stack Trace API" (https://github.com/v8/v8/wiki/Stack-Trace-API): * "To maintain restrictions imposed on strict mode functions, frames that have a diff --git a/src/jsc/bindings/FormatStackTraceForJS.h b/src/jsc/bindings/FormatStackTraceForJS.h index fc9515a4668b..5745cd5a77a7 100644 --- a/src/jsc/bindings/FormatStackTraceForJS.h +++ b/src/jsc/bindings/FormatStackTraceForJS.h @@ -45,10 +45,13 @@ class OrdinalNumber; } // namespace WTF namespace Zig { -class GlobalObject; class JSCStackTrace; } // namespace Zig +namespace Bun { +class GlobalObject; +} // namespace Bun + using JSC::EncodedJSValue; using JSC::PropertyName; @@ -60,7 +63,7 @@ constexpr size_t DEFAULT_ERROR_STACK_TRACE_LIMIT = 10; // Main stack trace formatting function WTF::String formatStackTrace( JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, const WTF::String& name, const WTF::String& message, @@ -89,7 +92,7 @@ namespace Zig { // GlobalObject member function for creating CallSite objects void createCallSitesFromFrames( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, Zig::JSCStackTrace& stackTrace, JSC::MarkedArgumentBuffer& callSites); diff --git a/src/jsc/bindings/FuzzilliREPRL.cpp b/src/jsc/bindings/FuzzilliREPRL.cpp index a6e93d2b6400..c8907d265142 100644 --- a/src/jsc/bindings/FuzzilliREPRL.cpp +++ b/src/jsc/bindings/FuzzilliREPRL.cpp @@ -2,7 +2,7 @@ #include "JavaScriptCore/CallFrame.h" #include "JavaScriptCore/Identifier.h" #include "JavaScriptCore/JSGlobalObject.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "root.h" #include "wtf/text/WTFString.h" #include @@ -255,7 +255,7 @@ JSC_DEFINE_HOST_FUNCTION(jsResetCoverage, (JSC::JSGlobalObject * globalObject, J } // Register the fuzzilli() function on a Bun global object -void Bun__REPRL__registerFuzzilliFunctions(Zig::GlobalObject* globalObject) +void Bun__REPRL__registerFuzzilliFunctions(Bun::GlobalObject* globalObject) { JSC::VM& vm = globalObject->vm(); diff --git a/src/jsc/bindings/HTMLEntryPoint.cpp b/src/jsc/bindings/HTMLEntryPoint.cpp index 95d5d987b1b3..4944ac13f277 100644 --- a/src/jsc/bindings/HTMLEntryPoint.cpp +++ b/src/jsc/bindings/HTMLEntryPoint.cpp @@ -4,11 +4,11 @@ #include #include "InternalModuleRegistry.h" #include "ModuleLoader.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include namespace Bun { using namespace JSC; -extern "C" JSPromise* Bun__loadHTMLEntryPoint(Zig::GlobalObject* globalObject) +extern "C" JSPromise* Bun__loadHTMLEntryPoint(Bun::GlobalObject* globalObject) { auto& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/IPC.cpp b/src/jsc/bindings/IPC.cpp index e4a60f60152e..2fb6ed92844b 100644 --- a/src/jsc/bindings/IPC.cpp +++ b/src/jsc/bindings/IPC.cpp @@ -2,9 +2,9 @@ #include "headers-handwritten.h" #include "BunBuiltinNames.h" #include "WebCoreJSBuiltins.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" -extern "C" [[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue IPCSerialize(Zig::GlobalObject* global, JSC::EncodedJSValue message, JSC::EncodedJSValue handle) +extern "C" [[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue IPCSerialize(Bun::GlobalObject* global, JSC::EncodedJSValue message, JSC::EncodedJSValue handle) { auto& vm = JSC::getVM(global); auto scope = DECLARE_THROW_SCOPE(vm); @@ -20,7 +20,7 @@ extern "C" [[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue IPCSerialize(Zig::G return JSC::JSValue::encode(result); } -extern "C" [[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue IPCParse(Zig::GlobalObject* global, JSC::EncodedJSValue target, JSC::EncodedJSValue serialized, JSC::EncodedJSValue fd) +extern "C" [[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue IPCParse(Bun::GlobalObject* global, JSC::EncodedJSValue target, JSC::EncodedJSValue serialized, JSC::EncodedJSValue fd) { auto& vm = JSC::getVM(global); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/ImportMetaObject.cpp b/src/jsc/bindings/ImportMetaObject.cpp index da6e4cfe4807..d868cfd03656 100644 --- a/src/jsc/bindings/ImportMetaObject.cpp +++ b/src/jsc/bindings/ImportMetaObject.cpp @@ -3,7 +3,7 @@ #include "headers.h" #include "ImportMetaObject.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ActiveDOMObject.h" #include "ExtendedDOMClientIsoSubspaces.h" #include "ExtendedDOMIsoSubspaces.h" @@ -73,7 +73,7 @@ static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObj JSC::JSValue moduleName = callFrame->argument(0); auto doIt = [&](const WTF::String& fromStr) -> JSC::EncodedJSValue { - Zig::GlobalObject* zigGlobalObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* zigGlobalObject = uncheckedDowncast(globalObject); if (zigGlobalObject->onLoadPlugins.hasVirtualModules()) { if (auto result = zigGlobalObject->onLoadPlugins.resolveVirtualModule(fromStr, String())) { if (fromStr == result.value()) @@ -143,7 +143,7 @@ ImportMetaObject* ImportMetaObject::create(JSC::VM& vm, JSC::JSGlobalObject* glo ImportMetaObject* ImportMetaObject::create(JSC::JSGlobalObject* globalObject, const WTF::String& url) { VM& vm = globalObject->vm(); - Zig::GlobalObject* zigGlobalObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* zigGlobalObject = uncheckedDowncast(globalObject); bool isBake = url.startsWith("bake:"_s); // Get the appropriate structure @@ -194,7 +194,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireResolve, (JSC::JSGlobalObject * global extern "C" JSC::EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); @@ -292,7 +292,7 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSyncPrivate(JSC::JSGlo { auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); - auto* globalObject = dynamicDowncast(lexicalGlobalObject); + auto* globalObject = dynamicDowncast(lexicalGlobalObject); JSC::JSValue moduleName = callFrame->argument(0); JSValue from = callFrame->argument(1); @@ -422,7 +422,7 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSyncPrivate(JSC::JSGlo JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); @@ -589,7 +589,7 @@ JSC_DEFINE_CUSTOM_SETTER(jsImportMetaObjectSetter_require, (JSGlobalObject * jsG JSC_DEFINE_CUSTOM_GETTER(jsImportMetaObjectGetter_env, (JSGlobalObject * jsGlobalObject, JSC::EncodedJSValue thisValue, PropertyName propertyName)) { - auto* globalObject = uncheckedDowncast(jsGlobalObject); + auto* globalObject = uncheckedDowncast(jsGlobalObject); return JSValue::encode(globalObject->m_processEnvObject.getInitializedOnMainThread(globalObject)); } diff --git a/src/jsc/bindings/ImportMetaObject.h b/src/jsc/bindings/ImportMetaObject.h index 6e3d8bf0efdb..de3541d8485e 100644 --- a/src/jsc/bindings/ImportMetaObject.h +++ b/src/jsc/bindings/ImportMetaObject.h @@ -4,7 +4,7 @@ #include "BunBuiltinNames.h" #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMWrapperCache.h" diff --git a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp index dabee36f67bd..82fa2591bcf8 100644 --- a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp +++ b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp @@ -11,7 +11,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Inspector { diff --git a/src/jsc/bindings/InspectorHTTPServerAgent.cpp b/src/jsc/bindings/InspectorHTTPServerAgent.cpp index 0b4bf89e9f07..ee0eef9b4191 100644 --- a/src/jsc/bindings/InspectorHTTPServerAgent.cpp +++ b/src/jsc/bindings/InspectorHTTPServerAgent.cpp @@ -7,7 +7,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Inspector { diff --git a/src/jsc/bindings/InspectorLifecycleAgent.cpp b/src/jsc/bindings/InspectorLifecycleAgent.cpp index c40e94aae0b7..be2f2b6b549b 100644 --- a/src/jsc/bindings/InspectorLifecycleAgent.cpp +++ b/src/jsc/bindings/InspectorLifecycleAgent.cpp @@ -1,5 +1,5 @@ #include "InspectorLifecycleAgent.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/InspectorTestReporterAgent.cpp b/src/jsc/bindings/InspectorTestReporterAgent.cpp index f10a8693c1d4..0c2e655606ad 100644 --- a/src/jsc/bindings/InspectorTestReporterAgent.cpp +++ b/src/jsc/bindings/InspectorTestReporterAgent.cpp @@ -8,7 +8,7 @@ #include #include #include "ErrorStackTrace.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ModuleLoader.h" #include diff --git a/src/jsc/bindings/InternalForTesting.cpp b/src/jsc/bindings/InternalForTesting.cpp index 141195bc2526..90aac7d34632 100644 --- a/src/jsc/bindings/InternalForTesting.cpp +++ b/src/jsc/bindings/InternalForTesting.cpp @@ -1,6 +1,6 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/JSCJSValue.h" #include "JavaScriptCore/JSCast.h" #include "JavaScriptCore/JSArrayBufferView.h" diff --git a/src/jsc/bindings/InternalForTesting.h b/src/jsc/bindings/InternalForTesting.h index 7d7ea01e4174..d6ffd26d6d58 100644 --- a/src/jsc/bindings/InternalForTesting.h +++ b/src/jsc/bindings/InternalForTesting.h @@ -1,6 +1,6 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/JSCJSValue.h" namespace Bun { diff --git a/src/jsc/bindings/InternalModuleRegistry.cpp b/src/jsc/bindings/InternalModuleRegistry.cpp index 37329fdde143..68e602496d49 100644 --- a/src/jsc/bindings/InternalModuleRegistry.cpp +++ b/src/jsc/bindings/InternalModuleRegistry.cpp @@ -1,5 +1,5 @@ #include "InternalModuleRegistry.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include @@ -182,7 +182,7 @@ JSC_DEFINE_HOST_FUNCTION(InternalModuleRegistry::jsCreateInternalModuleById, (JS auto throwScope = DECLARE_THROW_SCOPE(vm); auto id = callframe->argument(0).toUInt32(lexicalGlobalObject); - auto registry = uncheckedDowncast(lexicalGlobalObject)->internalModuleRegistry(); + auto registry = uncheckedDowncast(lexicalGlobalObject)->internalModuleRegistry(); auto mod = registry->createInternalModuleById(lexicalGlobalObject, vm, static_cast(id)); RETURN_IF_EXCEPTION(throwScope, {}); registry->internalField(static_cast(id)).set(vm, registry, mod); diff --git a/src/jsc/bindings/JS2Native.cpp b/src/jsc/bindings/JS2Native.cpp index cd4a94fb3712..2ebaf827a0e1 100644 --- a/src/jsc/bindings/JS2Native.cpp +++ b/src/jsc/bindings/JS2Native.cpp @@ -5,7 +5,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "GeneratedJS2Native.h" #include "wtf/Assertions.h" @@ -31,7 +31,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDollarLazy, (JSC::JSGlobalObject * lexicalGlobalObjec id <= JS2NATIVE_COUNT && id >= 0, "In call to $lazy, got invalid id '%d'. This is a bug in Bun's JS2Native code generator.", id); - Zig::GlobalObject* ptr = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* ptr = uncheckedDowncast(lexicalGlobalObject); return JSValue::encode(JS2NativeGenerated::callJS2Native(id, ptr)); } diff --git a/src/jsc/bindings/JSBakeResponse.cpp b/src/jsc/bindings/JSBakeResponse.cpp index 19330f92f51b..9d88e3403cd8 100644 --- a/src/jsc/bindings/JSBakeResponse.cpp +++ b/src/jsc/bindings/JSBakeResponse.cpp @@ -12,7 +12,7 @@ #include #include #include "JSBakeResponse.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ZigGeneratedClasses.h" #if !OS(WINDOWS) @@ -43,7 +43,7 @@ extern JSC_CALLCONV size_t Response__estimatedSize(void* ptr); bool isJSXElement(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* globalObject) { - auto* zigGlobal = static_cast(globalObject); + auto* zigGlobal = static_cast(globalObject); auto& vm = JSC::getVM(globalObject); // React does this: @@ -76,7 +76,7 @@ extern "C" bool JSC__JSValue__isJSXElement(JSC::EncodedJSValue JSValue0, JSC::JS return isJSXElement(JSValue0, globalObject); } -extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES BakeResponse__createForSSR(Zig::GlobalObject* globalObject, void* ptr, uint8_t kind) +extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES BakeResponse__createForSSR(Bun::GlobalObject* globalObject, void* ptr, uint8_t kind) { Structure* structure = globalObject->bakeAdditions().JSBakeResponseStructure(globalObject); @@ -106,7 +106,7 @@ static const HashTableValue JSBakeResponseConstructorTableValues[] = { }; -JSBakeResponse* JSBakeResponse::create(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::Structure* structure, void* ctx) +JSBakeResponse* JSBakeResponse::create(JSC::VM& vm, Bun::GlobalObject* globalObject, JSC::Structure* structure, void* ctx) { JSBakeResponse* ptr = new (NotNull, JSC::allocateCell(vm)) JSBakeResponse(vm, structure, ctx); ptr->finishCreation(vm); @@ -195,7 +195,7 @@ class JSBakeResponseConstructor final : public JSC::InternalFunction { // Must be defined for each specialization class. static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSObject* newTarget = asObject(callFrame->newTarget()); @@ -236,7 +236,7 @@ class JSBakeResponseConstructor final : public JSC::InternalFunction { static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES call(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { - Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = static_cast(lexicalGlobalObject); JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -287,7 +287,7 @@ class JSBakeResponseConstructor final : public JSC::InternalFunction { const JSC::ClassInfo JSBakeResponse::s_info = { "Response"_s, &JSResponse::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBakeResponse) }; const JSC::ClassInfo JSBakeResponseConstructor::s_info = { ""_s, &JSC::InternalFunction::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBakeResponseConstructor) }; -Structure* createJSBakeResponseStructure(JSC::VM& vm, Zig::GlobalObject* globalObject, JSObject* prototype) +Structure* createJSBakeResponseStructure(JSC::VM& vm, Bun::GlobalObject* globalObject, JSObject* prototype) { auto structure = JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, 0), JSBakeResponse::info(), NonArray, 0); @@ -300,7 +300,7 @@ Structure* createJSBakeResponseStructure(JSC::VM& vm, Zig::GlobalObject* globalO void setupJSBakeResponseClassStructure(JSC::LazyClassStructure::Initializer& init) { - auto* zigGlobal = static_cast(init.global); + auto* zigGlobal = static_cast(init.global); auto* prototype = JSC::constructEmptyObject(zigGlobal, zigGlobal->JSResponsePrototype()); auto* constructorStructure = JSBakeResponseConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()); diff --git a/src/jsc/bindings/JSBakeResponse.h b/src/jsc/bindings/JSBakeResponse.h index 83cff3a956bf..2100625d045d 100644 --- a/src/jsc/bindings/JSBakeResponse.h +++ b/src/jsc/bindings/JSBakeResponse.h @@ -22,7 +22,7 @@ class JSBakeResponse : public JSResponse { DECLARE_VISIT_CHILDREN; DECLARE_INFO; - static JSBakeResponse* create(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::Structure* structure, void* ctx); + static JSBakeResponse* create(JSC::VM& vm, Bun::GlobalObject* globalObject, JSC::Structure* structure, void* ctx); static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype); JSBakeResponseKind kind() const { return m_kind; } diff --git a/src/jsc/bindings/JSBuffer.cpp b/src/jsc/bindings/JSBuffer.cpp index 6b4fb82ddaa5..b468e38e3908 100644 --- a/src/jsc/bindings/JSBuffer.cpp +++ b/src/jsc/bindings/JSBuffer.cpp @@ -2,7 +2,7 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "WebCoreJSBuiltins.h" #include "JavaScriptCore/ExceptionHelpers.h" #include "JavaScriptCore/JSString.h" @@ -2441,7 +2441,7 @@ static JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlobalObje RELEASE_AND_RETURN(scope, writeToBuffer(lexicalGlobalObject, castedThis, str, offset, length, encoding)); } -extern "C" JSC::EncodedJSValue JSBuffer__fromMmap(Zig::GlobalObject* globalObject, void* ptr, size_t length) +extern "C" JSC::EncodedJSValue JSBuffer__fromMmap(Bun::GlobalObject* globalObject, void* ptr, size_t length) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/JSBufferList.cpp b/src/jsc/bindings/JSBufferList.cpp index a7a3ed9ac90b..163458ca16aa 100644 --- a/src/jsc/bindings/JSBufferList.cpp +++ b/src/jsc/bindings/JSBufferList.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMOperation.h" #include "headers.h" #include "BunClientData.h" @@ -171,7 +171,7 @@ JSC::JSValue JSBufferList::_getString(JSC::VM& vm, JSC::JSGlobalObject* lexicalG JSC::JSValue JSBufferList::_getBuffer(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, size_t total) { auto throwScope = DECLARE_THROW_SCOPE(vm); - auto* subclassStructure = static_cast(lexicalGlobalObject)->JSBufferSubclassStructure(); + auto* subclassStructure = static_cast(lexicalGlobalObject)->JSBufferSubclassStructure(); if (total <= 0 || length() == 0) { // Buffer.alloc(0) @@ -452,7 +452,7 @@ JSC::EncodedJSValue JSBufferListConstructor::construct(JSC::JSGlobalObject* lexi { auto& vm = JSC::getVM(lexicalGlobalObject); JSBufferList* bufferList = JSBufferList::create( - vm, lexicalGlobalObject, static_cast(lexicalGlobalObject)->JSBufferListStructure()); + vm, lexicalGlobalObject, static_cast(lexicalGlobalObject)->JSBufferListStructure()); return JSC::JSValue::encode(bufferList); } @@ -462,9 +462,9 @@ void JSBufferListConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* const ClassInfo JSBufferListConstructor::s_info = { "BufferList"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferListConstructor) }; -JSValue getBufferList(Zig::GlobalObject* globalObject) +JSValue getBufferList(Bun::GlobalObject* globalObject) { - return static_cast(globalObject)->JSBufferList(); + return static_cast(globalObject)->JSBufferList(); } } // namespace Zig diff --git a/src/jsc/bindings/JSBufferList.h b/src/jsc/bindings/JSBufferList.h index 635312f270e9..711ed0eb6190 100644 --- a/src/jsc/bindings/JSBufferList.h +++ b/src/jsc/bindings/JSBufferList.h @@ -2,7 +2,7 @@ #include "root.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace WebCore { using namespace JSC; @@ -168,6 +168,6 @@ class JSBufferListConstructor final : public JSC::InternalFunction { void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSBufferListPrototype* prototype); }; -JSValue getBufferList(Zig::GlobalObject* globalObject); +JSValue getBufferList(Bun::GlobalObject* globalObject); } diff --git a/src/jsc/bindings/JSBunRequest.cpp b/src/jsc/bindings/JSBunRequest.cpp index e7608b248854..8a2a80cc43c2 100644 --- a/src/jsc/bindings/JSBunRequest.cpp +++ b/src/jsc/bindings/JSBunRequest.cpp @@ -4,7 +4,7 @@ #include #include #include "JSBunRequest.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "AsyncContextFrame.h" #include #include "JSFetchHeaders.h" @@ -17,7 +17,7 @@ namespace Bun { -extern "C" SYSV_ABI JSC::EncodedJSValue Bun__JSRequest__createForBake(Zig::GlobalObject* globalObject, void* requestPtr) +extern "C" SYSV_ABI JSC::EncodedJSValue Bun__JSRequest__createForBake(Bun::GlobalObject* globalObject, void* requestPtr) { auto& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -291,7 +291,7 @@ JSC_DEFINE_HOST_FUNCTION(jsJSBunRequestClone, (JSC::JSGlobalObject * globalObjec return JSValue::encode(clone); } -Structure* createJSBunRequestStructure(JSC::VM& vm, Zig::GlobalObject* globalObject) +Structure* createJSBunRequestStructure(JSC::VM& vm, Bun::GlobalObject* globalObject) { auto prototypeStructure = JSBunRequestPrototype::createStructure(vm, globalObject, globalObject->JSRequestPrototype()); auto* prototype = JSBunRequestPrototype::create(vm, globalObject, prototypeStructure); diff --git a/src/jsc/bindings/JSBunRequest.h b/src/jsc/bindings/JSBunRequest.h index 1eb26605a8f7..7c65cfdd45a8 100644 --- a/src/jsc/bindings/JSBunRequest.h +++ b/src/jsc/bindings/JSBunRequest.h @@ -46,6 +46,6 @@ class JSBunRequest : public JSRequest { mutable JSC::WriteBarrier m_cookies; }; -JSC::Structure* createJSBunRequestStructure(JSC::VM&, Zig::GlobalObject*); +JSC::Structure* createJSBunRequestStructure(JSC::VM&, Bun::GlobalObject*); } // namespace Bun diff --git a/src/jsc/bindings/JSBundlerPlugin.cpp b/src/jsc/bindings/JSBundlerPlugin.cpp index af79303c095d..37da890de104 100644 --- a/src/jsc/bindings/JSBundlerPlugin.cpp +++ b/src/jsc/bindings/JSBundlerPlugin.cpp @@ -9,7 +9,7 @@ #include #include #include "helpers.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include @@ -590,7 +590,7 @@ extern "C" void JSBundlerPlugin__matchOnResolve(Bun::JSBundlerPlugin* plugin, Bu } } -extern "C" Bun::JSBundlerPlugin* JSBundlerPlugin__create(Zig::GlobalObject* globalObject, BunPluginTarget target) +extern "C" Bun::JSBundlerPlugin* JSBundlerPlugin__create(Bun::GlobalObject* globalObject, BunPluginTarget target) { return JSBundlerPlugin::create( globalObject->vm(), diff --git a/src/jsc/bindings/JSCTestingHelpers.cpp b/src/jsc/bindings/JSCTestingHelpers.cpp index 6807ad2b2ee8..cfdd79437150 100644 --- a/src/jsc/bindings/JSCTestingHelpers.cpp +++ b/src/jsc/bindings/JSCTestingHelpers.cpp @@ -4,7 +4,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { using namespace JSC; @@ -49,7 +49,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsLatin1String, return {}; } -JSC::JSValue createJSCTestingHelpers(Zig::GlobalObject* globalObject) +JSC::JSValue createJSCTestingHelpers(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/JSCTestingHelpers.h b/src/jsc/bindings/JSCTestingHelpers.h index db46851b7a59..d698f1fea93b 100644 --- a/src/jsc/bindings/JSCTestingHelpers.h +++ b/src/jsc/bindings/JSCTestingHelpers.h @@ -1,5 +1,5 @@ namespace Bun { -JSC::JSValue createJSCTestingHelpers(Zig::GlobalObject* global); +JSC::JSValue createJSCTestingHelpers(Bun::GlobalObject* global); } diff --git a/src/jsc/bindings/JSCommonJSExtensions.cpp b/src/jsc/bindings/JSCommonJSExtensions.cpp index eb8baaf5dee3..17bae7b339c5 100644 --- a/src/jsc/bindings/JSCommonJSExtensions.cpp +++ b/src/jsc/bindings/JSCommonJSExtensions.cpp @@ -1,5 +1,5 @@ #include "JSCommonJSExtensions.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "BunProcess.h" #include "ModuleLoader.h" #include "JSCommonJSModule.h" @@ -88,7 +88,7 @@ void JSCommonJSExtensions::finishCreation(JSC::VM& vm) Base::finishCreation(vm); ASSERT(inherits(info())); - Zig::GlobalObject* global = defaultGlobalObject(globalObject()); + Bun::GlobalObject* global = defaultGlobalObject(globalObject()); JSC::JSFunction* fnLoadJS = JSC::JSFunction::create( vm, global, @@ -136,16 +136,16 @@ void JSCommonJSExtensions::finishCreation(JSC::VM& vm) } extern "C" void NodeModuleModule__onRequireExtensionModify( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const BunString* key, BunLoaderType loader, JSC::JSValue value); extern "C" void NodeModuleModule__onRequireExtensionModifyNonFunction( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const BunString* key); -void onAssign(Zig::GlobalObject* globalObject, JSC::PropertyName propertyName, JSC::JSValue value) +void onAssign(Bun::GlobalObject* globalObject, JSC::PropertyName propertyName, JSC::JSValue value) { if (propertyName.isSymbol()) return; auto* name = propertyName.publicName(); @@ -201,7 +201,7 @@ bool JSCommonJSExtensions::deleteProperty(JSC::JSCell* cell, JSC::JSGlobalObject return deleted; } -extern "C" uint32_t JSCommonJSExtensions__appendFunction(Zig::GlobalObject* globalObject, JSC::JSValue value) +extern "C" uint32_t JSCommonJSExtensions__appendFunction(Bun::GlobalObject* globalObject, JSC::JSValue value) { JSCommonJSExtensions* extensions = globalObject->lazyRequireExtensionsObject(); extensions->m_registeredFunctions.append(JSC::WriteBarrier()); @@ -209,13 +209,13 @@ extern "C" uint32_t JSCommonJSExtensions__appendFunction(Zig::GlobalObject* glob return extensions->m_registeredFunctions.size() - 1; } -extern "C" void JSCommonJSExtensions__setFunction(Zig::GlobalObject* globalObject, uint32_t index, JSC::JSValue value) +extern "C" void JSCommonJSExtensions__setFunction(Bun::GlobalObject* globalObject, uint32_t index, JSC::JSValue value) { JSCommonJSExtensions* extensions = globalObject->lazyRequireExtensionsObject(); extensions->m_registeredFunctions[index].set(globalObject->vm(), globalObject, value); } -extern "C" uint32_t JSCommonJSExtensions__swapRemove(Zig::GlobalObject* globalObject, uint32_t index) +extern "C" uint32_t JSCommonJSExtensions__swapRemove(Bun::GlobalObject* globalObject, uint32_t index) { JSCommonJSExtensions* extensions = globalObject->lazyRequireExtensionsObject(); ASSERT(extensions->m_registeredFunctions.size() > 0); @@ -243,7 +243,7 @@ extern "C" uint32_t JSCommonJSExtensions__swapRemove(Zig::GlobalObject* globalOb JSC::EncodedJSValue builtinLoader(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame, BunLoaderType loaderType) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - Zig::GlobalObject* global = defaultGlobalObject(globalObject); + Bun::GlobalObject* global = defaultGlobalObject(globalObject); JSC::JSObject* modValue = callFrame->argument(0).getObject(); if (!modValue) { throwTypeError(globalObject, scope, "Module._extensions['.js'] must be called with a CommonJS module object"_s); diff --git a/src/jsc/bindings/JSCommonJSModule.cpp b/src/jsc/bindings/JSCommonJSModule.cpp index dc1645e8778b..8687516e7120 100644 --- a/src/jsc/bindings/JSCommonJSModule.cpp +++ b/src/jsc/bindings/JSCommonJSModule.cpp @@ -39,7 +39,7 @@ #include "root.h" #include "JavaScriptCore/SourceCode.h" #include "headers-handwritten.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include @@ -111,7 +111,7 @@ static bool canPerformFastEnumeration(Structure* s) extern "C" bool Bun__VM__specifierIsEvalEntryPoint(void*, EncodedJSValue); extern "C" void Bun__VM__setEntryPointEvalResultCJS(void*, EncodedJSValue); -static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Zig::GlobalObject* globalObject, JSCommonJSModule* moduleObject, JSString* dirname, JSValue filename) +static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Bun::GlobalObject* globalObject, JSCommonJSModule* moduleObject, JSString* dirname, JSValue filename) { auto scope = DECLARE_THROW_SCOPE(vm); SourceCode code = WTF::move(moduleObject->sourceCode); @@ -217,7 +217,7 @@ static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Zig::GlobalObject* globalObj return true; } -bool JSCommonJSModule::load(JSC::VM& vm, Zig::GlobalObject* globalObject) +bool JSCommonJSModule::load(JSC::VM& vm, Bun::GlobalObject* globalObject) { auto scope = DECLARE_THROW_SCOPE(vm); if (this->hasEvaluated || this->sourceCode.isNull()) { @@ -249,7 +249,7 @@ bool JSCommonJSModule::load(JSC::VM& vm, Zig::GlobalObject* globalObject) JSC_DEFINE_HOST_FUNCTION(jsFunctionEvaluateCommonJSModule, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe)) { auto& vm = JSC::getVM(lexicalGlobalObject); - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); // These casts are jsDynamicCast because require.cache pollution + invalid // this calls can put arbitrary values here instead of JSCommonJSModule* @@ -323,7 +323,7 @@ JSC_DEFINE_HOST_FUNCTION(requireResolvePathsFunction, (JSGlobalObject * globalOb JSC_DEFINE_CUSTOM_GETTER(jsRequireCacheGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - Zig::GlobalObject* thisObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* thisObject = uncheckedDowncast(globalObject); return JSValue::encode(thisObject->lazyRequireCacheObject()); } @@ -341,7 +341,7 @@ JSC_DEFINE_CUSTOM_SETTER(jsRequireCacheSetter, JSC_DEFINE_CUSTOM_GETTER(jsRequireExtensionsGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { - Zig::GlobalObject* thisObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* thisObject = uncheckedDowncast(globalObject); return JSValue::encode(thisObject->lazyRequireExtensionsObject()); } @@ -403,7 +403,7 @@ RequireFunctionPrototype* RequireFunctionPrototype::create( RequireFunctionPrototype* prototype = new (NotNull, JSC::allocateCell(vm)) RequireFunctionPrototype(vm, structure); prototype->finishCreation(vm); - prototype->putDirect(vm, vm.propertyNames->resolve, uncheckedDowncast(globalObject)->requireResolveFunctionUnbound(), 0); + prototype->putDirect(vm, vm.propertyNames->resolve, uncheckedDowncast(globalObject)->requireResolveFunctionUnbound(), 0); return prototype; } @@ -710,7 +710,7 @@ JSC_DEFINE_HOST_FUNCTION(functionJSCommonJSModule_compile, (JSGlobalObject * glo RETURN_IF_EXCEPTION(throwScope, {}); String wrappedString; - auto* zigGlobalObject = uncheckedDowncast(globalObject); + auto* zigGlobalObject = uncheckedDowncast(globalObject); if (zigGlobalObject->hasOverriddenModuleWrapper) [[unlikely]] { wrappedString = makeString( zigGlobalObject->m_moduleWrapperStart, @@ -744,7 +744,7 @@ JSC_DEFINE_HOST_FUNCTION(functionJSCommonJSModule_compile, (JSGlobalObject * glo WTF::NakedPtr exception; evaluateCommonJSModuleOnce( vm, - uncheckedDowncast(globalObject), + uncheckedDowncast(globalObject), moduleObject, jsString(vm, dirnameString), jsString(vm, filenameString)); @@ -868,11 +868,11 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateCommonJSModule, (JSGlobalObject * globa ASSERT(hasEvaluated.isBoolean()); JSValue parent = callframe->uncheckedArgument(3); - return JSValue::encode(JSCommonJSModule::create(uncheckedDowncast(globalObject), id, object, hasEvaluated.isTrue(), parent)); + return JSValue::encode(JSCommonJSModule::create(uncheckedDowncast(globalObject), id, object, hasEvaluated.isTrue(), parent)); } JSCommonJSModule* JSCommonJSModule::create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* requireMapKey, JSValue exportsObject, bool hasEvaluated, @@ -914,7 +914,7 @@ JSCommonJSModule* JSCommonJSModule::create( } JSCommonJSModule* JSCommonJSModule::create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, JSValue exportsObject, bool hasEvaluated, @@ -1155,7 +1155,7 @@ void JSCommonJSModule::setExportsObject(JSC::JSValue exportsObject) } Structure* createCommonJSModuleStructure( - Zig::GlobalObject* globalObject) + Bun::GlobalObject* globalObject) { return JSCommonJSModule::createStructure(globalObject); } @@ -1230,7 +1230,7 @@ const JSC::ClassInfo JSCommonJSModule::s_info = { "Module"_s, &Base::s_info, nul const JSC::ClassInfo RequireResolveFunctionPrototype::s_info = { "resolve"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(RequireResolveFunctionPrototype) }; const JSC::ClassInfo RequireFunctionPrototype::s_info = { "require"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(RequireFunctionPrototype) }; -ALWAYS_INLINE EncodedJSValue finishRequireWithError(Zig::GlobalObject* globalObject, JSC::ThrowScope& throwScope, JSC::JSValue specifierValue) +ALWAYS_INLINE EncodedJSValue finishRequireWithError(Bun::GlobalObject* globalObject, JSC::ThrowScope& throwScope, JSC::JSValue specifierValue) { JSC::JSValue exception = throwScope.exception(); ASSERT(exception); @@ -1251,7 +1251,7 @@ ALWAYS_INLINE EncodedJSValue finishRequireWithError(Zig::GlobalObject* globalObj // JSCommonJSModule.$require(resolvedId, newModule, userArgumentCount, userOptions) JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe)) { - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); ASSERT(callframe->argumentCount() == 4); @@ -1313,7 +1313,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlo JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireNativeModule, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe)) { - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -1348,7 +1348,7 @@ void RequireResolveFunctionPrototype::finishCreation(JSC::VM& vm) } void JSCommonJSModule::evaluate( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, ResolvedSource& source, bool isBuiltIn) @@ -1387,7 +1387,7 @@ void JSCommonJSModule::evaluate( } void JSCommonJSModule::evaluate( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, Ref&& sourceProvider, bool ignoreESModuleAnnotation) { @@ -1400,7 +1400,7 @@ void JSCommonJSModule::evaluate( } void JSCommonJSModule::evaluateWithPotentiallyOverriddenCompile( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, JSValue keyJSString, ResolvedSource& source) @@ -1449,7 +1449,7 @@ void JSCommonJSModule::evaluateWithPotentiallyOverriddenCompile( static JSC::SourceCode commonJSModuleSyntheticSourceCode(const SourceOrigin& sourceOrigin, const WTF::String& sourceURL); std::optional createCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSString* requireMapKey, ResolvedSource& source, bool isBuiltIn) @@ -1525,7 +1525,7 @@ static JSC::SourceCode commonJSModuleSyntheticSourceCode(const SourceOrigin& sou const JSC::Identifier& moduleKey, Vector& exportNames, JSC::MarkedArgumentBuffer& exportValues) -> void { - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1567,7 +1567,7 @@ static JSC::SourceCode commonJSModuleSyntheticSourceCode(const SourceOrigin& sou } std::optional createCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* requireMapKey, Ref&& sourceProvider, bool ignoreESModuleAnnotation) @@ -1622,7 +1622,7 @@ JSObject* JSCommonJSModule::createBoundRequireFunction(VM& vm, JSGlobalObject* l { ASSERT(!pathString.startsWith("file://"_s)); - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); JSString* filename = JSC::jsStringWithCache(vm, pathString); diff --git a/src/jsc/bindings/JSCommonJSModule.h b/src/jsc/bindings/JSCommonJSModule.h index eb7bf713307a..88b9c31e2ba1 100644 --- a/src/jsc/bindings/JSCommonJSModule.h +++ b/src/jsc/bindings/JSCommonJSModule.h @@ -7,7 +7,7 @@ #include "wtf/NakedPtr.h" #include "BunClientData.h" -namespace Zig { +namespace Bun { class GlobalObject; } namespace JSC { @@ -87,10 +87,10 @@ class JSCommonJSModule final : public JSC::JSDestructibleObject { static JSC::Structure* createStructure(JSC::JSGlobalObject* globalObject); - void evaluate(Zig::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource& resolvedSource, bool isBuiltIn); - void evaluate(Zig::GlobalObject* globalObject, Ref&& sourceProvider, bool ignoreESModuleAnnotation); - void evaluateWithPotentiallyOverriddenCompile(Zig::GlobalObject* globalObject, const WTF::String& sourceURL, JSValue keyJSString, ResolvedSource& resolvedSource); - inline void evaluate(Zig::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource& resolvedSource) + void evaluate(Bun::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource& resolvedSource, bool isBuiltIn); + void evaluate(Bun::GlobalObject* globalObject, Ref&& sourceProvider, bool ignoreESModuleAnnotation); + void evaluateWithPotentiallyOverriddenCompile(Bun::GlobalObject* globalObject, const WTF::String& sourceURL, JSValue keyJSString, ResolvedSource& resolvedSource); + inline void evaluate(Bun::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource& resolvedSource) { return evaluate(globalObject, sourceURL, resolvedSource, false); } @@ -101,17 +101,17 @@ class JSCommonJSModule final : public JSC::JSDestructibleObject { JSC::JSString* dirname, const JSC::SourceCode& sourceCode); static JSCommonJSModule* create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, JSValue exportsObject, bool hasEvaluated, JSValue parent); static JSCommonJSModule* create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* key, JSValue exportsObject, bool hasEvaluated, JSValue parent); static JSCommonJSModule* create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, ResolvedSource resolvedSource); @@ -130,7 +130,7 @@ class JSCommonJSModule final : public JSC::JSDestructibleObject { JSValue idOrDot() { return m_id.get(); } JSValue filename() { return m_filename.get(); } - bool load(JSC::VM& vm, Zig::GlobalObject* globalObject); + bool load(JSC::VM& vm, Bun::GlobalObject* globalObject); DECLARE_INFO; DECLARE_VISIT_CHILDREN; @@ -162,22 +162,22 @@ class JSCommonJSModule final : public JSC::JSDestructibleObject { }; JSC::Structure* createCommonJSModuleStructure( - Zig::GlobalObject* globalObject); + Bun::GlobalObject* globalObject); std::optional createCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierValue, ResolvedSource& source, bool isBuiltIn); std::optional createCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierValue, Ref&& provider, bool ignoreESModuleAnnotation); inline std::optional createCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierValue, ResolvedSource& source) { diff --git a/src/jsc/bindings/JSDOMExceptionHandling.cpp b/src/jsc/bindings/JSDOMExceptionHandling.cpp index ef3c4b60a329..cd7356cfbee3 100644 --- a/src/jsc/bindings/JSDOMExceptionHandling.cpp +++ b/src/jsc/bindings/JSDOMExceptionHandling.cpp @@ -73,7 +73,7 @@ void reportException(JSGlobalObject* lexicalGlobalObject, JSC::Exception* except // exceptionSourceURL = callFrame->sourceURL(); // } - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); if (exceptionDetails) { auto errorMessage = retrieveErrorMessage(*lexicalGlobalObject, vm, exception->value(), scope); diff --git a/src/jsc/bindings/JSDOMFile.cpp b/src/jsc/bindings/JSDOMFile.cpp index ac3e0588cf80..438d785418b7 100644 --- a/src/jsc/bindings/JSDOMFile.cpp +++ b/src/jsc/bindings/JSDOMFile.cpp @@ -73,7 +73,7 @@ class JSDOMFile : public JSC::InternalFunction { if (constructor != newTarget) { auto scope = DECLARE_THROW_SCOPE(vm); - auto* functionGlobalObject = static_cast( + auto* functionGlobalObject = static_cast( // ShadowRealm functions belong to a different global object. getFunctionRealm(lexicalGlobalObject, newTarget)); RETURN_IF_EXCEPTION(scope, {}); diff --git a/src/jsc/bindings/JSDOMGlobalObject.cpp b/src/jsc/bindings/JSDOMGlobalObject.cpp index c8970349ccba..e5e754c03d7b 100644 --- a/src/jsc/bindings/JSDOMGlobalObject.cpp +++ b/src/jsc/bindings/JSDOMGlobalObject.cpp @@ -1,12 +1,12 @@ #include "JSDOMGlobalObject.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace WebCore { -Zig::GlobalObject* toJSDOMGlobalObject(ScriptExecutionContext& ctx, DOMWrapperWorld& world) +Bun::GlobalObject* toJSDOMGlobalObject(ScriptExecutionContext& ctx, DOMWrapperWorld& world) { - return uncheckedDowncast(ctx.jsGlobalObject()); + return uncheckedDowncast(ctx.jsGlobalObject()); } // static JSDOMGlobalObject& callerGlobalObject(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame* callFrame, bool skipFirstFrame, bool lookUpFromVMEntryScope) diff --git a/src/jsc/bindings/JSDOMGlobalObject.h b/src/jsc/bindings/JSDOMGlobalObject.h index 8e55f27f6157..80e227c62043 100644 --- a/src/jsc/bindings/JSDOMGlobalObject.h +++ b/src/jsc/bindings/JSDOMGlobalObject.h @@ -2,7 +2,7 @@ #include "root.h" -namespace Zig { +namespace Bun { class GlobalObject; } @@ -16,7 +16,7 @@ class GlobalObject; namespace WebCore { -Zig::GlobalObject* toJSDOMGlobalObject(ScriptExecutionContext& ctx, DOMWrapperWorld& world); +Bun::GlobalObject* toJSDOMGlobalObject(ScriptExecutionContext& ctx, DOMWrapperWorld& world); template JSClass* toJSDOMGlobalObject(JSC::VM& vm, JSC::JSValue value) diff --git a/src/jsc/bindings/JSDOMWrapper.h b/src/jsc/bindings/JSDOMWrapper.h index d60ac10f50be..90437619ed53 100644 --- a/src/jsc/bindings/JSDOMWrapper.h +++ b/src/jsc/bindings/JSDOMWrapper.h @@ -21,7 +21,7 @@ #pragma once #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMGlobalObject.h" #include "NodeConstants.h" @@ -32,7 +32,7 @@ namespace WebCore { using namespace Zig; #ifndef RENAMED_JSDOM_GLOBAL_OBJECT #define RENAMED_JSDOM_GLOBAL_OBJECT -using JSDOMGlobalObject = Zig::GlobalObject; +using JSDOMGlobalObject = Bun::GlobalObject; } #endif class ScriptExecutionContext; diff --git a/src/jsc/bindings/JSDOMWrapperCache.cpp b/src/jsc/bindings/JSDOMWrapperCache.cpp index a48bd1311520..57c4cc966133 100644 --- a/src/jsc/bindings/JSDOMWrapperCache.cpp +++ b/src/jsc/bindings/JSDOMWrapperCache.cpp @@ -33,7 +33,7 @@ Structure* getCachedDOMStructure(const JSDOMGlobalObject& globalObject, const Cl Structure* cacheDOMStructure(JSDOMGlobalObject& globalObject, Structure* structure, const ClassInfo* classInfo) { - auto addToStructures = [](JSDOMStructureMap& structures, JSDOMGlobalObject& globalObject, Structure* structure, const ClassInfo* classInfo) { + auto addToStructures = [](Bun::JSDOMStructureMap& structures, JSDOMGlobalObject& globalObject, Structure* structure, const ClassInfo* classInfo) { ASSERT(!structures.contains(classInfo)); return structures.set(classInfo, JSC::WriteBarrier(globalObject.vm(), &globalObject, structure)).iterator->value.get(); }; diff --git a/src/jsc/bindings/JSEnvironmentVariableMap.cpp b/src/jsc/bindings/JSEnvironmentVariableMap.cpp index 9d6816d2ce36..3830a96ec93e 100644 --- a/src/jsc/bindings/JSEnvironmentVariableMap.cpp +++ b/src/jsc/bindings/JSEnvironmentVariableMap.cpp @@ -1,5 +1,5 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "helpers.h" @@ -344,7 +344,7 @@ JSC_DEFINE_HOST_FUNCTION(jsEditWindowsEnvVar, (JSGlobalObject * global, JSC::Cal } #endif -JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject) +JSValue createEnvironmentVariablesMap(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/JSEnvironmentVariableMap.h b/src/jsc/bindings/JSEnvironmentVariableMap.h index 0de7c81ba4f1..2eac99b7a2c3 100644 --- a/src/jsc/bindings/JSEnvironmentVariableMap.h +++ b/src/jsc/bindings/JSEnvironmentVariableMap.h @@ -1,6 +1,6 @@ #include "root.h" -namespace Zig { +namespace Bun { class GlobalObject; } @@ -10,6 +10,6 @@ class JSValue; namespace Bun { -JSC::JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject); +JSC::JSValue createEnvironmentVariablesMap(Bun::GlobalObject* globalObject); } diff --git a/src/jsc/bindings/JSFFIFunction.cpp b/src/jsc/bindings/JSFFIFunction.cpp index d03353812655..5eb752cef2a5 100644 --- a/src/jsc/bindings/JSFFIFunction.cpp +++ b/src/jsc/bindings/JSFFIFunction.cpp @@ -28,7 +28,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -45,13 +45,13 @@ class FFICallbackFunctionWrapper : public ThreadSafeRefCounted m_function; - JSC::Strong globalObject; + JSC::Strong globalObject; // Cached on the JS thread at construction time so the foreign-thread // trampoline never has to dereference a Strong to find the context. WebCore::ScriptExecutionContextIdentifier m_contextId; ~FFICallbackFunctionWrapper() = default; - FFICallbackFunctionWrapper(JSC::JSFunction* function, Zig::GlobalObject* globalObject) + FFICallbackFunctionWrapper(JSC::JSFunction* function, Bun::GlobalObject* globalObject) : m_function(globalObject->vm(), function) , globalObject(globalObject->vm(), globalObject) , m_contextId(globalObject->scriptExecutionContext()->identifier()) @@ -65,7 +65,7 @@ extern "C" void FFICallbackFunctionWrapper_destroy(FFICallbackFunctionWrapper* w } extern "C" FFICallbackFunctionWrapper* Bun__createFFICallbackFunction( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::EncodedJSValue callbackFn) { auto* vm = &globalObject->vm(); @@ -78,7 +78,7 @@ extern "C" FFICallbackFunctionWrapper* Bun__createFFICallbackFunction( return wrapper; } -extern "C" Zig::JSFFIFunction* Bun__CreateFFIFunctionWithData(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, void* data) +extern "C" Zig::JSFFIFunction* Bun__CreateFFIFunctionWithData(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, void* data) { auto& vm = JSC::getVM(globalObject); Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, globalObject, argCount, symbolName != nullptr ? Zig::toStringCopy(*symbolName) : String(), functionPointer, JSC::NoIntrinsic); @@ -86,7 +86,7 @@ extern "C" Zig::JSFFIFunction* Bun__CreateFFIFunctionWithData(Zig::GlobalObject* return function; } -extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionWithDataValue(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, void* data) +extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionWithDataValue(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, void* data) { return JSC::JSValue::encode(Bun__CreateFFIFunctionWithData(globalObject, symbolName, argCount, functionPointer, data)); } @@ -111,7 +111,7 @@ extern "C" void Bun__FFIFunction_setDataPtr(JSC::EncodedJSValue jsValue, void* p function->dataPtr = ptr; } -extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, bool addPtrField, void* symbolFromDynamicLibrary) +extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, bool addPtrField, void* symbolFromDynamicLibrary) { if (addPtrField) { auto* function = Zig::JSFFIFunction::createForFFI(globalObject->vm(), globalObject, argCount, symbolName != nullptr ? Zig::toStringCopy(*symbolName) : String(), reinterpret_cast(functionPointer)); @@ -156,7 +156,7 @@ void JSFFIFunction::finishCreation(VM& vm, NativeExecutable* executable, unsigne ASSERT(inherits(info())); } -JSFFIFunction* JSFFIFunction::create(VM& vm, Zig::GlobalObject* globalObject, unsigned length, const String& name, FFIFunction FFIFunction, Intrinsic intrinsic, NativeFunction nativeConstructor) +JSFFIFunction* JSFFIFunction::create(VM& vm, Bun::GlobalObject* globalObject, unsigned length, const String& name, FFIFunction FFIFunction, Intrinsic intrinsic, NativeFunction nativeConstructor) { NativeExecutable* executable = vm.getHostFunction(FFIFunction, ImplementationVisibility::Public, intrinsic, FFIFunction, nullptr, name); Structure* structure = globalObject->FFIFunctionStructure(); @@ -175,7 +175,7 @@ JSC_DEFINE_HOST_FUNCTION(JSFFIFunction::trampoline, (JSC::JSGlobalObject * globa #endif -JSFFIFunction* JSFFIFunction::createForFFI(VM& vm, Zig::GlobalObject* globalObject, unsigned length, const String& name, CFFIFunction FFIFunction) +JSFFIFunction* JSFFIFunction::createForFFI(VM& vm, Bun::GlobalObject* globalObject, unsigned length, const String& name, CFFIFunction FFIFunction) { #if OS(WINDOWS) NativeExecutable* executable = vm.getHostFunction(trampoline, ImplementationVisibility::Public, NoIntrinsic, trampoline, nullptr, name); @@ -219,7 +219,7 @@ FFI_Callback_threadsafe_call(FFICallbackFunctionWrapper& wrapper, size_t argCoun argsVec.append(args[i]); WebCore::ScriptExecutionContext::postTaskTo(wrapper.m_contextId, [argsVec = WTF::move(argsVec), protectedWrapper = Ref { wrapper }](WebCore::ScriptExecutionContext& ctx) mutable { - auto* globalObject = uncheckedDowncast(ctx.jsGlobalObject()); + auto* globalObject = uncheckedDowncast(ctx.jsGlobalObject()); auto& vm = JSC::getVM(globalObject); JSC::MarkedArgumentBuffer arguments; auto* function = protectedWrapper->m_function.get(); diff --git a/src/jsc/bindings/JSFFIFunction.h b/src/jsc/bindings/JSFFIFunction.h index 6eccae7b6174..81cd49d17b65 100644 --- a/src/jsc/bindings/JSFFIFunction.h +++ b/src/jsc/bindings/JSFFIFunction.h @@ -1,6 +1,6 @@ #pragma once -namespace Zig { +namespace Bun { class GlobalObject; } @@ -69,8 +69,8 @@ class JSFFIFunction final : public JSC::JSFunction { DECLARE_EXPORT_INFO; - JS_EXPORT_PRIVATE static JSFFIFunction* create(VM&, Zig::GlobalObject*, unsigned length, const String& name, FFIFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor); - JS_EXPORT_PRIVATE static JSFFIFunction* createForFFI(VM&, Zig::GlobalObject*, unsigned length, const String& name, CFFIFunction); + JS_EXPORT_PRIVATE static JSFFIFunction* create(VM&, Bun::GlobalObject*, unsigned length, const String& name, FFIFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor); + JS_EXPORT_PRIVATE static JSFFIFunction* createForFFI(VM&, Bun::GlobalObject*, unsigned length, const String& name, CFFIFunction); static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { diff --git a/src/jsc/bindings/JSMockFunction.cpp b/src/jsc/bindings/JSMockFunction.cpp index 9b39827ad788..fae00d22c9ad 100644 --- a/src/jsc/bindings/JSMockFunction.cpp +++ b/src/jsc/bindings/JSMockFunction.cpp @@ -4,7 +4,7 @@ #include "JavaScriptCore/Error.h" #include "JSMockFunction.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include @@ -233,7 +233,7 @@ class JSMockFunction : public JSC::InternalFunction { using Base = JSC::InternalFunction; static constexpr unsigned StructureFlags = Base::StructureFlags; - static JSMockFunction* create(JSC::VM& vm, Zig::GlobalObject* globalObject, JSC::Structure* structure, CallbackKind kind = CallbackKind::Call) + static JSMockFunction* create(JSC::VM& vm, Bun::GlobalObject* globalObject, JSC::Structure* structure, CallbackKind kind = CallbackKind::Call) { JSMockFunction* function = new (NotNull, JSC::allocateCell(vm)) JSMockFunction(vm, structure, kind); function->finishCreation(vm); @@ -324,7 +324,7 @@ class JSMockFunction : public JSC::InternalFunction { mock.initLater( [](const JSC::LazyProperty::Initializer& init) { JSMockFunction* mock = init.owner; - Zig::GlobalObject* globalObject = uncheckedDowncast(mock->globalObject()); + Bun::GlobalObject* globalObject = uncheckedDowncast(mock->globalObject()); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); JSC::Structure* structure = globalObject->mockModule.mockObjectStructure.getInitializedOnMainThread(globalObject); @@ -509,7 +509,7 @@ DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSMockFunction); static void pushImpl(JSMockFunction* fn, JSGlobalObject* jsGlobalObject, JSMockImplementation::Kind kind, JSValue value) { - Zig::GlobalObject* globalObject = uncheckedDowncast(jsGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(jsGlobalObject); auto& vm = JSC::getVM(globalObject); if (auto* current = tryJSDynamicCast(fn->fallbackImplmentation)) { @@ -529,7 +529,7 @@ static void pushImpl(JSMockFunction* fn, JSGlobalObject* jsGlobalObject, JSMockI static void pushImplOnce(JSMockFunction* fn, JSGlobalObject* jsGlobalObject, JSMockImplementation::Kind kind, JSValue value) { - Zig::GlobalObject* globalObject = uncheckedDowncast(jsGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(jsGlobalObject); auto& vm = JSC::getVM(globalObject); JSMockImplementation* impl = JSMockImplementation::create(globalObject, globalObject->mockModule.mockImplementationStructure.getInitializedOnMainThread(globalObject), kind, value, true); @@ -616,7 +616,7 @@ static SpyWeakHandleOwner& weakValueHandleOwner() const ClassInfo JSMockFunctionPrototype::s_info = { "Mock"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMockFunctionPrototype) }; -extern "C" void JSMock__resetSpies(Zig::GlobalObject* globalObject) +extern "C" void JSMock__resetSpies(Bun::GlobalObject* globalObject) { if (!globalObject->mockModule.activeSpies) { return; @@ -639,7 +639,7 @@ extern "C" void JSMock__resetSpies(Zig::GlobalObject* globalObject) globalObject->mockModule.activeSpies.clear(); } -extern "C" void JSMock__clearAllMocks(Zig::GlobalObject* globalObject) +extern "C" void JSMock__clearAllMocks(Bun::GlobalObject* globalObject) { if (!globalObject->mockModule.activeMocks) { return; @@ -675,7 +675,7 @@ JSMockModule JSMockModule::create(JSC::JSGlobalObject* globalObject) }); mock.mockResultStructure.initLater( [](const JSC::LazyProperty::Initializer& init) { - Zig::GlobalObject* globalObject = uncheckedDowncast(init.owner); + Bun::GlobalObject* globalObject = uncheckedDowncast(init.owner); JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype( globalObject, globalObject->objectPrototype(), @@ -717,7 +717,7 @@ JSMockModule JSMockModule::create(JSC::JSGlobalObject* globalObject) }); mock.mockObjectStructure.initLater( [](const JSC::LazyProperty::Initializer& init) { - Zig::GlobalObject* globalObject = uncheckedDowncast(init.owner); + Bun::GlobalObject* globalObject = uncheckedDowncast(init.owner); auto* prototype = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype()); // `putDirectCustomAccessor` doesn't pass the `this` value as expected. unfortunatly we @@ -816,7 +816,7 @@ extern Structure* createMockResultStructure(JSC::VM& vm, JSC::JSGlobalObject* gl return structure; } -static JSValue createMockResult(JSC::VM& vm, Zig::GlobalObject* globalObject, const WTF::String& type, JSC::JSValue value) +static JSValue createMockResult(JSC::VM& vm, Bun::GlobalObject* globalObject, const WTF::String& type, JSC::JSValue value) { JSC::Structure* structure = globalObject->mockModule.mockResultStructure.getInitializedOnMainThread(globalObject); @@ -828,7 +828,7 @@ static JSValue createMockResult(JSC::VM& vm, Zig::GlobalObject* globalObject, co JSC_DEFINE_HOST_FUNCTION(jsMockFunctionCall, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe)) { - Zig::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); JSMockFunction* fn = dynamicDowncast(callframe->jsCallee()); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1115,7 +1115,7 @@ JSC_DEFINE_HOST_FUNCTION(jsMockFunctionMockRestore, (JSC::JSGlobalObject * globa JSC_DEFINE_HOST_FUNCTION(jsMockFunctionMockImplementation, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callframe)) { auto& vm = JSC::getVM(lexicalGlobalObject); - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); JSValue thisValue = callframe->thisValue(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1137,7 +1137,7 @@ JSC_DEFINE_HOST_FUNCTION(jsMockFunctionMockImplementation, (JSC::JSGlobalObject JSC_DEFINE_HOST_FUNCTION(jsMockFunctionMockImplementationOnce, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callframe)) { auto& vm = JSC::getVM(lexicalGlobalObject); - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); JSValue thisValue = callframe->thisValue(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1336,7 +1336,7 @@ DEFINE_VISIT_CHILDREN(MockWithImplementationCleanupData); MockWithImplementationCleanupData* MockWithImplementationCleanupData::create(JSC::JSGlobalObject* globalObject, JSMockFunction* fn, JSValue impl, JSValue tail, JSValue fallback) { - auto* obj = create(globalObject->vm(), static_cast(globalObject)->mockModule.mockWithImplementationCleanupDataStructure.getInitializedOnMainThread(globalObject)); + auto* obj = create(globalObject->vm(), static_cast(globalObject)->mockModule.mockWithImplementationCleanupDataStructure.getInitializedOnMainThread(globalObject)); obj->finishCreation(globalObject->vm(), fn, impl, tail, fallback); return obj; } @@ -1358,7 +1358,7 @@ JSC_DEFINE_HOST_FUNCTION(jsMockFunctionWithImplementationCleanup, (JSC::JSGlobal } JSC_DEFINE_HOST_FUNCTION(jsMockFunctionWithImplementation, (JSC::JSGlobalObject * jsGlobalObject, JSC::CallFrame* callframe)) { - Zig::GlobalObject* globalObject = uncheckedDowncast(jsGlobalObject); + Bun::GlobalObject* globalObject = uncheckedDowncast(jsGlobalObject); JSValue thisValue = callframe->thisValue(); JSMockFunction* thisObject = dynamicDowncast(thisValue); @@ -1465,13 +1465,13 @@ BUN_DEFINE_HOST_FUNCTION(JSMock__jsSetSystemTime, (JSC::JSGlobalObject * globalO BUN_DEFINE_HOST_FUNCTION(JSMock__jsRestoreAllMocks, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { - JSMock__resetSpies(uncheckedDowncast(globalObject)); + JSMock__resetSpies(uncheckedDowncast(globalObject)); return JSValue::encode(jsUndefined()); } BUN_DEFINE_HOST_FUNCTION(JSMock__jsClearAllMocks, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { - JSMock__clearAllMocks(uncheckedDowncast(globalObject)); + JSMock__clearAllMocks(uncheckedDowncast(globalObject)); return JSValue::encode(jsUndefined()); } @@ -1480,7 +1480,7 @@ BUN_DEFINE_HOST_FUNCTION(JSMock__jsSpyOn, (JSC::JSGlobalObject * lexicalGlobalOb auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); - auto* globalObject = dynamicDowncast(lexicalGlobalObject); + auto* globalObject = dynamicDowncast(lexicalGlobalObject); if (!globalObject) [[unlikely]] { throwVMError(globalObject, scope, "Cannot run spyOn from a different global context"_s); return {}; @@ -1604,7 +1604,7 @@ BUN_DEFINE_HOST_FUNCTION(JSMock__jsSpyOn, (JSC::JSGlobalObject * lexicalGlobalOb BUN_DEFINE_HOST_FUNCTION(JSMock__jsMockFn, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callframe)) { auto& vm = JSC::getVM(lexicalGlobalObject); - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); JSMockFunction* thisObject = JSMockFunction::create( diff --git a/src/jsc/bindings/JSNodePerformanceHooksHistogram.cpp b/src/jsc/bindings/JSNodePerformanceHooksHistogram.cpp index b329eb2087ff..8651514ad3fe 100644 --- a/src/jsc/bindings/JSNodePerformanceHooksHistogram.cpp +++ b/src/jsc/bindings/JSNodePerformanceHooksHistogram.cpp @@ -3,7 +3,7 @@ #include "JSNodePerformanceHooksHistogram.h" #include "JSNodePerformanceHooksHistogramPrototype.h" #include "JSNodePerformanceHooksHistogramConstructor.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include "BunString.h" #include "JSDOMExceptionHandling.h" diff --git a/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp b/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp index 0962a5aa228a..dd9ce70c2651 100644 --- a/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp +++ b/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp @@ -3,7 +3,7 @@ #include "JSNodePerformanceHooksHistogramConstructor.h" #include "JSNodePerformanceHooksHistogram.h" #include "JSNodePerformanceHooksHistogramPrototype.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include "BunString.h" #include "wtf/text/ASCIILiteral.h" diff --git a/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.h b/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.h index ad165d5a3a7c..d8f16e7f2b91 100644 --- a/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.h +++ b/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.h @@ -1,7 +1,7 @@ #pragma once #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { diff --git a/src/jsc/bindings/JSPropertyIterator.cpp b/src/jsc/bindings/JSPropertyIterator.cpp index e4de689c18f4..be069c74992f 100644 --- a/src/jsc/bindings/JSPropertyIterator.cpp +++ b/src/jsc/bindings/JSPropertyIterator.cpp @@ -1,7 +1,7 @@ #include "root.h" #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/JSType.h" #include "JavaScriptCore/EnumerationMode.h" #include "JavaScriptCore/ExceptionScope.h" diff --git a/src/jsc/bindings/JSReactElement.cpp b/src/jsc/bindings/JSReactElement.cpp index b567c0542c3b..1a226077dc18 100644 --- a/src/jsc/bindings/JSReactElement.cpp +++ b/src/jsc/bindings/JSReactElement.cpp @@ -83,7 +83,7 @@ extern "C" JSC::EncodedJSValue JSReactElement__create( EncodedJSValue type, EncodedJSValue props) { - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); VM& vm = global->vm(); JSObject* element = constructEmptyObject(vm, global->JSReactElementStructure()); @@ -101,7 +101,7 @@ extern "C" JSC::EncodedJSValue JSReactElement__createFragment( uint8_t reactVersion, EncodedJSValue children) { - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); VM& vm = global->vm(); JSC::Symbol* fragmentSymbol = JSC::Symbol::create(vm, diff --git a/src/jsc/bindings/JSReactElement.h b/src/jsc/bindings/JSReactElement.h index c3e0e726c883..35f2b2421aad 100644 --- a/src/jsc/bindings/JSReactElement.h +++ b/src/jsc/bindings/JSReactElement.h @@ -2,7 +2,7 @@ #include "root.h" #include "headers.h" #include "JavaScriptCore/JSObjectInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" using namespace JSC; diff --git a/src/jsc/bindings/JSS3File.cpp b/src/jsc/bindings/JSS3File.cpp index aecfc1de9248..3fc995ef6cd2 100644 --- a/src/jsc/bindings/JSS3File.cpp +++ b/src/jsc/bindings/JSS3File.cpp @@ -1,7 +1,7 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ZigGeneratedClasses.h" #include "JavaScriptCore/JSType.h" diff --git a/src/jsc/bindings/JSS3File.h b/src/jsc/bindings/JSS3File.h index 8ba8c2839d8b..1516f062476a 100644 --- a/src/jsc/bindings/JSS3File.h +++ b/src/jsc/bindings/JSS3File.h @@ -1,6 +1,6 @@ #pragma once -namespace Zig { +namespace Bun { class GlobalObject; } diff --git a/src/jsc/bindings/JSSecrets.cpp b/src/jsc/bindings/JSSecrets.cpp index 2d4e9feb3764..08151d70c4a4 100644 --- a/src/jsc/bindings/JSSecrets.cpp +++ b/src/jsc/bindings/JSSecrets.cpp @@ -1,7 +1,7 @@ #include "ErrorCode.h" #include "root.h" #include "Secrets.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/JSSocketAddressDTO.cpp b/src/jsc/bindings/JSSocketAddressDTO.cpp index 5ab09090a543..ab0af85f984a 100644 --- a/src/jsc/bindings/JSSocketAddressDTO.cpp +++ b/src/jsc/bindings/JSSocketAddressDTO.cpp @@ -13,7 +13,7 @@ static constexpr PropertyOffset addressOffset = 0; static constexpr PropertyOffset familyOffset = 1; static constexpr PropertyOffset portOffset = 2; -JSObject* create(Zig::GlobalObject* globalObject, JSString* value, int32_t port, bool isIPv6) +JSObject* create(Bun::GlobalObject* globalObject, JSString* value, int32_t port, bool isIPv6) { static const NeverDestroyed IPv4 = MAKE_STATIC_STRING_IMPL("IPv4"); static const NeverDestroyed IPv6 = MAKE_STATIC_STRING_IMPL("IPv6"); @@ -70,7 +70,7 @@ Structure* createStructure(VM& vm, JSGlobalObject* globalObject) extern "C" JSC::EncodedJSValue JSSocketAddressDTO__create(JSGlobalObject* globalObject, EncodedJSValue address, uint16_t port, bool isIPv6) { VM& vm = globalObject->vm(); - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); auto* af = isIPv6 ? global->commonStrings().IPv6String(global) : global->commonStrings().IPv4String(global); diff --git a/src/jsc/bindings/JSSocketAddressDTO.h b/src/jsc/bindings/JSSocketAddressDTO.h index 6fe868bac49f..728d37e5037e 100644 --- a/src/jsc/bindings/JSSocketAddressDTO.h +++ b/src/jsc/bindings/JSSocketAddressDTO.h @@ -3,7 +3,7 @@ #include "headers.h" #include "root.h" #include "JavaScriptCore/JSObjectInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" using namespace JSC; @@ -11,7 +11,7 @@ namespace Bun { namespace JSSocketAddressDTO { Structure* createStructure(VM& vm, JSGlobalObject* globalObject); -JSObject* create(Zig::GlobalObject* globalObject, JSString* value, int port, bool isIPv6); +JSObject* create(Bun::GlobalObject* globalObject, JSString* value, int port, bool isIPv6); } // namespace JSSocketAddress } // namespace Bun diff --git a/src/jsc/bindings/JSStringDecoder.cpp b/src/jsc/bindings/JSStringDecoder.cpp index a9f7a4ddb553..11bbc905d129 100644 --- a/src/jsc/bindings/JSStringDecoder.cpp +++ b/src/jsc/bindings/JSStringDecoder.cpp @@ -3,7 +3,7 @@ #include #include #include "JavaScriptCore/ExceptionScope.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMOperation.h" #include "JSDOMAttribute.h" #include "headers.h" @@ -496,7 +496,7 @@ static JSC_DEFINE_CUSTOM_GETTER(jsStringDecoder_lastChar, (JSGlobalObject * lexi JSStringDecoder* castedThis = jsStringDecoderCast(lexicalGlobalObject, JSC::JSValue::decode(thisValue), "lastChar"_s); RETURN_IF_EXCEPTION(scope, {}); auto buffer = ArrayBuffer::create({ castedThis->m_lastChar, 4 }); - auto* globalObject = static_cast(lexicalGlobalObject); + auto* globalObject = static_cast(lexicalGlobalObject); JSC::JSUint8Array* uint8Array = JSC::JSUint8Array::create(lexicalGlobalObject, globalObject->JSBufferSubclassStructure(), WTF::move(buffer), 0, 4); RELEASE_AND_RETURN(scope, JSC::JSValue::encode(uint8Array)); } @@ -579,7 +579,7 @@ JSC::EncodedJSValue JSStringDecoderConstructor::construct(JSC::JSGlobalObject* l } } JSValue thisValue = callFrame->newTarget(); - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); JSObject* newTarget = asObject(thisValue); auto* constructor = globalObject->JSStringDecoder(); Structure* structure = globalObject->JSStringDecoderStructure(); diff --git a/src/jsc/bindings/JSWrappingFunction.cpp b/src/jsc/bindings/JSWrappingFunction.cpp index 2b35c618e96e..993033cdc879 100644 --- a/src/jsc/bindings/JSWrappingFunction.cpp +++ b/src/jsc/bindings/JSWrappingFunction.cpp @@ -1,5 +1,5 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSWrappingFunction.h" #include @@ -19,7 +19,7 @@ const ClassInfo JSWrappingFunction::s_info = { "Function"_s, &Base::s_info, null JS_EXPORT_PRIVATE JSWrappingFunction* JSWrappingFunction::create( VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const BunString* symbolName, Zig::NativeFunctionPtr functionPointer, JSC::JSValue wrappedFnValue) @@ -61,9 +61,9 @@ void JSWrappingFunction::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(JSWrappingFunction); extern "C" JSC::EncodedJSValue Bun__JSWrappingFunction__create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const BunString* symbolName, - Bun::NativeFunctionPtr functionPointer, + Zig::NativeFunctionPtr functionPointer, JSC::EncodedJSValue wrappedFnEncoded) { auto& vm = JSC::getVM(globalObject); @@ -74,7 +74,7 @@ extern "C" JSC::EncodedJSValue Bun__JSWrappingFunction__create( extern "C" JSC::EncodedJSValue Bun__JSWrappingFunction__getWrappedFunction( JSC::EncodedJSValue thisValueEncoded, - Zig::GlobalObject* globalObject) + Bun::GlobalObject* globalObject) { JSC::JSValue thisValue = JSC::JSValue::decode(thisValueEncoded); JSWrappingFunction* thisObject = dynamicDowncast(thisValue.asCell()); diff --git a/src/jsc/bindings/JSWrappingFunction.h b/src/jsc/bindings/JSWrappingFunction.h index 5b2aec591ba3..30a59af4bd64 100644 --- a/src/jsc/bindings/JSWrappingFunction.h +++ b/src/jsc/bindings/JSWrappingFunction.h @@ -1,6 +1,6 @@ #pragma once -namespace Zig { +namespace Bun { class GlobalObject; } @@ -50,7 +50,7 @@ class JSWrappingFunction final : public JSC::JSFunction { } DECLARE_EXPORT_INFO; - static JSWrappingFunction* create(JSC::VM& vm, Zig::GlobalObject* globalObject, const BunString* symbolName, NativeFunctionPtr functionPointer, JSC::JSValue wrappedFn); + static JSWrappingFunction* create(JSC::VM& vm, Bun::GlobalObject* globalObject, const BunString* symbolName, NativeFunctionPtr functionPointer, JSC::JSValue wrappedFn); static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { diff --git a/src/jsc/bindings/JSX509Certificate.cpp b/src/jsc/bindings/JSX509Certificate.cpp index 8d124fb2ff8a..7b120460ca92 100644 --- a/src/jsc/bindings/JSX509Certificate.cpp +++ b/src/jsc/bindings/JSX509Certificate.cpp @@ -9,7 +9,7 @@ #include "ErrorCode.h" #include "JSX509Certificate.h" #include "JSX509CertificatePrototype.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "wtf/ASCIICType.h" #include "wtf/Assertions.h" #include "wtf/SharedTask.h" diff --git a/src/jsc/bindings/JSX509Certificate.h b/src/jsc/bindings/JSX509Certificate.h index 098437408710..9430cffc6887 100644 --- a/src/jsc/bindings/JSX509Certificate.h +++ b/src/jsc/bindings/JSX509Certificate.h @@ -13,7 +13,7 @@ #include #include "KeyObject.h" -namespace Zig { +namespace Bun { class GlobalObject; } diff --git a/src/jsc/bindings/JSX509CertificateConstructor.cpp b/src/jsc/bindings/JSX509CertificateConstructor.cpp index 04b7fc1fb851..298953b74420 100644 --- a/src/jsc/bindings/JSX509CertificateConstructor.cpp +++ b/src/jsc/bindings/JSX509CertificateConstructor.cpp @@ -1,7 +1,7 @@ #include "root.h" #include "JSX509CertificateConstructor.h" #include "JSX509Certificate.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include namespace Bun { diff --git a/src/jsc/bindings/JSX509CertificateConstructor.h b/src/jsc/bindings/JSX509CertificateConstructor.h index ee740d0ee1a0..841dc714899d 100644 --- a/src/jsc/bindings/JSX509CertificateConstructor.h +++ b/src/jsc/bindings/JSX509CertificateConstructor.h @@ -4,7 +4,7 @@ #include #include -namespace Zig { +namespace Bun { class GlobalObject; } diff --git a/src/jsc/bindings/JSX509CertificatePrototype.cpp b/src/jsc/bindings/JSX509CertificatePrototype.cpp index c25cf8e2a906..3400ee77b396 100644 --- a/src/jsc/bindings/JSX509CertificatePrototype.cpp +++ b/src/jsc/bindings/JSX509CertificatePrototype.cpp @@ -3,7 +3,7 @@ #include "root.h" #include "JSDOMExceptionHandling.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ncrypto.h" #include "JSX509Certificate.h" #include "JSX509CertificatePrototype.h" diff --git a/src/jsc/bindings/ModuleLoader.cpp b/src/jsc/bindings/ModuleLoader.cpp index 30d7fe37d59b..ef90a2fa2f9a 100644 --- a/src/jsc/bindings/ModuleLoader.cpp +++ b/src/jsc/bindings/ModuleLoader.cpp @@ -4,7 +4,7 @@ #include "JavaScriptCore/JSGlobalObject.h" #include "ModuleLoader.h" #include "JavaScriptCore/Identifier.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include @@ -130,7 +130,7 @@ static JSC::SyntheticSourceProvider::SyntheticSourceGenerator generateInternalMo }; } -static OnLoadResult handleOnLoadObjectResult(Zig::GlobalObject* globalObject, JSC::JSObject* object) +static OnLoadResult handleOnLoadObjectResult(Bun::GlobalObject* globalObject, JSC::JSObject* object) { OnLoadResult result {}; result.type = OnLoadResultTypeObject; @@ -199,13 +199,13 @@ DEFINE_VISIT_CHILDREN(PendingVirtualModuleResult); PendingVirtualModuleResult* PendingVirtualModuleResult::create(JSC::JSGlobalObject* globalObject, const WTF::String& specifier, const WTF::String& referrer, bool wasModuleLock) { - auto* virtualModule = create(globalObject->vm(), static_cast(globalObject)->pendingVirtualModuleResultStructure()); + auto* virtualModule = create(globalObject->vm(), static_cast(globalObject)->pendingVirtualModuleResultStructure()); virtualModule->finishCreation(globalObject->vm(), specifier, referrer); virtualModule->wasModuleMock = wasModuleLock; return virtualModule; } -OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC::JSValue objectValue, BunString* specifier, bool wasModuleMock) +OnLoadResult handleOnLoadResultNotPromise(Bun::GlobalObject* globalObject, JSC::JSValue objectValue, BunString* specifier, bool wasModuleMock) { OnLoadResult result = {}; result.type = OnLoadResultTypeError; @@ -317,7 +317,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC:: return result; } -static OnLoadResult handleOnLoadResult(Zig::GlobalObject* globalObject, JSC::JSValue objectValue, BunString* specifier, bool wasModuleMock = false) +static OnLoadResult handleOnLoadResult(Bun::GlobalObject* globalObject, JSC::JSValue objectValue, BunString* specifier, bool wasModuleMock = false) { if (dynamicDowncast(objectValue)) { OnLoadResult result = {}; @@ -332,7 +332,7 @@ static OnLoadResult handleOnLoadResult(Zig::GlobalObject* globalObject, JSC::JSV template static JSValue handleVirtualModuleResult( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSValue virtualModuleResult, ErrorableResolvedSource* res, BunString* specifier, @@ -458,7 +458,7 @@ static JSValue handleVirtualModuleResult( } extern "C" void Bun__onFulfillAsyncModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::EncodedJSValue encodedPromiseValue, ErrorableResolvedSource* res, BunString* specifier, @@ -517,7 +517,7 @@ extern "C" void Bun__onFulfillAsyncModule( } JSValue fetchBuiltinModuleWithoutResolution( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, ErrorableResolvedSource* res) { @@ -567,7 +567,7 @@ JSValue fetchBuiltinModuleWithoutResolution( } JSValue resolveAndFetchBuiltinModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier) { void* bunVM = globalObject->bunVM(); @@ -614,7 +614,7 @@ JSValue resolveAndFetchBuiltinModule( } void evaluateCommonJSCustomExtension( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSCommonJSModule* target, String filename, JSValue filenameValue, @@ -639,7 +639,7 @@ void evaluateCommonJSCustomExtension( } JSValue fetchCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSCommonJSModule* target, JSValue specifierValue, String specifierWtfString, @@ -799,7 +799,7 @@ template JSValue fetchCommonJSModuleNonBuiltin( void* bunVM, JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, JSC::JSValue specifierValue, BunString* referrer, @@ -893,7 +893,7 @@ JSValue fetchCommonJSModuleNonBuiltin( template JSValue fetchCommonJSModuleNonBuiltin( void* bunVM, JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, JSC::JSValue specifierValue, BunString* referrer, @@ -906,7 +906,7 @@ template JSValue fetchCommonJSModuleNonBuiltin( template JSValue fetchCommonJSModuleNonBuiltin( void* bunVM, JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, JSC::JSValue specifierValue, BunString* referrer, @@ -921,7 +921,7 @@ extern "C" bool isBunTest; template static JSValue fetchESMSourceCode( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -1185,7 +1185,7 @@ static JSValue fetchESMSourceCode( } JSValue fetchESMSourceCodeSync( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -1196,7 +1196,7 @@ JSValue fetchESMSourceCodeSync( } JSValue fetchESMSourceCodeAsync( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -1242,7 +1242,7 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionOnLoadObjectResultResolve, (JSC::JSGlobalObje bool wasModuleMock = pendingModule->wasModuleMock; - JSC::JSValue result = handleVirtualModuleResult(static_cast(globalObject), objectResult, &res, &specifier, &referrer, wasModuleMock); + JSC::JSValue result = handleVirtualModuleResult(static_cast(globalObject), objectResult, &res, &specifier, &referrer, wasModuleMock); if (!scope.exception() && !res.success) [[unlikely]] { throwException(globalObject, scope, result); } diff --git a/src/jsc/bindings/ModuleLoader.h b/src/jsc/bindings/ModuleLoader.h index 5f8380c67242..f26445d34cb5 100644 --- a/src/jsc/bindings/ModuleLoader.h +++ b/src/jsc/bindings/ModuleLoader.h @@ -10,7 +10,7 @@ BUN_DECLARE_HOST_FUNCTION(jsFunctionOnLoadObjectResultResolve); BUN_DECLARE_HOST_FUNCTION(jsFunctionOnLoadObjectResultReject); BUN_DECLARE_HOST_FUNCTION(jsFunctionEvictIsolationSourceProviderCache); -namespace Zig { +namespace Bun { class GlobalObject; } @@ -92,7 +92,7 @@ class PendingVirtualModuleResult : public JSC::JSInternalFieldObjectImpl<3> { }; JSValue fetchESMSourceCodeSync( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSString* spceifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -100,7 +100,7 @@ JSValue fetchESMSourceCodeSync( BunString* typeAttribute); JSValue fetchESMSourceCodeAsync( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSString* spceifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -108,7 +108,7 @@ JSValue fetchESMSourceCodeAsync( BunString* typeAttribute); JSValue fetchCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSCommonJSModule* moduleObject, JSValue specifierValue, String specifier, @@ -119,7 +119,7 @@ template JSValue fetchCommonJSModuleNonBuiltin( void* bunVM, JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, JSC::JSValue specifierValue, BunString* referrer, @@ -131,11 +131,11 @@ JSValue fetchCommonJSModuleNonBuiltin( JSC::ThrowScope& scope); JSValue resolveAndFetchBuiltinModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier); JSValue fetchBuiltinModuleWithoutResolution( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, ErrorableResolvedSource* res); diff --git a/src/jsc/bindings/NapiClass.cpp b/src/jsc/bindings/NapiClass.cpp index 37381160e7ef..de3593cebbdd 100644 --- a/src/jsc/bindings/NapiClass.cpp +++ b/src/jsc/bindings/NapiClass.cpp @@ -63,7 +63,7 @@ JSC_HOST_CALL_ATTRIBUTES JSC::EncodedJSValue NapiClass_ConstructorFunction(JSC:: } NAPICallFrame frame(globalObject, callFrame, napi->dataPtr(), newTarget); - Bun::NapiHandleScope handleScope(uncheckedDowncast(globalObject)); + Bun::NapiHandleScope handleScope(uncheckedDowncast(globalObject)); JSValue ret = toJS(napi->constructor()(napi->env(), frame.toNapi())); napi_set_last_error(napi->env(), napi_ok); @@ -107,7 +107,7 @@ void NapiClass::finishCreation(VM& vm, NativeExecutable* executable, const Strin Base::finishCreation(vm, executable, 0, name); ASSERT(inherits(info())); this->m_constructor = constructor; - auto globalObject = static_cast(this->globalObject()); + auto globalObject = static_cast(this->globalObject()); this->putDirect(vm, vm.propertyNames->name, jsString(vm, name), JSC::PropertyAttribute::DontEnum | 0); diff --git a/src/jsc/bindings/NativePromiseContext.cpp b/src/jsc/bindings/NativePromiseContext.cpp index f060c8cdbada..24e4f3c0ffe0 100644 --- a/src/jsc/bindings/NativePromiseContext.cpp +++ b/src/jsc/bindings/NativePromiseContext.cpp @@ -1,6 +1,6 @@ #include "NativePromiseContext.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" // Implemented in src/runtime/api/NativePromiseContext.rs. Switches on // tag to release the ref on the right native type. @@ -41,7 +41,7 @@ void NativePromiseContext::destroy(JSC::JSCell* cell) } // namespace Bun -extern "C" JSC::EncodedJSValue Bun__NativePromiseContext__create(Zig::GlobalObject* globalObject, void* ctx, uint8_t tag) +extern "C" JSC::EncodedJSValue Bun__NativePromiseContext__create(Bun::GlobalObject* globalObject, void* ctx, uint8_t tag) { auto& vm = JSC::getVM(globalObject); auto* cell = Bun::NativePromiseContext::create( diff --git a/src/jsc/bindings/NodeAsyncHooks.cpp b/src/jsc/bindings/NodeAsyncHooks.cpp index 58beb067de3d..b2e4cf057b0b 100644 --- a/src/jsc/bindings/NodeAsyncHooks.cpp +++ b/src/jsc/bindings/NodeAsyncHooks.cpp @@ -4,7 +4,7 @@ #include "JavaScriptCore/ObjectConstructor.h" #include "JavaScriptCore/ArrayConstructor.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { @@ -17,7 +17,7 @@ using namespace JSC; JSC_DEFINE_HOST_FUNCTION(jsCleanupLater, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { ASSERT(callFrame->argumentCount() == 0); - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); global->asyncHooksNeedsCleanup = true; global->resetOnEachMicrotaskTick(); return JSC::JSValue::encode(JSC::jsUndefined()); diff --git a/src/jsc/bindings/NodeAsyncHooks.h b/src/jsc/bindings/NodeAsyncHooks.h index 6dd8f458793c..5fa5b0104e76 100644 --- a/src/jsc/bindings/NodeAsyncHooks.h +++ b/src/jsc/bindings/NodeAsyncHooks.h @@ -1,5 +1,5 @@ #include "config.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include namespace Bun { diff --git a/src/jsc/bindings/NodeDirent.cpp b/src/jsc/bindings/NodeDirent.cpp index f6667116545c..7ddbae57efc7 100644 --- a/src/jsc/bindings/NodeDirent.cpp +++ b/src/jsc/bindings/NodeDirent.cpp @@ -19,7 +19,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { @@ -47,7 +47,7 @@ static const HashTableValue JSDirentPrototypeTableValues[] = { { "isSymbolicLink"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsDirentProtoFuncIsSymbolicLink, 0 } }, }; -static Structure* getStructure(Zig::GlobalObject* globalObject) +static Structure* getStructure(Bun::GlobalObject* globalObject) { return globalObject->m_JSDirentClassStructure.get(globalObject); } @@ -197,7 +197,7 @@ JSC_DEFINE_HOST_FUNCTION(constructDirent, (JSC::JSGlobalObject * globalObject, J return JSValue::encode(object); } -static inline int32_t getType(JSC::VM& vm, JSValue value, Zig::GlobalObject* globalObject) +static inline int32_t getType(JSC::VM& vm, JSValue value, Bun::GlobalObject* globalObject) { JSObject* object = value.getObject(); if (!object) [[unlikely]] { @@ -323,12 +323,12 @@ void initJSDirentClassStructure(JSC::LazyClassStructure::Initializer& init) init.setConstructor(constructor); } -extern "C" JSC::EncodedJSValue Bun__JSDirentObjectConstructor(Zig::GlobalObject* globalobject) +extern "C" JSC::EncodedJSValue Bun__JSDirentObjectConstructor(Bun::GlobalObject* globalobject) { return JSValue::encode(globalobject->m_JSDirentClassStructure.constructor(globalobject)); } -extern "C" JSC::EncodedJSValue Bun__Dirent__toJS(Zig::GlobalObject* globalObject, int type, BunString* name, BunString* path, JSString** previousPath) +extern "C" JSC::EncodedJSValue Bun__Dirent__toJS(Bun::GlobalObject* globalObject, int type, BunString* name, BunString* path, JSString** previousPath) { auto& vm = globalObject->vm(); diff --git a/src/jsc/bindings/NodeFSStatBinding.cpp b/src/jsc/bindings/NodeFSStatBinding.cpp index e2cc3cf16eb7..40e20714fa12 100644 --- a/src/jsc/bindings/NodeFSStatBinding.cpp +++ b/src/jsc/bindings/NodeFSStatBinding.cpp @@ -18,7 +18,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/DateInstance.h" #if !OS(WINDOWS) #include @@ -157,7 +157,7 @@ static JSValue modeStatFunction(JSC::JSGlobalObject* globalObject, CallFrame* ca } template -Structure* getStructure(Zig::GlobalObject* globalObject) +Structure* getStructure(Bun::GlobalObject* globalObject) { if (isBigInt) { return globalObject->m_JSStatsBigIntClassStructure.getInitializedOnMainThread(globalObject); @@ -167,7 +167,7 @@ Structure* getStructure(Zig::GlobalObject* globalObject) } template -JSObject* getPrototype(Zig::GlobalObject* globalObject) +JSObject* getPrototype(Bun::GlobalObject* globalObject) { if (isBigInt) { return globalObject->m_JSStatsBigIntClassStructure.prototypeInitializedOnMainThread(globalObject); @@ -177,7 +177,7 @@ JSObject* getPrototype(Zig::GlobalObject* globalObject) } template -JSObject* getConstructor(Zig::GlobalObject* globalObject) +JSObject* getConstructor(Bun::GlobalObject* globalObject) { if (isBigInt) { return globalObject->m_JSStatsBigIntClassStructure.constructorInitializedOnMainThread(globalObject); @@ -598,7 +598,7 @@ JSC::Structure* createJSBigIntStatsObjectStructure(JSC::VM& vm, JSC::JSGlobalObj return structure; } -extern "C" JSC::EncodedJSValue Bun__createJSStatsObject(Zig::GlobalObject* globalObject, uint64_t dev, +extern "C" JSC::EncodedJSValue Bun__createJSStatsObject(Bun::GlobalObject* globalObject, uint64_t dev, uint64_t ino, uint64_t mode, uint64_t nlink, @@ -642,7 +642,7 @@ extern "C" JSC::EncodedJSValue Bun__createJSStatsObject(Zig::GlobalObject* globa return JSC::JSValue::encode(object); } -extern "C" JSC::EncodedJSValue Bun__createJSBigIntStatsObject(Zig::GlobalObject* globalObject, +extern "C" JSC::EncodedJSValue Bun__createJSBigIntStatsObject(Bun::GlobalObject* globalObject, uint64_t dev, uint64_t ino, uint64_t mode, @@ -817,7 +817,7 @@ inline JSValue constructJSStatsObject(JSC::JSGlobalObject* lexicalGlobalObject, { auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); auto* structure = getStructure(globalObject); auto* constructor = getConstructor(globalObject); @@ -825,7 +825,7 @@ inline JSValue constructJSStatsObject(JSC::JSGlobalObject* lexicalGlobalObject, if (constructor != newTarget) { auto scope = DECLARE_THROW_SCOPE(vm); - auto* functionGlobalObject = static_cast( + auto* functionGlobalObject = static_cast( // ShadowRealm functions belong to a different global object. getFunctionRealm(lexicalGlobalObject, newTarget)); RETURN_IF_EXCEPTION(scope, {}); @@ -915,12 +915,12 @@ JSC_DEFINE_HOST_FUNCTION(callBigIntStats, (JSC::JSGlobalObject * lexicalGlobalOb return JSValue::encode(callJSStatsFunction(lexicalGlobalObject, callFrame)); } -extern "C" JSC::EncodedJSValue Bun__JSBigIntStatsObjectConstructor(Zig::GlobalObject* globalobject) +extern "C" JSC::EncodedJSValue Bun__JSBigIntStatsObjectConstructor(Bun::GlobalObject* globalobject) { return JSValue::encode(globalobject->m_JSStatsBigIntClassStructure.constructor(globalobject)); } -extern "C" JSC::EncodedJSValue Bun__JSStatsObjectConstructor(Zig::GlobalObject* globalobject) +extern "C" JSC::EncodedJSValue Bun__JSStatsObjectConstructor(Bun::GlobalObject* globalobject) { return JSValue::encode(globalobject->m_JSStatsClassStructure.constructor(globalobject)); } diff --git a/src/jsc/bindings/NodeFSStatFSBinding.cpp b/src/jsc/bindings/NodeFSStatFSBinding.cpp index 42278a6f1e0c..938784bd7f3f 100644 --- a/src/jsc/bindings/NodeFSStatFSBinding.cpp +++ b/src/jsc/bindings/NodeFSStatFSBinding.cpp @@ -17,7 +17,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { @@ -34,7 +34,7 @@ JSC_DECLARE_HOST_FUNCTION(constructStatFS); JSC_DECLARE_HOST_FUNCTION(constructBigIntStatFS); template -Structure* getStatFSStructure(Zig::GlobalObject* globalObject) +Structure* getStatFSStructure(Bun::GlobalObject* globalObject) { if (isBigInt) { return globalObject->m_JSStatFSBigIntClassStructure.getInitializedOnMainThread(globalObject); @@ -44,7 +44,7 @@ Structure* getStatFSStructure(Zig::GlobalObject* globalObject) } template -JSObject* getStatFSPrototype(Zig::GlobalObject* globalObject) +JSObject* getStatFSPrototype(Bun::GlobalObject* globalObject) { if (isBigInt) { return globalObject->m_JSStatFSBigIntClassStructure.prototypeInitializedOnMainThread(globalObject); @@ -54,7 +54,7 @@ JSObject* getStatFSPrototype(Zig::GlobalObject* globalObject) } template -JSObject* getStatFSConstructor(Zig::GlobalObject* globalObject) +JSObject* getStatFSConstructor(Bun::GlobalObject* globalObject) { if (isBigInt) { return globalObject->m_JSStatFSBigIntClassStructure.constructorInitializedOnMainThread(globalObject); @@ -249,7 +249,7 @@ JSC::Structure* createJSBigIntStatFSObjectStructure(JSC::VM& vm, JSC::JSGlobalOb return structure; } -extern "C" JSC::EncodedJSValue Bun__createJSStatFSObject(Zig::GlobalObject* globalObject, +extern "C" JSC::EncodedJSValue Bun__createJSStatFSObject(Bun::GlobalObject* globalObject, int64_t fstype, int64_t bsize, int64_t blocks, @@ -282,7 +282,7 @@ extern "C" JSC::EncodedJSValue Bun__createJSStatFSObject(Zig::GlobalObject* glob return JSC::JSValue::encode(object); } -extern "C" JSC::EncodedJSValue Bun__createJSBigIntStatFSObject(Zig::GlobalObject* globalObject, +extern "C" JSC::EncodedJSValue Bun__createJSBigIntStatFSObject(Bun::GlobalObject* globalObject, int64_t fstype, int64_t bsize, int64_t blocks, @@ -361,7 +361,7 @@ inline JSValue constructJSStatFSObject(JSC::JSGlobalObject* lexicalGlobalObject, { auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); auto* structure = getStatFSStructure(globalObject); auto* constructor = getStatFSConstructor(globalObject); @@ -369,7 +369,7 @@ inline JSValue constructJSStatFSObject(JSC::JSGlobalObject* lexicalGlobalObject, if (constructor != newTarget) { auto scope = DECLARE_THROW_SCOPE(vm); - auto* functionGlobalObject = static_cast( + auto* functionGlobalObject = static_cast( // ShadowRealm functions belong to a different global object. getFunctionRealm(lexicalGlobalObject, newTarget)); RETURN_IF_EXCEPTION(scope, {}); @@ -417,12 +417,12 @@ JSC_DEFINE_HOST_FUNCTION(callBigIntStatFS, (JSC::JSGlobalObject * lexicalGlobalO return JSValue::encode(callJSStatFSFunction(lexicalGlobalObject, callFrame)); } -extern "C" JSC::EncodedJSValue Bun__JSBigIntStatFSObjectConstructor(Zig::GlobalObject* globalobject) +extern "C" JSC::EncodedJSValue Bun__JSBigIntStatFSObjectConstructor(Bun::GlobalObject* globalobject) { return JSValue::encode(globalobject->m_JSStatFSBigIntClassStructure.constructor(globalobject)); } -extern "C" JSC::EncodedJSValue Bun__JSStatFSObjectConstructor(Zig::GlobalObject* globalobject) +extern "C" JSC::EncodedJSValue Bun__JSStatFSObjectConstructor(Bun::GlobalObject* globalobject) { return JSValue::encode(globalobject->m_JSStatFSClassStructure.constructor(globalobject)); } diff --git a/src/jsc/bindings/NodeFetch.cpp b/src/jsc/bindings/NodeFetch.cpp index e4395e7ea7b4..b7d6d16c44f9 100644 --- a/src/jsc/bindings/NodeFetch.cpp +++ b/src/jsc/bindings/NodeFetch.cpp @@ -1,6 +1,6 @@ #include "root.h" #include "JSDOMGlobalObjectInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSFetchHeaders.h" #include "JSDOMFormData.h" @@ -19,7 +19,7 @@ using namespace JSC; using namespace WebCore; // Ensure overriding globals doesn't impact usages. -JSC::JSValue createNodeFetchInternalBinding(Zig::GlobalObject* globalObject) +JSC::JSValue createNodeFetchInternalBinding(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); diff --git a/src/jsc/bindings/NodeFetch.h b/src/jsc/bindings/NodeFetch.h index ee4ee9875d88..fd4169b88490 100644 --- a/src/jsc/bindings/NodeFetch.h +++ b/src/jsc/bindings/NodeFetch.h @@ -2,6 +2,6 @@ namespace Bun { -JSC::JSValue createNodeFetchInternalBinding(Zig::GlobalObject*); +JSC::JSValue createNodeFetchInternalBinding(Bun::GlobalObject*); } diff --git a/src/jsc/bindings/NodeHTTP.cpp b/src/jsc/bindings/NodeHTTP.cpp index 287742270eb1..8b3e1c07c2e5 100644 --- a/src/jsc/bindings/NodeHTTP.cpp +++ b/src/jsc/bindings/NodeHTTP.cpp @@ -1,6 +1,6 @@ #include "root.h" #include "JSDOMGlobalObjectInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include "helpers.h" #include "BunClientData.h" @@ -560,7 +560,7 @@ extern "C" EncodedJSValue NodeHTTPResponse__createForJS(size_t any_server, JSC:: template static EncodedJSValue NodeHTTPServer__onRequest( size_t any_server, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSValue thisValue, JSValue callback, JSValue methodString, @@ -814,7 +814,7 @@ extern "C" void NodeHTTPServer__writeHead_https( extern "C" EncodedJSValue NodeHTTPServer__onRequest_http( size_t any_server, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, EncodedJSValue thisValue, EncodedJSValue callback, EncodedJSValue methodString, @@ -837,7 +837,7 @@ extern "C" EncodedJSValue NodeHTTPServer__onRequest_http( extern "C" EncodedJSValue NodeHTTPServer__onRequest_https( size_t any_server, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, EncodedJSValue thisValue, EncodedJSValue callback, EncodedJSValue methodString, @@ -1128,7 +1128,7 @@ JSC_DEFINE_HOST_FUNCTION(jsHTTPSetHeader, (JSGlobalObject * globalObject, CallFr return JSValue::encode(jsUndefined()); } -JSValue createNodeHTTPInternalBinding(Zig::GlobalObject* globalObject) +JSValue createNodeHTTPInternalBinding(Bun::GlobalObject* globalObject) { auto* obj = constructEmptyObject(globalObject); VM& vm = globalObject->vm(); diff --git a/src/jsc/bindings/NodeHTTP.h b/src/jsc/bindings/NodeHTTP.h index 8035cc216c84..fe5010d168fc 100644 --- a/src/jsc/bindings/NodeHTTP.h +++ b/src/jsc/bindings/NodeHTTP.h @@ -7,6 +7,6 @@ JSC_DECLARE_HOST_FUNCTION(jsHTTPGetHeader); JSC_DECLARE_HOST_FUNCTION(jsHTTPSetHeader); JSC::Structure* createNodeHTTPServerSocketStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject); -JSC::JSValue createNodeHTTPInternalBinding(Zig::GlobalObject*); +JSC::JSValue createNodeHTTPInternalBinding(Bun::GlobalObject*); } diff --git a/src/jsc/bindings/NodeTLS.cpp b/src/jsc/bindings/NodeTLS.cpp index 218c78cd9939..e0e4226aa6d9 100644 --- a/src/jsc/bindings/NodeTLS.cpp +++ b/src/jsc/bindings/NodeTLS.cpp @@ -5,7 +5,7 @@ #include "JavaScriptCore/ArrayConstructor.h" #include "libusockets.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include "openssl/base.h" #include "openssl/bio.h" diff --git a/src/jsc/bindings/NodeTLS.h b/src/jsc/bindings/NodeTLS.h index c8948b6bf968..02aef487a94e 100644 --- a/src/jsc/bindings/NodeTLS.h +++ b/src/jsc/bindings/NodeTLS.h @@ -1,5 +1,5 @@ #include "config.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { diff --git a/src/jsc/bindings/NodeTimerObject.cpp b/src/jsc/bindings/NodeTimerObject.cpp index b534e41fedc0..5230558a3420 100644 --- a/src/jsc/bindings/NodeTimerObject.cpp +++ b/src/jsc/bindings/NodeTimerObject.cpp @@ -6,7 +6,7 @@ #include "JavaScriptCore/JSCast.h" #include "JavaScriptCore/JSObject.h" #include "JavaScriptCore/Heap.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ZigGeneratedClasses.h" #include diff --git a/src/jsc/bindings/NodeURL.cpp b/src/jsc/bindings/NodeURL.cpp index 09af0674a4e9..45b400245b9d 100644 --- a/src/jsc/bindings/NodeURL.cpp +++ b/src/jsc/bindings/NodeURL.cpp @@ -141,7 +141,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDomainToUnicode, (JSC::JSGlobalObject * globalObject, return JSC::JSValue::encode(jsEmptyString(vm)); } -JSC::JSValue createNodeURLBinding(Zig::GlobalObject* globalObject) +JSC::JSValue createNodeURLBinding(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/NodeURL.h b/src/jsc/bindings/NodeURL.h index 3252194123c9..ddf3e0009f5d 100644 --- a/src/jsc/bindings/NodeURL.h +++ b/src/jsc/bindings/NodeURL.h @@ -1,8 +1,8 @@ #include "config.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { -JSC::JSValue createNodeURLBinding(Zig::GlobalObject*); +JSC::JSValue createNodeURLBinding(Bun::GlobalObject*); } // namespace Bun diff --git a/src/jsc/bindings/NodeVM.cpp b/src/jsc/bindings/NodeVM.cpp index 3c51d04db600..75afd8b211d9 100644 --- a/src/jsc/bindings/NodeVM.cpp +++ b/src/jsc/bindings/NodeVM.cpp @@ -273,7 +273,7 @@ JSPromise* importModule(JSGlobalObject* globalObject, JSString* moduleName, RefP if (isUseMainContextDefaultLoaderConstant(globalObject, dynamicImportCallback)) { auto defer = fetcher->temporarilyUseDefaultLoader(); - Zig::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); + Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); RELEASE_AND_RETURN(scope, zigGlobalObject->moduleLoaderImportModule(zigGlobalObject, zigGlobalObject->moduleLoader(), moduleName, WTF::move(parameters), sourceOrigin, false)); } else if (!dynamicImportCallback || !dynamicImportCallback.isCallable()) { throwException(globalObject, scope, createError(globalObject, ErrorCode::ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING, "A dynamic import callback was not specified."_s)); @@ -669,7 +669,7 @@ bool getContextArg(JSGlobalObject* globalObject, JSValue& contextArg) if (contextArg.isUndefined()) { contextArg = JSC::constructEmptyObject(globalObject); } else if (contextArg.isSymbol()) { - Zig::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); + Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); if (contextArg == zigGlobalObject->m_nodeVMDontContextify.get(zigGlobalObject)) { contextArg = JSC::constructEmptyObject(globalObject); return true; @@ -682,7 +682,7 @@ bool getContextArg(JSGlobalObject* globalObject, JSValue& contextArg) bool isUseMainContextDefaultLoaderConstant(JSGlobalObject* globalObject, JSValue value) { if (value.isSymbol()) { - Zig::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); + Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); if (value == zigGlobalObject->m_nodeVMUseMainContextDefaultLoader.get(zigGlobalObject)) { return true; } @@ -788,7 +788,7 @@ static void promiseRejectionTrackerForNodeVM(JSGlobalObject* globalObject, JSC:: // Delegate to the parent global object so that unhandled rejections // in VM contexts are reported to the main process (matching Node.js behavior) auto* zigGlobalObject = defaultGlobalObject(globalObject); - Zig::GlobalObject::promiseRejectionTracker(zigGlobalObject, promise, operation); + Bun::GlobalObject::promiseRejectionTracker(zigGlobalObject, promise, operation); } const JSC::GlobalObjectMethodTable& NodeVMGlobalObject::globalObjectMethodTable() @@ -1507,7 +1507,7 @@ JSC_DEFINE_HOST_FUNCTION(vmIsModuleNamespaceObject, (JSGlobalObject * globalObje return JSValue::encode(jsBoolean(callFrame->argument(0).inherits(JSModuleNamespaceObject::info()))); } -JSC::JSValue createNodeVMBinding(Zig::GlobalObject* globalObject) +JSC::JSValue createNodeVMBinding(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); auto* obj = constructEmptyObject(globalObject); @@ -1568,7 +1568,7 @@ JSC::JSValue createNodeVMBinding(Zig::GlobalObject* globalObject) return obj; } -void configureNodeVM(JSC::VM& vm, Zig::GlobalObject* globalObject) +void configureNodeVM(JSC::VM& vm, Bun::GlobalObject* globalObject) { globalObject->m_nodeVMDontContextify.initLater([](const LazyProperty::Initializer& init) { init.set(JSC::Symbol::createWithDescription(init.vm, "vm_dont_contextify"_s)); diff --git a/src/jsc/bindings/NodeVM.h b/src/jsc/bindings/NodeVM.h index a2e259d021f1..c84c2607dfeb 100644 --- a/src/jsc/bindings/NodeVM.h +++ b/src/jsc/bindings/NodeVM.h @@ -1,7 +1,7 @@ #pragma once #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "BunGlobalScope.h" #include @@ -150,9 +150,9 @@ class NodeVMGlobalObject final : public Bun::GlobalScope { }; // Helper functions to create vm contexts and run code -JSC::JSValue createNodeVMBinding(Zig::GlobalObject*); +JSC::JSValue createNodeVMBinding(Bun::GlobalObject*); Structure* createNodeVMGlobalObjectStructure(JSC::VM&); -void configureNodeVM(JSC::VM&, Zig::GlobalObject*); +void configureNodeVM(JSC::VM&, Bun::GlobalObject*); // VM module functions JSC_DECLARE_HOST_FUNCTION(vmModule_createContext); diff --git a/src/jsc/bindings/NodeValidator.cpp b/src/jsc/bindings/NodeValidator.cpp index b647beb090f7..edb2662875be 100644 --- a/src/jsc/bindings/NodeValidator.cpp +++ b/src/jsc/bindings/NodeValidator.cpp @@ -1,6 +1,6 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/JSCJSValue.h" #include "JavaScriptCore/ExceptionScope.h" diff --git a/src/jsc/bindings/NodeValidator.h b/src/jsc/bindings/NodeValidator.h index 2f6d76f65cab..9307bed46496 100644 --- a/src/jsc/bindings/NodeValidator.h +++ b/src/jsc/bindings/NodeValidator.h @@ -2,7 +2,7 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include "BufferEncodingType.h" #include "JavaScriptCore/JSCJSValue.h" diff --git a/src/jsc/bindings/Path.cpp b/src/jsc/bindings/Path.cpp index 91af4a73079f..5d5b9fdc3b00 100644 --- a/src/jsc/bindings/Path.cpp +++ b/src/jsc/bindings/Path.cpp @@ -2,7 +2,7 @@ #include "root.h" #include "headers.h" #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -122,7 +122,7 @@ extern "C" JSC::EncodedJSValue PathParsedObject__create( JSC::EncodedJSValue ext, JSC::EncodedJSValue name) { - auto* global = uncheckedDowncast(globalObject); + auto* global = uncheckedDowncast(globalObject); auto& vm = JSC::getVM(globalObject); JSC::JSObject* result = JSC::constructEmptyObject(vm, global->pathParsedObjectStructure()); result->putDirectOffset(vm, 0, JSC::JSValue::decode(root)); @@ -135,7 +135,7 @@ extern "C" JSC::EncodedJSValue PathParsedObject__create( namespace Bun { -JSC::JSValue createNodePathBinding(Zig::GlobalObject* globalObject) +JSC::JSValue createNodePathBinding(Bun::GlobalObject* globalObject) { auto& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/Path.h b/src/jsc/bindings/Path.h index edc73912c239..9a5f8fc7bda4 100644 --- a/src/jsc/bindings/Path.h +++ b/src/jsc/bindings/Path.h @@ -1,8 +1,8 @@ #include "config.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { -JSC::JSValue createNodePathBinding(Zig::GlobalObject* globalObject); +JSC::JSValue createNodePathBinding(Bun::GlobalObject* globalObject); } // namespace Bun diff --git a/src/jsc/bindings/ProcessBindingFs.cpp b/src/jsc/bindings/ProcessBindingFs.cpp index 1eb6e96afad0..768973bbe96f 100644 --- a/src/jsc/bindings/ProcessBindingFs.cpp +++ b/src/jsc/bindings/ProcessBindingFs.cpp @@ -1,7 +1,7 @@ #include "ProcessBindingFs.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { using namespace JSC; diff --git a/src/jsc/bindings/ProcessBindingHTTPParser.cpp b/src/jsc/bindings/ProcessBindingHTTPParser.cpp index c4dfc88b0daf..f60c02e28d1d 100644 --- a/src/jsc/bindings/ProcessBindingHTTPParser.cpp +++ b/src/jsc/bindings/ProcessBindingHTTPParser.cpp @@ -1,5 +1,5 @@ #include "ProcessBindingHTTPParser.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "llhttp/llhttp.h" namespace Bun { diff --git a/src/jsc/bindings/ProcessBindingTTYWrap.cpp b/src/jsc/bindings/ProcessBindingTTYWrap.cpp index 4dfbc306f146..e127ca11a778 100644 --- a/src/jsc/bindings/ProcessBindingTTYWrap.cpp +++ b/src/jsc/bindings/ProcessBindingTTYWrap.cpp @@ -196,7 +196,7 @@ JSC_DEFINE_HOST_FUNCTION(jsTTYSetMode, (JSC::JSGlobalObject * globalObject, Call auto flag = callFrame->argument(0); bool raw = flag.asBoolean(); - Zig::GlobalObject* global = uncheckedDowncast(globalObject); + Bun::GlobalObject* global = uncheckedDowncast(globalObject); return JSValue::encode(jsNumber(Source__setRawModeStdin(global->uvLoop(), raw))); #else @@ -451,7 +451,7 @@ class TTYWrapConstructor final : public JSC::InternalFunction { #if OS(WINDOWS) auto* handle = new UV::TTY(); memset(handle, 0, sizeof(UV::TTY)); - int rc = uv_tty_init(uncheckedDowncast(globalObject)->uvLoop(), handle->tty(), fd, 0); + int rc = uv_tty_init(uncheckedDowncast(globalObject)->uvLoop(), handle->tty(), fd, 0); if (rc < 0) { delete handle; throwTypeError(globalObject, scope, "Failed to initialize TTY handle"_s); @@ -492,7 +492,7 @@ class TTYWrapConstructor final : public JSC::InternalFunction { const ClassInfo TTYWrapConstructor::s_info = { "TTY"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TTYWrapConstructor) }; -JSValue createBunTTYFunctions(Zig::GlobalObject* globalObject) +JSValue createBunTTYFunctions(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto* obj = constructEmptyObject(globalObject); diff --git a/src/jsc/bindings/ProcessBindingTTYWrap.h b/src/jsc/bindings/ProcessBindingTTYWrap.h index 53f82092da35..5ed5b4d760fa 100644 --- a/src/jsc/bindings/ProcessBindingTTYWrap.h +++ b/src/jsc/bindings/ProcessBindingTTYWrap.h @@ -1,7 +1,7 @@ #pragma once #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace JSC { class JSGlobalObject; @@ -10,7 +10,7 @@ class JSValue; namespace Bun { -JSC::JSValue createBunTTYFunctions(Zig::GlobalObject* globalObject); +JSC::JSValue createBunTTYFunctions(Bun::GlobalObject* globalObject); JSC::JSValue createNodeTTYWrapObject(JSC::JSGlobalObject* globalObject); JSC_DECLARE_HOST_FUNCTION(Process_functionInternalGetWindowSize); diff --git a/src/jsc/bindings/ProcessBindingUV.cpp b/src/jsc/bindings/ProcessBindingUV.cpp index d08c222e0e29..eafa373eeb84 100644 --- a/src/jsc/bindings/ProcessBindingUV.cpp +++ b/src/jsc/bindings/ProcessBindingUV.cpp @@ -2,7 +2,7 @@ #include "JavaScriptCore/ArrayAllocationProfile.h" #include "JavaScriptCore/JSCJSValue.h" #include "JavaScriptCore/ThrowScope.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/ObjectConstructor.h" #include "JavaScriptCore/JSMap.h" #include "JavaScriptCore/JSMapInlines.h" diff --git a/src/jsc/bindings/SQLClient.cpp b/src/jsc/bindings/SQLClient.cpp index a747fdc92b8a..4b26abd7b129 100644 --- a/src/jsc/bindings/SQLClient.cpp +++ b/src/jsc/bindings/SQLClient.cpp @@ -9,7 +9,7 @@ #include #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include "GCDefferalContext.h" @@ -135,7 +135,7 @@ static JSC::JSValue toJS(JSC::VM& vm, JSC::JSGlobalObject* globalObject, DataCel return jsNull(); break; case DataCellTag::Raw: { - Zig::GlobalObject* zigGlobal = uncheckedDowncast(globalObject); + Bun::GlobalObject* zigGlobal = uncheckedDowncast(globalObject); auto* subclassStructure = zigGlobal->JSBufferSubclassStructure(); auto* uint8Array = JSC::JSUint8Array::createUninitialized(globalObject, subclassStructure, cell.value.raw.length); RETURN_IF_EXCEPTION(scope, {}); @@ -175,7 +175,7 @@ static JSC::JSValue toJS(JSC::VM& vm, JSC::JSGlobalObject* globalObject, DataCel break; } case DataCellTag::Bytea: { - Zig::GlobalObject* zigGlobal = uncheckedDowncast(globalObject); + Bun::GlobalObject* zigGlobal = uncheckedDowncast(globalObject); auto* subclassStructure = zigGlobal->JSBufferSubclassStructure(); auto* uint8Array = JSC::JSUint8Array::createUninitialized(globalObject, subclassStructure, cell.value.bytea[1]); RETURN_IF_EXCEPTION(scope, {}); diff --git a/src/jsc/bindings/ScriptExecutionContext.cpp b/src/jsc/bindings/ScriptExecutionContext.cpp index 66a581369c58..94b85b529542 100644 --- a/src/jsc/bindings/ScriptExecutionContext.cpp +++ b/src/jsc/bindings/ScriptExecutionContext.cpp @@ -250,18 +250,18 @@ ScriptExecutionContext* executionContext(JSC::JSGlobalObject* globalObject) void ScriptExecutionContext::postTaskConcurrently(Function&& lambda) { auto* task = new EventLoopTask(WTF::move(lambda)); - static_cast(m_globalObject)->queueTaskConcurrently(task); + static_cast(m_globalObject)->queueTaskConcurrently(task); } // Executes the task on context's thread asynchronously. void ScriptExecutionContext::postTask(Function&& lambda) { auto* task = new EventLoopTask(WTF::move(lambda)); - static_cast(m_globalObject)->queueTask(task); + static_cast(m_globalObject)->queueTask(task); } // Executes the task on context's thread asynchronously. void ScriptExecutionContext::postTask(EventLoopTask* task) { - static_cast(m_globalObject)->queueTask(task); + static_cast(m_globalObject)->queueTask(task); } // Native bindings diff --git a/src/jsc/bindings/ServerRouteList.cpp b/src/jsc/bindings/ServerRouteList.cpp index 9150d93f96a7..719403f4e78a 100644 --- a/src/jsc/bindings/ServerRouteList.cpp +++ b/src/jsc/bindings/ServerRouteList.cpp @@ -1,7 +1,7 @@ #include "root.h" #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include @@ -89,7 +89,7 @@ class ServerRouteList final : public JSC::JSDestructibleObject { DECLARE_VISIT_CHILDREN; template - JSValue callRoute(Zig::GlobalObject* globalObject, uint32_t index, void* requestPtr, EncodedJSValue serverObject, EncodedJSValue* requestObject, Req* req); + JSValue callRoute(Bun::GlobalObject* globalObject, uint32_t index, void* requestPtr, EncodedJSValue serverObject, EncodedJSValue* requestObject, Req* req); private: Structure* structureForParamsObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, uint32_t index, std::span identifiers); @@ -241,7 +241,7 @@ JSObject* ServerRouteList::paramsObjectForRoute(JSC::VM& vm, JSC::JSGlobalObject } template -JSValue ServerRouteList::callRoute(Zig::GlobalObject* globalObject, uint32_t index, void* requestPtr, EncodedJSValue serverObject, EncodedJSValue* requestObject, Req* req) +JSValue ServerRouteList::callRoute(Bun::GlobalObject* globalObject, uint32_t index, void* requestPtr, EncodedJSValue serverObject, EncodedJSValue* requestObject, Req* req) { auto& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -266,7 +266,7 @@ JSValue ServerRouteList::callRoute(Zig::GlobalObject* globalObject, uint32_t ind } extern "C" JSC::EncodedJSValue Bun__ServerRouteList__callRoute( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, uint32_t index, void* requestPtr, JSC::EncodedJSValue serverObject, @@ -280,7 +280,7 @@ extern "C" JSC::EncodedJSValue Bun__ServerRouteList__callRoute( } extern "C" JSC::EncodedJSValue Bun__ServerRouteList__callRouteH3( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, uint32_t index, void* requestPtr, JSC::EncodedJSValue serverObject, @@ -293,19 +293,19 @@ extern "C" JSC::EncodedJSValue Bun__ServerRouteList__callRouteH3( return JSValue::encode(routeList->callRoute(globalObject, index, requestPtr, serverObject, requestObject, req)); } -extern "C" JSC::EncodedJSValue Bun__ServerRouteList__create(Zig::GlobalObject* globalObject, EncodedJSValue* callbacks, ZigString* paths, size_t pathsLength) +extern "C" JSC::EncodedJSValue Bun__ServerRouteList__create(Bun::GlobalObject* globalObject, EncodedJSValue* callbacks, ZigString* paths, size_t pathsLength) { auto* structure = globalObject->m_ServerRouteListStructure.get(globalObject); auto* routeList = ServerRouteList::create(globalObject->vm(), structure, std::span(callbacks, pathsLength), std::span(paths, pathsLength)); return JSValue::encode(routeList); } -Structure* createServerRouteListStructure(JSC::VM& vm, Zig::GlobalObject* globalObject) +Structure* createServerRouteListStructure(JSC::VM& vm, Bun::GlobalObject* globalObject) { return ServerRouteList::createStructure(vm, globalObject); } -JSObject* createJSBunRequestParamsPrototype(JSC::VM& vm, Zig::GlobalObject* globalObject) +JSObject* createJSBunRequestParamsPrototype(JSC::VM& vm, Bun::GlobalObject* globalObject) { auto* prototype = constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure()); prototype->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("RequestParams"_s)), JSC::PropertyAttribute::DontEnum | 0); diff --git a/src/jsc/bindings/ServerRouteList.h b/src/jsc/bindings/ServerRouteList.h index f81169624d96..ccad0aae1589 100644 --- a/src/jsc/bindings/ServerRouteList.h +++ b/src/jsc/bindings/ServerRouteList.h @@ -1,6 +1,6 @@ namespace Bun { -JSC::Structure* createServerRouteListStructure(JSC::VM&, Zig::GlobalObject*); -JSC::JSObject* createJSBunRequestParamsPrototype(JSC::VM&, Zig::GlobalObject*); +JSC::Structure* createServerRouteListStructure(JSC::VM&, Bun::GlobalObject*); +JSC::JSObject* createJSBunRequestParamsPrototype(JSC::VM&, Bun::GlobalObject*); } diff --git a/src/jsc/bindings/ShellBindings.cpp b/src/jsc/bindings/ShellBindings.cpp index f015c9280b4a..1becd8a29d6d 100644 --- a/src/jsc/bindings/ShellBindings.cpp +++ b/src/jsc/bindings/ShellBindings.cpp @@ -9,7 +9,7 @@ namespace Bun { using namespace JSC; using namespace WTF; -extern "C" SYSV_ABI EncodedJSValue Bun__createShellInterpreter(Zig::GlobalObject* _Nonnull globalObject, void* _Nonnull ptr, EncodedJSValue parsed_shell_script, EncodedJSValue resolve, EncodedJSValue reject) +extern "C" SYSV_ABI EncodedJSValue Bun__createShellInterpreter(Bun::GlobalObject* _Nonnull globalObject, void* _Nonnull ptr, EncodedJSValue parsed_shell_script, EncodedJSValue resolve, EncodedJSValue reject) { auto& vm = globalObject->vm(); const auto& existingArgs = uncheckedDowncast(JSValue::decode(parsed_shell_script))->values(); diff --git a/src/jsc/bindings/StrongRef.cpp b/src/jsc/bindings/StrongRef.cpp index d3314586e436..51c8ce9e7581 100644 --- a/src/jsc/bindings/StrongRef.cpp +++ b/src/jsc/bindings/StrongRef.cpp @@ -4,7 +4,7 @@ #include #include "BunClientData.h" #include "wtf/DebugHeap.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" extern "C" __attribute__((__always_inline__)) void Bun__StrongRef__delete(JSC::JSValue* _Nonnull handleSlot) { diff --git a/src/jsc/bindings/Undici.cpp b/src/jsc/bindings/Undici.cpp index 55ed921c2852..b5dfced1012d 100644 --- a/src/jsc/bindings/Undici.cpp +++ b/src/jsc/bindings/Undici.cpp @@ -5,7 +5,7 @@ #include "JSURLSearchParams.h" #include "JSAbortSignal.h" #include "JSDOMGlobalObjectInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSFetchHeaders.h" #include "JSDOMFormData.h" @@ -29,7 +29,7 @@ using namespace JSC; using namespace WebCore; // Ensure overriding globals doesn't impact usages. -JSC::JSValue createUndiciInternalBinding(Zig::GlobalObject* globalObject) +JSC::JSValue createUndiciInternalBinding(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); diff --git a/src/jsc/bindings/Undici.h b/src/jsc/bindings/Undici.h index 7ad8f3430a77..60e2b457a424 100644 --- a/src/jsc/bindings/Undici.h +++ b/src/jsc/bindings/Undici.h @@ -2,6 +2,6 @@ namespace Bun { -JSC::JSValue createUndiciInternalBinding(Zig::GlobalObject* globalObject); +JSC::JSValue createUndiciInternalBinding(Bun::GlobalObject* globalObject); } diff --git a/src/jsc/bindings/UtilInspect.cpp b/src/jsc/bindings/UtilInspect.cpp index ae09d5b11cdb..5983dd4d4566 100644 --- a/src/jsc/bindings/UtilInspect.cpp +++ b/src/jsc/bindings/UtilInspect.cpp @@ -5,7 +5,7 @@ #include "JavaScriptCore/JSString.h" #include "JavaScriptCore/JSCJSValue.h" #include "JavaScriptCore/JSGlobalObject.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/ObjectConstructor.h" namespace Bun { @@ -25,7 +25,7 @@ Structure* createUtilInspectOptionsStructure(VM& vm, JSC::JSGlobalObject* global return structure; } -JSObject* createInspectOptionsObject(VM& vm, Zig::GlobalObject* globalObject, unsigned max_depth, bool colors) +JSObject* createInspectOptionsObject(VM& vm, Bun::GlobalObject* globalObject, unsigned max_depth, bool colors) { JSFunction* stylizeFn = colors ? globalObject->utilInspectStylizeColorFunction() : globalObject->utilInspectStylizeNoColorFunction(); if (!stylizeFn) return nullptr; @@ -37,7 +37,7 @@ JSObject* createInspectOptionsObject(VM& vm, Zig::GlobalObject* globalObject, un } extern "C" JSC::EncodedJSValue JSC__JSValue__callCustomInspectFunction( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::EncodedJSValue encodedFunctionValue, JSC::EncodedJSValue encodedThisValue, unsigned depth, diff --git a/src/jsc/bindings/ZigException.cpp b/src/jsc/bindings/ZigException.cpp index 3312748ef965..ae5c34cdeefb 100644 --- a/src/jsc/bindings/ZigException.cpp +++ b/src/jsc/bindings/ZigException.cpp @@ -31,7 +31,7 @@ #include "JavaScriptCore/JSString.h" #include "JavaScriptCore/StackFrame.h" #include "JavaScriptCore/VM.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "helpers.h" #include "JavaScriptCore/JSObjectInlines.h" diff --git a/src/jsc/bindings/ZigLazyStaticFunctions.h b/src/jsc/bindings/ZigLazyStaticFunctions.h index 38033b52d19c..6c299e8491a5 100644 --- a/src/jsc/bindings/ZigLazyStaticFunctions.h +++ b/src/jsc/bindings/ZigLazyStaticFunctions.h @@ -2,13 +2,16 @@ #pragma once #include "root.h" -namespace Zig { +namespace Bun { class GlobalObject; +} + +namespace Zig { class JSFFIFunction; class LazyStaticFunctions { public: - void init(Zig::GlobalObject* globalObject); + void init(Bun::GlobalObject* globalObject); template void visit(Visitor& visitor); diff --git a/src/jsc/bindings/ZigSourceProvider.cpp b/src/jsc/bindings/ZigSourceProvider.cpp index fa3778b481d1..f14c8607744e 100644 --- a/src/jsc/bindings/ZigSourceProvider.cpp +++ b/src/jsc/bindings/ZigSourceProvider.cpp @@ -7,7 +7,7 @@ #include "BunAnalyzeTranspiledModule.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "wtf/Assertions.h" #include @@ -72,7 +72,7 @@ extern "C" void Bun__addSourceProviderSourceMap(void* bun_vm, SourceProvider* op extern "C" void Bun__removeSourceProviderSourceMap(void* bun_vm, SourceProvider* opaque_source_provider, BunString* specifier); Ref SourceProvider::create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, ResolvedSource& resolvedSource, JSC::SourceProviderSourceType sourceType, bool isBuiltin) diff --git a/src/jsc/bindings/ZigSourceProvider.h b/src/jsc/bindings/ZigSourceProvider.h index ccbb659c734e..e394dfdbb753 100644 --- a/src/jsc/bindings/ZigSourceProvider.h +++ b/src/jsc/bindings/ZigSourceProvider.h @@ -16,9 +16,11 @@ class SourceProvider; #include #include -namespace Zig { - +namespace Bun { class GlobalObject; +} + +namespace Zig { void forEachSourceProvider(WTF::Function); JSC::SourceID sourceIDForSourceURL(const WTF::String& sourceURL); @@ -37,7 +39,7 @@ class SourceProvider final : public JSC::SourceProvider { public: static Ref create( - Zig::GlobalObject*, + Bun::GlobalObject*, ResolvedSource& resolvedSource, JSC::SourceProviderSourceType sourceType = JSC::SourceProviderSourceType::Module, bool isBuiltIn = false); diff --git a/src/jsc/bindings/bindings.cpp b/src/jsc/bindings/bindings.cpp index 5ddf563c32c3..04113247e41b 100644 --- a/src/jsc/bindings/bindings.cpp +++ b/src/jsc/bindings/bindings.cpp @@ -77,7 +77,7 @@ #include "JavaScriptCore/VM.h" #include "JavaScriptCore/WasmFaultSignalHandler.h" #include "JavaScriptCore/Watchdog.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "helpers.h" #include "JavaScriptCore/JSObjectInlines.h" @@ -584,7 +584,7 @@ template static void handlePromise(PromiseType* promise, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue ctx, Zig::FFIFunction resolverFunction, Zig::FFIFunction rejecterFunction) { - auto globalThis = static_cast(globalObject); + auto globalThis = static_cast(globalObject); if constexpr (!isInternal) { JSFunction* performPromiseThenFunction = globalObject->performPromiseThenFunction(); @@ -1550,7 +1550,7 @@ std::optional specialObjectsDequal(JSC::JSGlobalObject* globalObject, Mark break; } // globalThis is only equal to globalThis - // NOTE: globalThis from JS is a JSGlobalProxy (GlobalProxyType) wrapping Zig::GlobalObject (GlobalObjectType) + // NOTE: globalThis from JS is a JSGlobalProxy (GlobalProxyType) wrapping Bun::GlobalObject (GlobalObjectType) case GlobalObjectType: { if (c1Type != c2Type) return false; auto* g1 = dynamicDowncast(c1); @@ -1826,7 +1826,7 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createFromJS(JSC::JSGlobalObject* JSC::EncodedJSValue WebCore__FetchHeaders__toJS(WebCore::FetchHeaders* headers, JSC::JSGlobalObject* lexicalGlobalObject) { - Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = static_cast(lexicalGlobalObject); ASSERT_NO_PENDING_EXCEPTION(globalObject); bool needsMemoryCost = headers->hasOneRef(); @@ -1844,7 +1844,7 @@ JSC::EncodedJSValue WebCore__FetchHeaders__toJS(WebCore::FetchHeaders* headers, JSC::EncodedJSValue WebCore__FetchHeaders__clone(WebCore::FetchHeaders* headers, JSC::JSGlobalObject* arg1) { auto throwScope = DECLARE_THROW_SCOPE(arg1->vm()); - Zig::GlobalObject* globalObject = static_cast(arg1); + Bun::GlobalObject* globalObject = static_cast(arg1); auto* clone = new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} }); WebCore::propagateException(*arg1, throwScope, clone->fill(*headers)); return JSC::JSValue::encode(WebCore::toJSNewlyCreated(arg1, globalObject, WTF::move(clone))); @@ -2076,7 +2076,7 @@ JSC::EncodedJSValue WebCore__FetchHeaders__createValue(JSC::JSGlobalObject* arg0 Ref headers = WebCore::FetchHeaders::create(); WebCore::propagateException(*arg0, throwScope, headers->fill(WebCore::FetchHeaders::Init(WTF::move(pairs)))); - JSValue value = WebCore::toJSNewlyCreated(arg0, static_cast(arg0), WTF::move(headers)); + JSValue value = WebCore::toJSNewlyCreated(arg0, static_cast(arg0), WTF::move(headers)); JSFetchHeaders* fetchHeaders = uncheckedDowncast(value); fetchHeaders->computeMemoryCost(); @@ -3163,7 +3163,7 @@ JSC::EncodedJSValue JSC__JSModuleLoader__evaluate(JSC::JSGlobalObject* globalObj } } -[[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue ReadableStream__empty(Zig::GlobalObject* globalObject) +[[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue ReadableStream__empty(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -3174,7 +3174,7 @@ JSC::EncodedJSValue JSC__JSModuleLoader__evaluate(JSC::JSGlobalObject* globalObj return JSValue::encode(emptyStream); } -[[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue ReadableStream__used(Zig::GlobalObject* globalObject) +[[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue ReadableStream__used(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -3801,7 +3801,7 @@ void JSC__JSPromise__rejectOnNextTickWithHandled(JSC::JSPromise* promise, JSC::J } promise->setFlags(static_cast(flags | JSC::JSPromise::isFirstResolvingFunctionCalledFlag)); - auto* globalObject = uncheckedDowncast(promise->globalObject()); + auto* globalObject = uncheckedDowncast(promise->globalObject()); auto rejectPromiseFunction = globalObject->rejectPromiseFunction(); auto asyncContext = globalObject->m_asyncContextData.get()->getInternalField(0); @@ -3986,7 +3986,7 @@ __attribute__((__always_inline__)) JSC::VM* JSC__JSGlobalObject__vm(JSC::JSGloba void JSC__JSGlobalObject__handleRejectedPromises(JSC::JSGlobalObject* arg0) { - return uncheckedDowncast(arg0)->handleRejectedPromises(); + return uncheckedDowncast(arg0)->handleRejectedPromises(); } #pragma mark - JSC::JSValue @@ -5681,7 +5681,7 @@ extern "C" size_t JSC__VM__externalMemorySize(JSC::VM* vm) extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue JSValue3, JSC::EncodedJSValue JSValue4) { - Zig::GlobalObject* globalObject = static_cast(arg0); + Bun::GlobalObject* globalObject = static_cast(arg0); JSValue microtaskArgs[] = { JSValue::decode(JSValue1), globalObject->m_asyncContextData.get()->getInternalField(0), @@ -5727,7 +5727,7 @@ extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC::JSGlobalObject* arg0 extern "C" WebCore::AbortSignal* WebCore__AbortSignal__new(JSC::JSGlobalObject* globalObject) { - Zig::GlobalObject* thisObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* thisObject = uncheckedDowncast(globalObject); auto* context = thisObject->scriptExecutionContext(); RefPtr abortSignal = WebCore::AbortSignal::create(context); return abortSignal.leakRef(); @@ -5735,7 +5735,7 @@ extern "C" WebCore::AbortSignal* WebCore__AbortSignal__new(JSC::JSGlobalObject* extern "C" JSC::EncodedJSValue WebCore__AbortSignal__create(JSC::JSGlobalObject* globalObject) { - Zig::GlobalObject* thisObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* thisObject = uncheckedDowncast(globalObject); auto* context = thisObject->scriptExecutionContext(); auto abortSignal = WebCore::AbortSignal::create(context); @@ -6011,7 +6011,7 @@ extern "C" void DOMFormData__toQueryString( CPP_DECL JSC::EncodedJSValue WebCore__DOMFormData__createFromURLQuery(JSC::JSGlobalObject* arg0, ZigString* arg1) { - Zig::GlobalObject* globalObject = static_cast(arg0); + Bun::GlobalObject* globalObject = static_cast(arg0); // don't need to copy the string because it internally does. auto str = toString(*arg1); // toString() in helpers.h returns an empty string when the input exceeds @@ -6027,7 +6027,7 @@ CPP_DECL JSC::EncodedJSValue WebCore__DOMFormData__createFromURLQuery(JSC::JSGlo CPP_DECL JSC::EncodedJSValue WebCore__DOMFormData__create(JSC::JSGlobalObject* arg0) { - Zig::GlobalObject* globalObject = static_cast(arg0); + Bun::GlobalObject* globalObject = static_cast(arg0); auto formData = DOMFormData::create(globalObject->scriptExecutionContext()); return JSValue::encode(toJSNewlyCreated(arg0, globalObject, WTF::move(formData))); } @@ -6118,18 +6118,18 @@ extern "C" EncodedJSValue JSC__createRangeError(JSC::JSGlobalObject* globalObjec extern "C" EncodedJSValue ExpectMatcherUtils__getSingleton(JSC::JSGlobalObject* globalObject_) { - Zig::GlobalObject* globalObject = static_cast(globalObject_); + Bun::GlobalObject* globalObject = static_cast(globalObject_); return JSValue::encode(globalObject->m_testMatcherUtilsObject.getInitializedOnMainThread(globalObject)); } extern "C" EncodedJSValue Expect__getPrototype(JSC::JSGlobalObject* globalObject) { - return JSValue::encode(static_cast(globalObject)->JSExpectPrototype()); + return JSValue::encode(static_cast(globalObject)->JSExpectPrototype()); } extern "C" EncodedJSValue ExpectStatic__getPrototype(JSC::JSGlobalObject* globalObject) { - return JSValue::encode(static_cast(globalObject)->JSExpectStaticPrototype()); + return JSValue::encode(static_cast(globalObject)->JSExpectStaticPrototype()); } extern "C" EncodedJSValue JSFunction__createFromZig( @@ -6548,7 +6548,7 @@ extern "C" JSC::EncodedJSValue Bun__REPL__formatValue( auto scope = DECLARE_THROW_SCOPE(vm); // Get the util.inspect function from the global object - auto* bunGlobal = uncheckedDowncast(globalObject); + auto* bunGlobal = uncheckedDowncast(globalObject); JSC::JSValue inspectFn = bunGlobal->utilInspectFunction(); if (!inspectFn || !inspectFn.isCallable()) { diff --git a/src/jsc/bindings/headers-cpp.h b/src/jsc/bindings/headers-cpp.h index 1453b0a0fb1b..4172b65c4dc4 100644 --- a/src/jsc/bindings/headers-cpp.h +++ b/src/jsc/bindings/headers-cpp.h @@ -145,13 +145,13 @@ extern "C" const size_t JSC__ThrowScope_object_align_ = alignof(JSC::ThrowScope) extern "C" const size_t JSC__TopExceptionScope_object_size_ = sizeof(JSC::TopExceptionScope); extern "C" const size_t JSC__TopExceptionScope_object_align_ = alignof(JSC::TopExceptionScope); -#ifndef INCLUDED__ZigGlobalObject_h_ -#define INCLUDED__ZigGlobalObject_h_ -#include ""ZigGlobalObject.h"" +#ifndef INCLUDED__BunGlobalObject_h_ +#define INCLUDED__BunGlobalObject_h_ +#include ""BunGlobalObject.h"" #endif -extern "C" const size_t Zig__GlobalObject_object_size_ = sizeof(Zig::GlobalObject); -extern "C" const size_t Zig__GlobalObject_object_align_ = alignof(Zig::GlobalObject); +extern "C" const size_t Bun__GlobalObject_object_size_ = sizeof(Bun::GlobalObject); +extern "C" const size_t Bun__GlobalObject_object_align_ = alignof(Bun::GlobalObject); #ifndef INCLUDED_Path_h #define INCLUDED_Path_h @@ -185,6 +185,6 @@ extern "C" const size_t Bun__Timer_object_align_ = alignof(Bun__Timer); extern "C" const size_t Bun__BodyValueBufferer_object_size_ = sizeof(Bun__BodyValueBufferer); extern "C" const size_t Bun__BodyValueBufferer_object_align_ = alignof(Bun__BodyValueBufferer); -const size_t sizes[39] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::DOMFormData), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(JSC::JSModuleLoader), sizeof(WebCore::AbortSignal), sizeof(JSC::JSPromise), sizeof(JSC::JSPromise), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(JSC::JSMap), sizeof(JSC::JSValue), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::TopExceptionScope), sizeof(FFI__ptr), sizeof(Reader__u8), sizeof(Reader__u16), sizeof(Reader__u32), sizeof(Reader__ptr), sizeof(Reader__i8), sizeof(Reader__i16), sizeof(Reader__i32), sizeof(Reader__f32), sizeof(Reader__f64), sizeof(Reader__i64), sizeof(Reader__u64), sizeof(Reader__intptr), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink), sizeof(FileSink), sizeof(FileSink)}; +const size_t sizes[39] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::DOMFormData), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(JSC::JSModuleLoader), sizeof(WebCore::AbortSignal), sizeof(JSC::JSPromise), sizeof(JSC::JSPromise), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(JSC::JSMap), sizeof(JSC::JSValue), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::TopExceptionScope), sizeof(FFI__ptr), sizeof(Reader__u8), sizeof(Reader__u16), sizeof(Reader__u32), sizeof(Reader__ptr), sizeof(Reader__i8), sizeof(Reader__i16), sizeof(Reader__i32), sizeof(Reader__f32), sizeof(Reader__f64), sizeof(Reader__i64), sizeof(Reader__u64), sizeof(Reader__intptr), sizeof(Bun::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink), sizeof(FileSink), sizeof(FileSink)}; -const size_t aligns[39] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::DOMFormData), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(JSC::JSModuleLoader), alignof(WebCore::AbortSignal), alignof(JSC::JSPromise), alignof(JSC::JSPromise), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(JSC::JSMap), alignof(JSC::JSValue), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::TopExceptionScope), alignof(FFI__ptr), alignof(Reader__u8), alignof(Reader__u16), alignof(Reader__u32), alignof(Reader__ptr), alignof(Reader__i8), alignof(Reader__i16), alignof(Reader__i32), alignof(Reader__f32), alignof(Reader__f64), alignof(Reader__i64), alignof(Reader__u64), alignof(Reader__intptr), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink), alignof(FileSink), alignof(FileSink)}; +const size_t aligns[39] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::DOMFormData), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(JSC::JSModuleLoader), alignof(WebCore::AbortSignal), alignof(JSC::JSPromise), alignof(JSC::JSPromise), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(JSC::JSMap), alignof(JSC::JSValue), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::TopExceptionScope), alignof(FFI__ptr), alignof(Reader__u8), alignof(Reader__u16), alignof(Reader__u32), alignof(Reader__ptr), alignof(Reader__i8), alignof(Reader__i16), alignof(Reader__i32), alignof(Reader__f32), alignof(Reader__f64), alignof(Reader__i64), alignof(Reader__u64), alignof(Reader__intptr), alignof(Bun::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink), alignof(FileSink), alignof(FileSink)}; diff --git a/src/jsc/bindings/headers.h b/src/jsc/bindings/headers.h index c85e73790653..727eedebfb07 100644 --- a/src/jsc/bindings/headers.h +++ b/src/jsc/bindings/headers.h @@ -430,19 +430,19 @@ extern "C" JSC::EncodedJSValue SYSV_ABI Reader__intptr__slowpath(JSC::JSGlobalOb #endif -#pragma mark - Zig::GlobalObject +#pragma mark - Bun::GlobalObject -CPP_DECL JSC::JSGlobalObject* Zig__GlobalObject__create(void* arg0, int32_t arg1, bool arg2, bool arg3, void* arg4); -CPP_DECL void* Zig__GlobalObject__getModuleRegistryMap(JSC::JSGlobalObject* arg0); -CPP_DECL bool Zig__GlobalObject__resetModuleRegistryMap(JSC::JSGlobalObject* arg0, void* arg1); +CPP_DECL JSC::JSGlobalObject* Bun__GlobalObject__create(void* arg0, int32_t arg1, bool arg2, bool arg3, void* arg4); +CPP_DECL void* Bun__GlobalObject__getModuleRegistryMap(JSC::JSGlobalObject* arg0); +CPP_DECL bool Bun__GlobalObject__resetModuleRegistryMap(JSC::JSGlobalObject* arg0, void* arg1); #ifdef __cplusplus -ZIG_DECL void Zig__GlobalObject__fetch(ErrorableResolvedSource* arg0, JSC::JSGlobalObject* arg1, BunString* arg2, BunString* arg3); -ZIG_DECL void Zig__GlobalObject__onCrash(); -ZIG_DECL JSC::EncodedJSValue Zig__GlobalObject__promiseRejectionTracker(JSC::JSGlobalObject* arg0, JSC::JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); -ZIG_DECL JSC::EncodedJSValue Zig__GlobalObject__reportUncaughtException(JSC::JSGlobalObject* arg0, JSC::Exception* arg1); -ZIG_DECL void Zig__GlobalObject__resolve(ErrorableString* arg0, JSC::JSGlobalObject* arg1, BunString* arg2, BunString* arg3, BunString* arg4); +ZIG_DECL void Bun__GlobalObject__fetch(ErrorableResolvedSource* arg0, JSC::JSGlobalObject* arg1, BunString* arg2, BunString* arg3); +ZIG_DECL void Bun__GlobalObject__onCrash(); +ZIG_DECL JSC::EncodedJSValue Bun__GlobalObject__promiseRejectionTracker(JSC::JSGlobalObject* arg0, JSC::JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); +ZIG_DECL JSC::EncodedJSValue Bun__GlobalObject__reportUncaughtException(JSC::JSGlobalObject* arg0, JSC::Exception* arg1); +ZIG_DECL void Bun__GlobalObject__resolve(ErrorableString* arg0, JSC::JSGlobalObject* arg1, BunString* arg2, BunString* arg3, BunString* arg4); #endif diff --git a/src/jsc/bindings/helpers.h b/src/jsc/bindings/helpers.h index cb9bc987755c..e96615381bbb 100644 --- a/src/jsc/bindings/helpers.h +++ b/src/jsc/bindings/helpers.h @@ -13,7 +13,7 @@ #include #include -namespace Zig { +namespace Bun { class GlobalObject; } diff --git a/src/jsc/bindings/napi.cpp b/src/jsc/bindings/napi.cpp index 8fef5dcfa30f..e8b8e311147b 100644 --- a/src/jsc/bindings/napi.cpp +++ b/src/jsc/bindings/napi.cpp @@ -6,7 +6,7 @@ #include "JavaScriptCore/DateInstance.h" #include "JavaScriptCore/JSCast.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/SourceCode.h" #include "js_native_api.h" @@ -294,7 +294,7 @@ static uint32_t getPropertyAttributes(const napi_property_descriptor& prop) return result; } -void NAPICallFrame::extract(size_t* argc, napi_value* argv, napi_value* this_arg, void** data, Zig::GlobalObject* globalObject) +void NAPICallFrame::extract(size_t* argc, napi_value* argv, napi_value* this_arg, void** data, Bun::GlobalObject* globalObject) { if (this_arg != nullptr) { @@ -322,7 +322,7 @@ void NAPICallFrame::extract(size_t* argc, napi_value* argv, napi_value* this_arg void Napi::defineProperty(napi_env env, JSC::JSObject* to, const napi_property_descriptor& property, bool isInstance, JSC::ThrowScope& scope) { - Zig::GlobalObject* globalObject = env->globalObject(); + Bun::GlobalObject* globalObject = env->globalObject(); JSC::VM& vm = JSC::getVM(globalObject); void* dataPtr = property.data; @@ -636,7 +636,7 @@ extern "C" napi_status napi_create_arraybuffer(napi_env env, NAPI_CHECK_ENV_NOT_IN_GC(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto& vm = JSC::getVM(globalObject); // Node probably doesn't create uninitialized array buffers @@ -723,7 +723,7 @@ extern "C" napi_status napi_get_named_property(napi_env env, napi_value object, } extern "C" size_t Bun__napi_module_register_count; -void Napi::executePendingNapiModule(Zig::GlobalObject* globalObject) +void Napi::executePendingNapiModule(Bun::GlobalObject* globalObject) { JSC::VM& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -808,7 +808,7 @@ void Napi::executePendingNapiModule(Zig::GlobalObject* globalObject) extern "C" void napi_module_register(napi_module* mod) { - Zig::GlobalObject* globalObject = defaultGlobalObject(); + Bun::GlobalObject* globalObject = defaultGlobalObject(); JSC::VM& vm = JSC::getVM(globalObject); // Increment this one even if the module is invalid so that functionDlopen // knows that napi_module_register was attempted @@ -916,7 +916,7 @@ extern "C" napi_status napi_remove_wrap(napi_env env, napi_value js_object, // may be null auto* napi_instance = dynamicDowncast(jsc_object); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto& vm = JSC::getVM(globalObject); NapiRef* ref = getWrapContentsIfExists(vm, globalObject, jsc_object); NAPI_RETURN_EARLY_IF_FALSE(env, ref, napi_invalid_arg); @@ -951,7 +951,7 @@ extern "C" napi_status napi_unwrap(napi_env env, napi_value js_object, JSObject* jsc_object = jsc_value.getObject(); NAPI_RETURN_EARLY_IF_FALSE(env, jsc_object, napi_object_expected); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto& vm = JSC::getVM(globalObject); NapiRef* ref = getWrapContentsIfExists(vm, globalObject, jsc_object); NAPI_RETURN_EARLY_IF_FALSE(env, ref, napi_invalid_arg); @@ -970,7 +970,7 @@ extern "C" napi_status napi_create_function(napi_env env, const char* utf8name, NAPI_CHECK_ARG(env, result); NAPI_CHECK_ARG(env, cb); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); auto name = WTF::String(); @@ -999,7 +999,7 @@ extern "C" napi_status napi_get_cb_info( NAPI_CHECK_ARG(env, cbinfo); auto* callFrame = reinterpret_cast(cbinfo); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); callFrame->extract(argc, argv, this_arg, data, globalObject); NAPI_RETURN_SUCCESS(env); @@ -1010,7 +1010,7 @@ napi_define_properties(napi_env env, napi_value object, size_t property_count, const napi_property_descriptor* properties) { NAPI_PREAMBLE_NO_THROW_SCOPE(env); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); NAPI_RETURN_IF_EXCEPTION_WITH_SCOPE(env, throwScope); @@ -1148,7 +1148,7 @@ extern "C" napi_status napi_add_finalizer(napi_env env, napi_value js_object, NAPI_CHECK_ENV_NOT_IN_GC(env); NAPI_CHECK_ARG(env, js_object); NAPI_CHECK_ARG(env, finalize_cb); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSC::JSValue objectValue = toJS(js_object); @@ -1274,7 +1274,7 @@ extern "C" napi_status napi_detach_arraybuffer(napi_env env, { NAPI_PREAMBLE(env); NAPI_CHECK_ENV_NOT_IN_GC(env); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSC::JSArrayBuffer* jsArrayBuffer = dynamicDowncast(toJS(arraybuffer)); @@ -1461,7 +1461,7 @@ node_api_create_external_string_latin1(napi_env env, NAPI_LOG("latin1 string finalizer"); env->doFinalizer(finalize_callback, str, hint); }); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSString* out = JSC::jsString(JSC::getVM(globalObject), WTF::String(WTF::move(impl))); ensureStillAliveHere(out); @@ -1497,7 +1497,7 @@ node_api_create_external_string_utf16(napi_env env, NAPI_LOG("utf16 string finalizer"); env->doFinalizer(finalize_callback, str, hint); }); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSString* out = JSC::jsString(JSC::getVM(globalObject), WTF::String(WTF::move(impl))); ensureStillAliveHere(out); @@ -1599,7 +1599,7 @@ extern "C" napi_status napi_object_freeze(napi_env env, napi_value object_value) JSC::JSValue value = toJS(object_value); NAPI_RETURN_EARLY_IF_FALSE(env, value.isObject(), napi_object_expected); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::JSObject* object = uncheckedDowncast(value); objectConstructorFreeze(globalObject, object); @@ -1614,7 +1614,7 @@ extern "C" napi_status napi_object_seal(napi_env env, napi_value object_value) JSC::JSValue value = toJS(object_value); NAPI_RETURN_EARLY_IF_FALSE(env, value.isObject(), napi_object_expected); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::JSObject* object = uncheckedDowncast(value); objectConstructorSeal(globalObject, object); @@ -1628,7 +1628,7 @@ extern "C" napi_status napi_get_global(napi_env env, napi_value* result) NAPI_PREAMBLE(env); NAPI_CHECK_ENV_NOT_IN_GC(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); // TODO change to global? or find another way to avoid JSGlobalProxy *result = toNapi(globalObject->globalThis(), globalObject); NAPI_RETURN_SUCCESS(env); @@ -1667,7 +1667,7 @@ extern "C" napi_status napi_create_dataview(napi_env env, size_t length, napi_value* result) { NAPI_PREAMBLE_NO_THROW_SCOPE(env); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto scope = DECLARE_THROW_SCOPE(JSC::getVM(globalObject)); RETURN_IF_EXCEPTION(scope, napi_set_last_error(env, napi_pending_exception)); NAPI_CHECK_ARG(env, arraybuffer); @@ -1717,7 +1717,7 @@ static JSC::TypedArrayType getTypedArrayTypeFromNAPI(napi_typedarray_type type) } static JSC::JSArrayBufferView* createArrayBufferView( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, napi_typedarray_type type, RefPtr&& arrayBuffer, size_t byteOffset, @@ -1761,7 +1761,7 @@ extern "C" napi_status napi_create_typedarray( napi_value* result) { NAPI_PREAMBLE(env); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); NAPI_RETURN_IF_EXCEPTION(env); NAPI_CHECK_ARG(env, arraybuffer); NAPI_CHECK_ARG(env, result); @@ -1890,7 +1890,7 @@ extern "C" napi_status napi_define_class(napi_env env, NAPI_CHECK_ARG(env, constructor); NAPI_RETURN_EARLY_IF_FALSE(env, properties || property_count == 0, napi_invalid_arg); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); size_t len = length; if (len == NAPI_AUTO_LENGTH) { @@ -1915,7 +1915,7 @@ extern "C" napi_status napi_coerce_to_string(napi_env env, napi_value value, NAPI_CHECK_ARG(env, value); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::JSValue jsValue = toJS(value); JSC::EnsureStillAliveScope ensureStillAlive(jsValue); @@ -1935,7 +1935,7 @@ extern "C" napi_status napi_coerce_to_bool(napi_env env, napi_value value, napi_ NAPI_CHECK_ARG(env, value); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSValue jsValue = toJS(value); // might throw @@ -1952,7 +1952,7 @@ extern "C" napi_status napi_coerce_to_number(napi_env env, napi_value value, nap NAPI_CHECK_ARG(env, value); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSValue jsValue = toJS(value); // might throw @@ -1969,7 +1969,7 @@ extern "C" napi_status napi_coerce_to_object(napi_env env, napi_value value, nap NAPI_CHECK_ARG(env, value); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSValue jsValue = toJS(value); // might throw @@ -1990,7 +1990,7 @@ extern "C" napi_status napi_get_property_names(napi_env env, napi_value object, JSObject* jsObject = jsValue.getObject(); NAPI_RETURN_EARLY_IF_FALSE(env, jsObject, napi_object_expected); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::EnsureStillAliveScope ensureStillAlive(jsValue); JSValue value = JSC::allPropertyKeys(globalObject, jsObject, PropertyNameMode::Strings, DontEnumPropertiesMode::Exclude); @@ -2008,7 +2008,7 @@ extern "C" napi_status napi_create_buffer(napi_env env, size_t length, NAPI_PREAMBLE(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto* subclassStructure = globalObject->JSBufferSubclassStructure(); // In Node.js, napi_create_buffer is uninitialized memory. @@ -2072,7 +2072,7 @@ extern "C" napi_status napi_create_external_buffer(napi_env env, size_t length, // before arm(), orphaning a GC cell with a disarmed destructor. NAPI_RETURN_EARLY_IF_FALSE(env, !env->hasPendingException(), napi_pending_exception); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); auto* subclassStructure = globalObject->JSBufferSubclassStructure(); @@ -2122,7 +2122,7 @@ extern "C" napi_status napi_create_external_arraybuffer(napi_env env, void* exte // still points at external_data with a disarmed destructor. NAPI_RETURN_EARLY_IF_FALSE(env, !env->hasPendingException(), napi_pending_exception); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); // Uses NapiExternalBufferDestructor instead of createSharedTask so that @@ -2251,7 +2251,7 @@ napi_status napi_get_value_string_any_encoding(napi_env env, napi_value napiValu JSValue jsValue = toJS(napiValue); NAPI_RETURN_EARLY_IF_FALSE(env, jsValue.isString(), napi_string_expected); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSString* jsString = jsValue.toString(globalObject); NAPI_RETURN_IF_VM_EXCEPTION(env); const auto view = jsString->view(globalObject); @@ -2404,7 +2404,7 @@ extern "C" napi_status napi_create_object(napi_env env, napi_value* result) NAPI_CHECK_ENV_NOT_IN_GC(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSValue value = JSValue(NapiPrototype::create(vm, globalObject->NapiPrototypeStructure())); @@ -2423,7 +2423,7 @@ extern "C" napi_status napi_create_external(napi_env env, void* data, NAPI_PREAMBLE(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); auto* structure = globalObject->NapiExternalStructure(); @@ -2663,7 +2663,7 @@ extern "C" napi_status napi_run_script(napi_env env, napi_value script, JSValue scriptValue = toJS(script); NAPI_RETURN_EARLY_IF_FALSE(env, scriptValue.isString(), napi_string_expected); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -2736,7 +2736,7 @@ extern "C" napi_status napi_create_bigint_words(napi_env env, // JSBigInt::createWithLength's size argument is unsigned int. NAPI_RETURN_EARLY_IF_FALSE(env, word_count <= UINT_MAX, napi_invalid_arg); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto& vm = env->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -2770,7 +2770,7 @@ extern "C" napi_status napi_create_symbol(napi_env env, napi_value description, NAPI_CHECK_ENV_NOT_IN_GC(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSC::JSValue descriptionValue = toJS(description); @@ -2808,7 +2808,7 @@ extern "C" napi_status napi_new_instance(napi_env env, napi_value constructor, JSC::CallData constructData = getConstructData(constructorObject); NAPI_RETURN_EARLY_IF_FALSE(env, constructData.type != JSC::CallData::Type::None, napi_function_expected); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSC::MarkedArgumentBuffer args; @@ -2827,7 +2827,7 @@ extern "C" napi_status napi_instanceof(napi_env env, napi_value object, napi_val NAPI_PREAMBLE_NO_THROW_SCOPE(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSValue objectValue = toJS(object); JSValue constructorValue = toJS(constructor); @@ -2873,7 +2873,7 @@ extern "C" napi_status napi_call_function(napi_env env, napi_value recv, // they will just call it with this function. NAPI_RETURN_EARLY_IF_FALSE(env, funcValue.isCallable() || dynamicDowncast(funcValue), napi_invalid_arg); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSC::MarkedArgumentBuffer args; @@ -2903,7 +2903,7 @@ extern "C" napi_status napi_type_tag_object(napi_env env, napi_value value, cons NAPI_PREAMBLE(env); NAPI_CHECK_ARG(env, value); NAPI_CHECK_ARG(env, type_tag); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSObject* js_object = toJS(value).getObject(); NAPI_RETURN_EARLY_IF_FALSE(env, js_object, napi_object_expected); JSValue napiTypeTagValue = globalObject->napiTypeTags()->get(js_object); @@ -2923,7 +2923,7 @@ extern "C" napi_status napi_check_object_type_tag(napi_env env, napi_value value NAPI_PREAMBLE(env); NAPI_CHECK_ARG(env, value); NAPI_CHECK_ARG(env, type_tag); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSObject* js_object = toJS(value).getObject(); NAPI_RETURN_EARLY_IF_FALSE(env, js_object, napi_object_expected); diff --git a/src/jsc/bindings/napi.h b/src/jsc/bindings/napi.h index aa305eae35c3..9d8e19f3ba9c 100644 --- a/src/jsc/bindings/napi.h +++ b/src/jsc/bindings/napi.h @@ -11,7 +11,7 @@ #include "node_api.h" #include #include "JSFFIFunction.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "napi_handle_scope.h" #include "napi_finalizer.h" #include "wtf/Assertions.h" @@ -174,7 +174,7 @@ struct NapiEnv : public WTF::RefCounted { WTF_MAKE_STRUCT_TZONE_ALLOCATED(NapiEnv); public: - NapiEnv(Zig::GlobalObject* globalObject, const napi_module& napiModule) + NapiEnv(Bun::GlobalObject* globalObject, const napi_module& napiModule) : m_globalObject(globalObject) , m_napiModule(napiModule) , m_vm(JSC::getVM(globalObject)) @@ -182,7 +182,7 @@ struct NapiEnv : public WTF::RefCounted { napi_internal_register_cleanup_zig(this); } - static Ref create(Zig::GlobalObject* globalObject, const napi_module& napiModule) + static Ref create(Bun::GlobalObject* globalObject, const napi_module& napiModule) { return adoptRef(*new NapiEnv(globalObject, napiModule)); } @@ -379,8 +379,8 @@ struct NapiEnv : public WTF::RefCounted { return static_cast(m_pendingException); } - inline Zig::GlobalObject* globalObject() const { return m_globalObject; } - // `bun test --isolate` creates a fresh Zig::GlobalObject per file and + inline Bun::GlobalObject* globalObject() const { return m_globalObject; } + // `bun test --isolate` creates a fresh Bun::GlobalObject per file and // gcUnprotect()s the previous one. NapiEnv outlives its owning global — // GC-enqueued NapiFinalizerTasks hold a Ref and run on the event // loop *after* the swap. Finalizer.run opens a NapiHandleScope via @@ -390,7 +390,7 @@ struct NapiEnv : public WTF::RefCounted { // segfault when the marker later walks it). The isolation swap calls this // to point surviving envs at the new global before unprotecting the old // one. - inline void retargetGlobalObject(Zig::GlobalObject* newGlobal) + inline void retargetGlobalObject(Bun::GlobalObject* newGlobal) { ASSERT(&JSC::getVM(newGlobal) == &m_vm); m_globalObject = newGlobal; @@ -491,7 +491,7 @@ struct NapiEnv : public WTF::RefCounted { }; private: - Zig::GlobalObject* m_globalObject = nullptr; + Bun::GlobalObject* m_globalObject = nullptr; napi_module m_napiModule; // ListHashSet preserves insertion order so cleanup() can run finalizers in reverse // (LIFO), matching Node.js teardown semantics for napi_wrap references. @@ -575,7 +575,7 @@ class NapiRefSelfDeletingWeakHandleOwner final : public JSC::WeakHandleOwner { // If a module registered itself by calling napi_module_register in a static constructor, run this // to run the module's entrypoint. -void executePendingNapiModule(Zig::GlobalObject* globalObject); +void executePendingNapiModule(Bun::GlobalObject* globalObject); } @@ -587,12 +587,12 @@ static inline JSValue toJS(napi_value val) return JSC::JSValue::decode(reinterpret_cast(val)); } -static inline Zig::GlobalObject* toJS(napi_env val) +static inline Bun::GlobalObject* toJS(napi_env val) { return val->globalObject(); } -static inline napi_value toNapi(JSC::JSValue val, Zig::GlobalObject* globalObject) +static inline napi_value toNapi(JSC::JSValue val, Bun::GlobalObject* globalObject) { if (val.isCell()) { if (auto* scope = globalObject->m_currentNapiHandleScopeImpl.get()) { @@ -940,7 +940,7 @@ class NAPICallFrame { // and receives the actual count of args. napi_value* argv, // [out] Array of values napi_value* this_arg, // [out] Receives the JS 'this' arg for the call - void** data, Zig::GlobalObject* globalObject); + void** data, Bun::GlobalObject* globalObject); JSValue newTarget() { diff --git a/src/jsc/bindings/napi_handle_scope.cpp b/src/jsc/bindings/napi_handle_scope.cpp index e691becdbec0..192f4697ce2f 100644 --- a/src/jsc/bindings/napi_handle_scope.cpp +++ b/src/jsc/bindings/napi_handle_scope.cpp @@ -1,7 +1,7 @@ #include "napi_handle_scope.h" #include "napi.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { @@ -81,7 +81,7 @@ NapiHandleScopeImpl::Slot* NapiHandleScopeImpl::reserveSlot() return &m_storage.last(); } -NapiHandleScopeImpl* NapiHandleScope::open(Zig::GlobalObject* globalObject, bool escapable) +NapiHandleScopeImpl* NapiHandleScope::open(Bun::GlobalObject* globalObject, bool escapable) { auto& vm = JSC::getVM(globalObject); // Do not create a new handle scope while a finalizer is in progress @@ -104,7 +104,7 @@ NapiHandleScopeImpl* NapiHandleScope::open(Zig::GlobalObject* globalObject, bool return impl; } -void NapiHandleScope::close(Zig::GlobalObject* globalObject, NapiHandleScopeImpl* current) +void NapiHandleScope::close(Bun::GlobalObject* globalObject, NapiHandleScopeImpl* current) { NAPI_LOG_CURRENT_FUNCTION; // napi handle scopes may be null pointers if created inside a finalizer @@ -120,7 +120,7 @@ void NapiHandleScope::close(Zig::GlobalObject* globalObject, NapiHandleScopeImpl } } -NapiHandleScope::NapiHandleScope(Zig::GlobalObject* globalObject) +NapiHandleScope::NapiHandleScope(Bun::GlobalObject* globalObject) : m_globalObject(globalObject) , m_impl(NapiHandleScope::open(globalObject, false)) { diff --git a/src/jsc/bindings/napi_handle_scope.h b/src/jsc/bindings/napi_handle_scope.h index a00471663782..deaee9b257b0 100644 --- a/src/jsc/bindings/napi_handle_scope.h +++ b/src/jsc/bindings/napi_handle_scope.h @@ -74,19 +74,19 @@ class NapiHandleScopeImpl : public JSC::JSCell { // Wrapper class used to open a new handle scope and close it when this instance goes out of scope class NapiHandleScope { public: - NapiHandleScope(Zig::GlobalObject* globalObject); + NapiHandleScope(Bun::GlobalObject* globalObject); ~NapiHandleScope(); // Create a new handle scope in the given environment - static NapiHandleScopeImpl* open(Zig::GlobalObject* globalObject, bool escapable); + static NapiHandleScopeImpl* open(Bun::GlobalObject* globalObject, bool escapable); // Closes the most recently created handle scope in the given environment and restores the old one. // Asserts that `current` is the active handle scope. - static void close(Zig::GlobalObject* globalObject, NapiHandleScopeImpl* current); + static void close(Bun::GlobalObject* globalObject, NapiHandleScopeImpl* current); private: NapiHandleScopeImpl* m_impl; - Zig::GlobalObject* m_globalObject; + Bun::GlobalObject* m_globalObject; }; // Create a new handle scope in the given environment diff --git a/src/jsc/bindings/napi_type_tag.cpp b/src/jsc/bindings/napi_type_tag.cpp index b05385b18ceb..9890920ecb8f 100644 --- a/src/jsc/bindings/napi_type_tag.cpp +++ b/src/jsc/bindings/napi_type_tag.cpp @@ -1,6 +1,6 @@ #include "napi_type_tag.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { diff --git a/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp b/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp index e498d98fc36a..20634a90a206 100644 --- a/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp +++ b/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp @@ -1,6 +1,6 @@ #include "JSNodeHTTPServerSocket.h" #include "JSNodeHTTPServerSocketPrototype.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ZigGeneratedClasses.h" #include "DOMIsoSubspaces.h" #include "ScriptExecutionContext.h" @@ -39,7 +39,7 @@ JSNodeHTTPServerSocket* JSNodeHTTPServerSocket::create(JSC::VM& vm, JSC::Structu return object; } -JSNodeHTTPServerSocket* JSNodeHTTPServerSocket::create(JSC::VM& vm, Zig::GlobalObject* globalObject, us_socket_t* socket, bool is_ssl, WebCore::JSNodeHTTPResponse* response) +JSNodeHTTPServerSocket* JSNodeHTTPServerSocket::create(JSC::VM& vm, Bun::GlobalObject* globalObject, us_socket_t* socket, bool is_ssl, WebCore::JSNodeHTTPResponse* response) { auto* structure = globalObject->m_JSNodeHTTPServerSocketStructure.getInitializedOnMainThread(globalObject); return create(vm, structure, socket, is_ssl, response); @@ -134,7 +134,7 @@ void JSNodeHTTPServerSocket::onClose() } // This function can be called during GC! - Zig::GlobalObject* globalObject = static_cast(this->globalObject()); + Bun::GlobalObject* globalObject = static_cast(this->globalObject()); if (!functionToCallOnClose) { if (auto* res = this->currentResponseObject.get(); res != nullptr && res->m_ctx != nullptr) { Bun__NodeHTTPResponse_onClose(res->m_ctx, JSValue::encode(res)); @@ -188,7 +188,7 @@ void JSNodeHTTPServerSocket::onClose() void JSNodeHTTPServerSocket::onDrain() { // This function can be called during GC! - Zig::GlobalObject* globalObject = static_cast(this->globalObject()); + Bun::GlobalObject* globalObject = static_cast(this->globalObject()); if (!functionToCallOnDrain) { return; } @@ -240,7 +240,7 @@ void JSNodeHTTPServerSocket::onDrain() void JSNodeHTTPServerSocket::onData(const char* data, int length, bool last) { // This function can be called during GC! - Zig::GlobalObject* globalObject = static_cast(this->globalObject()); + Bun::GlobalObject* globalObject = static_cast(this->globalObject()); if (!functionToCallOnData) { return; } @@ -349,7 +349,7 @@ extern "C" JSC::EncodedJSValue Bun__getNodeHTTPServerSocketThisValue(bool is_ssl return JSValue::encode(getNodeHTTPServerSocket(socket)); } -extern "C" JSC::EncodedJSValue Bun__createNodeHTTPServerSocketForClientError(bool isSSL, us_socket_t* us_socket, Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__createNodeHTTPServerSocketForClientError(bool isSSL, us_socket_t* us_socket, Bun::GlobalObject* globalObject) { auto& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/node/JSNodeHTTPServerSocket.h b/src/jsc/bindings/node/JSNodeHTTPServerSocket.h index 111a27ac1d46..5bb0abb3e8ca 100644 --- a/src/jsc/bindings/node/JSNodeHTTPServerSocket.h +++ b/src/jsc/bindings/node/JSNodeHTTPServerSocket.h @@ -53,7 +53,7 @@ class JSNodeHTTPServerSocket : public JSC::JSDestructibleObject { JSC::Strong strongThis = {}; static JSNodeHTTPServerSocket* create(JSC::VM& vm, JSC::Structure* structure, us_socket_t* socket, bool is_ssl, WebCore::JSNodeHTTPResponse* response); - static JSNodeHTTPServerSocket* create(JSC::VM& vm, Zig::GlobalObject* globalObject, us_socket_t* socket, bool is_ssl, WebCore::JSNodeHTTPResponse* response); + static JSNodeHTTPServerSocket* create(JSC::VM& vm, Bun::GlobalObject* globalObject, us_socket_t* socket, bool is_ssl, WebCore::JSNodeHTTPResponse* response); static void destroy(JSC::JSCell* cell) { diff --git a/src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.cpp b/src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.cpp index 1e4891172c96..30fd5160a504 100644 --- a/src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.cpp +++ b/src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.cpp @@ -1,7 +1,7 @@ #include "JSNodeHTTPServerSocketPrototype.h" #include "JSNodeHTTPServerSocket.h" #include "JSSocketAddressDTO.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ZigGeneratedClasses.h" #include "helpers.h" #include diff --git a/src/jsc/bindings/node/crypto/CryptoUtil.cpp b/src/jsc/bindings/node/crypto/CryptoUtil.cpp index c53ae57f7dd0..b7d861800b6a 100644 --- a/src/jsc/bindings/node/crypto/CryptoUtil.cpp +++ b/src/jsc/bindings/node/crypto/CryptoUtil.cpp @@ -22,15 +22,15 @@ using namespace ncrypto; namespace ExternZigHash { struct Hasher; -extern "C" Hasher* Bun__CryptoHasherExtern__getByName(Zig::GlobalObject* globalObject, const char* name, size_t nameLen); -Hasher* getByName(Zig::GlobalObject* globalObject, const StringView& name) +extern "C" Hasher* Bun__CryptoHasherExtern__getByName(Bun::GlobalObject* globalObject, const char* name, size_t nameLen); +Hasher* getByName(Bun::GlobalObject* globalObject, const StringView& name) { auto utf8 = name.utf8(); return Bun__CryptoHasherExtern__getByName(globalObject, utf8.data(), utf8.length()); } -extern "C" Hasher* Bun__CryptoHasherExtern__getFromOther(Zig::GlobalObject* global, Hasher* hasher); -Hasher* getFromOther(Zig::GlobalObject* globalObject, Hasher* hasher) +extern "C" Hasher* Bun__CryptoHasherExtern__getFromOther(Bun::GlobalObject* global, Hasher* hasher); +Hasher* getFromOther(Bun::GlobalObject* globalObject, Hasher* hasher) { return Bun__CryptoHasherExtern__getFromOther(globalObject, hasher); } @@ -47,8 +47,8 @@ bool update(Hasher* hasher, std::span data) return Bun__CryptoHasherExtern__update(hasher, data.data(), data.size()); } -extern "C" uint32_t Bun__CryptoHasherExtern__digest(Hasher* hasher, Zig::GlobalObject* globalObject, uint8_t* out, size_t outLen); -uint32_t digest(Hasher* hasher, Zig::GlobalObject* globalObject, std::span out) +extern "C" uint32_t Bun__CryptoHasherExtern__digest(Hasher* hasher, Bun::GlobalObject* globalObject, uint8_t* out, size_t outLen); +uint32_t digest(Hasher* hasher, Bun::GlobalObject* globalObject, std::span out) { return Bun__CryptoHasherExtern__digest(hasher, globalObject, out.data(), out.size()); } diff --git a/src/jsc/bindings/node/crypto/CryptoUtil.h b/src/jsc/bindings/node/crypto/CryptoUtil.h index 8382f54d80a8..1661f641c1ff 100644 --- a/src/jsc/bindings/node/crypto/CryptoUtil.h +++ b/src/jsc/bindings/node/crypto/CryptoUtil.h @@ -20,11 +20,11 @@ enum class DSASigEnc { namespace ExternZigHash { struct Hasher; -Hasher* getByName(Zig::GlobalObject* globalObject, const StringView& name); -Hasher* getFromOther(Zig::GlobalObject* globalObject, Hasher* hasher); +Hasher* getByName(Bun::GlobalObject* globalObject, const StringView& name); +Hasher* getFromOther(Bun::GlobalObject* globalObject, Hasher* hasher); void destroy(Hasher* hasher); bool update(Hasher* hasher, std::span data); -uint32_t digest(Hasher* hasher, Zig::GlobalObject* globalObject, std::span out); +uint32_t digest(Hasher* hasher, Bun::GlobalObject* globalObject, std::span out); uint32_t getDigestSize(Hasher* hasher); bool isXof(Hasher* hasher); diff --git a/src/jsc/bindings/node/crypto/JSCipher.cpp b/src/jsc/bindings/node/crypto/JSCipher.cpp index 02cb1e071a4b..4bed923805f2 100644 --- a/src/jsc/bindings/node/crypto/JSCipher.cpp +++ b/src/jsc/bindings/node/crypto/JSCipher.cpp @@ -2,7 +2,7 @@ #include "JSCipherPrototype.h" #include "JSCipherConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSDiffieHellman.cpp b/src/jsc/bindings/node/crypto/JSDiffieHellman.cpp index 3c5758e07f55..3a4b3667e8c1 100644 --- a/src/jsc/bindings/node/crypto/JSDiffieHellman.cpp +++ b/src/jsc/bindings/node/crypto/JSDiffieHellman.cpp @@ -2,7 +2,7 @@ #include "JSDiffieHellmanPrototype.h" #include "JSDiffieHellmanConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSDiffieHellmanGroup.cpp b/src/jsc/bindings/node/crypto/JSDiffieHellmanGroup.cpp index 5d05e6467a5f..30b9beb6f902 100644 --- a/src/jsc/bindings/node/crypto/JSDiffieHellmanGroup.cpp +++ b/src/jsc/bindings/node/crypto/JSDiffieHellmanGroup.cpp @@ -2,7 +2,7 @@ #include "JSDiffieHellmanGroupPrototype.h" #include "JSDiffieHellmanGroupConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp b/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp index 6e232aa85abc..b4e9c2a9dd4c 100644 --- a/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp @@ -5,7 +5,7 @@ #include "ErrorCode.h" #include "NodeValidator.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bun { @@ -44,7 +44,7 @@ JSC_DEFINE_HOST_FUNCTION(constructDiffieHellmanGroup, (JSC::JSGlobalObject * glo } // Get the appropriate structure and create the DiffieHellmanGroup object - auto* zigGlobalObject = dynamicDowncast(globalObject); + auto* zigGlobalObject = dynamicDowncast(globalObject); JSC::Structure* structure = zigGlobalObject->m_JSDiffieHellmanGroupClassStructure.get(zigGlobalObject); JSC::JSValue newTarget = callFrame->newTarget(); diff --git a/src/jsc/bindings/node/crypto/JSECDH.cpp b/src/jsc/bindings/node/crypto/JSECDH.cpp index 28d642c4e4e1..cddd44313853 100644 --- a/src/jsc/bindings/node/crypto/JSECDH.cpp +++ b/src/jsc/bindings/node/crypto/JSECDH.cpp @@ -2,7 +2,7 @@ #include "JSECDHPrototype.h" #include "JSECDHConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSKeyObject.cpp b/src/jsc/bindings/node/crypto/JSKeyObject.cpp index fecf27d7e52b..e81d426981c3 100644 --- a/src/jsc/bindings/node/crypto/JSKeyObject.cpp +++ b/src/jsc/bindings/node/crypto/JSKeyObject.cpp @@ -2,7 +2,7 @@ #include "JSKeyObjectPrototype.h" #include "JSKeyObjectConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSKeyObjectConstructor.cpp b/src/jsc/bindings/node/crypto/JSKeyObjectConstructor.cpp index 709b95f70b89..86cca49f93e4 100644 --- a/src/jsc/bindings/node/crypto/JSKeyObjectConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSKeyObjectConstructor.cpp @@ -14,7 +14,7 @@ #include "JSSecretKeyObject.h" #include "JSPublicKeyObject.h" #include "JSPrivateKeyObject.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "CryptoKeyAES.h" #include "CryptoKeyHMAC.h" #include "CryptoKeyRaw.h" diff --git a/src/jsc/bindings/node/crypto/JSPrivateKeyObject.cpp b/src/jsc/bindings/node/crypto/JSPrivateKeyObject.cpp index b92f405e9cda..4a53e072335d 100644 --- a/src/jsc/bindings/node/crypto/JSPrivateKeyObject.cpp +++ b/src/jsc/bindings/node/crypto/JSPrivateKeyObject.cpp @@ -2,7 +2,7 @@ #include "JSPrivateKeyObjectPrototype.h" #include "JSKeyObjectConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSPublicKeyObject.cpp b/src/jsc/bindings/node/crypto/JSPublicKeyObject.cpp index 650108fee620..69a434b0b03b 100644 --- a/src/jsc/bindings/node/crypto/JSPublicKeyObject.cpp +++ b/src/jsc/bindings/node/crypto/JSPublicKeyObject.cpp @@ -2,7 +2,7 @@ #include "JSPublicKeyObjectPrototype.h" #include "JSKeyObjectConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSSecretKeyObject.cpp b/src/jsc/bindings/node/crypto/JSSecretKeyObject.cpp index d125fb90ac3d..fa6d9f187614 100644 --- a/src/jsc/bindings/node/crypto/JSSecretKeyObject.cpp +++ b/src/jsc/bindings/node/crypto/JSSecretKeyObject.cpp @@ -2,7 +2,7 @@ #include "JSSecretKeyObjectPrototype.h" #include "JSSecretKeyObjectConstructor.h" #include "DOMIsoSubspaces.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/jsc/bindings/node/crypto/JSSign.cpp b/src/jsc/bindings/node/crypto/JSSign.cpp index 91d52748e04a..724e83843e70 100644 --- a/src/jsc/bindings/node/crypto/JSSign.cpp +++ b/src/jsc/bindings/node/crypto/JSSign.cpp @@ -2,7 +2,7 @@ #include "JavaScriptCore/JSArrayBufferView.h" #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/JSType.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include "JSDOMExceptionHandling.h" #include diff --git a/src/jsc/bindings/node/crypto/JSVerify.cpp b/src/jsc/bindings/node/crypto/JSVerify.cpp index 89ce5170a83e..80af53029b07 100644 --- a/src/jsc/bindings/node/crypto/JSVerify.cpp +++ b/src/jsc/bindings/node/crypto/JSVerify.cpp @@ -3,7 +3,7 @@ #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/JSType.h" #include "SubtleCrypto.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include "JSDOMExceptionHandling.h" #include diff --git a/src/jsc/bindings/node/crypto/KeyObject.cpp b/src/jsc/bindings/node/crypto/KeyObject.cpp index b2a44dc72c6f..f9e714a4d471 100644 --- a/src/jsc/bindings/node/crypto/KeyObject.cpp +++ b/src/jsc/bindings/node/crypto/KeyObject.cpp @@ -2,7 +2,7 @@ #include "JSPublicKeyObject.h" #include "JSPrivateKeyObject.h" #include "helpers.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "CryptoUtil.h" #include "ErrorCode.h" #include "NodeValidator.h" diff --git a/src/jsc/bindings/node/crypto/node_crypto_binding.cpp b/src/jsc/bindings/node/crypto/node_crypto_binding.cpp index e8c2d019dad4..65dd28622d35 100644 --- a/src/jsc/bindings/node/crypto/node_crypto_binding.cpp +++ b/src/jsc/bindings/node/crypto/node_crypto_binding.cpp @@ -3,7 +3,7 @@ #include "JavaScriptCore/JSArrayBufferView.h" #include "JavaScriptCore/JSCJSValue.h" #include "JavaScriptCore/JSCast.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "webcrypto/JSCryptoKey.h" #include "webcrypto/JSSubtleCrypto.h" #include "webcrypto/CryptoKeyOKP.h" @@ -197,7 +197,7 @@ JSC_DEFINE_HOST_FUNCTION(jsCertExportChallenge, (JSC::JSGlobalObject * lexicalGl return JSValue::encode(jsEmptyString(vm)); } - auto* bufferResult = JSC::JSUint8Array::create(lexicalGlobalObject, static_cast(lexicalGlobalObject)->JSBufferSubclassStructure(), WTF::move(result), 0, cert.len); + auto* bufferResult = JSC::JSUint8Array::create(lexicalGlobalObject, static_cast(lexicalGlobalObject)->JSBufferSubclassStructure(), WTF::move(result), 0, cert.len); RETURN_IF_EXCEPTION(scope, {}); return JSValue::encode(bufferResult); @@ -322,7 +322,7 @@ JSC_DEFINE_HOST_FUNCTION(jsGetCipherInfo, (JSC::JSGlobalObject * lexicalGlobalOb return JSValue::encode(result); } -JSValue createNodeCryptoBinding(Zig::GlobalObject* globalObject) +JSValue createNodeCryptoBinding(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); JSObject* obj = constructEmptyObject(globalObject); diff --git a/src/jsc/bindings/node/crypto/node_crypto_binding.h b/src/jsc/bindings/node/crypto/node_crypto_binding.h index 252784808ff5..00a71603af40 100644 --- a/src/jsc/bindings/node/crypto/node_crypto_binding.h +++ b/src/jsc/bindings/node/crypto/node_crypto_binding.h @@ -7,6 +7,6 @@ namespace Bun { -JSC::JSValue createNodeCryptoBinding(Zig::GlobalObject* globalObject); +JSC::JSValue createNodeCryptoBinding(Bun::GlobalObject* globalObject); } // namespace Bun diff --git a/src/jsc/bindings/node/http/JSConnectionsListConstructor.cpp b/src/jsc/bindings/node/http/JSConnectionsListConstructor.cpp index 1ecf281e1d8b..64272fa0bb2b 100644 --- a/src/jsc/bindings/node/http/JSConnectionsListConstructor.cpp +++ b/src/jsc/bindings/node/http/JSConnectionsListConstructor.cpp @@ -1,6 +1,6 @@ #include "JSConnectionsListConstructor.h" #include "JSConnectionsList.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include namespace Bun { diff --git a/src/jsc/bindings/node/http/JSHTTPParserConstructor.cpp b/src/jsc/bindings/node/http/JSHTTPParserConstructor.cpp index d1838b079eae..fb3d6dc89c6d 100644 --- a/src/jsc/bindings/node/http/JSHTTPParserConstructor.cpp +++ b/src/jsc/bindings/node/http/JSHTTPParserConstructor.cpp @@ -1,6 +1,6 @@ #include "JSHTTPParserConstructor.h" #include "JSHTTPParser.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ProcessBindingHTTPParser.h" namespace Bun { diff --git a/src/jsc/bindings/node/http/JSHTTPParserPrototype.cpp b/src/jsc/bindings/node/http/JSHTTPParserPrototype.cpp index 57124873e37a..f759e8b78caf 100644 --- a/src/jsc/bindings/node/http/JSHTTPParserPrototype.cpp +++ b/src/jsc/bindings/node/http/JSHTTPParserPrototype.cpp @@ -1,7 +1,7 @@ #include "JSHTTPParserPrototype.h" #include "JSHTTPParser.h" #include "JSConnectionsList.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMExceptionHandling.h" #include diff --git a/src/jsc/bindings/node/http/NodeHTTPParser.cpp b/src/jsc/bindings/node/http/NodeHTTPParser.cpp index 5443c08b2c31..2f9fa7f88a45 100644 --- a/src/jsc/bindings/node/http/NodeHTTPParser.cpp +++ b/src/jsc/bindings/node/http/NodeHTTPParser.cpp @@ -3,7 +3,7 @@ #include "helpers.h" #include "JSConnectionsList.h" #include "JSHTTPParser.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "uv.h" namespace Bun { diff --git a/src/jsc/bindings/root-pch.h b/src/jsc/bindings/root-pch.h index d4614fee3aab..7e9b70a4c464 100644 --- a/src/jsc/bindings/root-pch.h +++ b/src/jsc/bindings/root-pch.h @@ -8,7 +8,7 @@ // root.h is guaranteed to be the first thing parsed (the PCH wrapper // force-includes it). If they lived in root.h itself, a TU whose first // explicit include is BunClientData.h would re-enter root.h mid-parse and -// reach ZigGlobalObject.h before WebCore::clientData() is declared. The PCH +// reach BunGlobalObject.h before WebCore::clientData() is declared. The PCH // path is fine; --unifiedSources=false would not be. #include "root.h" @@ -17,4 +17,4 @@ // (-ftime-trace). Editing either already triggers a near-full rebuild via // depfiles, so precompiling them costs nothing extra incrementally. #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" diff --git a/src/jsc/bindings/sqlite/JSSQLStatement.cpp b/src/jsc/bindings/sqlite/JSSQLStatement.cpp index c68c7c2e8ba1..6dc2e7a95bdc 100644 --- a/src/jsc/bindings/sqlite/JSSQLStatement.cpp +++ b/src/jsc/bindings/sqlite/JSSQLStatement.cpp @@ -1668,7 +1668,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO int64_t memoryChange = sqlite_malloc_amount - currentMemoryUsage; JSSQLStatement* sqlStatement = JSSQLStatement::create( - static_cast(lexicalGlobalObject), statement, versionDB, memoryChange); + static_cast(lexicalGlobalObject), statement, versionDB, memoryChange); if (internalFlagsValue.isInt32()) { const int32_t internalFlags = internalFlagsValue.asInt32(); @@ -1935,7 +1935,7 @@ void JSSQLStatementConstructor::finishCreation(VM& vm) Base::finishCreation(vm); // TODO: use LazyClassStructure? - auto* instanceObject = JSSQLStatement::create(static_cast(globalObject()), nullptr, nullptr); + auto* instanceObject = JSSQLStatement::create(static_cast(globalObject()), nullptr, nullptr); JSValue proto = instanceObject->getPrototype(globalObject()); this->putDirect(vm, vm.propertyNames->prototype, proto, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); @@ -2914,7 +2914,7 @@ void JSSQLStatement::visitOutputConstraints(JSCell* cell, Visitor& visitor) template void JSSQLStatement::visitOutputConstraints(JSCell*, AbstractSlotVisitor&); template void JSSQLStatement::visitOutputConstraints(JSCell*, SlotVisitor&); -JSValue createJSSQLStatementConstructor(Zig::GlobalObject* globalObject) +JSValue createJSSQLStatementConstructor(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); JSObject* object = JSC::constructEmptyObject(globalObject); diff --git a/src/jsc/bindings/sqlite/JSSQLStatement.h b/src/jsc/bindings/sqlite/JSSQLStatement.h index 975ccbacd347..bc8128900dfe 100644 --- a/src/jsc/bindings/sqlite/JSSQLStatement.h +++ b/src/jsc/bindings/sqlite/JSSQLStatement.h @@ -26,7 +26,7 @@ #pragma once #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -84,6 +84,6 @@ class JSSQLStatementConstructor final : public JSC::JSFunction { static_assert(sizeof(JSSQLStatementConstructor) == sizeof(JSFunction), "Allocate JSSQLStatementConstructor in JSFunction IsoSubspace"); Structure* createJSSQLStatementStructure(JSGlobalObject* globalObject); -JSValue createJSSQLStatementConstructor(Zig::GlobalObject* globalObject); +JSValue createJSSQLStatementConstructor(Bun::GlobalObject* globalObject); } // namespace WebCore diff --git a/src/jsc/bindings/v8/V8Array.cpp b/src/jsc/bindings/v8/V8Array.cpp index 2e6dcf09eea5..a35268f1679a 100644 --- a/src/jsc/bindings/v8/V8Array.cpp +++ b/src/jsc/bindings/v8/V8Array.cpp @@ -25,7 +25,7 @@ namespace v8 { // Array::New with elements and length Local Array::New(Isolate* isolate, Local* elements, size_t length) { - Zig::GlobalObject* globalObject = isolate->globalObject(); + Bun::GlobalObject* globalObject = isolate->globalObject(); auto& vm = isolate->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -53,7 +53,7 @@ Local Array::New(Isolate* isolate, Local* elements, size_t length) // Array::New with just length Local Array::New(Isolate* isolate, int length) { - Zig::GlobalObject* globalObject = isolate->globalObject(); + Bun::GlobalObject* globalObject = isolate->globalObject(); auto& vm = isolate->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -69,7 +69,7 @@ MaybeLocal Array::New(Local context, size_t length, std::function()> next_value_callback) { Isolate* isolate = context->GetIsolate(); - Zig::GlobalObject* globalObject = context->globalObject(); + Bun::GlobalObject* globalObject = context->globalObject(); auto& vm = isolate->vm(); EscapableHandleScope handleScope(isolate); @@ -123,7 +123,7 @@ void Array::CheckCast(Value* obj) Maybe Array::Iterate(Local context, IterationCallback callback, void* callback_data) { const JSArray* jsArray = localToObjectPointer(); - Zig::GlobalObject* globalObject = context->globalObject(); + Bun::GlobalObject* globalObject = context->globalObject(); auto& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/v8/V8Context.h b/src/jsc/bindings/v8/V8Context.h index c92ca0dfdd8d..aa057d94c3b0 100644 --- a/src/jsc/bindings/v8/V8Context.h +++ b/src/jsc/bindings/v8/V8Context.h @@ -1,13 +1,13 @@ #pragma once -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "V8Data.h" namespace v8 { class Isolate; -// Context is always a reinterpret pointer to Zig::GlobalObject, so that functions accepting a +// Context is always a reinterpret pointer to Bun::GlobalObject, so that functions accepting a // Context can quickly access JSC data class Context : public Data { public: @@ -18,14 +18,14 @@ class Context : public Data { return localToCell()->vm(); } - const Zig::GlobalObject* globalObject() const + const Bun::GlobalObject* globalObject() const { - return dynamicDowncast(localToCell()); + return dynamicDowncast(localToCell()); } - Zig::GlobalObject* globalObject() + Bun::GlobalObject* globalObject() { - return dynamicDowncast(localToCell()); + return dynamicDowncast(localToCell()); } HandleScope* currentHandleScope() const diff --git a/src/jsc/bindings/v8/V8Function.cpp b/src/jsc/bindings/v8/V8Function.cpp index 9277e184f586..22fd354b54c2 100644 --- a/src/jsc/bindings/v8/V8Function.cpp +++ b/src/jsc/bindings/v8/V8Function.cpp @@ -29,7 +29,7 @@ Local Function::GetName() const RELEASE_ASSERT_NOT_REACHED("v8::Function::GetName called on invalid type"); } - auto* globalObject = uncheckedDowncast(localToObjectPointer()->globalObject()); + auto* globalObject = uncheckedDowncast(localToObjectPointer()->globalObject()); auto* handleScope = globalObject->V8GlobalInternals()->currentHandleScope(); auto* jsString = JSC::jsString(globalObject->vm(), wtfString); return handleScope->createLocal(globalObject->vm(), jsString); diff --git a/src/jsc/bindings/v8/V8Isolate.cpp b/src/jsc/bindings/v8/V8Isolate.cpp index 2f6928b49a8f..91b456274e00 100644 --- a/src/jsc/bindings/v8/V8Isolate.cpp +++ b/src/jsc/bindings/v8/V8Isolate.cpp @@ -1,7 +1,7 @@ #include "V8Isolate.h" #include "V8HandleScope.h" #include "shim/GlobalInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "real_v8.h" #include "v8_compatibility_assertions.h" diff --git a/src/jsc/bindings/v8/V8Isolate.h b/src/jsc/bindings/v8/V8Isolate.h index 5069cbd3e948..fac6aae6e60c 100644 --- a/src/jsc/bindings/v8/V8Isolate.h +++ b/src/jsc/bindings/v8/V8Isolate.h @@ -34,7 +34,7 @@ class Isolate final { BUN_EXPORT Local GetCurrentContext(); - Zig::GlobalObject* globalObject() { return m_globalObject; } + Bun::GlobalObject* globalObject() { return m_globalObject; } JSC::VM& vm() { return globalObject()->vm(); } shim::GlobalInternals* globalInternals() { return m_globalInternals; } HandleScope* currentHandleScope(); @@ -48,7 +48,7 @@ class Isolate final { TaggedPointer* falseSlot() { return &m_roots[Isolate::kFalseValueRootIndex]; } shim::GlobalInternals* m_globalInternals; - Zig::GlobalObject* m_globalObject; + Bun::GlobalObject* m_globalObject; uintptr_t m_padding[78]; diff --git a/src/jsc/bindings/v8/V8Object.cpp b/src/jsc/bindings/v8/V8Object.cpp index a244f62adc76..74fcc8ffe3dc 100644 --- a/src/jsc/bindings/v8/V8Object.cpp +++ b/src/jsc/bindings/v8/V8Object.cpp @@ -39,7 +39,7 @@ Local Object::New(Isolate* isolate) Maybe Object::Set(Local context, Local key, Local value) { - Zig::GlobalObject* globalObject = context->globalObject(); + Bun::GlobalObject* globalObject = context->globalObject(); JSObject* object = localToObjectPointer(); JSValue k = key->localToJSValue(); JSValue v = value->localToJSValue(); @@ -60,7 +60,7 @@ Maybe Object::Set(Local context, Local key, Local v Maybe Object::Set(Local context, uint32_t index, Local value) { - Zig::GlobalObject* globalObject = context->globalObject(); + Bun::GlobalObject* globalObject = context->globalObject(); JSObject* object = localToObjectPointer(); JSValue v = value->localToJSValue(); auto& vm = JSC::getVM(globalObject); @@ -77,7 +77,7 @@ Maybe Object::Set(Local context, uint32_t index, Local val MaybeLocal Object::Get(Local context, Local key) { - Zig::GlobalObject* globalObject = context->globalObject(); + Bun::GlobalObject* globalObject = context->globalObject(); JSObject* object = localToObjectPointer(); JSValue k = key->localToJSValue(); auto& vm = JSC::getVM(globalObject); @@ -98,7 +98,7 @@ MaybeLocal Object::Get(Local context, Local key) MaybeLocal Object::Get(Local context, uint32_t index) { - Zig::GlobalObject* globalObject = context->globalObject(); + Bun::GlobalObject* globalObject = context->globalObject(); JSObject* object = localToObjectPointer(); auto& vm = JSC::getVM(globalObject); @@ -119,7 +119,7 @@ void Object::SetInternalField(int index, Local data) RELEASE_ASSERT(fields, "object has no internal fields"); RELEASE_ASSERT(index >= 0 && index < fields->size(), "internal field index is out of bounds"); JSObject* js_object = localToObjectPointer(); - auto* globalObject = dynamicDowncast(js_object->globalObject()); + auto* globalObject = dynamicDowncast(js_object->globalObject()); fields->at(index).set(globalObject->vm(), localToCell(), data->localToJSValue()); } @@ -132,7 +132,7 @@ Local Object::SlowGetInternalField(int index) { auto* fields = getInternalFieldsContainer(this); JSObject* js_object = localToObjectPointer(); - auto* globalObject = dynamicDowncast(js_object->globalObject()); + auto* globalObject = dynamicDowncast(js_object->globalObject()); HandleScope* handleScope = globalObject->V8GlobalInternals()->currentHandleScope(); if (fields && index >= 0 && index < fields->size()) { auto& field = fields->at(index); diff --git a/src/jsc/bindings/v8/shim/FunctionTemplate.cpp b/src/jsc/bindings/v8/shim/FunctionTemplate.cpp index 6de66fabebf3..57e00185d4c1 100644 --- a/src/jsc/bindings/v8/shim/FunctionTemplate.cpp +++ b/src/jsc/bindings/v8/shim/FunctionTemplate.cpp @@ -59,7 +59,7 @@ JSC::EncodedJSValue FunctionTemplate::functionCall(JSC::JSGlobalObject* globalOb { auto* callee = dynamicDowncast(callFrame->jsCallee()); auto* functionTemplate = callee->functionTemplate(); - auto* isolate = uncheckedDowncast(globalObject)->V8GlobalInternals()->isolate(); + auto* isolate = uncheckedDowncast(globalObject)->V8GlobalInternals()->isolate(); auto& vm = JSC::getVM(globalObject); WTF::Vector args(callFrame->argumentCount() + 1); @@ -88,7 +88,7 @@ JSC::EncodedJSValue FunctionTemplate::functionCall(JSC::JSGlobalObject* globalOb ImplicitArgs implicit_args = { .unused = nullptr, .isolate = isolate, - // Context is always a reinterpret pointer to Zig::GlobalObject + // Context is always a reinterpret pointer to Bun::GlobalObject .context = reinterpret_cast(globalObject), .return_value = TaggedPointer(), // target holds the Function being called, which contains the FunctionTemplate diff --git a/src/jsc/bindings/v8/shim/GlobalInternals.cpp b/src/jsc/bindings/v8/shim/GlobalInternals.cpp index 7145ecf8ce45..cb04c231516a 100644 --- a/src/jsc/bindings/v8/shim/GlobalInternals.cpp +++ b/src/jsc/bindings/v8/shim/GlobalInternals.cpp @@ -24,7 +24,7 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers; const ClassInfo GlobalInternals::s_info = { "GlobalInternals"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(GlobalInternals) }; -GlobalInternals* GlobalInternals::create(VM& vm, Structure* structure, Zig::GlobalObject* globalObject) +GlobalInternals* GlobalInternals::create(VM& vm, Structure* structure, Bun::GlobalObject* globalObject) { GlobalInternals* internals = new (NotNull, JSC::allocateCell(vm)) GlobalInternals(vm, structure, globalObject); internals->finishCreation(vm); diff --git a/src/jsc/bindings/v8/shim/GlobalInternals.h b/src/jsc/bindings/v8/shim/GlobalInternals.h index e55ac4af20f5..4eb1160d534e 100644 --- a/src/jsc/bindings/v8/shim/GlobalInternals.h +++ b/src/jsc/bindings/v8/shim/GlobalInternals.h @@ -17,7 +17,7 @@ class GlobalInternals : public JSC::JSCell { public: using Base = JSC::JSCell; - static GlobalInternals* create(JSC::VM& vm, JSC::Structure* structure, Zig::GlobalObject* globalObject); + static GlobalInternals* create(JSC::VM& vm, JSC::Structure* structure, Bun::GlobalObject* globalObject); static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { @@ -72,7 +72,7 @@ class GlobalInternals : public JSC::JSCell { friend class ::v8::Context; private: - Zig::GlobalObject* m_globalObject; + Bun::GlobalObject* m_globalObject; JSC::LazyClassStructure m_objectTemplateStructure; JSC::LazyClassStructure m_handleScopeBufferStructure; JSC::LazyClassStructure m_functionTemplateStructure; @@ -88,7 +88,7 @@ class GlobalInternals : public JSC::JSCell { Isolate m_isolate; void finishCreation(JSC::VM& vm); - GlobalInternals(JSC::VM& vm, JSC::Structure* structure, Zig::GlobalObject* globalObject) + GlobalInternals(JSC::VM& vm, JSC::Structure* structure, Bun::GlobalObject* globalObject) : Base(vm, structure) , m_currentHandleScope(nullptr) , m_undefinedValue(Oddball::Kind::kUndefined) diff --git a/src/jsc/bindings/v8/v8.h b/src/jsc/bindings/v8/v8.h index 8ed2c62f8a2f..cb03a5489e50 100644 --- a/src/jsc/bindings/v8/v8.h +++ b/src/jsc/bindings/v8/v8.h @@ -1,6 +1,6 @@ #pragma once -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #define V8_UNIMPLEMENTED() \ do { \ diff --git a/src/jsc/bindings/webcore/AbortController.h b/src/jsc/bindings/webcore/AbortController.h index 580f6810ea83..8c89c23d7a1e 100644 --- a/src/jsc/bindings/webcore/AbortController.h +++ b/src/jsc/bindings/webcore/AbortController.h @@ -27,7 +27,7 @@ #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ScriptWrappable.h" #include @@ -37,7 +37,7 @@ namespace JSC { class JSValue; } -namespace Zig { +namespace Bun { class GlobalObject; } @@ -58,7 +58,7 @@ class AbortController final : public ScriptWrappable, public RefCounted protectedSignal() const; - void abort(Zig::GlobalObject&, JSC::JSValue reason); + void abort(Bun::GlobalObject&, JSC::JSValue reason); WebCoreOpaqueRoot opaqueRoot(); diff --git a/src/jsc/bindings/webcore/AbortSignal.h b/src/jsc/bindings/webcore/AbortSignal.h index 1442edfe8806..49640fe96672 100644 --- a/src/jsc/bindings/webcore/AbortSignal.h +++ b/src/jsc/bindings/webcore/AbortSignal.h @@ -31,7 +31,7 @@ #include "EventTarget.h" #include "JSValueInWrappedObject.h" #include "JavaScriptCore/JSGlobalObject.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "wtf/DebugHeap.h" #include "wtf/FastMalloc.h" #include diff --git a/src/jsc/bindings/webcore/DOMIsoSubspaces.h b/src/jsc/bindings/webcore/DOMIsoSubspaces.h index c67afb40065d..93a7fb60161f 100644 --- a/src/jsc/bindings/webcore/DOMIsoSubspaces.h +++ b/src/jsc/bindings/webcore/DOMIsoSubspaces.h @@ -926,7 +926,7 @@ class DOMIsoSubspaces { std::unique_ptr m_subspaceForEventTarget; std::unique_ptr m_subspaceForEventEmitter; - std::unique_ptr m_subspaceForZigGlobalObject; + std::unique_ptr m_subspaceForBunGlobalObject; std::unique_ptr m_subspaceForExposedToWorkerAndWindow; std::unique_ptr m_subspaceForURLSearchParams; diff --git a/src/jsc/bindings/webcore/JSCallbackData.cpp b/src/jsc/bindings/webcore/JSCallbackData.cpp index afb8caffb8b9..0d5dab65b50b 100644 --- a/src/jsc/bindings/webcore/JSCallbackData.cpp +++ b/src/jsc/bindings/webcore/JSCallbackData.cpp @@ -28,7 +28,7 @@ #include "config.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSCallbackData.h" diff --git a/src/jsc/bindings/webcore/JSDOMConstructorBase.h b/src/jsc/bindings/webcore/JSDOMConstructorBase.h index 6bd8ba5e8941..6f4d3256c523 100644 --- a/src/jsc/bindings/webcore/JSDOMConstructorBase.h +++ b/src/jsc/bindings/webcore/JSDOMConstructorBase.h @@ -22,7 +22,7 @@ #include "JSDOMGlobalObject.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" namespace WebCore { diff --git a/src/jsc/bindings/webcore/JSDOMConvertBase.h b/src/jsc/bindings/webcore/JSDOMConvertBase.h index d67a71350597..24ab6fad7770 100644 --- a/src/jsc/bindings/webcore/JSDOMConvertBase.h +++ b/src/jsc/bindings/webcore/JSDOMConvertBase.h @@ -26,7 +26,7 @@ #pragma once #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMGlobalObject.h" #include "JSDOMExceptionHandling.h" #include "JSDOMConvertResult.h" diff --git a/src/jsc/bindings/webcore/JSDOMGlobalObjectInlines.h b/src/jsc/bindings/webcore/JSDOMGlobalObjectInlines.h index 313b14aa2061..8a4dfeba06fc 100644 --- a/src/jsc/bindings/webcore/JSDOMGlobalObjectInlines.h +++ b/src/jsc/bindings/webcore/JSDOMGlobalObjectInlines.h @@ -32,14 +32,14 @@ namespace WebCore { template -inline JSC::JSObject* getDOMConstructor(JSC::VM& vm, const Zig::GlobalObject& globalObject) +inline JSC::JSObject* getDOMConstructor(JSC::VM& vm, const Bun::GlobalObject& globalObject) { - // No locking is necessary unless we need to add a new constructor to Zig::GlobalObject::constructors(). + // No locking is necessary unless we need to add a new constructor to Bun::GlobalObject::constructors(). if (JSC::JSObject* constructor = globalObject.constructors().array()[static_cast(constructorID)].get()) return constructor; - JSC::JSObject* constructor = ConstructorClass::create(vm, ConstructorClass::createStructure(vm, const_cast(globalObject), ConstructorClass::prototypeForStructure(vm, globalObject)), const_cast(globalObject)); + JSC::JSObject* constructor = ConstructorClass::create(vm, ConstructorClass::createStructure(vm, const_cast(globalObject), ConstructorClass::prototypeForStructure(vm, globalObject)), const_cast(globalObject)); ASSERT(!globalObject.constructors().array()[static_cast(constructorID)].get()); - Zig::GlobalObject& mutableGlobalObject = const_cast(globalObject); + Bun::GlobalObject& mutableGlobalObject = const_cast(globalObject); mutableGlobalObject.constructors().array()[static_cast(constructorID)].set(vm, &globalObject, constructor); return constructor; } diff --git a/src/jsc/bindings/webcore/JSErrorEvent.cpp b/src/jsc/bindings/webcore/JSErrorEvent.cpp index f23fd3bfd677..29a6aee57ada 100644 --- a/src/jsc/bindings/webcore/JSErrorEvent.cpp +++ b/src/jsc/bindings/webcore/JSErrorEvent.cpp @@ -21,7 +21,7 @@ #include "config.h" #include "JSErrorEvent.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ActiveDOMObject.h" #include "ExtendedDOMClientIsoSubspaces.h" diff --git a/src/jsc/bindings/webcore/JSEventEmitter.cpp b/src/jsc/bindings/webcore/JSEventEmitter.cpp index 25168b83f179..70572aa08079 100644 --- a/src/jsc/bindings/webcore/JSEventEmitter.cpp +++ b/src/jsc/bindings/webcore/JSEventEmitter.cpp @@ -151,7 +151,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSEventEmitterDOMConstru } Structure* structure = JSEventEmitter::createStructure(vm, lexicalGlobalObject, jsValue); JSEventEmitter* instance - = JSEventEmitter::create(structure, static_cast(lexicalGlobalObject), object.copyRef()); + = JSEventEmitter::create(structure, static_cast(lexicalGlobalObject), object.copyRef()); RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(instance)); } diff --git a/src/jsc/bindings/webcore/JSEventEmitterCustom.cpp b/src/jsc/bindings/webcore/JSEventEmitterCustom.cpp index 1e29e1a25aa0..1aff117dd10a 100644 --- a/src/jsc/bindings/webcore/JSEventEmitterCustom.cpp +++ b/src/jsc/bindings/webcore/JSEventEmitterCustom.cpp @@ -4,7 +4,7 @@ #include "EventEmitter.h" #include "JSDOMWrapperCache.h" #include "JSEventListener.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMConstructor.h" #include "JSDOMConvertBase.h" @@ -67,7 +67,7 @@ JSEventEmitter* jsEventEmitterCastFast(VM& vm, JSC::JSGlobalObject* lexicalGloba // TODO: properly propagate exception upwards (^ getIfPropertyExists) auto scope = DECLARE_TOP_EXCEPTION_SCOPE(vm); - auto* globalObject = static_cast(lexicalGlobalObject); + auto* globalObject = static_cast(lexicalGlobalObject); auto impl = EventEmitter::create(*globalObject->scriptExecutionContext()); impl->setThisObject(thisObject); diff --git a/src/jsc/bindings/webcore/JSEventListener.cpp b/src/jsc/bindings/webcore/JSEventListener.cpp index e1d7f4eb3eb7..101916ab4b4b 100644 --- a/src/jsc/bindings/webcore/JSEventListener.cpp +++ b/src/jsc/bindings/webcore/JSEventListener.cpp @@ -133,7 +133,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionEmitUncaughtException, (JSC::JSGlobalObject * } JSC_DEFINE_HOST_FUNCTION(jsFunctionEmitUncaughtExceptionNextTick, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); Bun::Process* process = globalObject->processObject(); auto exception = callFrame->argument(0); auto func = JSFunction::create(globalObject->vm(), globalObject, 1, String(), jsFunctionEmitUncaughtException, JSC::ImplementationVisibility::Private); diff --git a/src/jsc/bindings/webcore/JSEventTargetCustom.cpp b/src/jsc/bindings/webcore/JSEventTargetCustom.cpp index 2dc97930715d..a50ed0271daf 100644 --- a/src/jsc/bindings/webcore/JSEventTargetCustom.cpp +++ b/src/jsc/bindings/webcore/JSEventTargetCustom.cpp @@ -76,7 +76,7 @@ JSEventTargetWrapper jsEventTargetCast(VM& vm, JSValue thisValue) if (!object) return {}; } - if (auto* global = dynamicDowncast(object)) + if (auto* global = dynamicDowncast(object)) return { global->eventTarget(), *global }; return {}; diff --git a/src/jsc/bindings/webcore/JSMIMEBindings.cpp b/src/jsc/bindings/webcore/JSMIMEBindings.cpp index e4cc9dab9d70..e810bf21f230 100644 --- a/src/jsc/bindings/webcore/JSMIMEBindings.cpp +++ b/src/jsc/bindings/webcore/JSMIMEBindings.cpp @@ -3,14 +3,14 @@ #include "JSMIMEType.h" #include "JavaScriptCore/JSObject.h" #include "JavaScriptCore/JSCJSValueInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace WebCore { using namespace JSC; // Create the combined MIME binding object with both MIMEParams and MIMEType -JSValue createMIMEBinding(Zig::GlobalObject* globalObject) +JSValue createMIMEBinding(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); JSObject* obj = constructEmptyObject(globalObject); diff --git a/src/jsc/bindings/webcore/JSMIMEBindings.h b/src/jsc/bindings/webcore/JSMIMEBindings.h index 453364e8f14b..7fbc600f1e5f 100644 --- a/src/jsc/bindings/webcore/JSMIMEBindings.h +++ b/src/jsc/bindings/webcore/JSMIMEBindings.h @@ -2,13 +2,13 @@ #include "root.h" -namespace Zig { +namespace Bun { class GlobalObject; } namespace WebCore { // Function to create a unified MIME binding object -JSC::JSValue createMIMEBinding(Zig::GlobalObject* globalObject); +JSC::JSValue createMIMEBinding(Bun::GlobalObject* globalObject); } // namespace WebCore diff --git a/src/jsc/bindings/webcore/JSMIMEParams.cpp b/src/jsc/bindings/webcore/JSMIMEParams.cpp index 9ba34573cb8b..a05ce0b7584f 100644 --- a/src/jsc/bindings/webcore/JSMIMEParams.cpp +++ b/src/jsc/bindings/webcore/JSMIMEParams.cpp @@ -17,7 +17,7 @@ #include "wtf/text/StringBuilder.h" #include "wtf/text/WTFString.h" #include "wtf/ASCIICType.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "NodeValidator.h" // For Bun::V:: #include "ErrorCode.h" // For Bun::ERR:: #include "JavaScriptCore/JSMapInlines.h" @@ -712,7 +712,7 @@ void setupJSMIMEParamsClassStructure(LazyClassStructure::Initializer& init) init.setConstructor(constructor); } -JSValue createJSMIMEBinding(Zig::GlobalObject* globalObject) +JSValue createJSMIMEBinding(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); JSObject* obj = constructEmptyObject(globalObject); diff --git a/src/jsc/bindings/webcore/JSMIMEParams.h b/src/jsc/bindings/webcore/JSMIMEParams.h index a40bbe8fa8b3..e5ff3acaf921 100644 --- a/src/jsc/bindings/webcore/JSMIMEParams.h +++ b/src/jsc/bindings/webcore/JSMIMEParams.h @@ -88,7 +88,7 @@ class JSMIMEParamsConstructor final : public JSC::InternalFunction { // Function to setup the structures lazily void setupJSMIMEParamsClassStructure(JSC::LazyClassStructure::Initializer&); -JSC::JSValue createJSMIMEBinding(Zig::GlobalObject* globalObject); +JSC::JSValue createJSMIMEBinding(Bun::GlobalObject* globalObject); bool parseMIMEParamsString(JSGlobalObject* globalObject, JSMap* map, StringView input); } // namespace WebCore diff --git a/src/jsc/bindings/webcore/JSMIMEType.cpp b/src/jsc/bindings/webcore/JSMIMEType.cpp index de7e66ccfe8c..16a46815b4af 100644 --- a/src/jsc/bindings/webcore/JSMIMEType.cpp +++ b/src/jsc/bindings/webcore/JSMIMEType.cpp @@ -15,7 +15,7 @@ #include "wtf/text/StringBuilder.h" #include "wtf/text/WTFString.h" #include "wtf/ASCIICType.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "NodeValidator.h" // For Bun::V:: #include "ErrorCode.h" // For Bun::ERR:: #include "JavaScriptCore/JSMapInlines.h" diff --git a/src/jsc/bindings/webcore/JSPerformance.cpp b/src/jsc/bindings/webcore/JSPerformance.cpp index 8f0fa04800e4..3c2ac2de258a 100644 --- a/src/jsc/bindings/webcore/JSPerformance.cpp +++ b/src/jsc/bindings/webcore/JSPerformance.cpp @@ -285,7 +285,7 @@ void JSPerformance::finishCreation(VM& vm) this->putDirect( vm, JSC::Identifier::fromString(vm, "timeOrigin"_s), - jsNumber(Bun__readOriginTimerStart(static_cast(this->globalObject())->bunVM())), + jsNumber(Bun__readOriginTimerStart(static_cast(this->globalObject())->bunVM())), PropertyAttribute::ReadOnly | 0); } diff --git a/src/jsc/bindings/webcore/JSPerformanceObserverCallback.cpp b/src/jsc/bindings/webcore/JSPerformanceObserverCallback.cpp index db1050173bfa..9a6653e0b589 100644 --- a/src/jsc/bindings/webcore/JSPerformanceObserverCallback.cpp +++ b/src/jsc/bindings/webcore/JSPerformanceObserverCallback.cpp @@ -28,7 +28,7 @@ #include "JSPerformanceObserver.h" #include "JSPerformanceObserverEntryList.h" #include "ScriptExecutionContext.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace WebCore { using namespace JSC; diff --git a/src/jsc/bindings/webcore/JSReadableStream.cpp b/src/jsc/bindings/webcore/JSReadableStream.cpp index d1eb55a7192a..7d3439f0d5b9 100644 --- a/src/jsc/bindings/webcore/JSReadableStream.cpp +++ b/src/jsc/bindings/webcore/JSReadableStream.cpp @@ -40,7 +40,7 @@ #include #include "ZigGeneratedClasses.h" #include "JavaScriptCore/BuiltinNames.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "WebCoreJSBuiltins.h" namespace WebCore { @@ -96,7 +96,7 @@ JSC_DEFINE_HOST_FUNCTION(jsReadableStreamProtoFuncText, (JSGlobalObject * global return {}; } - return ZigGlobalObject__readableStreamToText(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); + return BunGlobalObject__readableStreamToText(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); } JSC_DEFINE_HOST_FUNCTION(jsReadableStreamProtoFuncBytes, (JSGlobalObject * globalObject, CallFrame* callFrame)) @@ -109,7 +109,7 @@ JSC_DEFINE_HOST_FUNCTION(jsReadableStreamProtoFuncBytes, (JSGlobalObject * globa return {}; } - return ZigGlobalObject__readableStreamToBytes(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); + return BunGlobalObject__readableStreamToBytes(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); } JSC_DEFINE_HOST_FUNCTION(jsReadableStreamProtoFuncJSON, (JSGlobalObject * globalObject, CallFrame* callFrame)) @@ -122,7 +122,7 @@ JSC_DEFINE_HOST_FUNCTION(jsReadableStreamProtoFuncJSON, (JSGlobalObject * global return {}; } - return ZigGlobalObject__readableStreamToJSON(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); + return BunGlobalObject__readableStreamToJSON(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); } JSC_DEFINE_HOST_FUNCTION(jsReadableStreamProtoFuncBlob, (JSGlobalObject * globalObject, CallFrame* callFrame)) @@ -135,7 +135,7 @@ JSC_DEFINE_HOST_FUNCTION(jsReadableStreamProtoFuncBlob, (JSGlobalObject * global return {}; } - return ZigGlobalObject__readableStreamToBlob(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); + return BunGlobalObject__readableStreamToBlob(defaultGlobalObject(globalObject), JSValue::encode(thisObject)); } using JSReadableStreamDOMConstructor = JSDOMBuiltinConstructor; diff --git a/src/jsc/bindings/webcore/JSWebSocket.cpp b/src/jsc/bindings/webcore/JSWebSocket.cpp index 24fe06a9eda7..e0fe5bcf6dd4 100644 --- a/src/jsc/bindings/webcore/JSWebSocket.cpp +++ b/src/jsc/bindings/webcore/JSWebSocket.cpp @@ -204,7 +204,7 @@ static inline JSC::EncodedJSValue constructJSWebSocket3(JSGlobalObject* lexicalG { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); + auto* globalObject = uncheckedDowncast(lexicalGlobalObject); auto* context = globalObject->scriptExecutionContext(); if (!context) [[unlikely]] return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "WebSocket"_s); @@ -1038,7 +1038,7 @@ WebSocket* JSWebSocket::toWrapped(JSC::VM&, JSC::JSValue value) } // https://github.com/oven-sh/bun/issues/11866 -JSC::JSValue getWebSocketConstructor(Zig::GlobalObject* globalObject) +JSC::JSValue getWebSocketConstructor(Bun::GlobalObject* globalObject) { return WebCore::JSWebSocket::getConstructor(globalObject->vm(), globalObject); } diff --git a/src/jsc/bindings/webcore/JSWebSocket.h b/src/jsc/bindings/webcore/JSWebSocket.h index 46f4a2ab1bc1..9dc5faf93280 100644 --- a/src/jsc/bindings/webcore/JSWebSocket.h +++ b/src/jsc/bindings/webcore/JSWebSocket.h @@ -97,6 +97,6 @@ template<> struct JSDOMWrapperConverterTraits { using ToWrappedReturnType = WebSocket*; }; -JSC::JSValue getWebSocketConstructor(Zig::GlobalObject* globalObject); +JSC::JSValue getWebSocketConstructor(Bun::GlobalObject* globalObject); } // namespace WebCore diff --git a/src/jsc/bindings/webcore/MessagePort.cpp b/src/jsc/bindings/webcore/MessagePort.cpp index f152366907f2..7853a3a39695 100644 --- a/src/jsc/bindings/webcore/MessagePort.cpp +++ b/src/jsc/bindings/webcore/MessagePort.cpp @@ -187,7 +187,7 @@ void MessagePort::dispatchOneMessage(ScriptExecutionContext& context, MessageWit Ref vm = globalObject->vm(); auto scope = DECLARE_TOP_EXCEPTION_SCOPE(vm); - if (Zig::GlobalObject::scriptExecutionStatus(globalObject, globalObject) != ScriptExecutionStatus::Running) + if (Bun::GlobalObject::scriptExecutionStatus(globalObject, globalObject) != ScriptExecutionStatus::Running) return; auto ports = MessagePort::entanglePorts(context, WTF::move(message.transferredPorts)); diff --git a/src/jsc/bindings/webcore/PerformanceMark.cpp b/src/jsc/bindings/webcore/PerformanceMark.cpp index 6ddda4c5f8b9..8f9fd34db0cd 100644 --- a/src/jsc/bindings/webcore/PerformanceMark.cpp +++ b/src/jsc/bindings/webcore/PerformanceMark.cpp @@ -41,7 +41,7 @@ namespace WebCore { static double performanceNow(ScriptExecutionContext& scriptExecutionContext) { - return static_cast(Bun__readOriginTimer(uncheckedDowncast(scriptExecutionContext.globalObject())->bunVM())) / 1000000; + return static_cast(Bun__readOriginTimer(uncheckedDowncast(scriptExecutionContext.globalObject())->bunVM())) / 1000000; } ExceptionOr> PerformanceMark::create(JSC::JSGlobalObject& globalObject, ScriptExecutionContext& scriptExecutionContext, const String& name, std::optional&& markOptions) diff --git a/src/jsc/bindings/webcore/PerformanceObserver.cpp b/src/jsc/bindings/webcore/PerformanceObserver.cpp index 38aab5a09589..919bb7b55ae6 100644 --- a/src/jsc/bindings/webcore/PerformanceObserver.cpp +++ b/src/jsc/bindings/webcore/PerformanceObserver.cpp @@ -47,7 +47,7 @@ PerformanceObserver::PerformanceObserver(ScriptExecutionContext& scriptExecution // m_performance = &workerGlobalScope.performance(); // } else // ASSERT_NOT_REACHED(); - m_performance = uncheckedDowncast(scriptExecutionContext.globalObject())->performance(); + m_performance = uncheckedDowncast(scriptExecutionContext.globalObject())->performance(); } void PerformanceObserver::disassociate() diff --git a/src/jsc/bindings/webcore/ReadableStream.cpp b/src/jsc/bindings/webcore/ReadableStream.cpp index 9fbe7ff14761..96178e0f18fb 100644 --- a/src/jsc/bindings/webcore/ReadableStream.cpp +++ b/src/jsc/bindings/webcore/ReadableStream.cpp @@ -35,7 +35,7 @@ #include "JSReadableStreamSource.h" #include "WebCoreJSClientData.h" #include "WebCoreJSBuiltins.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ZigGeneratedClasses.h" #include "helpers.h" #include "BunClientData.h" @@ -294,7 +294,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionTransferToNativeReadableStream, (JSGlobalObje using namespace JSC; using namespace WebCore; -extern "C" bool ReadableStream__tee(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject, JSC::EncodedJSValue* possibleReadableStream1, JSC::EncodedJSValue* possibleReadableStream2) +extern "C" bool ReadableStream__tee(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject, JSC::EncodedJSValue* possibleReadableStream1, JSC::EncodedJSValue* possibleReadableStream2) { auto* readableStream = dynamicDowncast(JSC::JSValue::decode(possibleReadableStream)); if (!readableStream) [[unlikely]] @@ -345,7 +345,7 @@ extern "C" bool ReadableStream__tee(JSC::EncodedJSValue possibleReadableStream, return true; } -extern "C" void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject) +extern "C" void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject) { auto* readableStream = dynamicDowncast(JSC::JSValue::decode(possibleReadableStream)); if (!readableStream) [[unlikely]] @@ -373,7 +373,7 @@ extern "C" void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStrea // Like ReadableStream__cancel but forwards an arbitrary JS reason verbatim to // the stream's cancel algorithm instead of synthesizing a DOMException. Used // by fetch() to honor AbortSignal.reason when cancelling a request body. -extern "C" void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject, JSC::EncodedJSValue encodedReason) +extern "C" void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject, JSC::EncodedJSValue encodedReason) { auto* readableStream = dynamicDowncast(JSC::JSValue::decode(possibleReadableStream)); if (!readableStream) [[unlikely]] @@ -392,7 +392,7 @@ extern "C" void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleRea markCancelResultHandled(invokeReadableStreamFunction(*globalObject, privateName, JSC::jsUndefined(), arguments)); } -extern "C" void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject) +extern "C" void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject) { auto value = JSC::JSValue::decode(possibleReadableStream); if (value.isEmpty() || !value.isCell()) @@ -406,20 +406,20 @@ extern "C" void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStrea readableStream->setDisturbed(true); } -extern "C" bool ReadableStream__isDisturbed(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject) +extern "C" bool ReadableStream__isDisturbed(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject) { ASSERT(globalObject); return WebCore::ReadableStream::isDisturbed(globalObject, dynamicDowncast(JSC::JSValue::decode(possibleReadableStream))); } -extern "C" bool ReadableStream__isLocked(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject) +extern "C" bool ReadableStream__isLocked(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject) { ASSERT(globalObject); WebCore::JSReadableStream* stream = dynamicDowncast(JSValue::decode(possibleReadableStream)); return stream != nullptr && WebCore::ReadableStream::isLocked(globalObject, stream); } -extern "C" int32_t ReadableStreamTag__tagged(Zig::GlobalObject* globalObject, JSC::EncodedJSValue* possibleReadableStream, void** ptr) +extern "C" int32_t ReadableStreamTag__tagged(Bun::GlobalObject* globalObject, JSC::EncodedJSValue* possibleReadableStream, void** ptr) { ASSERT(globalObject); JSC::JSObject* object = JSValue::decode(*possibleReadableStream).getObject(); @@ -510,7 +510,7 @@ extern "C" int32_t ReadableStreamTag__tagged(Zig::GlobalObject* globalObject, JS return 0; } -extern "C" JSC::EncodedJSValue ZigGlobalObject__createNativeReadableStream(Zig::GlobalObject* globalObject, JSC::EncodedJSValue nativePtr) +extern "C" JSC::EncodedJSValue BunGlobalObject__createNativeReadableStream(Bun::GlobalObject* globalObject, JSC::EncodedJSValue nativePtr) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -527,7 +527,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__createNativeReadableStream(Zig:: return JSValue::encode(result); } -static inline JSC::EncodedJSValue ZigGlobalObject__readableStreamToArrayBufferBody(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) +static inline JSC::EncodedJSValue BunGlobalObject__readableStreamToArrayBufferBody(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) { auto& vm = JSC::getVM(globalObject); @@ -565,12 +565,12 @@ static inline JSC::EncodedJSValue ZigGlobalObject__readableStreamToArrayBufferBo RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(promise)); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToArrayBuffer(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) { - return ZigGlobalObject__readableStreamToArrayBufferBody(static_cast(globalObject), readableStreamValue); + return BunGlobalObject__readableStreamToArrayBufferBody(static_cast(globalObject), readableStreamValue); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBytes(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToBytes(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) { auto& vm = JSC::getVM(globalObject); @@ -608,7 +608,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBytes(Zig::Globa RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(promise)); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToText(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToText(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) { auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -631,7 +631,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToText(Zig::Global return JSC::JSValue::encode(result); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToFormData(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue, JSC::EncodedJSValue contentTypeValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToFormData(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue, JSC::EncodedJSValue contentTypeValue) { auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -655,7 +655,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToFormData(Zig::Gl return JSC::JSValue::encode(result); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToJSON(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToJSON(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) { auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -678,7 +678,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToJSON(Zig::Global return JSC::JSValue::encode(result); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBlob(Zig::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToBlob(Bun::GlobalObject* globalObject, JSC::EncodedJSValue readableStreamValue) { auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -712,7 +712,7 @@ JSC_DEFINE_HOST_FUNCTION(functionReadableStreamToArrayBuffer, (JSC::JSGlobalObje } auto readableStreamValue = callFrame->uncheckedArgument(0); - return ZigGlobalObject__readableStreamToArrayBufferBody(static_cast(globalObject), JSValue::encode(readableStreamValue)); + return BunGlobalObject__readableStreamToArrayBufferBody(static_cast(globalObject), JSValue::encode(readableStreamValue)); } JSC_DEFINE_HOST_FUNCTION(functionReadableStreamToBytes, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) @@ -726,5 +726,5 @@ JSC_DEFINE_HOST_FUNCTION(functionReadableStreamToBytes, (JSC::JSGlobalObject * g } auto readableStreamValue = callFrame->uncheckedArgument(0); - return ZigGlobalObject__readableStreamToBytes(static_cast(globalObject), JSValue::encode(readableStreamValue)); + return BunGlobalObject__readableStreamToBytes(static_cast(globalObject), JSValue::encode(readableStreamValue)); } diff --git a/src/jsc/bindings/webcore/SerializedScriptValue.cpp b/src/jsc/bindings/webcore/SerializedScriptValue.cpp index 6452cea51e5d..68731de03038 100644 --- a/src/jsc/bindings/webcore/SerializedScriptValue.cpp +++ b/src/jsc/bindings/webcore/SerializedScriptValue.cpp @@ -106,7 +106,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "blob.h" #include "ZigGeneratedClasses.h" #include "JSX509Certificate.h" diff --git a/src/jsc/bindings/webcore/WebSocket.cpp b/src/jsc/bindings/webcore/WebSocket.cpp index 89203ec56d06..fa4b6688c823 100644 --- a/src/jsc/bindings/webcore/WebSocket.cpp +++ b/src/jsc/bindings/webcore/WebSocket.cpp @@ -1500,7 +1500,7 @@ void WebSocket::didReceiveBinaryData(const AtomString& eventName, const std::spa context->postTask([name = eventName, buffer = WTF::move(arrayBuffer), protectedThis = Ref { *this }](ScriptExecutionContext& context) { size_t length = buffer->byteLength(); auto* globalObject = context.jsGlobalObject(); - auto* subclassStructure = static_cast(globalObject)->JSBufferSubclassStructure(); + auto* subclassStructure = static_cast(globalObject)->JSBufferSubclassStructure(); JSUint8Array* uint8array = JSUint8Array::create(globalObject, subclassStructure, buffer.copyRef(), 0, length); JSC::EnsureStillAliveScope ensureStillAlive(uint8array); MessageEvent::Init init; diff --git a/src/jsc/bindings/webcore/Worker.cpp b/src/jsc/bindings/webcore/Worker.cpp index a1c5c9b5086a..897fe7cb8194 100644 --- a/src/jsc/bindings/webcore/Worker.cpp +++ b/src/jsc/bindings/webcore/Worker.cpp @@ -273,7 +273,7 @@ void Worker::enqueueToParent(MessageWithMessagePorts&& message) // sender. A sustained producer (e.g. a tight postMessage loop) would otherwise // make every per-message pop a contended acquire. template -static inline bool drainInbox(Worker::MessageInbox& inbox, Zig::GlobalObject* globalObject, ScriptExecutionContext& context, Dispatch&& dispatch) +static inline bool drainInbox(Worker::MessageInbox& inbox, Bun::GlobalObject* globalObject, ScriptExecutionContext& context, Dispatch&& dispatch) { size_t limit; Deque batch; @@ -326,7 +326,7 @@ static inline bool drainInbox(Worker::MessageInbox& inbox, Zig::GlobalObject* gl void Worker::drainToWorker(ScriptExecutionContext& context) { - auto* globalObject = uncheckedDowncast(context.jsGlobalObject()); + auto* globalObject = uncheckedDowncast(context.jsGlobalObject()); if (!globalObject) { Locker locker { m_toWorker.lock }; m_toWorker.drainScheduled.store(false, std::memory_order_relaxed); @@ -412,7 +412,7 @@ bool Worker::postTaskToWorkerGlobalScope(Function // ---- Worker-thread entry points --------------------------------------------- -void Worker::dispatchOnline(Zig::GlobalObject* workerGlobalObject) +void Worker::dispatchOnline(Bun::GlobalObject* workerGlobalObject) { // Pending→Running under the same lock postTaskToWorkerGlobalScope uses, so // a message post racing this transition either queues (drained below by @@ -460,7 +460,7 @@ static inline void workerScheduleInitialDrain(Worker& worker, Worker::MessageInb worker.drainToWorker(ctx); } -void Worker::fireEarlyMessages(Zig::GlobalObject* workerGlobalObject) +void Worker::fireEarlyMessages(Bun::GlobalObject* workerGlobalObject) { auto tasks = [&]() { Locker lock(m_pendingTasksMutex); @@ -494,7 +494,7 @@ void Worker::dispatchErrorWithMessage(WTF::String message) }); } -bool Worker::dispatchErrorWithValue(Zig::GlobalObject* workerGlobalObject, JSValue value) +bool Worker::dispatchErrorWithValue(Bun::GlobalObject* workerGlobalObject, JSValue value) { auto serialized = SerializedScriptValue::create(*workerGlobalObject, value, SerializationForStorage::No, SerializationErrorMode::NonThrowing); if (!serialized) @@ -565,7 +565,7 @@ bool Worker::dispatchExit(int32_t exitCode) // ---- extern "C" shims (called from native code) ------------------------------ -extern "C" void WebWorker__teardownJSCVM(Zig::GlobalObject* globalObject) +extern "C" void WebWorker__teardownJSCVM(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); vm.setHasTerminationRequest(); @@ -589,7 +589,7 @@ extern "C" void WebWorker__teardownJSCVM(Zig::GlobalObject* globalObject) vm.heap.collectNow(JSC::Sync, JSC::CollectionScope::Full); - // Drop the single ref taken by `Zig__GlobalObject__create` + // Drop the single ref taken by `Bun__GlobalObject__create` // (`vmPtr->refSuppressingSaferCPPChecking()`), bringing the VM refcount // to zero — `~VM` runs here while the API lock is still held by this // thread. The worker thread acquires the API lock manually with no @@ -603,17 +603,17 @@ extern "C" void WebWorker__dispatchExit(Worker* worker, int32_t exitCode) worker->dispatchExit(exitCode); } -extern "C" void WebWorker__dispatchOnline(Worker* worker, Zig::GlobalObject* globalObject) +extern "C" void WebWorker__dispatchOnline(Worker* worker, Bun::GlobalObject* globalObject) { worker->dispatchOnline(globalObject); } -extern "C" void WebWorker__fireEarlyMessages(Worker* worker, Zig::GlobalObject* globalObject) +extern "C" void WebWorker__fireEarlyMessages(Worker* worker, Bun::GlobalObject* globalObject) { worker->fireEarlyMessages(globalObject); } -extern "C" void WebWorker__dispatchError(Zig::GlobalObject* globalObject, Worker* worker, BunString* message, JSC::EncodedJSValue errorValue) +extern "C" void WebWorker__dispatchError(Bun::GlobalObject* globalObject, Worker* worker, BunString* message, JSC::EncodedJSValue errorValue) { JSValue error = JSC::JSValue::decode(errorValue); WTF::String messageStr = message->transferToWTFString(); @@ -664,7 +664,7 @@ JSC_DEFINE_HOST_FUNCTION(jsReceiveMessageOnPort, (JSGlobalObject * lexicalGlobal return Bun::throwError(lexicalGlobalObject, scope, Bun::ErrorCode::ERR_INVALID_ARG_TYPE, "The \"port\" argument must be a MessagePort instance"_s); } -JSValue createNodeWorkerThreadsBinding(Zig::GlobalObject* globalObject) +JSValue createNodeWorkerThreadsBinding(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); @@ -727,7 +727,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPostMessage, JSC::VM& vm = leixcalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - Zig::GlobalObject* globalObject = dynamicDowncast(leixcalGlobalObject); + Bun::GlobalObject* globalObject = dynamicDowncast(leixcalGlobalObject); if (!globalObject) [[unlikely]] return JSValue::encode(jsUndefined()); diff --git a/src/jsc/bindings/webcore/Worker.h b/src/jsc/bindings/webcore/Worker.h index ced0e30d8a48..d72880901da9 100644 --- a/src/jsc/bindings/webcore/Worker.h +++ b/src/jsc/bindings/webcore/Worker.h @@ -127,10 +127,10 @@ class Worker final : public ThreadSafeRefCounted, public EventTargetWith WorkerOptions& options() { return m_options; } // -- Worker-thread entry points (each posts to m_parentContextId) -------- - void dispatchOnline(Zig::GlobalObject* workerGlobalObject); - void fireEarlyMessages(Zig::GlobalObject* workerGlobalObject); + void dispatchOnline(Bun::GlobalObject* workerGlobalObject); + void fireEarlyMessages(Bun::GlobalObject* workerGlobalObject); void dispatchErrorWithMessage(WTF::String message); - bool dispatchErrorWithValue(Zig::GlobalObject* workerGlobalObject, JSValue value); + bool dispatchErrorWithValue(Bun::GlobalObject* workerGlobalObject, JSValue value); bool dispatchExit(int32_t exitCode); // Post a task to the parent's ScriptExecutionContext by stable identifier. @@ -191,7 +191,7 @@ class Worker final : public ThreadSafeRefCounted, public EventTargetWith void* impl_ { nullptr }; }; -JSValue createNodeWorkerThreadsBinding(Zig::GlobalObject* globalObject); +JSValue createNodeWorkerThreadsBinding(Bun::GlobalObject* globalObject); JSC_DECLARE_HOST_FUNCTION(jsFunctionPostMessage); diff --git a/src/jsc/bindings/xxhash3.cpp b/src/jsc/bindings/xxhash3.cpp index b77dd94438c2..31e2a031da18 100644 --- a/src/jsc/bindings/xxhash3.cpp +++ b/src/jsc/bindings/xxhash3.cpp @@ -615,7 +615,7 @@ HWY_AFTER_NAMESPACE(); // Dispatch table + C entry point (compiled once). // // This TU intentionally includes no JSC/WebKit headers of its own — in -// particular not ZigGlobalObject.h, which would drag the whole JSC type +// particular not BunGlobalObject.h, which would drag the whole JSC type // universe in and balloon the object's debug info. The // `bun:internal-for-testing` host wrapper that needs JSC types lives in // xxhash3_testing.cpp and calls the C symbol below. diff --git a/src/jsc/bindings/xxhash3_testing.cpp b/src/jsc/bindings/xxhash3_testing.cpp index 5a2ccc16eb41..b63683c6d1de 100644 --- a/src/jsc/bindings/xxhash3_testing.cpp +++ b/src/jsc/bindings/xxhash3_testing.cpp @@ -1,7 +1,7 @@ // Testing-only JS binding for the SIMD xxHash3 kernel. // // Kept in its own TU (not xxhash3.cpp) so the Highway kernel stays free of -// JSC/WebKit headers — otherwise `ZigGlobalObject.h` drags the whole JSC type +// JSC/WebKit headers — otherwise `BunGlobalObject.h` drags the whole JSC type // universe into a SIMD-only unit, ballooning its debug info and compile cost. // This wrapper just forwards to the C entry point. @@ -10,7 +10,7 @@ #include "xxhash3.h" #include "xxhash3_testing.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/headergen/sizegen.cpp b/src/jsc/headergen/sizegen.cpp index 890bac5fc0af..4339e083eb3d 100644 --- a/src/jsc/headergen/sizegen.cpp +++ b/src/jsc/headergen/sizegen.cpp @@ -5,7 +5,7 @@ using namespace std; #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "Path.h" diff --git a/src/jsc/jsc.zig b/src/jsc/jsc.zig index 66c995ad137b..318d4d6bd888 100644 --- a/src/jsc/jsc.zig +++ b/src/jsc/jsc.zig @@ -1,5 +1,5 @@ //! Bindings to JavaScriptCore and other JavaScript primatives such as -//! VirtualMachine, JSGlobalObject (Zig::GlobalObject), and the event loop. +//! VirtualMachine, JSGlobalObject (Bun::GlobalObject), and the event loop. //! //! Web and runtime-specific APIs should go in `bun.webcore` and `bun.api`. //! @@ -14,7 +14,7 @@ else /// Web Template Framework pub const wtf = @import("./WTF.zig").WTF; -/// Binding for JSCInitialize in ZigGlobalObject.cpp +/// Binding for JSCInitialize in BunGlobalObject.cpp pub fn initialize(eval_mode: bool) void { markBinding(@src()); bun.analytics.Features.jsc += 1; diff --git a/src/jsc/lib.rs b/src/jsc/lib.rs index f1e9717a439c..1162bfcf6e76 100644 --- a/src/jsc/lib.rs +++ b/src/jsc/lib.rs @@ -1,5 +1,5 @@ //! Bindings to JavaScriptCore and other JavaScript primitives such as -//! VirtualMachine, JSGlobalObject (Zig::GlobalObject), and the event loop. +//! VirtualMachine, JSGlobalObject (Bun::GlobalObject), and the event loop. //! //! Web and runtime-specific APIs should go in `bun.webcore` and `bun.api`. //! @@ -556,7 +556,7 @@ pub mod process_auto_killer; #[path = "WorkTask.rs"] pub mod work_task; -/// Binding for JSCInitialize in ZigGlobalObject.cpp +/// Binding for JSCInitialize in BunGlobalObject.cpp pub fn initialize(eval_mode: bool) { // The counter lives in `bun_core` so this crate doesn't depend on // `bun_analytics`. diff --git a/src/jsc/modules/AbortControllerModuleModule.h b/src/jsc/modules/AbortControllerModuleModule.h index 0f97df6ddc82..f27146d76c86 100644 --- a/src/jsc/modules/AbortControllerModuleModule.h +++ b/src/jsc/modules/AbortControllerModuleModule.h @@ -14,7 +14,7 @@ inline void generateNativeModule_AbortControllerModule( JSC::MarkedArgumentBuffer& exportValues) { - Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = static_cast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto* abortController = WebCore::JSAbortController::getConstructor(vm, globalObject).getObject(); diff --git a/src/jsc/modules/BunAppModule.h b/src/jsc/modules/BunAppModule.h index e4c82f4e5e86..6b46ec3bc455 100644 --- a/src/jsc/modules/BunAppModule.h +++ b/src/jsc/modules/BunAppModule.h @@ -12,7 +12,7 @@ DEFINE_NATIVE_MODULE(BunApp) { INIT_NATIVE_MODULE(1); - auto* zig = static_cast(globalObject); + auto* zig = static_cast(globalObject); JSValue ssrResponseConstructor = zig->bakeAdditions().JSBakeResponseConstructor(zig); put(JSC::Identifier::fromString(vm, "Response"_s), ssrResponseConstructor); diff --git a/src/jsc/modules/BunJSCModule.h b/src/jsc/modules/BunJSCModule.h index deb683bb80d7..1fab1bc16585 100644 --- a/src/jsc/modules/BunJSCModule.h +++ b/src/jsc/modules/BunJSCModule.h @@ -411,7 +411,7 @@ JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint, VM& vm = globalObject->vm(); JSC::JSObject* object = JSC::constructEmptyObject( - vm, uncheckedDowncast(globalObject)->memoryFootprintStructure()); + vm, uncheckedDowncast(globalObject)->memoryFootprintStructure()); object->putDirectOffset(vm, 0, jsNumber(current_rss)); object->putDirectOffset(vm, 1, jsNumber(peak_rss)); diff --git a/src/jsc/modules/BunTestModule.h b/src/jsc/modules/BunTestModule.h index b5c5c84b6701..e33bed4a66ee 100644 --- a/src/jsc/modules/BunTestModule.h +++ b/src/jsc/modules/BunTestModule.h @@ -7,7 +7,7 @@ void generateNativeModule_BunTest( JSC::MarkedArgumentBuffer& exportValues) { auto& vm = JSC::getVM(lexicalGlobalObject); - auto globalObject = uncheckedDowncast(lexicalGlobalObject); + auto globalObject = uncheckedDowncast(lexicalGlobalObject); auto topExceptionScope = DECLARE_TOP_EXCEPTION_SCOPE(vm); JSObject* object = globalObject->lazyTestModuleObject(); diff --git a/src/jsc/modules/NodeBufferModule.h b/src/jsc/modules/NodeBufferModule.h index c679ae05d490..dad58afda71f 100644 --- a/src/jsc/modules/NodeBufferModule.h +++ b/src/jsc/modules/NodeBufferModule.h @@ -139,13 +139,13 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplemented, JSC_DEFINE_CUSTOM_GETTER(jsGetter_INSPECT_MAX_BYTES, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, PropertyName propertyName)) { - auto globalObject = static_cast(lexicalGlobalObject); + auto globalObject = static_cast(lexicalGlobalObject); return JSValue::encode(jsNumber(globalObject->INSPECT_MAX_BYTES)); } JSC_DEFINE_CUSTOM_SETTER(jsSetter_INSPECT_MAX_BYTES, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, PropertyName propertyName)) { - auto globalObject = static_cast(lexicalGlobalObject); + auto globalObject = static_cast(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); auto val = JSValue::decode(value); diff --git a/src/jsc/modules/NodeModuleModule.cpp b/src/jsc/modules/NodeModuleModule.cpp index 335bbb27b198..64c32b3e2067 100644 --- a/src/jsc/modules/NodeModuleModule.cpp +++ b/src/jsc/modules/NodeModuleModule.cpp @@ -17,7 +17,7 @@ #include "JSCommonJSExtensions.h" #include "PathInlines.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "headers.h" #include "ErrorCode.h" @@ -160,8 +160,8 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModuleModuleConstructor, JSString* dirname = jsEmptyString(vm); - // TODO: handle when JSGlobalObject !== Zig::GlobalObject, such as in node:vm - Structure* structure = static_cast(globalObject) + // TODO: handle when JSGlobalObject !== Bun::GlobalObject, such as in node:vm + Structure* structure = static_cast(globalObject) ->CommonJSModuleObjectStructure(); // TODO: handle ShadowRealm, node:vm, new.target, subclasses @@ -622,13 +622,13 @@ JSC_DEFINE_CUSTOM_SETTER(setterRequireFunction, static JSValue getModuleCacheObject(VM& vm, JSObject* moduleObject) { - return uncheckedDowncast(moduleObject->globalObject()) + return uncheckedDowncast(moduleObject->globalObject()) ->lazyRequireCacheObject(); } static JSValue getModuleExtensionsObject(VM& vm, JSObject* moduleObject) { - return uncheckedDowncast(moduleObject->globalObject()) + return uncheckedDowncast(moduleObject->globalObject()) ->lazyRequireExtensionsObject(); } @@ -701,7 +701,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionSetCJSWrapperItem, (JSGlobalObject * globalOb auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); JSValue a = callFrame->argument(0); JSValue b = callFrame->argument(1); - Zig::GlobalObject* global = defaultGlobalObject(globalObject); + Bun::GlobalObject* global = defaultGlobalObject(globalObject); String aString = a.toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, {}); String bString = b.toWTFString(globalObject); @@ -813,7 +813,7 @@ JSC_DEFINE_CUSTOM_GETTER(moduleRunMain, } extern "C" void Bun__VirtualMachine__setOverrideModuleRunMain(void* bunVM, bool isOriginal); -extern "C" JSC::EncodedJSValue NodeModuleModule__callOverriddenRunMain(Zig::GlobalObject* global, JSValue argv1) +extern "C" JSC::EncodedJSValue NodeModuleModule__callOverriddenRunMain(Bun::GlobalObject* global, JSValue argv1) { auto overrideHandler = uncheckedDowncast(global->m_moduleRunMainFunction.get(global)); MarkedArgumentBuffer args; @@ -944,7 +944,7 @@ class JSModuleConstructor : public JSC::InternalFunction { } static JSModuleConstructor* create(JSC::VM& vm, - Zig::GlobalObject* globalObject) + Bun::GlobalObject* globalObject) { auto* structure = createStructure(vm, globalObject, globalObject->functionPrototype()); @@ -1050,26 +1050,26 @@ extern "C" JSC::EncodedJSValue Bun__createNodeModuleSourceMapOriginObject( } void addNodeModuleConstructorProperties(JSC::VM& vm, - Zig::GlobalObject* globalObject) + Bun::GlobalObject* globalObject) { globalObject->m_nodeModuleConstructor.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { JSObject* moduleConstructor = JSModuleConstructor::create( - init.vm, static_cast(init.owner)); + init.vm, static_cast(init.owner)); init.set(moduleConstructor); }); globalObject->m_nodeModuleSourceMapEntryStructure.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { init.set(createNodeModuleSourceMapEntryStructure(init.vm, init.owner)); }); globalObject->m_nodeModuleSourceMapOriginStructure.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { init.set(createNodeModuleSourceMapOriginStructure(init.vm, init.owner)); }); globalObject->m_moduleRunMainFunction.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { JSFunction* runMainFunction = JSFunction::create( init.vm, init.owner, 2, "runMain"_s, jsFunctionRunMain, JSC::ImplementationVisibility::Public, @@ -1078,7 +1078,7 @@ void addNodeModuleConstructorProperties(JSC::VM& vm, }); globalObject->m_moduleResolveFilenameFunction.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { JSFunction* resolveFilenameFunction = JSFunction::create( init.vm, init.owner, 2, "_resolveFilename"_s, jsFunctionResolveFileName, JSC::ImplementationVisibility::Public, @@ -1087,7 +1087,7 @@ void addNodeModuleConstructorProperties(JSC::VM& vm, }); globalObject->m_modulePrototypeUnderscoreCompileFunction.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { JSFunction* resolveFilenameFunction = JSFunction::create( init.vm, init.owner, 2, "_compile"_s, functionJSCommonJSModule_compile, JSC::ImplementationVisibility::Public, @@ -1096,13 +1096,13 @@ void addNodeModuleConstructorProperties(JSC::VM& vm, }); globalObject->m_commonJSRequireESMFromHijackedExtensionFunction.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { JSC::JSFunction* requireESM = JSC::JSFunction::create(init.vm, init.owner, commonJSRequireESMFromHijackedExtensionCodeGenerator(init.vm), init.owner); init.set(requireESM); }); globalObject->m_lazyRequireCacheObject.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { JSC::VM& vm = init.vm; JSC::JSGlobalObject* globalObject = init.owner; @@ -1115,7 +1115,7 @@ void addNodeModuleConstructorProperties(JSC::VM& vm, }); globalObject->m_lazyRequireExtensionsObject.initLater( - [](const Zig::GlobalObject::Initializer& init) { + [](const Bun::GlobalObject::Initializer& init) { JSC::VM& vm = init.vm; JSC::JSGlobalObject* globalObject = init.owner; @@ -1140,7 +1140,7 @@ void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, Vector& exportNames, JSC::MarkedArgumentBuffer& exportValues) { - Zig::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); auto& vm = JSC::getVM(globalObject); auto topExceptionScope = DECLARE_TOP_EXCEPTION_SCOPE(vm); auto* constructor = globalObject->m_nodeModuleConstructor.getInitializedOnMainThread(globalObject); diff --git a/src/jsc/modules/NodeModuleModule.h b/src/jsc/modules/NodeModuleModule.h index 6a412ece5d41..c47af8bebfb8 100644 --- a/src/jsc/modules/NodeModuleModule.h +++ b/src/jsc/modules/NodeModuleModule.h @@ -18,7 +18,7 @@ using namespace JSC; namespace Bun { JSC_DECLARE_HOST_FUNCTION(jsFunctionIsModuleResolveFilenameSlowPathEnabled); -void addNodeModuleConstructorProperties(JSC::VM &vm, Zig::GlobalObject *globalObject); +void addNodeModuleConstructorProperties(JSC::VM &vm, Bun::GlobalObject *globalObject); extern "C" JSC::EncodedJSValue Resolver__nodeModulePathsJSValue(BunString specifier, JSC::JSGlobalObject*, bool use_dirname); extern "C" bool ModuleLoader__isBuiltin(const char* data, size_t len); diff --git a/src/jsc/modules/NodeProcessModule.h b/src/jsc/modules/NodeProcessModule.h index 6a0ce5818f7b..fd0f813370a5 100644 --- a/src/jsc/modules/NodeProcessModule.h +++ b/src/jsc/modules/NodeProcessModule.h @@ -1,4 +1,4 @@ -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "_NativeModule.h" #include #include diff --git a/src/jsc/modules/NodeStringDecoderModule.h b/src/jsc/modules/NodeStringDecoderModule.h index d4ffdc85a3e5..cad22c468641 100644 --- a/src/jsc/modules/NodeStringDecoderModule.h +++ b/src/jsc/modules/NodeStringDecoderModule.h @@ -1,5 +1,5 @@ #include "../bindings/JSStringDecoder.h" -#include "../bindings/ZigGlobalObject.h" +#include "../bindings/BunGlobalObject.h" #include namespace Zig { diff --git a/src/jsc/modules/ObjectModule.cpp b/src/jsc/modules/ObjectModule.cpp index 442e1e4f7a9d..49eedb54ca7a 100644 --- a/src/jsc/modules/ObjectModule.cpp +++ b/src/jsc/modules/ObjectModule.cpp @@ -12,7 +12,7 @@ generateObjectModuleSourceCode(JSC::JSGlobalObject* globalObject, JSC::MarkedArgumentBuffer& exportValues) -> void { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); - GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* globalObject = defaultGlobalObject(lexicalGlobalObject); JSC::EnsureStillAliveScope stillAlive(object); PropertyNameArrayBuilder properties(vm, PropertyNameMode::Strings, @@ -46,7 +46,7 @@ generateObjectModuleSourceCodeForJSON(JSC::JSGlobalObject* globalObject, JSC::MarkedArgumentBuffer& exportValues) -> void { auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); - GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + Bun::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); JSC::EnsureStillAliveScope stillAlive(object); PropertyNameArrayBuilder properties(vm, PropertyNameMode::Strings, diff --git a/src/jsc/modules/ObjectModule.h b/src/jsc/modules/ObjectModule.h index 9e4807a8c4d9..c4e18e022d59 100644 --- a/src/jsc/modules/ObjectModule.h +++ b/src/jsc/modules/ObjectModule.h @@ -1,6 +1,6 @@ #pragma once -#include "../bindings/ZigGlobalObject.h" +#include "../bindings/BunGlobalObject.h" #include namespace Zig { diff --git a/src/jsc/modules/_NativeModule.h b/src/jsc/modules/_NativeModule.h index 82beb9692e08..32b364da03c8 100644 --- a/src/jsc/modules/_NativeModule.h +++ b/src/jsc/modules/_NativeModule.h @@ -3,7 +3,7 @@ #include "JSBuffer.h" #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" // These modules are implemented in native code as a function which writes ESM @@ -79,8 +79,8 @@ JSC::MarkedArgumentBuffer &exportValues) #define INIT_NATIVE_MODULE(numberOfExportNames) \ - Zig::GlobalObject *globalObject = \ - static_cast(lexicalGlobalObject); \ + Bun::GlobalObject *globalObject = \ + static_cast(lexicalGlobalObject); \ JSC::VM &vm = globalObject->vm(); \ JSC::JSObject *defaultObject = JSC::constructEmptyObject( \ globalObject, globalObject->objectPrototype(), numberOfExportNames); \ diff --git a/src/jsc/virtual_machine_exports.rs b/src/jsc/virtual_machine_exports.rs index 38760d616aee..03610fa4679a 100644 --- a/src/jsc/virtual_machine_exports.rs +++ b/src/jsc/virtual_machine_exports.rs @@ -11,7 +11,7 @@ use bun_core::String as BunString; use bun_event_loop::ManagedTask::ManagedTask; use bun_sourcemap::{BakeSourceProvider, DevServerSourceProvider}; -// `Bun__ZigGlobalObject__uvLoop` is Windows-only: `#[cfg(windows)]` on the fn +// `Bun__GlobalObject__uvLoop` is Windows-only: `#[cfg(windows)]` on the fn // definition itself. // // `#[unsafe(no_mangle)] extern "C"` thunks for everything below are emitted by @@ -209,7 +209,7 @@ pub fn on_did_append_plugin(jsc_vm: &mut VirtualMachine, global: &JSGlobalObject #[cfg(windows)] #[unsafe(no_mangle)] -pub(crate) extern "C" fn Bun__ZigGlobalObject__uvLoop(jsc_vm: &mut VirtualMachine) -> *mut c_void { +pub(crate) extern "C" fn Bun__GlobalObject__uvLoop(jsc_vm: &mut VirtualMachine) -> *mut c_void { jsc_vm.uv_loop().cast() } diff --git a/src/jsc/virtual_machine_exports.zig b/src/jsc/virtual_machine_exports.zig index f09ded873041..5a3bb7c1fd2f 100644 --- a/src/jsc/virtual_machine_exports.zig +++ b/src/jsc/virtual_machine_exports.zig @@ -1,6 +1,6 @@ comptime { if (bun.Environment.isWindows) { - @export(&Bun__ZigGlobalObject__uvLoop, .{ .name = "Bun__ZigGlobalObject__uvLoop" }); + @export(&Bun__GlobalObject__uvLoop, .{ .name = "Bun__GlobalObject__uvLoop" }); } } @@ -146,7 +146,7 @@ pub export fn Bun__onDidAppendPlugin(jsc_vm: *VirtualMachine, globalObject: *JSG jsc_vm.transpiler.linker.plugin_runner = &jsc_vm.plugin_runner.?; } -pub fn Bun__ZigGlobalObject__uvLoop(jsc_vm: *VirtualMachine) callconv(.c) *bun.windows.libuv.Loop { +pub fn Bun__GlobalObject__uvLoop(jsc_vm: *VirtualMachine) callconv(.c) *bun.windows.libuv.Loop { return jsc_vm.uvLoop(); } diff --git a/src/jsc/web_worker.rs b/src/jsc/web_worker.rs index ceb045b8f5e6..da676e2c3668 100644 --- a/src/jsc/web_worker.rs +++ b/src/jsc/web_worker.rs @@ -730,7 +730,7 @@ impl WebWorker { /// The owning C++ `WebCore::Worker`. Never null; this struct is freed by /// `~Worker`, so the pointer cannot dangle. Passed as `worker_ptr` to - /// `Zig__GlobalObject__create` so the ZigGlobalObject is born with its + /// `Bun__GlobalObject__create` so the BunGlobalObject is born with its /// WorkerGlobalScope wired. #[inline] pub fn cpp_worker(&self) -> *mut c_void { diff --git a/src/runtime/bake/BakeGlobalObject.cpp b/src/runtime/bake/BakeGlobalObject.cpp index b86cfa16c340..776b3ae80881 100644 --- a/src/runtime/bake/BakeGlobalObject.cpp +++ b/src/runtime/bake/BakeGlobalObject.cpp @@ -50,7 +50,7 @@ bakeModuleLoaderImportModule(JSC::JSGlobalObject* global, } // TODO: make static cast instead of jscast - return uncheckedDowncast(global)->moduleLoaderImportModule(global, moduleLoader, moduleNameValue, WTF::move(parameters), sourceOrigin, false); + return uncheckedDowncast(global)->moduleLoaderImportModule(global, moduleLoader, moduleNameValue, WTF::move(parameters), sourceOrigin, false); } JSC::Identifier bakeModuleLoaderResolve(JSC::JSGlobalObject* jsGlobal, @@ -87,7 +87,7 @@ JSC::Identifier bakeModuleLoaderResolve(JSC::JSGlobalObject* jsGlobal, } } - return Zig::GlobalObject::moduleLoaderResolve(jsGlobal, loader, key, referrer, WTF::move(origin), useImportMap); + return Bun::GlobalObject::moduleLoaderResolve(jsGlobal, loader, key, referrer, WTF::move(origin), useImportMap); } static JSC::JSPromise* rejectedInternalPromise(JSC::JSGlobalObject* globalObject, JSC::JSValue value) @@ -163,12 +163,12 @@ JSC::JSPromise* bakeModuleLoaderFetch(JSC::JSGlobalObject* globalObject, #endif JSString* bakePrefixRemovedString = jsNontrivialString(vm, bakePrefixRemoved); JSValue bakePrefixRemovedJsvalue = bakePrefixRemovedString; - return Zig::GlobalObject::moduleLoaderFetch(globalObject, loader, bakePrefixRemovedJsvalue, WTF::move(parameters), WTF::move(script)); + return Bun::GlobalObject::moduleLoaderFetch(globalObject, loader, bakePrefixRemovedJsvalue, WTF::move(parameters), WTF::move(script)); } return rejectedInternalPromise(globalObject, createTypeError(globalObject, "BakeGlobalObject does not have per-thread data configured"_s)); } - auto result = Zig::GlobalObject::moduleLoaderFetch(globalObject, loader, key, WTF::move(parameters), WTF::move(script)); + auto result = Bun::GlobalObject::moduleLoaderFetch(globalObject, loader, key, WTF::move(parameters), WTF::move(script)); RETURN_IF_EXCEPTION(scope, rejectedInternalPromise(globalObject, scope.exception()->value())); return result; } @@ -200,7 +200,7 @@ extern "C" BunVirtualMachine* Bun__getVM(); const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable() { - const auto& parent = Zig::GlobalObject::globalObjectMethodTable(); + const auto& parent = Bun::GlobalObject::globalObjectMethodTable(); #define INHERIT_HOOK_METHOD(name) \ parent.name @@ -231,7 +231,7 @@ const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable() return table; } -// A lot of this function is taken from 'Zig__GlobalObject__create' +// A lot of this function is taken from 'Bun__GlobalObject__create' // TODO: remove this entire method extern "C" GlobalObject* BakeCreateProdGlobal(void* console) { @@ -240,7 +240,7 @@ extern "C" GlobalObject* BakeCreateProdGlobal(void* console) BUN_PANIC("Failed to allocate JavaScriptCore Virtual Machine. Did your computer run out of memory? Or maybe you compiled Bun with a mismatching libc++ version or compiler?"); } // We need to unsafely ref this so it stays alive, later in - // `Zig__GlobalObject__destructOnExit` will call + // `Bun__GlobalObject__destructOnExit` will call // `vm.derefSuppressingSaferCPPChecking()` to free it. vmPtr->refSuppressingSaferCPPChecking(); JSC::VM& vm = *vmPtr; diff --git a/src/runtime/bake/BakeGlobalObject.h b/src/runtime/bake/BakeGlobalObject.h index 58e4d3f2753d..284206c932c9 100644 --- a/src/runtime/bake/BakeGlobalObject.h +++ b/src/runtime/bake/BakeGlobalObject.h @@ -1,12 +1,12 @@ #pragma once #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" namespace Bake { -class GlobalObject : public Zig::GlobalObject { +class GlobalObject : public Bun::GlobalObject { public: - using Base = Zig::GlobalObject; + using Base = Bun::GlobalObject; void* m_perThreadData = nullptr; DECLARE_INFO; @@ -32,7 +32,7 @@ class GlobalObject : public Zig::GlobalObject { void finishCreation(JSC::VM& vm); GlobalObject(JSC::VM& vm, JSC::Structure* structure, const JSC::GlobalObjectMethodTable* methodTable) - : Zig::GlobalObject(vm, structure, methodTable) + : Bun::GlobalObject(vm, structure, methodTable) { } }; diff --git a/src/runtime/bake/BakeSourceProvider.h b/src/runtime/bake/BakeSourceProvider.h index 0da0fcaa8282..2eb52ee0637c 100644 --- a/src/runtime/bake/BakeSourceProvider.h +++ b/src/runtime/bake/BakeSourceProvider.h @@ -21,7 +21,7 @@ class SourceProvider final : public JSC::StringSourceProvider { JSC::SourceProviderSourceType sourceType) { auto provider = adoptRef(*new SourceProvider(source, sourceOrigin, WTF::move(sourceURL), startPosition, sourceType)); - auto* zigGlobalObject = uncheckedDowncast(globalObject); + auto* zigGlobalObject = uncheckedDowncast(globalObject); auto specifier = Bun::toString(provider->sourceURL()); Bun__addBakeSourceProviderSourceMap(zigGlobalObject->bunVM(), provider.ptr(), &specifier); return provider; diff --git a/src/runtime/bake/DevServerSourceProvider.h b/src/runtime/bake/DevServerSourceProvider.h index 39d1dd9d940d..deb137b045f5 100644 --- a/src/runtime/bake/DevServerSourceProvider.h +++ b/src/runtime/bake/DevServerSourceProvider.h @@ -2,7 +2,7 @@ #include "root.h" #include "headers-handwritten.h" #include "JavaScriptCore/SourceOrigin.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "MiString.h" namespace Bake { @@ -26,7 +26,7 @@ class DevServerSourceProvider final : public JSC::StringSourceProvider { JSC::SourceProviderSourceType sourceType) { auto provider = adoptRef(*new DevServerSourceProvider(source, sourceMapJSONPtr, sourceMapJSONLength, sourceOrigin, WTF::move(sourceURL), startPosition, sourceType)); - auto* zigGlobalObject = uncheckedDowncast<::Zig::GlobalObject>(globalObject); + auto* zigGlobalObject = uncheckedDowncast<::Bun::GlobalObject>(globalObject); auto specifier = Bun::toString(provider->sourceURL()); provider->m_globalObject = zigGlobalObject; provider->m_specifier = specifier; @@ -67,7 +67,7 @@ class DevServerSourceProvider final : public JSC::StringSourceProvider { } MiString m_sourceMapJSON; - Zig::GlobalObject* m_globalObject; + Bun::GlobalObject* m_globalObject; BunString m_specifier; }; diff --git a/src/runtime/cli/repl_command.rs b/src/runtime/cli/repl_command.rs index 9cc0e0f19db0..80a34252093f 100644 --- a/src/runtime/cli/repl_command.rs +++ b/src/runtime/cli/repl_command.rs @@ -296,7 +296,7 @@ impl<'a, 'r> ReplRunner<'a, 'r> { // Local extern declarations for C++ exports the bun_jsc wrappers don't expose yet. unsafe extern "C" { fn Bun__ExposeNodeModuleGlobals(global: *const JSGlobalObject); - // Local shim for `JSGlobalObject::setTimeZone` (ZigGlobalObject.cpp) until + // Local shim for `JSGlobalObject::setTimeZone` (BunGlobalObject.cpp) until // bun_jsc grows a wrapper. fn JSGlobalObject__setTimeZone( global: *const JSGlobalObject, diff --git a/src/runtime/ffi_imports.rs b/src/runtime/ffi_imports.rs index e978f9b64d63..38d64d2aeac3 100644 --- a/src/runtime/ffi_imports.rs +++ b/src/runtime/ffi_imports.rs @@ -19,7 +19,7 @@ //! from `generated_classes.rs` — those are owned by the generator. #![allow(non_snake_case, improper_ctypes, clippy::missing_safety_doc)] -// ─── ZigGlobalObject.cpp / BunObject.cpp ──────────────────────────────────── +// ─── BunGlobalObject.cpp / BunObject.cpp ──────────────────────────────────── // (populated incrementally — see audit comment in generated_host_exports.rs) // Empty until the first migration lands; an empty `unsafe extern "C" {}` block // and `use crate::ffi_imports::*` over zero items are both legal Rust. diff --git a/src/runtime/hw_exports.rs b/src/runtime/hw_exports.rs index dd343b1a658c..352a2f7ae658 100644 --- a/src/runtime/hw_exports.rs +++ b/src/runtime/hw_exports.rs @@ -11,7 +11,7 @@ //! → `src/jsc/rare_data.rs` //! - `Resolver__nodeModulePathsForJS` / `Resolver__nodeModulePathsJSValue` //! → `src/jsc/resolver_jsc.rs` -//! - `Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming` +//! - `Bun__GlobalObject__getBodyStreamOrBytesForWasmStreaming` //! → `src/runtime/webcore/wasm_streaming.rs` //! - `Bun__Chrome__autoDetect` / `Bun__Chrome__ensure` //! → `src/runtime/webview/ChromeProcess.rs` @@ -697,7 +697,7 @@ pub fn bindgen_node_os_dispatch_set_priority2( // `NewRuntimeFunction` here. // // ABI: `generate-js2native.ts` declares these on the C++ side as -// `extern "C" SYSV_ABI ...(Zig::GlobalObject*)` (the `callJS2Native` switch +// `extern "C" SYSV_ABI ...(Bun::GlobalObject*)` (the `callJS2Native` switch // dispatches through them), so the Rust thunk MUST be `jsc` (sysv64 on // win-x64), not plain `c`. With `c`, the win-x64 callee read `global` from // RCX while C++ passed it in RDI → garbage `&JSGlobalObject` propagated into diff --git a/src/runtime/jsc_hooks.rs b/src/runtime/jsc_hooks.rs index e7eac1d2afab..8a166e62220c 100644 --- a/src/runtime/jsc_hooks.rs +++ b/src/runtime/jsc_hooks.rs @@ -4690,7 +4690,7 @@ unsafe fn resolve_embedded_node_file_hook( // + `_resolve`. // // This is the resolution path behind `Bun__resolveSync`, -// `Zig__GlobalObject__resolve`, `import.meta.resolve`, and +// `Bun__GlobalObject__resolve`, `import.meta.resolve`, and // `Module._findPath`. The body drives `transpiler.resolver` (a // `bun_resolver::Resolver` value field of `VirtualMachine`) and reaches into // `ServerEntryPoint` / `ObjectURLRegistry` — all forward-deps on `bun_jsc`, diff --git a/src/runtime/server/RequestContext.rs b/src/runtime/server/RequestContext.rs index bbaeac780aa9..25195a5f6523 100644 --- a/src/runtime/server/RequestContext.rs +++ b/src/runtime/server/RequestContext.rs @@ -543,7 +543,7 @@ where // These consts must resolve to the *exported* `#[no_mangle]` symbols // (`Bun__HTTPRequestContext*__on*`), not the inner generic // `host_on_*::<..>` shims: the function-pointer value is what C++'s - // `GlobalObject::promiseHandlerID` compares against (ZigGlobalObject.cpp), + // `GlobalObject::promiseHandlerID` compares against (BunGlobalObject.cpp), // and the exported wrapper has a different address from the generic it // forwards to. We route through a const-fn lookup keyed on the // (SSL, DEBUG, H3) tuple so the blanket impl can name concrete exports. diff --git a/src/runtime/socket/Listener.zig b/src/runtime/socket/Listener.zig index 6e098ac14f6d..30f673d6654a 100644 --- a/src/runtime/socket/Listener.zig +++ b/src/runtime/socket/Listener.zig @@ -208,7 +208,7 @@ pub fn listen(globalObject: *jsc.JSGlobalObject, opts: JSValue) bun.JSError!JSVa // `Listener` is mimalloc-allocated, so LSAN can't trace `loop->data.head → // this.group → head_sockets → us_socket_t` once the only pointer into the // group lives inside a mimalloc page. `process.exit()` from JS makes - // `Zig__GlobalObject__destructOnExit` early-return (vm.entryScope set), so + // `Bun__GlobalObject__destructOnExit` early-return (vm.entryScope set), so // `finalize()`/`deinit()` never run and the accepted sockets' 88-byte // `us_create_poll` allocations are reported as leaked. Registering the // embedded group as a root region restores the same reachability the old diff --git a/src/runtime/test_runner/bun_test.rs b/src/runtime/test_runner/bun_test.rs index a59d41f484d2..dea5bd55a31b 100644 --- a/src/runtime/test_runner/bun_test.rs +++ b/src/runtime/test_runner/bun_test.rs @@ -468,7 +468,7 @@ impl BunTestRoot { } /// Tear down `bun:test` GC roots before `global_exit()` so - /// `Zig__GlobalObject__destructOnExit()`'s `collectNow()` can reclaim the + /// `Bun__GlobalObject__destructOnExit()`'s `collectNow()` can reclaim the /// closures they pin. Releases the active file's per-test `Strong`s (the /// bail path skips its `scopeguard::defer! { exit_file() }` because /// `process::exit()` does not unwind), the preload-hook `Strong`s held in @@ -1362,7 +1362,7 @@ impl Drop for BunTest { } } -// `ZigGlobalObject::promiseHandlerID` (C++) compares the fn-ptr passed to +// `BunGlobalObject::promiseHandlerID` (C++) compares the fn-ptr passed to // `JSValue::then` against `&Bun__TestScope__Describe2__bunTestThen` by // identity, so the Rust thunk MUST be the symbol itself — exporting a // `static JSHostFn = thunk` puts the name in `.data` (nm `d`), and the address diff --git a/src/runtime/timer/mod.rs b/src/runtime/timer/mod.rs index 3da015b92d2a..02ac39fe7f22 100644 --- a/src/runtime/timer/mod.rs +++ b/src/runtime/timer/mod.rs @@ -1149,7 +1149,7 @@ impl All { /// # Safety /// JS thread only, with the TLS `RuntimeState` still installed and `vm` /// the live per-thread VM. Must run BEFORE JSC teardown - /// (`Zig__GlobalObject__destructOnExit` / `WebWorker__teardownJSCVM`) and + /// (`Bun__GlobalObject__destructOnExit` / `WebWorker__teardownJSCVM`) and /// BEFORE `runtime_state` is nulled — the GC sweep frees the /// `TimeoutObject` boxes whose `event_loop_timer` fields the heap nodes /// alias. diff --git a/src/runtime/webcore/FileSink.rs b/src/runtime/webcore/FileSink.rs index 970c5e5f5000..164508947d73 100644 --- a/src/runtime/webcore/FileSink.rs +++ b/src/runtime/webcore/FileSink.rs @@ -1732,7 +1732,7 @@ impl FileSink { // function-pointer variables). C++ declares them via // `BUN_DECLARE_HOST_FUNCTION(Bun__FileSink__onResolveStream)` and compares the // resulting symbol address against the handler passed to `JSValue::then` in -// `Zig::GlobalObject::promiseHandlerID`. A `pub static …: JSHostFn = shim` +// `Bun::GlobalObject::promiseHandlerID`. A `pub static …: JSHostFn = shim` // exports the address of an 8-byte data slot, which never equals the shim's // code address → RELEASE_ASSERT_NOT_REACHED at runtime. bun_jsc::jsc_host_abi! { diff --git a/src/runtime/webcore/ReadableStream.rs b/src/runtime/webcore/ReadableStream.rs index 637b437a23b4..03292ac0210a 100644 --- a/src/runtime/webcore/ReadableStream.rs +++ b/src/runtime/webcore/ReadableStream.rs @@ -123,7 +123,7 @@ unsafe extern "C" { reason: JSValue, ); safe fn ReadableStream__detach(stream: JSValue, global: &JSGlobalObject); - safe fn ZigGlobalObject__createNativeReadableStream( + safe fn BunGlobalObject__createNativeReadableStream( global: &JSGlobalObject, native_ptr: JSValue, ) -> JSValue; @@ -310,7 +310,7 @@ impl ReadableStream { pub fn from_native(global_this: &JSGlobalObject, native: JSValue) -> JsResult { bun_jsc::from_js_host_call(global_this, || { - ZigGlobalObject__createNativeReadableStream(global_this, native) + BunGlobalObject__createNativeReadableStream(global_this, native) }) } diff --git a/src/runtime/webcore/ReadableStream.zig b/src/runtime/webcore/ReadableStream.zig index c084d9ebae17..b7c7d0a8bc6d 100644 --- a/src/runtime/webcore/ReadableStream.zig +++ b/src/runtime/webcore/ReadableStream.zig @@ -294,11 +294,11 @@ pub fn fromJS(value: JSValue, globalThis: *JSGlobalObject) bun.JSError!?Readable }; } -extern fn ZigGlobalObject__createNativeReadableStream(*JSGlobalObject, nativePtr: JSValue) JSValue; +extern fn BunGlobalObject__createNativeReadableStream(*JSGlobalObject, nativePtr: JSValue) JSValue; pub fn fromNative(globalThis: *JSGlobalObject, native: jsc.JSValue) bun.JSError!jsc.JSValue { jsc.markBinding(@src()); - return bun.jsc.fromJSHostCall(globalThis, @src(), ZigGlobalObject__createNativeReadableStream, .{ globalThis, native }); + return bun.jsc.fromJSHostCall(globalThis, @src(), BunGlobalObject__createNativeReadableStream, .{ globalThis, native }); } pub fn fromOwnedSlice(globalThis: *JSGlobalObject, bytes: []u8, recommended_chunk_size: Blob.SizeType) bun.JSError!jsc.JSValue { diff --git a/src/runtime/webcore/wasm_streaming.rs b/src/runtime/webcore/wasm_streaming.rs index ea8df6b44eee..b467d2597440 100644 --- a/src/runtime/webcore/wasm_streaming.rs +++ b/src/runtime/webcore/wasm_streaming.rs @@ -1,4 +1,4 @@ -//! `Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming` — lives here rather +//! `Bun__GlobalObject__getBodyStreamOrBytesForWasmStreaming` — lives here rather //! than in `bun_jsc::JSGlobalObject` because the body inspects `Response`/`Body`/ //! `Blob`/`ReadableStream`, which are `bun_runtime` types (forward-dep of //! `bun_jsc`). @@ -155,7 +155,7 @@ pub(crate) fn get_body_stream_or_bytes_for_wasm_streaming( /// `this` must be a valid, live `JSGlobalObject` pointer for the duration of /// the call (guaranteed by the C++ host caller). #[unsafe(no_mangle)] -pub(crate) unsafe extern "C" fn Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming( +pub(crate) unsafe extern "C" fn Bun__GlobalObject__getBodyStreamOrBytesForWasmStreaming( this: *mut JSGlobalObject, response_value: JSValue, streaming_compiler: *mut c_void, diff --git a/src/runtime/webview/ChromeBackend.cpp b/src/runtime/webview/ChromeBackend.cpp index 6562810592bd..5ff06db7f4ad 100644 --- a/src/runtime/webview/ChromeBackend.cpp +++ b/src/runtime/webview/ChromeBackend.cpp @@ -3,7 +3,7 @@ #include "bun-uws/src/SocketKinds.h" #include "JSWebView.h" #include "ipc_protocol.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "BunClientData.h" #include "ScriptExecutionContext.h" #include "BunString.h" @@ -94,14 +94,14 @@ using namespace JSC; // Implemented in ChromeProcess.rs. Returns the parent's socketpair fd (bidirectional). // path overrides auto-detection; extraArgv (count entries, each NUL- // terminated) appends after core flags. All pointers nullable. -extern "C" int32_t Bun__Chrome__ensure(Zig::GlobalObject*, const char* userDataDir, +extern "C" int32_t Bun__Chrome__ensure(Bun::GlobalObject*, const char* userDataDir, const char* path, const char* const* extraArgv, uint32_t extraArgvLen, bool stdoutInherit, bool stderrInherit); extern "C" void* Blob__fromBytesWithType(JSC::JSGlobalObject*, const uint8_t* ptr, size_t len, const char* mime); -extern "C" JSC::EncodedJSValue SYSV_ABI Blob__create(Zig::GlobalObject*, void* impl); +extern "C" JSC::EncodedJSValue SYSV_ABI Blob__create(Bun::GlobalObject*, void* impl); extern "C" void Bun__eventLoop__incrementRefConcurrently(void* bunVM, int delta); -extern "C" void Bun__EventLoop__enter(Zig::GlobalObject*); -extern "C" void Bun__EventLoop__exit(Zig::GlobalObject*); +extern "C" void Bun__EventLoop__enter(Bun::GlobalObject*); +extern "C" void Bun__EventLoop__exit(Bun::GlobalObject*); extern "C" void Bun__EventLoop__runCallback2(JSGlobalObject*, EncodedJSValue cb, EncodedJSValue thisVal, EncodedJSValue arg0, EncodedJSValue arg1); @@ -279,7 +279,7 @@ static constexpr us_socket_vtable_t s_cdpVTable = { .on_handshake = nullptr, }; -bool Transport::ensureSpawned(Zig::GlobalObject* zig, const WTF::String& userDataDir, +bool Transport::ensureSpawned(Bun::GlobalObject* zig, const WTF::String& userDataDir, const WTF::String& path, const WTF::Vector& extraArgv, bool stdoutInherit, bool stderrInherit) { @@ -450,7 +450,7 @@ static void wsOnClose(void* ctx, unsigned short code) t.rejectAllAndMarkDead(makeString("Chrome WebSocket closed (code "_s, code, ')')); } -bool Transport::ensureConnected(Zig::GlobalObject* zig, const WTF::String& wsUrl, bool autoDetected, +bool Transport::ensureConnected(Bun::GlobalObject* zig, const WTF::String& wsUrl, bool autoDetected, const WTF::String& userDataDir, bool stdoutInherit, bool stderrInherit) { // Already connected — singleton semantics, first call wins. diff --git a/src/runtime/webview/ChromeBackend.h b/src/runtime/webview/ChromeBackend.h index 9f13970fb939..b9f8115b4206 100644 --- a/src/runtime/webview/ChromeBackend.h +++ b/src/runtime/webview/ChromeBackend.h @@ -30,7 +30,7 @@ struct us_socket_t; -namespace Zig { +namespace Bun { class GlobalObject; } @@ -378,7 +378,7 @@ class Transport { // Chrome's output (chatty on stderr — GCM/updater/font-config noise). // Spawn args apply only on the FIRST call — subsequent views share the // one Chrome, so mismatched args across views get the first-call's. - bool ensureSpawned(Zig::GlobalObject*, const WTF::String& userDataDir = {}, + bool ensureSpawned(Bun::GlobalObject*, const WTF::String& userDataDir = {}, const WTF::String& path = {}, const WTF::Vector& extraArgv = {}, bool stdoutInherit = false, bool stderrInherit = false); @@ -398,7 +398,7 @@ class Transport { // ensureSpawned instead of rejecting the user's promise with a // confusing WebSocket error. autoDetected=false means explicit // backend.url; connect failure surfaces directly. - bool ensureConnected(Zig::GlobalObject*, const WTF::String& wsUrl, bool autoDetected, + bool ensureConnected(Bun::GlobalObject*, const WTF::String& wsUrl, bool autoDetected, const WTF::String& userDataDir = {}, bool stdoutInherit = false, bool stderrInherit = false); // Next CDP id — caller uses it with Command(id, ...) then calls send(). @@ -416,7 +416,7 @@ class Transport { void onWritable(); void onClose(); - Zig::GlobalObject* m_global = nullptr; + Bun::GlobalObject* m_global = nullptr; TransportMode m_mode = TransportMode::None; // Pipe mode: usockets-adopted socketpair fd. us_socket_t* m_readSock = nullptr; diff --git a/src/runtime/webview/JSWebView.cpp b/src/runtime/webview/JSWebView.cpp index 4c248ceb5240..a8f2d0acfb85 100644 --- a/src/runtime/webview/JSWebView.cpp +++ b/src/runtime/webview/JSWebView.cpp @@ -8,7 +8,7 @@ #include "ChromeBackend.h" #include "WebKitBackend.h" #include "ipc_protocol.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "BunClientData.h" #include "ScriptExecutionContext.h" #include "ScriptWrappableInlines.h" diff --git a/src/runtime/webview/JSWebViewConstructor.cpp b/src/runtime/webview/JSWebViewConstructor.cpp index 64111d5431d8..2fd7fcf71602 100644 --- a/src/runtime/webview/JSWebViewConstructor.cpp +++ b/src/runtime/webview/JSWebViewConstructor.cpp @@ -4,7 +4,7 @@ #include "root.h" #include "JSWebView.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/runtime/webview/JSWebViewPrototype.cpp b/src/runtime/webview/JSWebViewPrototype.cpp index e8aeb133a2f8..67328d3af67b 100644 --- a/src/runtime/webview/JSWebViewPrototype.cpp +++ b/src/runtime/webview/JSWebViewPrototype.cpp @@ -4,7 +4,7 @@ #include "root.h" #include "JSWebView.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "ErrorCode.h" #include #include diff --git a/src/runtime/webview/WebKitBackend.cpp b/src/runtime/webview/WebKitBackend.cpp index cd961d74c420..661691066775 100644 --- a/src/runtime/webview/WebKitBackend.cpp +++ b/src/runtime/webview/WebKitBackend.cpp @@ -10,7 +10,7 @@ #include "bun-uws/src/SocketKinds.h" #include "ipc_protocol.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "BunClientData.h" #include #include @@ -40,15 +40,15 @@ using namespace JSC; using namespace WebViewProto; // Spawn + process-exit watch implemented in HostProcess.rs (EVFILT_PROC). -extern "C" int32_t Bun__WebViewHost__ensure(Zig::GlobalObject*, bool stdoutInherit, bool stderrInherit); +extern "C" int32_t Bun__WebViewHost__ensure(Bun::GlobalObject*, bool stdoutInherit, bool stderrInherit); extern "C" void* Blob__fromMmapWithType(JSC::JSGlobalObject*, uint8_t* ptr, size_t len, const char* mime); -extern "C" JSC::EncodedJSValue SYSV_ABI Blob__create(Zig::GlobalObject*, void* impl); -extern "C" JSC::EncodedJSValue JSBuffer__fromMmap(Zig::GlobalObject*, void* ptr, size_t length); +extern "C" JSC::EncodedJSValue SYSV_ABI Blob__create(Bun::GlobalObject*, void* impl); +extern "C" JSC::EncodedJSValue JSBuffer__fromMmap(Bun::GlobalObject*, void* ptr, size_t length); extern "C" void Bun__eventLoop__incrementRefConcurrently(void* bunVM, int delta); // Bracket the whole onData batch. exit() drains microtasks when outermost, // so all the promise reactions from this batch run before we return to usockets. -extern "C" void Bun__EventLoop__enter(Zig::GlobalObject*); -extern "C" void Bun__EventLoop__exit(Zig::GlobalObject*); +extern "C" void Bun__EventLoop__enter(Bun::GlobalObject*); +extern "C" void Bun__EventLoop__exit(Bun::GlobalObject*); // runCallback does its own nested enter/exit + reportActiveExceptionAsUnhandled // on throw — one bad onNavigated callback won't poison the rest of the batch. extern "C" void Bun__EventLoop__runCallback2(JSC::JSGlobalObject*, JSC::EncodedJSValue cb, @@ -127,7 +127,7 @@ void HostClient::updateKeepAlive() WebCore::clientData(global->vm())->bunVM, want ? 1 : -1); } -bool HostClient::ensureSpawned(Zig::GlobalObject* zig, bool stdoutInherit, bool stderrInherit) +bool HostClient::ensureSpawned(Bun::GlobalObject* zig, bool stdoutInherit, bool stderrInherit) { if (sock && !dead) return true; diff --git a/src/runtime/webview/WebKitBackend.h b/src/runtime/webview/WebKitBackend.h index 46ce8b6daa08..c280fb77b255 100644 --- a/src/runtime/webview/WebKitBackend.h +++ b/src/runtime/webview/WebKitBackend.h @@ -19,7 +19,7 @@ struct us_socket_t; -namespace Zig { +namespace Bun { class GlobalObject; } @@ -41,7 +41,7 @@ namespace WK { // Bun__WebViewHost__ensure (implemented in HostProcess.rs). struct HostClient { us_socket_t* sock = nullptr; - Zig::GlobalObject* global = nullptr; + Bun::GlobalObject* global = nullptr; bool dead = false; uint32_t nextViewId = 1; @@ -51,7 +51,7 @@ struct HostClient { WTF::Vector txQueue; bool sockRefd = false; - bool ensureSpawned(Zig::GlobalObject*, bool stdoutInherit, bool stderrInherit); + bool ensureSpawned(Bun::GlobalObject*, bool stdoutInherit, bool stderrInherit); void writeFrame(WebViewProto::Op, uint32_t viewId, const uint8_t* payload, uint32_t len); void handleReply(const WebViewProto::Frame&, WebViewProto::Reader); void rejectAllAndMarkDead(const WTF::String& reason); diff --git a/test/leaksan.supp b/test/leaksan.supp index 6093941b0904..11deb28350c3 100644 --- a/test/leaksan.supp +++ b/test/leaksan.supp @@ -5,7 +5,7 @@ leak:resolver.package_json.PackageJSON.parse__anon leak:resolver.resolver.Resolver.parseTSConfig leak:JSC::Identifier::fromString leak:jsc.JSGlobalObject.JSGlobalObject.create -leak:Zig__GlobalObject__create +leak:Bun__GlobalObject__create leak:_objc_msgSend_uncached leak:WTF::AutomaticThread::start leak:Bun__transpileFile @@ -25,7 +25,7 @@ leak:BIO_new leak:_tlv_get_addr leak:Bun::generateModule leak:Zig::ImportMetaObject::createFromSpecifier -leak:Zig::GlobalObject::moduleLoaderResolve +leak:Bun::GlobalObject::moduleLoaderResolve leak:JSModuleLoader__import leak:dyld::ThreadLocalVariables leak:JSC__JSModuleLoader__loadAndEvaluateModule @@ -43,7 +43,7 @@ leak:runtime.node.fs_events.InitLibrary leak:runtime.node.fs_events.FSEventsLoop._schedule leak:Bun__Path__join leak:Bun__Path__resolve -leak:Zig::GlobalObject::moduleLoaderImportModule +leak:Bun::GlobalObject::moduleLoaderImportModule leak:bake.FrameworkRouter.JSFrameworkRouter.getFileIdForRouter leak:runtime.webcore.Blob.findOrCreateFileFromPath__anon leak:runtime.node.node_fs_binding.Bindings(.mkdtemp).runSync diff --git a/test/regression/issue/29519.test.ts b/test/regression/issue/29519.test.ts index 15a965c8a519..aacbfc872d1b 100644 --- a/test/regression/issue/29519.test.ts +++ b/test/regression/issue/29519.test.ts @@ -1,6 +1,6 @@ // https://github.com/oven-sh/bun/issues/29519 // -// Both --isolate and ShadowRealm construct a fresh Zig::GlobalObject on a +// Both --isolate and ShadowRealm construct a fresh Bun::GlobalObject on a // warm VM. collectContinuously runs a dedicated collector thread so the // marker overlaps finishCreation/init; sloppy-mode indirect eval below grows // the global's JSSegmentedVariableObject::m_variables (the storage the @@ -13,10 +13,10 @@ import { bunEnv, bunExe, isWindows, tempDir } from "harness"; // is identical on Linux/macOS, so skip Windows to keep duration reasonable. // Both tests spawn independent subprocesses with no shared state, so run them // concurrently to halve wall-clock. -describe.skipIf(isWindows).concurrent("Zig::GlobalObject creation on a warm VM under concurrent GC", () => { +describe.skipIf(isWindows).concurrent("Bun::GlobalObject creation on a warm VM under concurrent GC", () => { test("bun test --isolate survives concurrent GC while swapping globals", async () => { const files: Record = {}; - // Six files is enough to recycle the Zig::GlobalObject IsoSubspace slot + // Six files is enough to recycle the Bun::GlobalObject IsoSubspace slot // a few times even without the collector thread getting lucky on timing. for (let i = 0; i < 6; i++) { // Indirect eval (`(0, eval)(…)`) runs in the global scope, so these go @@ -60,7 +60,7 @@ describe.skipIf(isWindows).concurrent("Zig::GlobalObject creation on a warm VM u }, 120_000); // deriveShadowRealmGlobalObject() is the other path that constructs a - // Zig::GlobalObject on a warm VM; cover it under the same GC pressure so the + // Bun::GlobalObject on a warm VM; cover it under the same GC pressure so the // DeferGC there doesn't silently regress. test("ShadowRealm creation survives concurrent GC", async () => { const src = ` diff --git a/test/regression/issue/30205.test.ts b/test/regression/issue/30205.test.ts index 9bd23e922fb7..26b6854b0817 100644 --- a/test/regression/issue/30205.test.ts +++ b/test/regression/issue/30205.test.ts @@ -1,8 +1,8 @@ // https://github.com/oven-sh/bun/issues/30205 // -// `bun test --isolate` / `--parallel` creates a fresh Zig::GlobalObject per +// `bun test --isolate` / `--parallel` creates a fresh Bun::GlobalObject per // file and gcUnprotect()s the previous one. NapiEnv holds a raw -// `Zig::GlobalObject*` in m_globalObject; for non-experimental addons +// `Bun::GlobalObject*` in m_globalObject; for non-experimental addons // (nm_version != NAPI_VERSION_EXPERIMENTAL), napi finalizers are deferred to // the event loop as NapiFinalizerTask. Objects rooted on the old global only // become collectable when the swap unprotects it, so their finalizers run From 285caeb0fb3d95df64585c3f8a7177f5a75a8c8f Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 4 Jun 2026 21:48:36 +0000 Subject: [PATCH 02/20] NodeModuleModule: use defaultGlobalObject in the Module constructor The constructor static_cast the lexical global to Bun::GlobalObject, which is wrong when invoked from a non-Bun global such as a node:vm context. Use defaultGlobalObject() so those callers fall back to the main global's CommonJSModule structure instead of reading through a bogus pointer. --- src/jsc/modules/NodeModuleModule.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/jsc/modules/NodeModuleModule.cpp b/src/jsc/modules/NodeModuleModule.cpp index 64c32b3e2067..4b5c83ec8da1 100644 --- a/src/jsc/modules/NodeModuleModule.cpp +++ b/src/jsc/modules/NodeModuleModule.cpp @@ -160,8 +160,9 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModuleModuleConstructor, JSString* dirname = jsEmptyString(vm); - // TODO: handle when JSGlobalObject !== Bun::GlobalObject, such as in node:vm - Structure* structure = static_cast(globalObject) + // The lexical global object is not always a Bun::GlobalObject (e.g. inside + // node:vm); fall back to the main global's structure in that case. + Structure* structure = defaultGlobalObject(globalObject) ->CommonJSModuleObjectStructure(); // TODO: handle ShadowRealm, node:vm, new.target, subclasses From 32661a6cf10db1a9942ee5e7e3f637b4c4ded722 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 4 Jun 2026 22:25:58 +0000 Subject: [PATCH 03/20] Merge namespace Zig into namespace Bun and rename remaining Zig-prefixed binding files Continues the rename started with ZigGlobalObject: - namespace Zig is gone; all members (SourceProvider, JSFFIFunction, CallSite, ImportMetaObject, JSCStackTrace, string helpers, ...) now live in namespace Bun - ZigSourceProvider.{h,cpp}, ZigException.cpp, ZigGeneratedCode.cpp and ZigLazyStaticFunctions{,-inlines}.h are renamed to Bun* - the C ABI exception types (ZigException, ZigStackTrace, ZigStackFrame, ZigStackFramePosition, ZigStackFrameCode, ZigErrorType, ZigErrorCode) are renamed to Bun* on both the C++ and Rust sides, along with their Rust source files and modules - CommonStringsForZig -> CommonStringsForBun, Zig_ErrorCode* -> Bun_ErrorCode*, zig__ModuleInfo* and zig__renderDiff -> bun__* ZigString/ZigStringSlice, ZIG_EXPORT/ZIG_DECL and the crate-internal zig_* names are left for the larger sweep in #30747. --- .gitattributes | 4 +- src/ast_jsc/lib.rs | 10 +- src/bun_bin/phase_c_exports.rs | 10 +- src/bun_core/string/mod.rs | 2 +- src/bundler/analyze_transpiled_module.rs | 6 +- src/bundler_jsc/analyze_jsc.rs | 4 +- src/codegen/cppbind.ts | 2 +- src/codegen/generate-classes.ts | 8 +- src/codegen/generate-host-exports.ts | 2 +- src/codegen/shared-types.ts | 2 +- src/http_jsc/websocket_client.rs | 2 +- src/jsc/{ZigErrorType.rs => BunErrorType.rs} | 2 +- src/jsc/{ZigException.rs => BunException.rs} | 46 +++--- .../{ZigStackFrame.rs => BunStackFrame.rs} | 38 ++--- ...StackFrameCode.rs => BunStackFrameCode.rs} | 4 +- ...mePosition.rs => BunStackFramePosition.rs} | 6 +- .../{ZigStackTrace.rs => BunStackTrace.rs} | 18 +-- src/jsc/CommonStrings.rs | 36 ++--- src/jsc/ConsoleObject.rs | 12 +- src/jsc/Debugger.rs | 10 +- src/jsc/ErrorCode.rs | 6 +- src/jsc/Errorable.rs | 6 +- src/jsc/Exception.rs | 6 +- src/jsc/JSValue.rs | 10 +- src/jsc/ResolvedSource.rs | 2 +- src/jsc/RuntimeTranspilerStore.rs | 2 +- src/jsc/SavedSourceMap.rs | 4 +- src/jsc/VirtualMachine.rs | 88 +++++------ .../bindings/BunAnalyzeTranspiledModule.cpp | 14 +- src/jsc/bindings/BunAnalyzeTranspiledModule.h | 2 +- src/jsc/bindings/BunClientData.h | 7 +- src/jsc/bindings/BunCommonStrings.cpp | 32 ++-- .../{ZigException.cpp => BunException.cpp} | 54 +++---- ...GeneratedCode.cpp => BunGeneratedCode.cpp} | 0 src/jsc/bindings/BunGlobalObject.cpp | 16 +- src/jsc/bindings/BunGlobalObject.h | 10 +- ...nes.h => BunLazyStaticFunctions-inlines.h} | 4 +- ...icFunctions.h => BunLazyStaticFunctions.h} | 4 +- src/jsc/bindings/BunObject.cpp | 4 +- src/jsc/bindings/BunPlugin.cpp | 8 +- src/jsc/bindings/BunPlugin.h | 4 +- src/jsc/bindings/BunProcess.cpp | 2 +- ...urceProvider.cpp => BunSourceProvider.cpp} | 10 +- ...igSourceProvider.h => BunSourceProvider.h} | 4 +- src/jsc/bindings/BunString.cpp | 46 +++--- src/jsc/bindings/CallSite.cpp | 2 +- src/jsc/bindings/CallSite.h | 2 +- src/jsc/bindings/CallSitePrototype.cpp | 2 +- src/jsc/bindings/CallSitePrototype.h | 2 +- src/jsc/bindings/CodeCoverage.cpp | 2 +- src/jsc/bindings/ConsoleObject.h | 2 +- src/jsc/bindings/ErrorCode.cpp | 6 +- src/jsc/bindings/ErrorStackFrame.cpp | 8 +- src/jsc/bindings/ErrorStackFrame.h | 2 +- src/jsc/bindings/ErrorStackTrace.cpp | 28 ++-- src/jsc/bindings/ErrorStackTrace.h | 2 +- src/jsc/bindings/FormatStackTraceForJS.cpp | 36 ++--- src/jsc/bindings/FormatStackTraceForJS.h | 11 +- src/jsc/bindings/ImportMetaObject.cpp | 2 +- src/jsc/bindings/ImportMetaObject.h | 2 +- src/jsc/bindings/InspectorLifecycleAgent.cpp | 6 +- src/jsc/bindings/InspectorLifecycleAgent.h | 2 +- .../bindings/InspectorTestReporterAgent.cpp | 6 +- src/jsc/bindings/IsolatedModuleCache.cpp | 10 +- src/jsc/bindings/IsolatedModuleCache.h | 10 +- src/jsc/bindings/JSBuffer.cpp | 4 +- src/jsc/bindings/JSBufferList.cpp | 2 +- src/jsc/bindings/JSBundlerPlugin.h | 2 +- src/jsc/bindings/JSCommonJSModule.cpp | 10 +- src/jsc/bindings/JSDOMWrapper.h | 2 +- src/jsc/bindings/JSEnvironmentVariableMap.cpp | 10 +- src/jsc/bindings/JSFFIFunction.cpp | 16 +- src/jsc/bindings/JSFFIFunction.h | 2 +- src/jsc/bindings/JSStringDecoder.cpp | 2 +- src/jsc/bindings/JSWrappingFunction.cpp | 6 +- src/jsc/bindings/JSWrappingFunction.h | 2 +- src/jsc/bindings/ModuleLoader.cpp | 18 +-- src/jsc/bindings/NapiClass.cpp | 2 +- src/jsc/bindings/NapiRef.cpp | 2 +- src/jsc/bindings/NapiWeakValue.cpp | 2 +- src/jsc/bindings/Path.cpp | 8 +- src/jsc/bindings/ProcessBindingTTYWrap.cpp | 4 +- src/jsc/bindings/ServerRouteList.cpp | 2 +- src/jsc/bindings/URLSearchParams.cpp | 4 +- src/jsc/bindings/bindings.cpp | 146 +++++++++--------- src/jsc/bindings/headers-cpp.h | 4 +- src/jsc/bindings/headers-handwritten.h | 60 +++---- src/jsc/bindings/headers.h | 4 +- src/jsc/bindings/helpers.h | 8 +- src/jsc/bindings/napi.cpp | 6 +- src/jsc/bindings/napi.h | 2 +- src/jsc/bindings/napi_external.h | 2 +- src/jsc/bindings/objects.h | 4 +- .../webcore/SerializedScriptValue.cpp | 2 +- src/jsc/bindings/webcore/WebSocket.cpp | 10 +- src/jsc/host_fn.rs | 2 +- src/jsc/lib.rs | 50 +++--- src/jsc/modules/AbortControllerModuleModule.h | 4 +- src/jsc/modules/BunAppModule.h | 4 +- src/jsc/modules/BunJSCModule.h | 8 +- src/jsc/modules/BunObjectModule.h | 4 +- src/jsc/modules/BunTestModule.h | 4 +- src/jsc/modules/NodeBufferModule.h | 4 +- src/jsc/modules/NodeConstantsModule.h | 4 +- src/jsc/modules/NodeModuleModule.cpp | 4 +- src/jsc/modules/NodeModuleModule.h | 6 +- src/jsc/modules/NodeProcessModule.h | 4 +- src/jsc/modules/NodeStringDecoderModule.h | 4 +- src/jsc/modules/NodeTTYModule.cpp | 4 +- src/jsc/modules/NodeTTYModule.h | 4 +- src/jsc/modules/NodeUtilTypesModule.cpp | 4 +- src/jsc/modules/NodeUtilTypesModule.h | 4 +- src/jsc/modules/ObjectModule.cpp | 4 +- src/jsc/modules/ObjectModule.h | 4 +- src/jsc/modules/UTF8ValidateModule.h | 4 +- src/jsc/modules/_NativeModule.h | 4 +- src/runtime/api/BunObject.rs | 2 +- src/runtime/bake/BakeSourceProvider.cpp | 2 +- .../bake/DevServer/ErrorReportRequest.rs | 32 ++-- src/runtime/ffi/mod.rs | 2 +- src/runtime/hw_exports.rs | 6 +- src/runtime/jsc_hooks.rs | 2 +- src/runtime/test_runner/diff_format.rs | 2 +- src/runtime/webview/ChromeBackend.cpp | 2 +- src/sourcemap/lib.rs | 6 +- test/js/bun/util/reportError.test.ts | 4 +- test/leaksan.supp | 8 +- test/no-validate-leaksan.txt | 2 +- 128 files changed, 628 insertions(+), 636 deletions(-) rename src/jsc/{ZigErrorType.rs => BunErrorType.rs} (91%) rename src/jsc/{ZigException.rs => BunException.rs} (84%) rename src/jsc/{ZigStackFrame.rs => BunStackFrame.rs} (92%) rename src/jsc/{ZigStackFrameCode.rs => BunStackFrameCode.rs} (95%) rename src/jsc/{ZigStackFramePosition.rs => BunStackFramePosition.rs} (89%) rename src/jsc/{ZigStackTrace.rs => BunStackTrace.rs} (94%) rename src/jsc/bindings/{ZigException.cpp => BunException.cpp} (94%) rename src/jsc/bindings/{ZigGeneratedCode.cpp => BunGeneratedCode.cpp} (100%) rename src/jsc/bindings/{ZigLazyStaticFunctions-inlines.h => BunLazyStaticFunctions-inlines.h} (96%) rename src/jsc/bindings/{ZigLazyStaticFunctions.h => BunLazyStaticFunctions.h} (90%) rename src/jsc/bindings/{ZigSourceProvider.cpp => BunSourceProvider.cpp} (98%) rename src/jsc/bindings/{ZigSourceProvider.h => BunSourceProvider.h} (98%) diff --git a/.gitattributes b/.gitattributes index a049d004f441..06ea6a42fa5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -30,8 +30,8 @@ src/api/schema.d.ts linguist-generated fixture.*.c linguist-generated src/api/schema.js linguist-generated *-fixture* linguist-generated -src/jsc/bindings/ZigGeneratedCode.h linguist-generated -src/jsc/bindings/ZigGeneratedCode.cpp linguist-generated +src/jsc/bindings/BunGeneratedCode.h linguist-generated +src/jsc/bindings/BunGeneratedCode.cpp linguist-generated src/jsc/bindings/headers.h linguist-generated src/jsc/bindings/headers.zig linguist-generated diff --git a/src/ast_jsc/lib.rs b/src/ast_jsc/lib.rs index d31a65480881..c13be12af4af 100644 --- a/src/ast_jsc/lib.rs +++ b/src/ast_jsc/lib.rs @@ -10,19 +10,19 @@ use bun_core::ZigString; use bun_jsc::{self as jsc, BuildMessage, JSGlobalObject, JSValue, JsResult, ResolveMessage}; pub fn msg_from_js(global_object: &JSGlobalObject, file: Vec, err: JSValue) -> JsResult { - let mut zig_exception_holder = jsc::zig_exception::Holder::init(); + let mut bun_exception_holder = jsc::bun_exception::Holder::init(); if let Some(value) = err.to_error() { - value.to_zig_exception(global_object, zig_exception_holder.zig_exception()); + value.to_bun_exception(global_object, bun_exception_holder.bun_exception()); } else { - zig_exception_holder.zig_exception().message = err.to_bun_string(global_object)?; + bun_exception_holder.bun_exception().message = err.to_bun_string(global_object)?; } Ok(Msg { data: Data { text: Cow::Owned( - zig_exception_holder - .zig_exception() + bun_exception_holder + .bun_exception() .message .to_owned_slice(), ), diff --git a/src/bun_bin/phase_c_exports.rs b/src/bun_bin/phase_c_exports.rs index 42151cd22b25..cbdb05894b15 100644 --- a/src/bun_bin/phase_c_exports.rs +++ b/src/bun_bin/phase_c_exports.rs @@ -244,11 +244,11 @@ pub(crate) extern "C" fn Bun__VM__scriptExecutionStatus(_vm: *const VirtualMachi // ── bundler analyze ───────────────────────────────────────────────────────── // REAL: src/bundler/analyze_transpiled_module.rs -// zig__ModuleInfoDeserialized__deinit +// bun__ModuleInfoDeserialized__deinit // REAL: src/bundler_jsc/analyze_jsc.rs -// zig__ModuleInfoDeserialized__toJSModuleRecord -// zig__renderDiff +// bun__ModuleInfoDeserialized__toJSModuleRecord +// bun__renderDiff // ════════════════════════════════════════════════════════════════════════════ // Genuinely unimplemented — no C++ body. Kept so the @@ -292,5 +292,5 @@ pub(crate) extern "C" fn DNSResolver__getConstructor(_global: *mut JSGlobalObjec unreachable!("DNSResolver has no JS-visible constructor (no `construct` in .classes.ts)") } -// (zig__renderDiff now defined in src/runtime/test_runner/diff_format.rs.) -// (zig__ModuleInfoDeserialized__toJSModuleRecord now defined in src/bundler_jsc/analyze_jsc.rs.) +// (bun__renderDiff now defined in src/runtime/test_runner/diff_format.rs.) +// (bun__ModuleInfoDeserialized__toJSModuleRecord now defined in src/bundler_jsc/analyze_jsc.rs.) diff --git a/src/bun_core/string/mod.rs b/src/bun_core/string/mod.rs index 01c10021cde5..06b4226a2661 100644 --- a/src/bun_core/string/mod.rs +++ b/src/bun_core/string/mod.rs @@ -1453,7 +1453,7 @@ impl ZigString { pub fn dupe_for_js(utf8: &[u8]) -> Result { if let Some(utf16) = strings::to_utf16_alloc(utf8, false, false)? { // Ownership transferred to JSC: `mark_global()` tags the buffer so - // `Zig::toString*` adopts it into a WTF string and `mi_free`s it on + // `Bun::toString*` adopts it into a WTF string and `mi_free`s it on // string death. `heap::release` is the hand-off-to-foreign-owner // spelling. let leaked: &'static mut [u16] = crate::heap::release(utf16.into_boxed_slice()); diff --git a/src/bundler/analyze_transpiled_module.rs b/src/bundler/analyze_transpiled_module.rs index e01a50021bd1..feb3a02e85a9 100644 --- a/src/bundler/analyze_transpiled_module.rs +++ b/src/bundler/analyze_transpiled_module.rs @@ -520,11 +520,11 @@ impl ModuleInfoExt for ModuleInfo { } } -// zig__renderDiff, zig__ModuleInfoDeserialized__toJSModuleRecord, and the +// bun__renderDiff, bun__ModuleInfoDeserialized__toJSModuleRecord, and the // JSModuleRecord/IdentifierArray opaques: see bun_bundler_jsc::analyze_jsc #[unsafe(no_mangle)] -pub(crate) extern "C" fn zig__ModuleInfo__destroy(info: *mut ModuleInfo) { +pub(crate) extern "C" fn bun__ModuleInfo__destroy(info: *mut ModuleInfo) { // SAFETY: C++ caller passes a non-null pointer obtained from `ModuleInfo::create`. let info = unsafe { NonNull::new(info).unwrap_unchecked() }; // SAFETY: `info` came from `bun_core::heap::into_raw` and ownership is transferred back here. @@ -532,7 +532,7 @@ pub(crate) extern "C" fn zig__ModuleInfo__destroy(info: *mut ModuleInfo) { } #[unsafe(no_mangle)] -pub(crate) extern "C" fn zig__ModuleInfoDeserialized__deinit(info: *mut ModuleInfoDeserialized) { +pub(crate) extern "C" fn bun__ModuleInfoDeserialized__deinit(info: *mut ModuleInfoDeserialized) { // SAFETY: C++ caller passes a non-null pointer obtained from `create` or // `ModuleInfoExt::into_deserialized`. let info = unsafe { NonNull::new(info).unwrap_unchecked() }; diff --git a/src/bundler_jsc/analyze_jsc.rs b/src/bundler_jsc/analyze_jsc.rs index 7648b1b3763c..a2395e03db0d 100644 --- a/src/bundler_jsc/analyze_jsc.rs +++ b/src/bundler_jsc/analyze_jsc.rs @@ -2,7 +2,7 @@ //! `ModuleInfoDeserialized` into a `JSC::JSModuleRecord`. Aliased back so the //! `extern "C"` symbol names are still discoverable from C++. //! -//! Note: the `zig__renderDiff` export lives in +//! Note: the `bun__renderDiff` export lives in //! `bun_runtime::test_runner::diff_format` instead — `DiffFormatter` is a //! higher-tier type this crate cannot depend on, and the C++ caller only needs //! the symbol at link time, not a particular crate. @@ -13,7 +13,7 @@ use analyze::{ModuleInfoDeserialized, RecordKind, RequestedModuleValue, StringID use bun_bundler::analyze_transpiled_module as analyze; #[unsafe(no_mangle)] -pub(crate) extern "C" fn zig__ModuleInfoDeserialized__toJSModuleRecord( +pub(crate) extern "C" fn bun__ModuleInfoDeserialized__toJSModuleRecord( global_object: &JSGlobalObject, vm: &VM, module_key: &IdentifierArray, diff --git a/src/codegen/cppbind.ts b/src/codegen/cppbind.ts index a92afd4b0474..e7e699b303dc 100644 --- a/src/codegen/cppbind.ts +++ b/src/codegen/cppbind.ts @@ -455,7 +455,7 @@ const rustSharedTypes: Record = { "EncodedJSValue": "crate::JSValue", "JSC::JSGlobalObject": "crate::JSGlobalObject", "Bun::GlobalObject": "crate::JSGlobalObject", - "ZigException": "crate::zig_exception::ZigException", + "BunException": "crate::bun_exception::BunException", "ZigString": "bun_core::ZigString", "JSC::VM": "crate::VM", "JSC::JSPromise": "crate::JSPromise", diff --git a/src/codegen/generate-classes.ts b/src/codegen/generate-classes.ts index cc22f8fa1c86..2c4ad6963abf 100644 --- a/src/codegen/generate-classes.ts +++ b/src/codegen/generate-classes.ts @@ -3232,7 +3232,7 @@ const GENERATED_CLASSES_HEADER = [ #include "root.h" -namespace Zig { +namespace Bun { JSC_DECLARE_HOST_FUNCTION(jsFunctionInherits); @@ -3246,7 +3246,7 @@ JSC_DECLARE_HOST_FUNCTION(jsFunctionInherits); ` namespace WebCore { -using namespace Zig; +using namespace Bun; using namespace JSC; `, @@ -3297,7 +3297,7 @@ const GENERATED_CLASSES_IMPL_HEADER_POST = ` namespace WebCore { using namespace JSC; -using namespace Zig; +using namespace Bun; #include "ZigGeneratedClasses.lut.h" @@ -3317,7 +3317,7 @@ ${jsclasses .map((v, i) => `#include "${v}"`) .join("\n")} -JSC_DEFINE_HOST_FUNCTION(Zig::jsFunctionInherits, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionInherits, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { auto id = callFrame->argument(0).toInt32(globalObject); auto value = callFrame->argument(1); diff --git a/src/codegen/generate-host-exports.ts b/src/codegen/generate-host-exports.ts index fe45e275c89a..abeec2f01e25 100644 --- a/src/codegen/generate-host-exports.ts +++ b/src/codegen/generate-host-exports.ts @@ -501,7 +501,7 @@ const importCandidates: Array<[string, string]> = [ ["bun_jsc", "JSInternalPromise"], ["bun_jsc", "JSObject"], ["bun_jsc", "JSPromise"], - ["bun_jsc", "ZigStackFrame"], + ["bun_jsc", "BunStackFrame"], ["bun_jsc::virtual_machine", "VirtualMachine"], ["bun_jsc::debugger", "InspectorBunFrontendDevServerAgentHandle"], ["bun_jsc::debugger", "LifecycleHandle"], diff --git a/src/codegen/shared-types.ts b/src/codegen/shared-types.ts index 0b8753e07c64..d5a9b41eba70 100644 --- a/src/codegen/shared-types.ts +++ b/src/codegen/shared-types.ts @@ -40,7 +40,7 @@ export const sharedTypes: Record = { "JSC::EncodedJSValue": "jsc.JSValue", "EncodedJSValue": "jsc.JSValue", "JSC::JSGlobalObject": "jsc.JSGlobalObject", - "ZigException": "jsc.ZigException", + "BunException": "jsc.BunException", "Inspector::InspectorHTTPServerAgent": "HTTPServerAgent.InspectorHTTPServerAgent", "HotReloadId": "HTTPServerAgent.HotReloadId", "ServerId": "HTTPServerAgent.ServerId", diff --git a/src/http_jsc/websocket_client.rs b/src/http_jsc/websocket_client.rs index 23aa399797ac..bc8241b43c8f 100644 --- a/src/http_jsc/websocket_client.rs +++ b/src/http_jsc/websocket_client.rs @@ -426,7 +426,7 @@ impl WebSocket { let mut outstring; if let Some(utf16) = utf16_bytes { // Ownership of the UTF-16 buffer transfers to C++: with - // `clone=false` and the global tag set, `Zig::toString` + // `clone=false` and the global tag set, `Bun::toString` // adopts the allocation into a `WTF::ExternalStringImpl` // which `mi_free`s it later. Dropping the Vec here would // be a UAF + double-free, so `utf16` must never be freed diff --git a/src/jsc/ZigErrorType.rs b/src/jsc/BunErrorType.rs similarity index 91% rename from src/jsc/ZigErrorType.rs rename to src/jsc/BunErrorType.rs index f184dcffa34c..44a393b2ded3 100644 --- a/src/jsc/ZigErrorType.rs +++ b/src/jsc/BunErrorType.rs @@ -3,7 +3,7 @@ use crate::error_code::ErrorCode; #[repr(C)] #[derive(Copy, Clone)] -pub struct ZigErrorType { +pub struct BunErrorType { pub code: ErrorCode, // Bare JSValue field is OK here — this is a #[repr(C)] FFI payload // passed by value across the C++ boundary, not a heap-allocated Rust struct. diff --git a/src/jsc/ZigException.rs b/src/jsc/BunException.rs similarity index 84% rename from src/jsc/ZigException.rs rename to src/jsc/BunException.rs index 123cdac745e7..ffdf952c1a4d 100644 --- a/src/jsc/ZigException.rs +++ b/src/jsc/BunException.rs @@ -8,22 +8,22 @@ use bun_url::URL as ZigURL; use crate::module_loader::ModuleLoader; use crate::virtual_machine::VirtualMachine; -use crate::{JSErrorCode, JSGlobalObject, JSRuntimeType, JSValue, ZigStackFrame, ZigStackTrace}; +use crate::{JSErrorCode, JSGlobalObject, JSRuntimeType, JSValue, BunStackFrame, BunStackTrace}; // SAFETY (safe fn): `JSValue` is a by-value scalar; `JSGlobalObject` is an // opaque `UnsafeCell`-backed handle (`&` is ABI-identical to non-null `*mut`); -// `ZigException` is a `#[repr(C)]` out-param the C++ side fills in-place. +// `BunException` is a `#[repr(C)]` out-param the C++ side fills in-place. unsafe extern "C" { - pub(crate) safe fn ZigException__collectSourceLines( + pub(crate) safe fn BunException__collectSourceLines( js_value: JSValue, global: &JSGlobalObject, - exception: &mut ZigException, + exception: &mut BunException, ); } /// Represents a JavaScript exception with additional information #[repr(C)] -pub struct ZigException { +pub struct BunException { pub r#type: JSErrorCode, pub runtime_type: JSRuntimeType, @@ -38,7 +38,7 @@ pub struct ZigException { pub name: String, pub message: String, - pub stack: ZigStackTrace, + pub stack: BunStackTrace, pub exception: *mut c_void, @@ -49,9 +49,9 @@ pub struct ZigException { pub browser_url: String, } -impl ZigException { +impl BunException { pub fn collect_source_lines(&mut self, value: JSValue, global: &JSGlobalObject) { - ZigException__collectSourceLines(value, global, self); + BunException__collectSourceLines(value, global, self); } // Kept as explicit `deinit` (not `Drop`) — this is a #[repr(C)] FFI @@ -79,9 +79,9 @@ impl ZigException { } } - // `ZigException__fromException` is declared in headers.h but has no C++ + // `BunException__fromException` is declared in headers.h but has no C++ // body (bindings.cpp dropped it; the only producer is - // `JSC__JSValue__toZigException` which writes through an out-param), so + // `JSC__JSValue__toBunException` which writes through an out-param), so // there is intentionally no `from_exception` here. pub fn add_to_error_list( @@ -132,11 +132,11 @@ impl ZigException { pub struct Holder { pub source_line_numbers: [i32; Self::SOURCE_LINES_COUNT], pub source_lines: [String; Self::SOURCE_LINES_COUNT], - pub frames: [ZigStackFrame; Self::FRAME_COUNT], + pub frames: [BunStackFrame; Self::FRAME_COUNT], pub loaded: bool, - // Never read until `loaded` flips and `zig_exception()` writes it; + // Never read until `loaded` flips and `bun_exception()` writes it; // all access must be gated on `loaded`. - pub zig_exception: MaybeUninit, + pub bun_exception: MaybeUninit, pub need_to_clear_parser_arena_on_deinit: bool, } @@ -146,10 +146,10 @@ impl Holder { pub fn zero() -> Self { Self { - frames: core::array::from_fn(|_| ZigStackFrame::ZERO), + frames: core::array::from_fn(|_| BunStackFrame::ZERO), source_line_numbers: [-1; Self::SOURCE_LINES_COUNT], source_lines: core::array::from_fn(|_| String::EMPTY), - zig_exception: MaybeUninit::uninit(), + bun_exception: MaybeUninit::uninit(), loaded: false, need_to_clear_parser_arena_on_deinit: false, } @@ -166,8 +166,8 @@ impl Holder { // call won't leak WTF string refs. pub fn deinit(&mut self, vm: &mut VirtualMachine) { if self.loaded { - // SAFETY: `loaded == true` ⇔ `zig_exception()` has written this slot. - unsafe { self.zig_exception.assume_init_mut() }.deinit(); + // SAFETY: `loaded == true` ⇔ `bun_exception()` has written this slot. + unsafe { self.bun_exception.assume_init_mut() }.deinit(); // Make idempotent so the subsequent `Drop` is a no-op. self.loaded = false; } @@ -176,15 +176,15 @@ impl Holder { } } - pub fn zig_exception(&mut self) -> &mut ZigException { + pub fn bun_exception(&mut self) -> &mut BunException { if !self.loaded { - self.zig_exception.write(ZigException { + self.bun_exception.write(BunException { r#type: JSErrorCode(255), runtime_type: JSRuntimeType::NOTHING, name: String::EMPTY, message: String::EMPTY, exception: ptr::null_mut(), - stack: ZigStackTrace { + stack: BunStackTrace { source_lines_ptr: self.source_lines.as_mut_ptr(), source_lines_numbers: self.source_line_numbers.as_mut_ptr(), source_lines_len: Self::SOURCE_LINES_COUNT as u8, @@ -207,7 +207,7 @@ impl Holder { // SAFETY: either the branch above just wrote it, or `loaded` was already // true from a prior call that wrote it. - unsafe { self.zig_exception.assume_init_mut() } + unsafe { self.bun_exception.assume_init_mut() } } } @@ -218,8 +218,8 @@ impl Drop for Holder { // skips the tail `deinit` call. fn drop(&mut self) { if self.loaded { - // SAFETY: `loaded == true` ⇔ `zig_exception()` has written this slot. - unsafe { self.zig_exception.assume_init_mut() }.deinit(); + // SAFETY: `loaded == true` ⇔ `bun_exception()` has written this slot. + unsafe { self.bun_exception.assume_init_mut() }.deinit(); self.loaded = false; } } diff --git a/src/jsc/ZigStackFrame.rs b/src/jsc/BunStackFrame.rs similarity index 92% rename from src/jsc/ZigStackFrame.rs rename to src/jsc/BunStackFrame.rs index 4f51600a947b..1f62ad4ea775 100644 --- a/src/jsc/ZigStackFrame.rs +++ b/src/jsc/BunStackFrame.rs @@ -9,15 +9,15 @@ use bun_paths::strings; use bun_url::URL as ZigURL; use crate::schema_api as api; -use crate::{ZigStackFrameCode, ZigStackFramePosition}; +use crate::{BunStackFrameCode, BunStackFramePosition}; /// Represents a single frame in a stack trace #[repr(C)] -pub struct ZigStackFrame { +pub struct BunStackFrame { pub function_name: BunString, pub source_url: BunString, - pub position: ZigStackFramePosition, - pub code_type: ZigStackFrameCode, + pub position: BunStackFramePosition, + pub code_type: BunStackFrameCode, pub is_async: bool, /// This informs formatters whether to display as a blob URL or not @@ -27,13 +27,13 @@ pub struct ZigStackFrame { pub jsc_stack_frame_index: i32, } -impl ZigStackFrame { +impl BunStackFrame { /// Explicit deref of owned strings. /// /// Intentionally NOT `Drop`: this `#[repr(C)]` extern struct lives both in - /// C++-populated buffers (`ZigStackTrace.frames_ptr`) and in the Rust-owned - /// `Holder.frames: [ZigStackFrame; 32]` array. `Holder::deinit()` calls - /// `ZigException::deinit()` → `frame.deinit()` to release the strings, but + /// C++-populated buffers (`BunStackTrace.frames_ptr`) and in the Rust-owned + /// `Holder.frames: [BunStackFrame; 32]` array. `Holder::deinit()` calls + /// `BunException::deinit()` → `frame.deinit()` to release the strings, but /// the array elements are then later dropped by Rust when `Holder` itself /// drops. A `Drop` impl would deref the same `WTF::StringImpl` a second /// time (UAF). Explicit `deinit` only. @@ -70,17 +70,17 @@ impl ZigStackFrame { frame.position = self.position; // api::StackFrameScope is a #[repr(transparent)] u8 newtype with the same - // discriminants as ZigStackFrameCode. + // discriminants as BunStackFrameCode. frame.scope = api::StackFrameScope(self.code_type.0); Ok(frame) } - pub const ZERO: ZigStackFrame = ZigStackFrame { + pub const ZERO: BunStackFrame = BunStackFrame { function_name: BunString::EMPTY, - code_type: ZigStackFrameCode::NONE, + code_type: BunStackFrameCode::NONE, source_url: BunString::EMPTY, - position: ZigStackFramePosition::INVALID, + position: BunStackFramePosition::INVALID, is_async: false, remapped: false, jsc_stack_frame_index: -1, @@ -116,7 +116,7 @@ impl ZigStackFrame { pub struct SourceURLFormatter<'a> { pub source_url: BunString, - pub position: ZigStackFramePosition, + pub position: BunStackFramePosition, pub enable_color: bool, pub origin: Option<&'a ZigURL<'a>>, pub exclude_line_column: bool, @@ -225,7 +225,7 @@ impl<'a> fmt::Display for SourceURLFormatter<'a> { pub struct NameFormatter { pub function_name: BunString, - pub code_type: ZigStackFrameCode, + pub code_type: BunStackFrameCode, pub enable_color: bool, pub is_async: bool, } @@ -235,7 +235,7 @@ impl fmt::Display for NameFormatter { let name = &self.function_name; match self.code_type { - ZigStackFrameCode::EVAL => { + BunStackFrameCode::EVAL => { if self.enable_color { f.write_str(concat!( Output::pretty_fmt!("", true), @@ -253,7 +253,7 @@ impl fmt::Display for NameFormatter { } } } - ZigStackFrameCode::FUNCTION => { + BunStackFrameCode::FUNCTION => { if !name.is_empty() { if self.enable_color { if self.is_async { @@ -291,15 +291,15 @@ impl fmt::Display for NameFormatter { } } } - ZigStackFrameCode::GLOBAL => {} - ZigStackFrameCode::WASM => { + BunStackFrameCode::GLOBAL => {} + BunStackFrameCode::WASM => { if !name.is_empty() { write!(f, "{}", name)?; } else { f.write_str("WASM")?; } } - ZigStackFrameCode::CONSTRUCTOR => { + BunStackFrameCode::CONSTRUCTOR => { write!(f, "new {}", name)?; } _ => { diff --git a/src/jsc/ZigStackFrameCode.rs b/src/jsc/BunStackFrameCode.rs similarity index 95% rename from src/jsc/ZigStackFrameCode.rs rename to src/jsc/BunStackFrameCode.rs index de39dee88b90..68beb4e2c3a3 100644 --- a/src/jsc/ZigStackFrameCode.rs +++ b/src/jsc/BunStackFrameCode.rs @@ -4,9 +4,9 @@ // `match` arms below must keep a fallthrough for unknown values. #[repr(transparent)] #[derive(Copy, Clone, Eq, PartialEq, Hash)] -pub struct ZigStackFrameCode(pub u8); +pub struct BunStackFrameCode(pub u8); -impl ZigStackFrameCode { +impl BunStackFrameCode { pub const NONE: Self = Self(0); /// 🏃 pub const EVAL: Self = Self(1); diff --git a/src/jsc/ZigStackFramePosition.rs b/src/jsc/BunStackFramePosition.rs similarity index 89% rename from src/jsc/ZigStackFramePosition.rs rename to src/jsc/BunStackFramePosition.rs index 2c415386e185..75738c450202 100644 --- a/src/jsc/ZigStackFramePosition.rs +++ b/src/jsc/BunStackFramePosition.rs @@ -5,15 +5,15 @@ pub use bun_core::Ordinal; /// Represents a position in source code with line and column information #[repr(C)] #[derive(Copy, Clone, PartialEq, Eq)] -pub struct ZigStackFramePosition { +pub struct BunStackFramePosition { pub line: Ordinal, pub column: Ordinal, /// -1 if not present pub line_start_byte: c_int, } -impl ZigStackFramePosition { - pub const INVALID: ZigStackFramePosition = ZigStackFramePosition { +impl BunStackFramePosition { + pub const INVALID: BunStackFramePosition = BunStackFramePosition { line: Ordinal::INVALID, column: Ordinal::INVALID, line_start_byte: -1, diff --git a/src/jsc/ZigStackTrace.rs b/src/jsc/BunStackTrace.rs similarity index 94% rename from src/jsc/ZigStackTrace.rs rename to src/jsc/BunStackTrace.rs index de55243069b2..8afbcff56a30 100644 --- a/src/jsc/ZigStackTrace.rs +++ b/src/jsc/BunStackTrace.rs @@ -7,17 +7,17 @@ use bun_core::ZigStringSlice; use bun_url::URL as ZigURL; use crate::SourceProvider; -use crate::ZigStackFrame; +use crate::BunStackFrame; /// Represents a JavaScript stack trace #[repr(C)] -pub struct ZigStackTrace { +pub struct BunStackTrace { pub source_lines_ptr: *mut BunString, pub source_lines_numbers: *mut i32, pub source_lines_len: u8, pub source_lines_to_collect: u8, - pub frames_ptr: *mut ZigStackFrame, + pub frames_ptr: *mut BunStackFrame, pub frames_len: u8, pub frames_cap: u8, @@ -29,9 +29,9 @@ pub struct ZigStackTrace { pub referenced_source_provider: Option>, } -impl ZigStackTrace { - pub fn from_frames(frames_slice: &mut [ZigStackFrame]) -> ZigStackTrace { - ZigStackTrace { +impl BunStackTrace { + pub fn from_frames(frames_slice: &mut [BunStackFrame]) -> BunStackTrace { + BunStackTrace { source_lines_ptr: ptr::dangling_mut(), source_lines_numbers: ptr::dangling_mut(), source_lines_len: 0, @@ -89,13 +89,13 @@ impl ZigStackTrace { Ok(stack_trace) } - pub fn frames(&self) -> &[ZigStackFrame] { + pub fn frames(&self) -> &[BunStackFrame] { // SAFETY: frames_ptr points to a caller-owned buffer of at least frames_len elements // (populated by C++ via FFI). unsafe { bun_core::ffi::slice(self.frames_ptr, self.frames_len as usize) } } - pub fn frames_mutable(&mut self) -> &mut [ZigStackFrame] { + pub fn frames_mutable(&mut self) -> &mut [BunStackFrame] { // SAFETY: frames_ptr points to a caller-owned buffer of at least frames_len elements. unsafe { bun_core::ffi::slice_mut(self.frames_ptr, self.frames_len as usize) } } @@ -130,7 +130,7 @@ impl ZigStackTrace { } pub struct SourceLineIterator<'a> { - pub trace: &'a ZigStackTrace, + pub trace: &'a BunStackTrace, pub i: i32, } diff --git a/src/jsc/CommonStrings.rs b/src/jsc/CommonStrings.rs index 41254ee4b381..8d89041b4940 100644 --- a/src/jsc/CommonStrings.rs +++ b/src/jsc/CommonStrings.rs @@ -10,7 +10,7 @@ pub struct CommonStrings<'a> { #[repr(u8)] #[derive(Copy, Clone)] -enum CommonStringsForZig { +enum CommonStringsForBun { IPv4 = 0, IPv6 = 1, IN4Loopback = 2, @@ -30,70 +30,70 @@ unsafe extern "C" { // `JSGlobalObject` is an opaque `UnsafeCell`-backed FFI handle; `&T` is // ABI-identical to non-null `*const T` and the C++ side's lazy init of its // common-strings table (interior mutation) is invisible to Rust. - safe fn Bun__CommonStringsForZig__toJS( - common_string: CommonStringsForZig, + safe fn Bun__CommonStringsForBun__toJS( + common_string: CommonStringsForBun, global_object: &JSGlobalObject, ) -> JSValue; } -impl CommonStringsForZig { +impl CommonStringsForBun { #[inline] fn to_js(self, global_object: &JSGlobalObject) -> JSValue { - Bun__CommonStringsForZig__toJS(self, global_object) + Bun__CommonStringsForBun__toJS(self, global_object) } } impl<'a> CommonStrings<'a> { #[inline] pub fn ipv4(self) -> JSValue { - CommonStringsForZig::IPv4.to_js(self.global_object) + CommonStringsForBun::IPv4.to_js(self.global_object) } #[inline] pub fn ipv6(self) -> JSValue { - CommonStringsForZig::IPv6.to_js(self.global_object) + CommonStringsForBun::IPv6.to_js(self.global_object) } #[inline] pub fn in4_loopback(self) -> JSValue { - CommonStringsForZig::IN4Loopback.to_js(self.global_object) + CommonStringsForBun::IN4Loopback.to_js(self.global_object) } #[inline] pub fn in6_any(self) -> JSValue { - CommonStringsForZig::IN6Any.to_js(self.global_object) + CommonStringsForBun::IN6Any.to_js(self.global_object) } #[inline] pub fn ipv4_lower(self) -> JSValue { - CommonStringsForZig::Ipv4Lower.to_js(self.global_object) + CommonStringsForBun::Ipv4Lower.to_js(self.global_object) } #[inline] pub fn ipv6_lower(self) -> JSValue { - CommonStringsForZig::Ipv6Lower.to_js(self.global_object) + CommonStringsForBun::Ipv6Lower.to_js(self.global_object) } #[inline] pub fn default(self) -> JSValue { - CommonStringsForZig::FetchDefault.to_js(self.global_object) + CommonStringsForBun::FetchDefault.to_js(self.global_object) } #[inline] pub fn error(self) -> JSValue { - CommonStringsForZig::FetchError.to_js(self.global_object) + CommonStringsForBun::FetchError.to_js(self.global_object) } #[inline] pub fn include(self) -> JSValue { - CommonStringsForZig::FetchInclude.to_js(self.global_object) + CommonStringsForBun::FetchInclude.to_js(self.global_object) } #[inline] pub fn buffer(self) -> JSValue { - CommonStringsForZig::Buffer.to_js(self.global_object) + CommonStringsForBun::Buffer.to_js(self.global_object) } #[inline] pub fn arraybuffer(self) -> JSValue { - CommonStringsForZig::BinaryTypeArrayBuffer.to_js(self.global_object) + CommonStringsForBun::BinaryTypeArrayBuffer.to_js(self.global_object) } #[inline] pub fn nodebuffer(self) -> JSValue { - CommonStringsForZig::BinaryTypeNodeBuffer.to_js(self.global_object) + CommonStringsForBun::BinaryTypeNodeBuffer.to_js(self.global_object) } #[inline] pub fn uint8array(self) -> JSValue { - CommonStringsForZig::BinaryTypeUint8Array.to_js(self.global_object) + CommonStringsForBun::BinaryTypeUint8Array.to_js(self.global_object) } } diff --git a/src/jsc/ConsoleObject.rs b/src/jsc/ConsoleObject.rs index 96455a9a6513..0836f2b4ba50 100644 --- a/src/jsc/ConsoleObject.rs +++ b/src/jsc/ConsoleObject.rs @@ -1246,7 +1246,7 @@ impl<'a> DynWriteAdapter<'a> { } pub fn write_trace(writer: &mut dyn bun_io::Write, global: &JSGlobalObject) { - let mut holder = crate::zig_exception::Holder::init(); + let mut holder = crate::bun_exception::Holder::init(); // SAFETY: per-thread VM; `console.trace()` only runs on the JS thread. let vm = VirtualMachine::get().as_mut(); @@ -1254,15 +1254,15 @@ pub fn write_trace(writer: &mut dyn bun_io::Write, global: &JSGlobalObject) { let err = ZigString::init(b"trace output").to_error_instance(global); { - let exception = holder.zig_exception(); - err.to_zig_exception(global, exception); + let exception = holder.bun_exception(); + err.to_bun_exception(global, exception); } // `exception` and `&holder.need_to_clear_parser_arena_on_deinit` would be // two simultaneous `&mut` into `holder`. Capture the flag in a local and // write it back after. let mut need_to_clear = holder.need_to_clear_parser_arena_on_deinit; - vm.remap_zig_exception( - holder.zig_exception(), + vm.remap_bun_exception( + holder.bun_exception(), err, None, &mut need_to_clear, @@ -1274,7 +1274,7 @@ pub fn write_trace(writer: &mut dyn bun_io::Write, global: &JSGlobalObject) { let mut adapter = DynWriteAdapter::new(writer); let _ = VirtualMachine::print_stack_trace( adapter.interface(), - &holder.zig_exception().stack, + &holder.bun_exception().stack, Output::enable_ansi_colors_stderr(), ); diff --git a/src/jsc/Debugger.rs b/src/jsc/Debugger.rs index 8cffe3d10db1..bb22ed90f818 100644 --- a/src/jsc/Debugger.rs +++ b/src/jsc/Debugger.rs @@ -16,7 +16,7 @@ use bun_io::KeepAlive; use bun_io::posix_event_loop::{AllocatorType, get_vm_ctx}; use crate::virtual_machine::{VirtualMachine, runtime_hooks}; -use crate::{self as jsc, CallFrame, JSGlobalObject, ZigException}; +use crate::{self as jsc, CallFrame, JSGlobalObject, BunException}; bun_core::declare_scope!(debugger, visible); bun_core::declare_scope!(TestReporterAgent, visible); @@ -1076,13 +1076,13 @@ pub struct LifecycleAgent { bun_opaque::opaque_ffi! { pub struct LifecycleHandle; } // SAFETY (safe fn): `LifecycleHandle` is an `opaque_ffi!` ZST handle (`!Freeze` -// via `UnsafeCell`); `ZigException` is a `#[repr(C)]` out-param the C++ side +// via `UnsafeCell`); `BunException` is a `#[repr(C)]` out-param the C++ side // reads/fills in-place. unsafe extern "C" { safe fn Bun__LifecycleAgentReportReload(agent: &mut LifecycleHandle); safe fn Bun__LifecycleAgentReportError( agent: &mut LifecycleHandle, - exception: &mut ZigException, + exception: &mut BunException, ); safe fn Bun__LifecycleAgentPreventExit(agent: &mut LifecycleHandle); safe fn Bun__LifecycleAgentStopPreventingExit(agent: &mut LifecycleHandle); @@ -1102,7 +1102,7 @@ impl LifecycleHandle { Bun__LifecycleAgentReportReload(self) } - pub fn report_error(&mut self, exception: &mut ZigException) { + pub fn report_error(&mut self, exception: &mut BunException) { bun_core::scoped_log!(LifecycleAgent, "reportError"); Bun__LifecycleAgentReportError(self, exception) } @@ -1138,7 +1138,7 @@ impl LifecycleAgent { core::ptr::NonNull::new(self.handle).map(|p| LifecycleHandle::opaque_mut(p.as_ptr())) } - pub(crate) fn report_error(&mut self, exception: &mut ZigException) { + pub(crate) fn report_error(&mut self, exception: &mut BunException) { if let Some(h) = self.handle_mut() { h.report_error(exception); } diff --git a/src/jsc/ErrorCode.rs b/src/jsc/ErrorCode.rs index 871a3b3f94eb..9ebf56cd52ff 100644 --- a/src/jsc/ErrorCode.rs +++ b/src/jsc/ErrorCode.rs @@ -1499,7 +1499,7 @@ impl<'a, G: GlobalObjectRef + ?Sized> ErrorBuilder<'a, G> { } // C++ compares parser-error sentinels against these exported statics -// (`extern "C" ZigErrorCode Zig_ErrorCodeParserError;`, headers-handwritten.h). +// (`extern "C" BunErrorCode Bun_ErrorCodeParserError;`, headers-handwritten.h). // CAUTION: `from()` above currently maps via `code.errno`, which never yields // the hard-coded 0xFFFE/0xFFFD placeholder values, so a code produced by // `from()` will never compare equal to these constants. Until @@ -1508,9 +1508,9 @@ impl<'a, G: GlobalObjectRef + ?Sized> ErrorBuilder<'a, G> { // same source as `from()`, that mismatch stands. #[unsafe(no_mangle)] -pub(crate) static Zig_ErrorCodeParserError: ErrorCodeInt = ErrorCode::PARSER_ERROR; +pub(crate) static Bun_ErrorCodeParserError: ErrorCodeInt = ErrorCode::PARSER_ERROR; #[unsafe(no_mangle)] -pub(crate) static Zig_ErrorCodeJSErrorObject: ErrorCodeInt = ErrorCode::JS_ERROR_OBJECT; +pub(crate) static Bun_ErrorCodeJSErrorObject: ErrorCodeInt = ErrorCode::JS_ERROR_OBJECT; // ported from: src/jsc/bindings/ErrorCode.ts diff --git a/src/jsc/Errorable.rs b/src/jsc/Errorable.rs index fb37f37efba8..80e839fffd07 100644 --- a/src/jsc/Errorable.rs +++ b/src/jsc/Errorable.rs @@ -1,6 +1,6 @@ use crate::JSValue; use crate::error_code::ErrorCode; -use crate::zig_error_type::ZigErrorType; +use crate::bun_error_type::BunErrorType; #[repr(C)] pub struct Errorable { @@ -11,7 +11,7 @@ pub struct Errorable { #[repr(C)] pub union Result { pub value: T, - pub err: ZigErrorType, + pub err: BunErrorType, } impl Errorable { @@ -42,7 +42,7 @@ impl Errorable { pub fn err(code: bun_core::Error, err_value: JSValue) -> Self { Self { result: Result { - err: ZigErrorType { + err: BunErrorType { code: ErrorCode::from(code), value: err_value, }, diff --git a/src/jsc/Exception.rs b/src/jsc/Exception.rs index 4e690c116684..e5976fa68683 100644 --- a/src/jsc/Exception.rs +++ b/src/jsc/Exception.rs @@ -1,4 +1,4 @@ -use crate::{JSGlobalObject, JSValue, ZigStackTrace}; +use crate::{JSGlobalObject, JSValue, BunStackTrace}; bun_opaque::opaque_ffi! { /// Opaque representation of a JavaScript exception @@ -9,13 +9,13 @@ unsafe extern "C" { safe fn JSC__Exception__getStackTrace( this: &Exception, global: &JSGlobalObject, - stack: &mut ZigStackTrace, + stack: &mut BunStackTrace, ); safe fn JSC__Exception__asJSValue(this: &Exception) -> JSValue; } impl Exception { - pub fn get_stack_trace(&self, global: &JSGlobalObject, stack: &mut ZigStackTrace) { + pub fn get_stack_trace(&self, global: &JSGlobalObject, stack: &mut BunStackTrace) { JSC__Exception__getStackTrace(self, global, stack); } diff --git a/src/jsc/JSValue.rs b/src/jsc/JSValue.rs index a132373d7843..b8f4d204e23e 100644 --- a/src/jsc/JSValue.rs +++ b/src/jsc/JSValue.rs @@ -12,7 +12,7 @@ use core::marker::PhantomData; use crate::array_buffer::MarkedArrayBuffer_deallocator; use crate::{ AnyPromise, ArrayBuffer, BuiltinName, JSArrayIterator, JSGlobalObject, JSInternalPromise, - JSObject, JSPromise, JSString, JSType, JsClass, JsError, JsResult, ZigException, + JSObject, JSPromise, JSString, JSType, JsClass, JsError, JsResult, BunException, bun_string_jsc, ffi, host_fn, }; @@ -901,8 +901,8 @@ impl JSValue { let s = bun_core::OwnedString::new(self.to_bun_string(global)?); Ok(s.to_utf8()) } - pub fn to_zig_exception(self, global: &JSGlobalObject, exception: &mut ZigException) { - JSC__JSValue__toZigException(self, global, exception) + pub fn to_bun_exception(self, global: &JSGlobalObject, exception: &mut BunException) { + JSC__JSValue__toBunException(self, global, exception) } pub fn to_error(self) -> Option { let v = JSC__JSValue__toError_(self); @@ -1991,10 +1991,10 @@ unsafe extern "C" { out: &mut bun_core::String, ); safe fn JSC__JSValue__toError_(this: JSValue) -> JSValue; - safe fn JSC__JSValue__toZigException( + safe fn JSC__JSValue__toBunException( this: JSValue, global: &JSGlobalObject, - exception: &mut ZigException, + exception: &mut BunException, ); safe fn JSC__JSValue__getUnixTimestamp(this: JSValue) -> f64; safe fn JSC__JSValue__isPrimitive(this: JSValue) -> bool; diff --git a/src/jsc/ResolvedSource.rs b/src/jsc/ResolvedSource.rs index e43fbd8b1f1b..6f2c4d574e7f 100644 --- a/src/jsc/ResolvedSource.rs +++ b/src/jsc/ResolvedSource.rs @@ -109,7 +109,7 @@ impl From for OwnedResolvedSource { impl OwnedResolvedSource { /// Hand the raw value to C++ (which takes over the `deref()` obligation /// per `headers-handwritten.h` `BunString::deref` callers in - /// `Zig::ResolvedSource` consumers). After this, Rust must not touch the + /// `Bun::ResolvedSource` consumers). After this, Rust must not touch the /// strings. #[inline] pub fn into_ffi(self) -> ResolvedSource { diff --git a/src/jsc/RuntimeTranspilerStore.rs b/src/jsc/RuntimeTranspilerStore.rs index 28057e87299b..94a5764fbf76 100644 --- a/src/jsc/RuntimeTranspilerStore.rs +++ b/src/jsc/RuntimeTranspilerStore.rs @@ -541,7 +541,7 @@ impl TranspilerJob { let referrer = core::mem::take(&mut self.non_threadsafe_referrer).into_inner(); let mut log = core::mem::replace(&mut self.log, bun_ast::Log::init()); // Take RAII ownership out of the job; `into_ffi()` below transfers the - // +1 strings to `AsyncModule::fulfill` → C++ `Zig::ResolvedSource`. + // +1 strings to `AsyncModule::fulfill` → C++ `Bun::ResolvedSource`. let mut owned_resolved_source = core::mem::take(&mut self.resolved_source); let resolved_source = owned_resolved_source.as_mut(); let specifier = 'brk: { diff --git a/src/jsc/SavedSourceMap.rs b/src/jsc/SavedSourceMap.rs index 78127b7d66fb..6ef7d7ca236f 100644 --- a/src/jsc/SavedSourceMap.rs +++ b/src/jsc/SavedSourceMap.rs @@ -263,7 +263,7 @@ impl Drop for SavedSourceMap { // SAFETY: pointer was stored by us and is live until table teardown. unsafe { ParsedSourceMap::deref(source_map) }; } else if let Some(_provider) = value.get::() { - // do nothing, we did not hold a ref to ZigSourceProvider + // do nothing, we did not hold a ref to BunSourceProvider } else if let Some(ism) = value.get::() { // SAFETY: blob was heap-allocated via `put_mappings` // (`Box<[u8]>::into_raw`); the tagged pointer's address IS @@ -355,7 +355,7 @@ impl SavedSourceMap { // SAFETY: pointer was stored by us and is live until replaced. unsafe { ParsedSourceMap::deref(parsed_source_map) }; } else if let Some(_provider) = old_value.get::() { - // do nothing, we did not hold a ref to ZigSourceProvider + // do nothing, we did not hold a ref to BunSourceProvider } else if let Some(ism) = old_value.get::() { // SAFETY: blob was heap-allocated via `put_mappings` // (`Box<[u8]>::into_raw`); the tagged pointer's address IS diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index a3c604750c4b..432dd6f589cf 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -20,7 +20,7 @@ use crate::saved_source_map::SavedSourceMap; use crate::{ self as jsc, ErrorableResolvedSource, ErrorableString, Exception, JSGlobalObject, JSInternalPromise, JSValue, JsResult, OpaqueCallback, PlatformEventLoop, ResolvedSource, VM, - ZigException, + BunException, }; pub use crate::process_auto_killer as ProcessAutoKiller; @@ -61,7 +61,7 @@ pub(crate) type OnUnhandledRejection = fn(&mut VirtualMachine, &JSGlobalObject, pub(crate) type MacroMap = bun_collections::ArrayHashMap; /// `api::JsException` lives in /// [`crate::schema_api`] (not `bun_options_types::schema::api`) because its -/// `stack: StackTrace` field transitively names `ZigStackFramePosition` from +/// `stack: StackTrace` field transitively names `BunStackFramePosition` from /// this crate — see the `schema_api` module doc in lib.rs. pub type ExceptionList = Vec; @@ -1258,7 +1258,7 @@ impl VirtualMachine { self.had_errors = false; // The actual print path needs `ConsoleObject::Formatter` + - // `ZigException` (high tier). Dispatch through `RuntimeHooks` — + // `BunException` (high tier). Dispatch through `RuntimeHooks` — // mirroring `auto_tick`/`ensure_debugger` — so the error is actually // emitted to stderr before callers hard-exit. With no hook installed // (low-tier unit tests), fail loudly: PORTING.md §Forbidden bans a @@ -2529,7 +2529,7 @@ pub fn process_fetch_log( }; } - // C++ `Zig::toString` does `createWithoutCopying`, so the buffer + // C++ `Bun::toString` does `createWithoutCopying`, so the buffer // must outlive the AggregateError. Mark it global so JSC adopts it // as an ExternalStringImpl and frees it via `free_global_string`. let message_text: &'static mut [u8] = bun_core::heap::release( @@ -4855,19 +4855,19 @@ impl VirtualMachine { if was_internal { if let Some(exception_) = exception { - let mut holder = crate::zig_exception::Holder::init(); + let mut holder = crate::bun_exception::Holder::init(); // Note: `holder.deinit(self)` runs at the tail (for borrowck) // — semantics unchanged because // `need_to_clear_parser_arena_on_deinit` is false here. - let zig_exception: &mut ZigException = holder.zig_exception(); - exception_.get_stack_trace(global_ref, &mut zig_exception.stack); - if zig_exception.stack.frames_len > 0 { - let _ = Self::print_stack_trace(writer, &zig_exception.stack, allow_ansi_color); + let bun_exception: &mut BunException = holder.bun_exception(); + exception_.get_stack_trace(global_ref, &mut bun_exception.stack); + if bun_exception.stack.frames_len > 0 { + let _ = Self::print_stack_trace(writer, &bun_exception.stack, allow_ansi_color); } if let Some(list) = exception_list { let top_level_dir = self.top_level_dir(); let _ = - zig_exception.add_to_error_list(list, top_level_dir, Some(&self.origin)); + bun_exception.add_to_error_list(list, top_level_dir, Some(&self.origin)); } holder.deinit(self); } @@ -4974,7 +4974,7 @@ impl VirtualMachine { /// Note: takes a runtime bool + concrete writer. pub fn print_stack_trace( writer: &mut bun_core::io::Writer, - trace: &crate::ZigStackTrace, + trace: &crate::BunStackTrace, allow_ansi_colors: bool, ) -> Result<(), bun_core::Error> { let stack = trace.frames(); @@ -5045,10 +5045,10 @@ impl VirtualMachine { } /// # Safety - /// `frames` must point to `frames_count` initialized `ZigStackFrame`s. + /// `frames` must point to `frames_count` initialized `BunStackFrame`s. pub unsafe fn remap_stack_frame_positions( &mut self, - frames: *mut crate::ZigStackFrame, + frames: *mut crate::BunStackFrame, frames_count: usize, ) { if frames_count == 0 { @@ -5063,7 +5063,7 @@ impl VirtualMachine { // would be purely a perf optimization (most stacks repeat the same // source); do the straightforward per-frame resolve. See the PERF // note below. - // SAFETY: caller passes `frames_count` valid `ZigStackFrame`s. + // SAFETY: caller passes `frames_count` valid `BunStackFrame`s. let frames = unsafe { bun_core::ffi::slice_mut(frames, frames_count) }; for frame in frames { if frame.position.is_invalid() || frame.remapped { @@ -5106,9 +5106,9 @@ impl VirtualMachine { } /// Fills `exception` from `error_instance`, remapping stack frames through source maps. - pub fn remap_zig_exception( + pub fn remap_bun_exception( &mut self, - exception: &mut ZigException, + exception: &mut BunException, error_instance: JSValue, exception_list: Option<&mut ExceptionList>, must_reset_parser_arena_later: &mut bool, @@ -5118,7 +5118,7 @@ impl VirtualMachine { // `global()` returns `&'static`, so the borrow detaches from `&self` // and survives the `&mut self` reborrows below. let global = self.global(); - error_instance.to_zig_exception(global, exception); + error_instance.to_bun_exception(global, exception); // `Cell` so the `Tail` drop-guard below can hold a shared `&Cell` // and read the *current* value at scope-exit without a raw-ptr deref, // while the body freely `.set()`s it. @@ -5134,7 +5134,7 @@ impl VirtualMachine { // early `return` is covered. struct Tail<'a> { this: *mut VirtualMachine, - exception: *mut ZigException, + exception: *mut BunException, exception_list: Option<&'a mut ExceptionList>, enable_source_code_preview: &'a Cell, source_code_slice: *const Option, @@ -5145,7 +5145,7 @@ impl VirtualMachine { // before the body below reborrows them; no overlap at drop. let this = unsafe { &mut *self.this }; // SAFETY: `self.exception` is the caller's stack - // `ZigException`, live for the guard scope; no overlap at drop. + // `BunException`, live for the guard scope; no overlap at drop. let exception = unsafe { &mut *self.exception }; #[cfg(debug_assertions)] { @@ -5189,7 +5189,7 @@ impl VirtualMachine { }; // SAFETY: re-borrow through the guard's raw ptrs; `_tail` does not // touch them until Drop, so no aliasing during the body. - let exception: &mut ZigException = unsafe { &mut *_tail.exception }; + let exception: &mut BunException = unsafe { &mut *_tail.exception }; // SAFETY: as above — re-borrow through the guard's raw ptr; `_tail` // does not touch `source_code_slice` until Drop. let source_code_slice: &mut Option = @@ -5202,7 +5202,7 @@ impl VirtualMachine { || name.eql_comptime("moduleEvaluation") || name.eql_comptime("processTicksAndRejections") } - fn is_hidden_frame(f: &crate::ZigStackFrame) -> bool { + fn is_hidden_frame(f: &crate::BunStackFrame) -> bool { f.source_url.eql_comptime("bun:wrap") || f.function_name.eql_comptime("::bunternal::") } fn is_unknown_source(url: &bun_core::String) -> bool { @@ -5211,7 +5211,7 @@ impl VirtualMachine { let mut frames_len = exception.stack.frames_len as usize; // SAFETY: `frames_ptr[..frames_len]` is the caller-owned `Holder` - // backing buffer (ZigStackTrace contract). + // backing buffer (BunStackTrace contract). let frames_buf = unsafe { bun_core::ffi::slice_mut(exception.stack.frames_ptr, frames_len) }; @@ -5241,7 +5241,7 @@ impl VirtualMachine { { continue; } - // Note: `frames[j] = frame`. `ZigStackFrame` impls + // Note: `frames[j] = frame`. `BunStackFrame` impls // `Drop` so `copy_within` is unavailable; swap instead — // the discarded tail past `j` is never read after we // truncate `frames_len` below. @@ -5399,11 +5399,11 @@ impl VirtualMachine { let last_line = frames[top].position.line.zero_based().max(0); if let Some(lines_buf) = bun_core::strings::get_lines_in_text::< - { crate::zig_exception::Holder::SOURCE_LINES_COUNT }, + { crate::bun_exception::Holder::SOURCE_LINES_COUNT }, >(code.slice(), last_line as u32) { let lines = lines_buf.as_slice(); - const N: usize = crate::zig_exception::Holder::SOURCE_LINES_COUNT; + const N: usize = crate::bun_exception::Holder::SOURCE_LINES_COUNT; // SAFETY: `Holder` backs both arrays with `[_; SOURCE_LINES_COUNT]`. let source_lines = unsafe { bun_core::ffi::slice_mut(exception.stack.source_lines_ptr, N) }; @@ -5464,9 +5464,9 @@ impl VirtualMachine { } /// Prints an already-remapped exception (name, message, stack, source lines) to `writer`. - pub fn print_externally_remapped_zig_exception( + pub fn print_externally_remapped_bun_exception( &mut self, - zig_exception: &mut ZigException, + bun_exception: &mut BunException, formatter: Option<&mut crate::console_object::Formatter>, writer: &mut bun_core::io::Writer, allow_side_effects: bool, @@ -5475,7 +5475,7 @@ impl VirtualMachine { let mut default_formatter = crate::console_object::Formatter::new(self.global()); let f = formatter.unwrap_or(&mut default_formatter); self.print_error_instance_body( - zig_exception, + bun_exception, JSValue::ZERO, None, f, @@ -5501,7 +5501,7 @@ impl VirtualMachine { // `print_error_instance_body` dispatches on runtime bools, so it // carries the union of all // branches' locals (every `pretty_write!` expands to two `write!`s). - // More importantly, `remap_zig_exception` below calls + // More importantly, `remap_bun_exception` below calls // `fetch_without_on_load_plugins` → the transpiler for source-line // preview, and on Windows that call tree stack-allocates `PathBuffer`s // (`MAX_PATH_BYTES = 98302` vs 4096 on Linux). One cycle can therefore @@ -5513,7 +5513,7 @@ impl VirtualMachine { // the caller (`format2` / `Bun.inspect`). let extra_headroom: usize = if cfg!(windows) { // 3× PathBuffer ≈ 288 KB — empirically enough for the - // `remap_zig_exception` → `transpile_source_code` chain on the + // `remap_bun_exception` → `transpile_source_code` chain on the // 16K-deep Error test (`bun-inspect.test.ts`). bun_paths::MAX_PATH_BYTES * 3 } else { @@ -5530,19 +5530,19 @@ impl VirtualMachine { return Ok(()); } - // Note: `Holder` is ~4 KB (32 ZigStackFrames + 6 source lines + - // ZigException). It sits next to the large runtime-dispatched body, so + // Note: `Holder` is ~4 KB (32 BunStackFrames + 6 source lines + + // BunException). It sits next to the large runtime-dispatched body, so // box it to keep the per-level recursion frame small enough for the // 16K-deep `bun-inspect.test.ts` Error chain on Windows debug. - let mut exception_holder = Box::new(crate::zig_exception::Holder::init()); - // Note: reshaped for borrowck — `zig_exception()` returns a + let mut exception_holder = Box::new(crate::bun_exception::Holder::init()); + // Note: reshaped for borrowck — `bun_exception()` returns a // `&mut` into the holder; we need to also borrow // `need_to_clear_parser_arena_on_deinit` disjointly. Route through a // raw pointer (the holder is heap-pinned for the call). - let exception: *mut ZigException = exception_holder.zig_exception(); + let exception: *mut BunException = exception_holder.bun_exception(); let mut source_code_slice: Option = None; - self.remap_zig_exception( + self.remap_bun_exception( // SAFETY: `exception` points into stack-local `exception_holder`. unsafe { &mut *exception }, error_instance, @@ -5558,7 +5558,7 @@ impl VirtualMachine { unsafe { &mut *exception }, error_instance, None, // Note: `exception_list` was already - // consumed by `remap_zig_exception` above (only writer). + // consumed by `remap_bun_exception` above (only writer). formatter, writer, allow_ansi_color, @@ -5569,7 +5569,7 @@ impl VirtualMachine { // `exception_holder.deinit` // releases the WTFString refs (`name`/`message`/stack-frame // `function_name`/`source_url`/source-line bodies) populated by - // `JSC__JSValue__toZigException`. Skipping this leaks ~1 KB/error and + // `JSC__JSValue__toBunException`. Skipping this leaks ~1 KB/error and // OOMs the inspect-error-leak test. exception_holder.deinit(self); result @@ -5583,7 +5583,7 @@ impl VirtualMachine { #[allow(clippy::too_many_arguments)] fn print_error_instance_body( &mut self, - exception: &mut ZigException, + exception: &mut BunException, error_instance: JSValue, exception_list: Option<&mut ExceptionList>, formatter: &mut crate::console_object::Formatter, @@ -5625,10 +5625,10 @@ impl VirtualMachine { // Defer the GitHub-annotation print to scope exit. struct DeferGhAnnotation { run: bool, - /// BACKREF — borrows the caller's stack-local `ZigException`, live + /// BACKREF — borrows the caller's stack-local `BunException`, live /// across this drop guard (declared after the `&mut` rebind so it /// drops first). - exception: bun_ptr::BackRef, + exception: bun_ptr::BackRef, } impl Drop for DeferGhAnnotation { fn drop(&mut self) { @@ -5677,7 +5677,7 @@ impl VirtualMachine { const MAX_LINE_LENGTH: usize = 1024; // SAFETY: `source_lines_numbers[..source_lines_len]` is the - // caller-owned buffer (see ZigStackTrace contract). + // caller-owned buffer (see BunStackTrace contract). let line_numbers = exception.stack.source_line_numbers(); let max_line: i32 = line_numbers.iter().copied().fold(-1, i32::max); let max_line_number_pad = count_digits(max_line + 1); @@ -5789,7 +5789,7 @@ impl VirtualMachine { } let frames = exception.stack.frames(); - let mut top_frame: Option<&crate::ZigStackFrame> = frames.first(); + let mut top_frame: Option<&crate::BunStackFrame> = frames.first(); if self.hide_bun_stackframes { for frame in frames { if frame.position.is_invalid() @@ -6216,7 +6216,7 @@ impl VirtualMachine { /// Emits a GitHub Actions `::error` annotation for the exception when running in CI. #[cold] #[inline(never)] - pub fn print_github_annotation(exception: &ZigException) { + pub fn print_github_annotation(exception: &BunException) { let name = &exception.name; let message = &exception.message; let frames = exception.stack.frames(); diff --git a/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp b/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp index 5cbad52e3bf8..9134f5757d5b 100644 --- a/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp +++ b/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp @@ -10,7 +10,7 @@ #include #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/ExceptionScope.h" -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include "BunGlobalObject.h" #include "headers-handwritten.h" #include "IsolatedModuleCache.h" @@ -39,8 +39,8 @@ Identifier getFromIdentifierArray(VM& vm, Identifier* identifierArray, uint32_t return identifierArray[n]; } -extern "C" JSModuleRecord* zig__ModuleInfoDeserialized__toJSModuleRecord(JSGlobalObject* globalObject, VM& vm, const Identifier& module_key, const SourceCode& source_code, VariableEnvironment& declared_variables, VariableEnvironment& lexical_variables, bun_ModuleInfoDeserialized* module_info); -extern "C" void zig__renderDiff(const char* expected_ptr, size_t expected_len, const char* received_ptr, size_t received_len, JSGlobalObject* globalObject); +extern "C" JSModuleRecord* bun__ModuleInfoDeserialized__toJSModuleRecord(JSGlobalObject* globalObject, VM& vm, const Identifier& module_key, const SourceCode& source_code, VariableEnvironment& declared_variables, VariableEnvironment& lexical_variables, bun_ModuleInfoDeserialized* module_info); +extern "C" void bun__renderDiff(const char* expected_ptr, size_t expected_len, const char* received_ptr, size_t received_len, JSGlobalObject* globalObject); extern "C" Identifier* JSC__IdentifierArray__create(size_t len) { @@ -176,7 +176,7 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj VariableEnvironment declaredVariables = VariableEnvironment(); VariableEnvironment lexicalVariables = VariableEnvironment(); - auto provider = static_cast(sourceCode.provider()); + auto provider = static_cast(sourceCode.provider()); if (provider->m_resolvedSource.module_info == nullptr) { dataLog("[note] module_info is null for module: ", moduleKey.utf8(), "\n"); @@ -184,12 +184,12 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj } auto* moduleInfo = static_cast(provider->m_resolvedSource.module_info); - auto moduleRecord = zig__ModuleInfoDeserialized__toJSModuleRecord(globalObject, vm, moduleKey, sourceCode, declaredVariables, lexicalVariables, moduleInfo); + auto moduleRecord = bun__ModuleInfoDeserialized__toJSModuleRecord(globalObject, vm, moduleKey, sourceCode, declaredVariables, lexicalVariables, moduleInfo); // Under --isolate the same SourceProvider is reused across globals via the // IsolatedModuleCache, so module_info must remain alive on the provider; // ~SourceProvider frees it. Otherwise, free now. if (!Bun::IsolatedModuleCache::canUse(vm, uncheckedDowncast(globalObject)->bunVM())) { - zig__ModuleInfoDeserialized__deinit(moduleInfo); + bun__ModuleInfoDeserialized__deinit(moduleInfo); provider->m_resolvedSource.module_info = nullptr; } if (moduleRecord == nullptr) { @@ -239,7 +239,7 @@ static EncodedJSValue fallbackParse(JSGlobalObject* globalObject, const Identifi dataLog(" ------", "\n"); dataLog(" BunAnalyzeTranspiledModule:", "\n"); - zig__renderDiff(expected.utf8().data(), expected.utf8().length(), actual.utf8().data(), actual.utf8().length(), globalObject); + bun__renderDiff(expected.utf8().data(), expected.utf8().length(), actual.utf8().data(), actual.utf8().length(), globalObject); RELEASE_AND_RETURN(scope, JSValue::encode(rejectWithError(createError(globalObject, WTF::String::fromLatin1("Imports different between parseFromSourceCode and fallbackParse"))))); } diff --git a/src/jsc/bindings/BunAnalyzeTranspiledModule.h b/src/jsc/bindings/BunAnalyzeTranspiledModule.h index 34fcb810df0d..a84b0bf2d251 100644 --- a/src/jsc/bindings/BunAnalyzeTranspiledModule.h +++ b/src/jsc/bindings/BunAnalyzeTranspiledModule.h @@ -1,2 +1,2 @@ struct bun_ModuleInfoDeserialized; -extern "C" void zig__ModuleInfoDeserialized__deinit(bun_ModuleInfoDeserialized* info); +extern "C" void bun__ModuleInfoDeserialized__deinit(bun_ModuleInfoDeserialized* info); diff --git a/src/jsc/bindings/BunClientData.h b/src/jsc/bindings/BunClientData.h index 3e0356eb5843..1bf65113e7f7 100644 --- a/src/jsc/bindings/BunClientData.h +++ b/src/jsc/bindings/BunClientData.h @@ -30,12 +30,9 @@ namespace Bun { class GlobalObject; } -namespace Zig { -} - namespace WebCore { using namespace JSC; -using namespace Zig; +using namespace Bun; enum class UseCustomHeapCellType { Yes, No }; @@ -127,7 +124,7 @@ class JSVMClientData : public JSC::VM::ClientData { // Backing storage for Bun::IsolatedModuleCache (see IsolatedModuleCache.h). // All access should go through that class. Stored as the JSC base type to - // avoid pulling ZigSourceProvider.h into this header; the cache class + // avoid pulling BunSourceProvider.h into this header; the cache class // downcasts on lookup. Values hold strong refs by design: this map is the // only owner once the previous global is GC'd, so a weak map would empty // after every swap. diff --git a/src/jsc/bindings/BunCommonStrings.cpp b/src/jsc/bindings/BunCommonStrings.cpp index 27cbc72e19eb..49165620f917 100644 --- a/src/jsc/bindings/BunCommonStrings.cpp +++ b/src/jsc/bindings/BunCommonStrings.cpp @@ -143,7 +143,7 @@ extern "C" JSC::EncodedJSValue Bun__HTTPMethod__toJS(HTTPMethod method, Bun::Glo return JSValue::encode(toJS(globalObject, method)); } -enum class CommonStringsForZig : uint8_t { +enum class CommonStringsForBun : uint8_t { IPv4 = 0, IPv6 = 1, IN4Loopback = 2, @@ -159,35 +159,35 @@ enum class CommonStringsForZig : uint8_t { binaryTypeUint8Array = 12, }; -static JSC::JSValue toJS(Bun::GlobalObject* globalObject, CommonStringsForZig commonString) +static JSC::JSValue toJS(Bun::GlobalObject* globalObject, CommonStringsForBun commonString) { auto& commonStrings = globalObject->commonStrings(); switch (commonString) { - case CommonStringsForZig::IPv4: + case CommonStringsForBun::IPv4: return commonStrings.IPv4String(globalObject); - case CommonStringsForZig::IPv6: + case CommonStringsForBun::IPv6: return commonStrings.IPv6String(globalObject); - case CommonStringsForZig::IN4Loopback: + case CommonStringsForBun::IN4Loopback: return commonStrings.IN4LoopbackString(globalObject); - case CommonStringsForZig::IN6Any: + case CommonStringsForBun::IN6Any: return commonStrings.IN6AnyString(globalObject); - case CommonStringsForZig::ipv4Lower: + case CommonStringsForBun::ipv4Lower: return commonStrings.ipv4LowerString(globalObject); - case CommonStringsForZig::ipv6Lower: + case CommonStringsForBun::ipv6Lower: return commonStrings.ipv6LowerString(globalObject); - case CommonStringsForZig::fetchDefault: + case CommonStringsForBun::fetchDefault: return globalObject->vm().smallStrings.defaultString(); - case CommonStringsForZig::fetchError: + case CommonStringsForBun::fetchError: return commonStrings.fetchErrorString(globalObject); - case CommonStringsForZig::fetchInclude: + case CommonStringsForBun::fetchInclude: return commonStrings.fetchIncludeString(globalObject); - case CommonStringsForZig::buffer: + case CommonStringsForBun::buffer: return commonStrings.bufferString(globalObject); - case CommonStringsForZig::binaryTypeArrayBuffer: + case CommonStringsForBun::binaryTypeArrayBuffer: return commonStrings.binaryTypeArrayBufferString(globalObject); - case CommonStringsForZig::binaryTypeNodeBuffer: + case CommonStringsForBun::binaryTypeNodeBuffer: return commonStrings.binaryTypeNodeBufferString(globalObject); - case CommonStringsForZig::binaryTypeUint8Array: + case CommonStringsForBun::binaryTypeUint8Array: return commonStrings.binaryTypeUint8ArrayString(globalObject); default: { ASSERT_NOT_REACHED(); @@ -196,7 +196,7 @@ static JSC::JSValue toJS(Bun::GlobalObject* globalObject, CommonStringsForZig co } } -extern "C" JSC::EncodedJSValue Bun__CommonStringsForZig__toJS(CommonStringsForZig commonString, Bun::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__CommonStringsForBun__toJS(CommonStringsForBun commonString, Bun::GlobalObject* globalObject) { return JSValue::encode(toJS(globalObject, commonString)); } diff --git a/src/jsc/bindings/ZigException.cpp b/src/jsc/bindings/BunException.cpp similarity index 94% rename from src/jsc/bindings/ZigException.cpp rename to src/jsc/bindings/BunException.cpp index ae5c34cdeefb..f5869aef05e9 100644 --- a/src/jsc/bindings/ZigException.cpp +++ b/src/jsc/bindings/BunException.cpp @@ -1,5 +1,5 @@ /** - * ZigException handling and error processing utilities. + * BunException handling and error processing utilities. * * This file contains functions for converting JavaScript exceptions to ZigException, * processing stack traces, and collecting source lines. @@ -63,19 +63,19 @@ enum PopulateStackTraceFlags { #define SYNTAX_ERROR_CODE 4 -using Zig::FinalizerSafety; +using Bun::FinalizerSafety; -static void populateStackFrameMetadata(JSC::VM& vm, JSC::JSGlobalObject* globalObject, const JSC::StackFrame& stackFrame, ZigStackFrame& frame, FinalizerSafety finalizerSafety) +static void populateStackFrameMetadata(JSC::VM& vm, JSC::JSGlobalObject* globalObject, const JSC::StackFrame& stackFrame, BunStackFrame& frame, FinalizerSafety finalizerSafety) { if (stackFrame.isWasmFrame()) { - frame.code_type = ZigStackFrameCodeWasm; + frame.code_type = BunStackFrameCodeWasm; - auto name = Zig::functionName(vm, globalObject, stackFrame, finalizerSafety, nullptr); + auto name = Bun::functionName(vm, globalObject, stackFrame, finalizerSafety, nullptr); if (!name.isEmpty()) { frame.function_name = Bun::toStringRef(name); } - auto sourceURL = Zig::sourceURL(vm, stackFrame); + auto sourceURL = Bun::sourceURL(vm, stackFrame); if (sourceURL != "[wasm code]"_s) { // [wasm code] is a useless source URL, so we don't bother to set it. // It is the default value JSC returns. @@ -84,25 +84,25 @@ static void populateStackFrameMetadata(JSC::VM& vm, JSC::JSGlobalObject* globalO return; } - auto sourceURL = Zig::sourceURL(vm, stackFrame); + auto sourceURL = Bun::sourceURL(vm, stackFrame); frame.source_url = Bun::toStringRef(sourceURL); auto m_codeBlock = stackFrame.codeBlock(); if (m_codeBlock) { switch (m_codeBlock->codeType()) { case JSC::EvalCode: { - frame.code_type = ZigStackFrameCodeEval; + frame.code_type = BunStackFrameCodeEval; return; } case JSC::ModuleCode: { - frame.code_type = ZigStackFrameCodeModule; + frame.code_type = BunStackFrameCodeModule; return; } case JSC::GlobalCode: { - frame.code_type = ZigStackFrameCodeGlobal; + frame.code_type = BunStackFrameCodeGlobal; return; } case JSC::FunctionCode: { - frame.code_type = !m_codeBlock->isConstructor() ? ZigStackFrameCodeFunction : ZigStackFrameCodeConstructor; + frame.code_type = !m_codeBlock->isConstructor() ? BunStackFrameCodeFunction : BunStackFrameCodeConstructor; break; } default: @@ -113,12 +113,12 @@ static void populateStackFrameMetadata(JSC::VM& vm, JSC::JSGlobalObject* globalO WTF::String functionName; if (finalizerSafety == FinalizerSafety::MustNotTriggerGC) { // Use the safe overload that avoids property access - functionName = Zig::functionName(vm, globalObject, stackFrame, finalizerSafety, nullptr); + functionName = Bun::functionName(vm, globalObject, stackFrame, finalizerSafety, nullptr); } else { // Use the richer callee-based path if (auto calleeCell = stackFrame.callee()) { if (auto* callee = calleeCell->getObject()) - functionName = Zig::functionName(vm, globalObject, callee); + functionName = Bun::functionName(vm, globalObject, callee); } } if (!functionName.isEmpty()) @@ -129,7 +129,7 @@ static void populateStackFrameMetadata(JSC::VM& vm, JSC::JSGlobalObject* globalO static void populateStackFramePosition(const JSC::StackFrame& stackFrame, BunString* source_lines, OrdinalNumber* source_line_numbers, uint8_t source_lines_count, - ZigStackFramePosition& position, JSC::SourceProvider** referenced_source_provider, PopulateStackTraceFlags flags) + BunStackFramePosition& position, JSC::SourceProvider** referenced_source_provider, PopulateStackTraceFlags flags) { auto code = stackFrame.codeBlock(); if (!code) @@ -156,7 +156,7 @@ static void populateStackFramePosition(const JSC::StackFrame& stackFrame, BunStr } auto location = Bun::getAdjustedPositionForBytecode(code, stackFrame.bytecodeIndex()); - memcpy(&position, &location, sizeof(ZigStackFramePosition)); + memcpy(&position, &location, sizeof(BunStackFramePosition)); if (flags == PopulateStackTraceFlags::OnlyPosition) return; @@ -224,8 +224,8 @@ static void populateStackFramePosition(const JSC::StackFrame& stackFrame, BunStr } } -static void populateStackFrame(JSC::VM& vm, ZigStackTrace& trace, const JSC::StackFrame& stackFrame, - ZigStackFrame& frame, bool is_top, JSC::SourceProvider** referenced_source_provider, JSC::JSGlobalObject* globalObject, PopulateStackTraceFlags flags, FinalizerSafety finalizerSafety) +static void populateStackFrame(JSC::VM& vm, BunStackTrace& trace, const JSC::StackFrame& stackFrame, + BunStackFrame& frame, bool is_top, JSC::SourceProvider** referenced_source_provider, JSC::JSGlobalObject* globalObject, PopulateStackTraceFlags flags, FinalizerSafety finalizerSafety) { if (flags == PopulateStackTraceFlags::OnlyPosition) { populateStackFrameMetadata(vm, globalObject, stackFrame, frame, finalizerSafety); @@ -421,7 +421,7 @@ class V8StackTraceIterator { } }; -static void populateStackTrace(JSC::VM& vm, const WTF::Vector& frames, ZigStackTrace& trace, JSC::JSGlobalObject* globalObject, PopulateStackTraceFlags flags, FinalizerSafety finalizerSafety = FinalizerSafety::NotInFinalizer) +static void populateStackTrace(JSC::VM& vm, const WTF::Vector& frames, BunStackTrace& trace, JSC::JSGlobalObject* globalObject, PopulateStackTraceFlags flags, FinalizerSafety finalizerSafety = FinalizerSafety::NotInFinalizer) { if (flags == PopulateStackTraceFlags::OnlyPosition) { uint8_t frame_i = 0; @@ -437,7 +437,7 @@ static void populateStackTrace(JSC::VM& vm, const WTF::Vector& if (stack_frame_i >= total_frame_count) break; - ZigStackFrame& frame = trace.frames_ptr[frame_i]; + BunStackFrame& frame = trace.frames_ptr[frame_i]; frame.jsc_stack_frame_index = static_cast(stack_frame_i); populateStackFrame(vm, trace, frames[stack_frame_i], frame, frame_i == 0, &trace.referenced_source_provider, globalObject, flags, finalizerSafety); stack_frame_i++; @@ -446,7 +446,7 @@ static void populateStackTrace(JSC::VM& vm, const WTF::Vector& trace.frames_len = frame_i; } else if (flags == PopulateStackTraceFlags::OnlySourceLines) { for (uint8_t i = 0; i < trace.frames_len; i++) { - ZigStackFrame& frame = trace.frames_ptr[i]; + BunStackFrame& frame = trace.frames_ptr[i]; // A call with flags set to OnlySourceLines always follows a call with flags set to OnlyPosition, // so jsc_stack_frame_index is always a valid value here. ASSERT(frame.jsc_stack_frame_index >= 0); @@ -473,7 +473,7 @@ static JSC::JSValue getNonObservable(JSC::VM& vm, JSC::JSGlobalObject* global, J return {}; } -static void fromErrorInstance(ZigException& except, JSC::JSGlobalObject* global, +static void fromErrorInstance(BunException& except, JSC::JSGlobalObject* global, JSC::ErrorInstance* err, const Vector* stackTrace, JSC::JSValue val, PopulateStackTraceFlags flags) { @@ -618,9 +618,9 @@ static void fromErrorInstance(ZigException& except, JSC::JSGlobalObject* global, current.is_async = frame.isAsync; if (frame.isConstructor) { - current.code_type = ZigStackFrameCodeConstructor; + current.code_type = BunStackFrameCodeConstructor; } else if (frame.isGlobalCode) { - current.code_type = ZigStackFrameCodeGlobal; + current.code_type = BunStackFrameCodeGlobal; } except.stack.frames_len += 1; @@ -700,7 +700,7 @@ static void fromErrorInstance(ZigException& except, JSC::JSGlobalObject* global, } } -void exceptionFromString(ZigException& except, JSC::JSValue value, JSC::JSGlobalObject* global) +void exceptionFromString(BunException& except, JSC::JSValue value, JSC::JSGlobalObject* global) { auto& vm = JSC::getVM(global); if (vm.hasPendingTerminationException()) [[unlikely]] { @@ -828,12 +828,12 @@ void exceptionFromString(ZigException& except, JSC::JSValue value, JSC::JSGlobal except.message = Bun::toStringRef(str); } -extern "C" void JSC__Exception__getStackTrace(JSC::Exception* arg0, JSC::JSGlobalObject* global, ZigStackTrace* trace) +extern "C" void JSC__Exception__getStackTrace(JSC::Exception* arg0, JSC::JSGlobalObject* global, BunStackTrace* trace) { populateStackTrace(arg0->vm(), arg0->stack(), *trace, global, PopulateStackTraceFlags::OnlyPosition); } -extern "C" [[ZIG_EXPORT(check_slow)]] void JSC__JSValue__toZigException(JSC::EncodedJSValue jsException, JSC::JSGlobalObject* global, ZigException* exception) +extern "C" [[ZIG_EXPORT(check_slow)]] void JSC__JSValue__toBunException(JSC::EncodedJSValue jsException, JSC::JSGlobalObject* global, BunException* exception) { JSC::JSValue value = JSC::JSValue::decode(jsException); if (value == JSC::JSValue {}) { @@ -868,7 +868,7 @@ extern "C" [[ZIG_EXPORT(check_slow)]] void JSC__JSValue__toZigException(JSC::Enc exceptionFromString(*exception, value, global); } -extern "C" void ZigException__collectSourceLines(JSC::EncodedJSValue jsException, JSC::JSGlobalObject* global, ZigException* exception) +extern "C" void BunException__collectSourceLines(JSC::EncodedJSValue jsException, JSC::JSGlobalObject* global, BunException* exception) { JSC::JSValue value = JSC::JSValue::decode(jsException); if (value == JSC::JSValue {}) { diff --git a/src/jsc/bindings/ZigGeneratedCode.cpp b/src/jsc/bindings/BunGeneratedCode.cpp similarity index 100% rename from src/jsc/bindings/ZigGeneratedCode.cpp rename to src/jsc/bindings/BunGeneratedCode.cpp diff --git a/src/jsc/bindings/BunGlobalObject.cpp b/src/jsc/bindings/BunGlobalObject.cpp index 763b27878def..4fce06eea839 100644 --- a/src/jsc/bindings/BunGlobalObject.cpp +++ b/src/jsc/bindings/BunGlobalObject.cpp @@ -165,7 +165,7 @@ #include "webcrypto/JSCryptoKey.h" #include "webcrypto/JSSubtleCrypto.h" #include "ZigGeneratedClasses.h" -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include "UtilInspect.h" #include "Base64Helpers.h" #include "wtf/text/OrdinalNumber.h" @@ -2342,7 +2342,7 @@ void GlobalObject::finishCreation(VM& vm) m_NapiClassStructure.initLater( [](LazyClassStructure::Initializer& init) { - init.setStructure(Zig::NapiClass::createStructure(init.vm, init.global, init.global->functionPrototype())); + init.setStructure(Bun::NapiClass::createStructure(init.vm, init.global, init.global->functionPrototype())); }); m_JSArrayBufferControllerPrototype.initLater( @@ -2472,12 +2472,12 @@ void GlobalObject::finishCreation(VM& vm) m_importMetaObjectStructure.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(Zig::ImportMetaObject::createStructure(init.vm, init.owner)); + init.set(Bun::ImportMetaObject::createStructure(init.vm, init.owner)); }); m_importMetaBakeObjectStructure.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(Zig::ImportMetaObject::createStructure(init.vm, init.owner, true)); + init.set(Bun::ImportMetaObject::createStructure(init.vm, init.owner, true)); }); m_asyncBoundFunctionStructure.initLater( @@ -2605,7 +2605,7 @@ void GlobalObject::finishCreation(VM& vm) m_JSFFIFunctionStructure.initLater( [](LazyClassStructure::Initializer& init) { - init.setStructure(Zig::JSFFIFunction::createStructure(init.vm, init.global, init.global->functionPrototype())); + init.setStructure(Bun::JSFFIFunction::createStructure(init.vm, init.global, init.global->functionPrototype())); }); // Initialize LazyProperties for stdin/stderr/stdout @@ -3175,7 +3175,7 @@ extern "C" bool JSGlobalObject__setTimeZone(JSC::JSGlobalObject* globalObject, c { auto& vm = JSC::getVM(globalObject); - if (WTF::setTimeZoneOverride(Zig::toString(*timeZone))) { + if (WTF::setTimeZoneOverride(Bun::toString(*timeZone))) { vm.dateCache.resetIfNecessarySlow(); return true; } @@ -3659,7 +3659,7 @@ JSC::JSObject* GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObje JSModuleRecord* record, RefPtr) { - return Zig::ImportMetaObject::create(globalObject, key); + return Bun::ImportMetaObject::create(globalObject, key); } JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject* lexicalGlobalObject, @@ -3782,7 +3782,7 @@ void GlobalObject::instantiateStreaming(JSGlobalObject* globalObject, JSC::JSPro handleResponseOnStreamingAction(globalObject, promise, source, JSC::Wasm::CompilerMode::FullCompile, importObject, WTF::move(compileOptions)); } -GlobalObject::PromiseFunctions GlobalObject::promiseHandlerID(Zig::FFIFunction handler) +GlobalObject::PromiseFunctions GlobalObject::promiseHandlerID(Bun::FFIFunction handler) { if (handler == BunServe__onResolvePlugins) { return GlobalObject::PromiseFunctions::BunServe__Plugins__onResolve; diff --git a/src/jsc/bindings/BunGlobalObject.h b/src/jsc/bindings/BunGlobalObject.h index c52dad7af872..a13a6d3baf8c 100644 --- a/src/jsc/bindings/BunGlobalObject.h +++ b/src/jsc/bindings/BunGlobalObject.h @@ -91,12 +91,10 @@ extern "C" bool Bun__VirtualMachine__isShuttingDown(void* /* BunVM */); extern "C" uv_loop_t* Bun__GlobalObject__uvLoop(void* /* BunVM */); #endif -namespace Zig { -class JSCStackTrace; -} // namespace Zig - namespace Bun { +class JSCStackTrace; + using JSDOMStructureMap = UncheckedKeyHashMap>; using DOMGuardedObjectSet = UncheckedKeyHashSet; @@ -719,8 +717,8 @@ class GlobalObject : public Bun::GlobalScope { String agentClusterID() const; static String defaultAgentClusterID(); - Zig::BunPlugin::OnLoad onLoadPlugins {}; - Zig::BunPlugin::OnResolve onResolvePlugins {}; + Bun::BunPlugin::OnLoad onLoadPlugins {}; + Bun::BunPlugin::OnResolve onResolvePlugins {}; // This increases the cache hit rate for JSC::VM's SourceProvider cache // It also avoids an extra allocation for the SourceProvider diff --git a/src/jsc/bindings/ZigLazyStaticFunctions-inlines.h b/src/jsc/bindings/BunLazyStaticFunctions-inlines.h similarity index 96% rename from src/jsc/bindings/ZigLazyStaticFunctions-inlines.h rename to src/jsc/bindings/BunLazyStaticFunctions-inlines.h index 19ff293f93aa..d1a4c91b6a90 100644 --- a/src/jsc/bindings/ZigLazyStaticFunctions-inlines.h +++ b/src/jsc/bindings/BunLazyStaticFunctions-inlines.h @@ -1,7 +1,7 @@ // GENERATED FILE #pragma once -namespace Zig { +namespace Bun { /* -- BEGIN DOMCall DEFINITIONS -- */ @@ -30,4 +30,4 @@ static void DOMCall__FFI__ptr__put(JSC::JSGlobalObject* globalObject, JSC::Encod /* -- END DOMCall DEFINITIONS-- */ -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/ZigLazyStaticFunctions.h b/src/jsc/bindings/BunLazyStaticFunctions.h similarity index 90% rename from src/jsc/bindings/ZigLazyStaticFunctions.h rename to src/jsc/bindings/BunLazyStaticFunctions.h index 6c299e8491a5..42872c450734 100644 --- a/src/jsc/bindings/ZigLazyStaticFunctions.h +++ b/src/jsc/bindings/BunLazyStaticFunctions.h @@ -6,7 +6,7 @@ namespace Bun { class GlobalObject; } -namespace Zig { +namespace Bun { class JSFFIFunction; class LazyStaticFunctions { @@ -21,4 +21,4 @@ class LazyStaticFunctions { /* -- END FUNCTION DEFINITIONS-- */ }; -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/BunObject.cpp b/src/jsc/bindings/BunObject.cpp index 67c4b0e76424..d8787edd6d44 100644 --- a/src/jsc/bindings/BunObject.cpp +++ b/src/jsc/bindings/BunObject.cpp @@ -1185,7 +1185,7 @@ static void exportBunObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC: } // namespace Bun -namespace Zig { +namespace Bun { void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, @@ -1207,4 +1207,4 @@ void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject, Bun::exportBunObject(vm, globalObject, object, exportNames, exportValues); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/BunPlugin.cpp b/src/jsc/bindings/BunPlugin.cpp index 41bc06c10266..a75811162689 100644 --- a/src/jsc/bindings/BunPlugin.cpp +++ b/src/jsc/bindings/BunPlugin.cpp @@ -35,7 +35,7 @@ #include "AsyncContextFrame.h" #include "ImportMetaObject.h" -namespace Zig { +namespace Bun { extern "C" void Bun__onDidAppendPlugin(void* bunVM, JSGlobalObject* globalObject); using OnAppendPluginCallback = void (*)(void*, JSGlobalObject* globalObject); @@ -881,7 +881,7 @@ EncodedJSValue BunPlugin::OnResolve::run(JSC::JSGlobalObject* globalObject, BunS return JSValue::encode(JSC::jsUndefined()); } -} // namespace Zig +} // namespace Bun extern "C" JSC::EncodedJSValue Bun__runOnResolvePlugins(Bun::GlobalObject* globalObject, BunString* namespaceString, BunString* path, BunString* from, BunPluginTarget target) { @@ -897,7 +897,7 @@ namespace Bun { Structure* createModuleMockStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { - return Zig::JSModuleMock::createStructure(vm, globalObject, prototype); + return Bun::JSModuleMock::createStructure(vm, globalObject, prototype); } JSC::JSValue runVirtualModule(Bun::GlobalObject* globalObject, BunString* specifier, bool& wasModuleMock) @@ -919,7 +919,7 @@ JSC::JSValue runVirtualModule(Bun::GlobalObject* globalObject, BunString* specif JSValue result; - if (Zig::JSModuleMock* moduleMock = dynamicDowncast(function)) { + if (Bun::JSModuleMock* moduleMock = dynamicDowncast(function)) { wasModuleMock = true; // module mock result = moduleMock->executeOnce(globalObject); diff --git a/src/jsc/bindings/BunPlugin.h b/src/jsc/bindings/BunPlugin.h index b24823d5986a..6df95766e489 100644 --- a/src/jsc/bindings/BunPlugin.h +++ b/src/jsc/bindings/BunPlugin.h @@ -9,7 +9,7 @@ BUN_DECLARE_HOST_FUNCTION(jsFunctionBunPlugin); BUN_DECLARE_HOST_FUNCTION(jsFunctionBunPluginClear); -namespace Zig { +namespace Bun { using namespace JSC; @@ -99,7 +99,7 @@ class BunPlugin { }; }; -} // namespace Zig +} // namespace Bun namespace Bun { class GlobalObject; diff --git a/src/jsc/bindings/BunProcess.cpp b/src/jsc/bindings/BunProcess.cpp index c4242dbe2a18..28e3a17079cb 100644 --- a/src/jsc/bindings/BunProcess.cpp +++ b/src/jsc/bindings/BunProcess.cpp @@ -991,7 +991,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, (JSC::JSGlobalObject * globalObj Bun::V::validateString(scope, globalObject, value, "directory"_s); RETURN_IF_EXCEPTION(scope, {}); - ZigString str = Zig::toZigString(value.toWTFString(globalObject)); + ZigString str = Bun::toZigString(value.toWTFString(globalObject)); JSC::JSValue result = JSC::JSValue::decode(Bun__Process__setCwd(globalObject, &str)); RETURN_IF_EXCEPTION(scope, {}); diff --git a/src/jsc/bindings/ZigSourceProvider.cpp b/src/jsc/bindings/BunSourceProvider.cpp similarity index 98% rename from src/jsc/bindings/ZigSourceProvider.cpp rename to src/jsc/bindings/BunSourceProvider.cpp index f14c8607744e..ac2187088cb4 100644 --- a/src/jsc/bindings/ZigSourceProvider.cpp +++ b/src/jsc/bindings/BunSourceProvider.cpp @@ -2,7 +2,7 @@ #include "helpers.h" -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include "MimallocWTFMalloc.h" #include "BunAnalyzeTranspiledModule.h" @@ -18,7 +18,7 @@ #include #include -namespace Zig { +namespace Bun { using Base = JSC::SourceProvider; using BytecodeCacheGenerator = JSC::BytecodeCacheGenerator; @@ -176,7 +176,7 @@ SourceProvider::~SourceProvider() Bun__removeSourceProviderSourceMap(m_bunVM, this, &str); } if (m_resolvedSource.module_info != nullptr) { - zig__ModuleInfoDeserialized__deinit(static_cast(m_resolvedSource.module_info)); + bun__ModuleInfoDeserialized__deinit(static_cast(m_resolvedSource.module_info)); m_resolvedSource.module_info = nullptr; } // The Rust side hands these as +1 (RuntimeTranspilerStore::run_from_js_thread: @@ -404,9 +404,9 @@ int SourceProvider::readCache(JSC::VM& vm, const JSC::SourceCode& sourceCode) // } } -extern "C" BunString ZigSourceProvider__getSourceSlice(SourceProvider* provider) +extern "C" BunString BunSourceProvider__getSourceSlice(SourceProvider* provider) { return Bun::toStringView(provider->source()); } -}; // namespace Zig +}; // namespace Bun diff --git a/src/jsc/bindings/ZigSourceProvider.h b/src/jsc/bindings/BunSourceProvider.h similarity index 98% rename from src/jsc/bindings/ZigSourceProvider.h rename to src/jsc/bindings/BunSourceProvider.h index e394dfdbb753..c53d060613cb 100644 --- a/src/jsc/bindings/ZigSourceProvider.h +++ b/src/jsc/bindings/BunSourceProvider.h @@ -20,7 +20,7 @@ namespace Bun { class GlobalObject; } -namespace Zig { +namespace Bun { void forEachSourceProvider(WTF::Function); JSC::SourceID sourceIDForSourceURL(const WTF::String& sourceURL); @@ -81,4 +81,4 @@ class SourceProvider final : public JSC::SourceProvider { unsigned m_hash = 0; }; -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/BunString.cpp b/src/jsc/bindings/BunString.cpp index 836fa35a6aab..86cfe17dd8cd 100644 --- a/src/jsc/bindings/BunString.cpp +++ b/src/jsc/bindings/BunString.cpp @@ -189,11 +189,11 @@ JSC::JSString* toJS(JSC::JSGlobalObject* globalObject, BunString bunString) } if (bunString.tag == BunStringTag::StaticZigString) { - return JSC::jsString(globalObject->vm(), Zig::toStringStatic(bunString.impl.zig)); + return JSC::jsString(globalObject->vm(), Bun::toStringStatic(bunString.impl.zig)); } if (bunString.tag == BunStringTag::ZigString) { - return Zig::toJSStringGC(bunString.impl.zig, globalObject); + return Bun::toJSStringGC(bunString.impl.zig, globalObject); } UNREACHABLE(); @@ -549,14 +549,14 @@ extern "C" [[ZIG_EXPORT(nothrow)]] void BunString__toWTFString(BunString* bunStr { WTF::String str; if (bunString->tag == BunStringTag::ZigString) { - if (Zig::isTaggedExternalPtr(bunString->impl.zig.ptr)) { - str = Zig::toString(bunString->impl.zig); + if (Bun::isTaggedExternalPtr(bunString->impl.zig.ptr)) { + str = Bun::toString(bunString->impl.zig); } else { - str = Zig::toStringCopy(bunString->impl.zig); + str = Bun::toStringCopy(bunString->impl.zig); } } else if (bunString->tag == BunStringTag::StaticZigString) { - str = Zig::toStringStatic(bunString->impl.zig); + str = Bun::toStringStatic(bunString->impl.zig); } else { return; } @@ -776,13 +776,13 @@ size_t BunString::utf8ByteLength(const WTF::String& str) WTF::String BunString::toWTFString() const { if (this->tag == BunStringTag::ZigString) { - if (Zig::isTaggedExternalPtr(this->impl.zig.ptr)) { - return Zig::toString(this->impl.zig); + if (Bun::isTaggedExternalPtr(this->impl.zig.ptr)) { + return Bun::toString(this->impl.zig); } else { - return Zig::toStringCopy(this->impl.zig); + return Bun::toStringCopy(this->impl.zig); } } else if (this->tag == BunStringTag::StaticZigString) { - return Zig::toStringCopy(this->impl.zig); + return Bun::toStringCopy(this->impl.zig); } else if (this->tag == BunStringTag::WTFStringImpl) { return WTF::String(this->impl.wtf); } @@ -798,7 +798,7 @@ void BunString::appendToBuilder(WTF::StringBuilder& builder) const } if (this->tag == BunStringTag::ZigString || this->tag == BunStringTag::StaticZigString) { - Zig::appendToBuilder(this->impl.zig, builder); + Bun::appendToBuilder(this->impl.zig, builder); return; } @@ -808,13 +808,13 @@ void BunString::appendToBuilder(WTF::StringBuilder& builder) const WTF::String BunString::toWTFString(ZeroCopyTag) const { if (this->tag == BunStringTag::ZigString) { - if (Zig::isTaggedUTF8Ptr(this->impl.zig.ptr)) { - return Zig::toStringCopy(this->impl.zig); + if (Bun::isTaggedUTF8Ptr(this->impl.zig.ptr)) { + return Bun::toStringCopy(this->impl.zig); } else { - return Zig::toString(this->impl.zig); + return Bun::toString(this->impl.zig); } } else if (this->tag == BunStringTag::StaticZigString) { - return Zig::toStringStatic(this->impl.zig); + return Bun::toStringStatic(this->impl.zig); } else if (this->tag == BunStringTag::WTFStringImpl) { ASSERT(this->impl.wtf->refCount() > 0 && !this->impl.wtf->isEmpty()); return WTF::String(this->impl.wtf); @@ -837,25 +837,25 @@ WTF::String BunString::toWTFString(NonNullTag) const WTF::String BunString::transferToWTFString() { if (this->tag == BunStringTag::ZigString) { - if (Zig::isTaggedUTF8Ptr(this->impl.zig.ptr)) { - auto str = Zig::toStringCopy(this->impl.zig); - *this = Zig::BunStringEmpty; + if (Bun::isTaggedUTF8Ptr(this->impl.zig.ptr)) { + auto str = Bun::toStringCopy(this->impl.zig); + *this = Bun::BunStringEmpty; return str; } else { - auto str = Zig::toString(this->impl.zig); - *this = Zig::BunStringEmpty; + auto str = Bun::toString(this->impl.zig); + *this = Bun::BunStringEmpty; return str; } } else if (this->tag == BunStringTag::StaticZigString) { - auto str = Zig::toStringStatic(this->impl.zig); - *this = Zig::BunStringEmpty; + auto str = Bun::toStringStatic(this->impl.zig); + *this = Bun::BunStringEmpty; return str; } else if (this->tag == BunStringTag::WTFStringImpl) { ASSERT(this->impl.wtf->refCount() > 0 && !this->impl.wtf->isEmpty()); auto str = WTF::String(this->impl.wtf); this->impl.wtf->deref(); - *this = Zig::BunStringEmpty; + *this = Bun::BunStringEmpty; return str; } diff --git a/src/jsc/bindings/CallSite.cpp b/src/jsc/bindings/CallSite.cpp index fbae0b2099af..80ca6b39e7d4 100644 --- a/src/jsc/bindings/CallSite.cpp +++ b/src/jsc/bindings/CallSite.cpp @@ -16,7 +16,7 @@ using namespace JSC; using namespace WebCore; -namespace Zig { +namespace Bun { const JSC::ClassInfo CallSite::s_info = { "CallSite"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(CallSite) }; diff --git a/src/jsc/bindings/CallSite.h b/src/jsc/bindings/CallSite.h index aa3345514c3d..58e95672135e 100644 --- a/src/jsc/bindings/CallSite.h +++ b/src/jsc/bindings/CallSite.h @@ -14,7 +14,7 @@ using namespace JSC; using namespace WebCore; -namespace Zig { +namespace Bun { class JSCStackFrame; diff --git a/src/jsc/bindings/CallSitePrototype.cpp b/src/jsc/bindings/CallSitePrototype.cpp index 5a537ecccb62..b3e277b88657 100644 --- a/src/jsc/bindings/CallSitePrototype.cpp +++ b/src/jsc/bindings/CallSitePrototype.cpp @@ -17,7 +17,7 @@ #include using namespace JSC; -namespace Zig { +namespace Bun { JSC_DECLARE_HOST_FUNCTION(callSiteProtoFuncGetThis); JSC_DECLARE_HOST_FUNCTION(callSiteProtoFuncGetTypeName); diff --git a/src/jsc/bindings/CallSitePrototype.h b/src/jsc/bindings/CallSitePrototype.h index 503076399085..6bf6770ba459 100644 --- a/src/jsc/bindings/CallSitePrototype.h +++ b/src/jsc/bindings/CallSitePrototype.h @@ -9,7 +9,7 @@ using namespace JSC; -namespace Zig { +namespace Bun { class CallSitePrototype final : public JSC::JSNonFinalObject { public: diff --git a/src/jsc/bindings/CodeCoverage.cpp b/src/jsc/bindings/CodeCoverage.cpp index 51ea142f9e4e..d7b305dc1d0a 100644 --- a/src/jsc/bindings/CodeCoverage.cpp +++ b/src/jsc/bindings/CodeCoverage.cpp @@ -1,5 +1,5 @@ #include "root.h" -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include using namespace JSC; diff --git a/src/jsc/bindings/ConsoleObject.h b/src/jsc/bindings/ConsoleObject.h index 52032f44c36b..cd87bab6b0ae 100644 --- a/src/jsc/bindings/ConsoleObject.h +++ b/src/jsc/bindings/ConsoleObject.h @@ -69,4 +69,4 @@ class ConsoleObject final : public JSC::ConsoleClient { bool m_profileRestoreBreakpointActiveValue { false }; }; -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/ErrorCode.cpp b/src/jsc/bindings/ErrorCode.cpp index e9c12541a77d..8f07f863d820 100644 --- a/src/jsc/bindings/ErrorCode.cpp +++ b/src/jsc/bindings/ErrorCode.cpp @@ -251,7 +251,7 @@ JSObject* createError(JSC::JSGlobalObject* globalObject, ErrorCode code, const S return createError(globalObject->vm(), globalObject, code, message); } -JSObject* createError(Zig::JSGlobalObject* globalObject, ErrorCode code, JSC::JSValue message) +JSObject* createError(Bun::JSGlobalObject* globalObject, ErrorCode code, JSC::JSValue message) { auto& vm = JSC::getVM(globalObject); return createError(vm, globalObject, code, message); @@ -321,7 +321,7 @@ void JSValueToStringSafe(JSC::JSGlobalObject* globalObject, WTF::StringBuilder& case JSC::JSType::InternalFunctionType: case JSC::JSType::JSFunctionType: { auto& vm = JSC::getVM(globalObject); - auto name = Zig::functionName(vm, globalObject, cell->getObject()); + auto name = Bun::functionName(vm, globalObject, cell->getObject()); if (!name.isEmpty()) { builder.append("[Function: "_s); @@ -400,7 +400,7 @@ void determineSpecificType(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WTF:: } if (cell->isCallable()) { builder.append("function "_s); - auto name = Zig::functionName(vm, globalObject, cell->getObject()); + auto name = Bun::functionName(vm, globalObject, cell->getObject()); if (!name.isEmpty()) { builder.append(name); diff --git a/src/jsc/bindings/ErrorStackFrame.cpp b/src/jsc/bindings/ErrorStackFrame.cpp index 806a340be246..f7e240f31238 100644 --- a/src/jsc/bindings/ErrorStackFrame.cpp +++ b/src/jsc/bindings/ErrorStackFrame.cpp @@ -8,10 +8,10 @@ namespace Bun { using namespace JSC; -/// Adjust a `ZigStackFramePosition` by a number of bytes. This accounts for when the adjustment +/// Adjust a `BunStackFramePosition` by a number of bytes. This accounts for when the adjustment /// crosses line boundaries, and thus requires the source code in order to properly compute /// the result. -void adjustPositionBackwards(ZigStackFramePosition& pos, int amount, CodeBlock* code) +void adjustPositionBackwards(BunStackFramePosition& pos, int amount, CodeBlock* code) { if (pos.byte_position - amount < 0) { pos.line_zero_based = 0; @@ -62,11 +62,11 @@ void adjustPositionBackwards(ZigStackFramePosition& pos, int amount, CodeBlock* pos.byte_position -= amount; } -ZigStackFramePosition getAdjustedPositionForBytecode(JSC::CodeBlock* code, JSC::BytecodeIndex bc) +BunStackFramePosition getAdjustedPositionForBytecode(JSC::CodeBlock* code, JSC::BytecodeIndex bc) { auto expr = code->expressionInfoForBytecodeIndex(bc); - ZigStackFramePosition pos { + BunStackFramePosition pos { .line_zero_based = OrdinalNumber::fromOneBasedInt(expr.lineColumn.line).zeroBasedInt(), .column_zero_based = OrdinalNumber::fromOneBasedInt(expr.lineColumn.column).zeroBasedInt(), .byte_position = (int)expr.divot, diff --git a/src/jsc/bindings/ErrorStackFrame.h b/src/jsc/bindings/ErrorStackFrame.h index d7a04e83d6cd..4fd026f83bd6 100644 --- a/src/jsc/bindings/ErrorStackFrame.h +++ b/src/jsc/bindings/ErrorStackFrame.h @@ -4,6 +4,6 @@ namespace Bun { -ZigStackFramePosition getAdjustedPositionForBytecode(JSC::CodeBlock* code, JSC::BytecodeIndex bc); +BunStackFramePosition getAdjustedPositionForBytecode(JSC::CodeBlock* code, JSC::BytecodeIndex bc); } // namespace Bun diff --git a/src/jsc/bindings/ErrorStackTrace.cpp b/src/jsc/bindings/ErrorStackTrace.cpp index 96da90877070..549670aab3cb 100644 --- a/src/jsc/bindings/ErrorStackTrace.cpp +++ b/src/jsc/bindings/ErrorStackTrace.cpp @@ -29,7 +29,7 @@ using namespace JSC; using namespace WebCore; -namespace Zig { +namespace Bun { static ImplementationVisibility getImplementationVisibility(JSC::CodeBlock* codeBlock) { @@ -152,13 +152,13 @@ void JSCStackTrace::getFramesForCaller(JSC::VM& vm, JSC::CallFrame* callFrame, J JSC::JSObject* callerObject = caller.getObject(); auto* globalObject = callerObject->globalObject(); - WTF::String callerName = Zig::functionName(vm, globalObject, callerObject); + WTF::String callerName = Bun::functionName(vm, globalObject, callerObject); // Match V8: remove all frames up to and including the caller. If the caller // is not found anywhere in the sync portion of the stack, remove everything. // We match by cell identity first, then by name — name matching is needed // because a resumed async function's frame callee is the generator's `next` - // function (a different cell) but Zig::functionName still reports the + // function (a different cell) but Bun::functionName still reports the // original async function's name. size_t removeCount = stackTrace.size(); for (size_t i = 0; i < stackTrace.size(); i++) { @@ -169,7 +169,7 @@ void JSCStackTrace::getFramesForCaller(JSC::VM& vm, JSC::CallFrame* callFrame, J removeCount = i + 1; break; } - if (!callerName.isEmpty() && Zig::functionName(vm, globalObject, frame, FinalizerSafety::NotInFinalizer, nullptr) == callerName) { + if (!callerName.isEmpty() && Bun::functionName(vm, globalObject, frame, FinalizerSafety::NotInFinalizer, nullptr) == callerName) { removeCount = i + 1; break; } @@ -210,7 +210,7 @@ static bool isVisibleBuiltinFunction(JSC::CodeBlock* codeBlock) } const JSC::SourceCode& source = codeBlock->source(); - return !Zig::sourceURL(source).isEmpty(); + return !Bun::sourceURL(source).isEmpty(); } JSCStackFrame::JSCStackFrame(JSC::VM& vm, JSC::StackVisitor& visitor) @@ -351,14 +351,14 @@ ALWAYS_INLINE String JSCStackFrame::retrieveSourceURL() return String(sourceURLWasmString); } - auto url = Zig::sourceURL(m_codeBlock); + auto url = Bun::sourceURL(m_codeBlock); if (!url.isEmpty()) { return url; } if (m_callee && m_callee->isObject()) { if (auto* jsFunction = dynamicDowncast(m_callee)) { - WTF::String url = Zig::sourceURL(m_vm, jsFunction); + WTF::String url = Bun::sourceURL(m_vm, jsFunction); if (!url.isEmpty()) { return url; } @@ -393,12 +393,12 @@ ALWAYS_INLINE String JSCStackFrame::retrieveFunctionName() if (m_callee) { auto* calleeObject = m_callee->getObject(); if (calleeObject) { - return Zig::functionName(m_vm, calleeObject->globalObject(), calleeObject); + return Bun::functionName(m_vm, calleeObject->globalObject(), calleeObject); } } if (m_codeBlock) { - auto functionName = Zig::functionName(m_vm, m_codeBlock); + auto functionName = Bun::functionName(m_vm, m_codeBlock); if (!functionName.isEmpty()) { return functionName; } @@ -480,7 +480,7 @@ String sourceURL(JSC::CodeBlock* codeBlock) return String(); } - return Zig::sourceURL(*codeBlock); + return Bun::sourceURL(*codeBlock); } String sourceURL(JSC::VM& vm, const JSC::StackFrame& frame) @@ -526,7 +526,7 @@ String sourceURL(JSC::VM& vm, JSC::JSFunction* function) return String(); } - return Zig::sourceURL(jsExecutable->source()); + return Bun::sourceURL(jsExecutable->source()); } String functionName(JSC::VM& vm, JSC::CodeBlock* codeBlock) @@ -705,7 +705,7 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, const } if (auto* callee = frame.callee()) { if (auto* object = callee->getObject()) { - functionName = Zig::functionName(vm, lexicalGlobalObject, object); + functionName = Bun::functionName(vm, lexicalGlobalObject, object); if (flags) { if (auto* unlinkedCodeBlock = codeblock->unlinkedCodeBlock()) { @@ -724,13 +724,13 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, const } if (functionName.isEmpty()) { - functionName = Zig::functionName(vm, codeblock); + functionName = Bun::functionName(vm, codeblock); } } } else { if (auto* callee = frame.callee()) { if (auto* object = callee->getObject()) { - functionName = Zig::functionName(vm, lexicalGlobalObject, object); + functionName = Bun::functionName(vm, lexicalGlobalObject, object); } } } diff --git a/src/jsc/bindings/ErrorStackTrace.h b/src/jsc/bindings/ErrorStackTrace.h index 0a7894244092..e2c024952529 100644 --- a/src/jsc/bindings/ErrorStackTrace.h +++ b/src/jsc/bindings/ErrorStackTrace.h @@ -14,7 +14,7 @@ using namespace JSC; using namespace WebCore; -namespace Zig { +namespace Bun { /* JSCStackFrame is an alternative to JSC::StackFrame, which provides the following advantages\changes: * - Also hold the call frame (ExecState). This is mainly used by CallSite to get "this value". diff --git a/src/jsc/bindings/FormatStackTraceForJS.cpp b/src/jsc/bindings/FormatStackTraceForJS.cpp index f2c1b4e149fd..ed79d17acf72 100644 --- a/src/jsc/bindings/FormatStackTraceForJS.cpp +++ b/src/jsc/bindings/FormatStackTraceForJS.cpp @@ -181,8 +181,8 @@ WTF::String formatStackTrace( // "".test(/[a-0]/); auto originalLine = WTF::OrdinalNumber::fromOneBasedInt(err->line()); - ZigStackFrame remappedFrame = {}; - memset(&remappedFrame, 0, sizeof(ZigStackFrame)); + BunStackFrame remappedFrame = {}; + memset(&remappedFrame, 0, sizeof(BunStackFrame)); remappedFrame.position.line_zero_based = originalLine.zeroBasedInt(); remappedFrame.position.column_zero_based = 0; @@ -238,19 +238,19 @@ WTF::String formatStackTrace( // Pass 1: collect (line, col, source_url) for frames that should be // source-mapped, then batch the remap so the Rust side can resolve each // file's map once instead of per frame. - WTF::Vector remappedFrames; + WTF::Vector remappedFrames; WTF::Vector sourceURLs; WTF::Vector originalLineColumns; remappedFrames.grow(framesCount); - memset(remappedFrames.begin(), 0, sizeof(ZigStackFrame) * framesCount); + memset(remappedFrames.begin(), 0, sizeof(BunStackFrame) * framesCount); sourceURLs.grow(framesCount); originalLineColumns.grow(framesCount); bool anyRemap = false; for (size_t i = 0; i < framesCount; i++) { StackFrame& frame = stackTrace.at(i); - ZigStackFrame& remappedFrame = remappedFrames[i]; - // Match `ZigStackFramePosition::INVALID` exactly so the Rust batch loop's + BunStackFrame& remappedFrame = remappedFrames[i]; + // Match `BunStackFramePosition::INVALID` exactly so the Rust batch loop's // `position.isInvalid()` skips frames we never populate (vm-context // frames, frames without line/col info). memset alone leaves // `line_start_byte = 0` which fails that byte-compare. @@ -270,7 +270,7 @@ WTF::String formatStackTrace( } } - sourceURLs[i] = Zig::sourceURL(vm, frame); + sourceURLs[i] = Bun::sourceURL(vm, frame); bool isDefinitelyNotRunninginNodeVMGlobalObject = globalObject == globalObjectForFrame; bool isDefaultGlobalObjectInAFinalizer = (globalObject && !lexicalGlobalObject && !errorInstance); @@ -293,7 +293,7 @@ WTF::String formatStackTrace( // re-derived from `frame`; only the remap output is read from pass 1. for (size_t i = 0; i < framesCount; i++) { StackFrame& frame = stackTrace.at(i); - ZigStackFrame& remappedFrame = remappedFrames[i]; + BunStackFrame& remappedFrame = remappedFrames[i]; unsigned int flags = static_cast(FunctionNameFlags::AddNewKeyword); JSC::JSGlobalObject* globalObjectForFrame = lexicalGlobalObject; @@ -305,7 +305,7 @@ WTF::String formatStackTrace( } } - WTF::String functionName = Zig::functionName(vm, globalObjectForFrame, frame, errorInstance ? Zig::FinalizerSafety::NotInFinalizer : Zig::FinalizerSafety::MustNotTriggerGC, &flags); + WTF::String functionName = Bun::functionName(vm, globalObjectForFrame, frame, errorInstance ? Bun::FinalizerSafety::NotInFinalizer : Bun::FinalizerSafety::MustNotTriggerGC, &flags); OrdinalNumber originalLine = {}; OrdinalNumber originalColumn = {}; OrdinalNumber displayLine = {}; @@ -435,24 +435,24 @@ static JSValue computeErrorInfoWithPrepareStackTrace(JSC::VM& vm, Bun::GlobalObj MarkedArgumentBuffer callSites; // Create the call sites (one per frame) - Zig::createCallSitesFromFrames(globalObject, lexicalGlobalObject, stackTrace, callSites); + Bun::createCallSitesFromFrames(globalObject, lexicalGlobalObject, stackTrace, callSites); // We need to sourcemap it if it's a GlobalObject. const int n = stackTrace.size(); - WTF::Vector remappedFrames; + WTF::Vector remappedFrames; WTF::Vector sourceURLs; WTF::Vector didRemap; remappedFrames.grow(n); - memset(remappedFrames.begin(), 0, sizeof(ZigStackFrame) * n); + memset(remappedFrames.begin(), 0, sizeof(BunStackFrame) * n); sourceURLs.grow(n); didRemap.grow(n); bool anyRemap = false; for (int i = 0; i < n; i++) { - ZigStackFrame& frame = remappedFrames[i]; + BunStackFrame& frame = remappedFrames[i]; auto& stackFrame = stackFrames.at(i); - sourceURLs[i] = Zig::sourceURL(vm, stackFrame); + sourceURLs[i] = Bun::sourceURL(vm, stackFrame); didRemap[i] = false; frame.position.line_zero_based = -1; frame.position.column_zero_based = -1; @@ -493,7 +493,7 @@ static JSValue computeErrorInfoWithPrepareStackTrace(JSC::VM& vm, Bun::GlobalObj } for (int i = 0; i < n; i++) { - ZigStackFrame& frame = remappedFrames[i]; + BunStackFrame& frame = remappedFrames[i]; WTF::String sourceURLForFrame = didRemap[i] ? frame.source_url.toWTFString() : sourceURLs[i]; auto* callsite = uncheckedDowncast(callSites.at(i)); @@ -604,7 +604,7 @@ void computeLineColumnWithSourcemap(JSC::VM& vm, JSC::SourceProvider* _Nonnull s OrdinalNumber line = OrdinalNumber::fromOneBasedInt(lineColumn.line); OrdinalNumber column = OrdinalNumber::fromOneBasedInt(lineColumn.column); - ZigStackFrame frame = {}; + BunStackFrame frame = {}; frame.position.line_zero_based = line.zeroBasedInt(); frame.position.column_zero_based = column.zeroBasedInt(); frame.source_url = Bun::toStringRef(sourceURL); @@ -796,7 +796,7 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb } // namespace Bun -namespace Zig { +namespace Bun { void createCallSitesFromFrames(Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSCStackTrace& stackTrace, MarkedArgumentBuffer& callSites) { @@ -822,4 +822,4 @@ void createCallSitesFromFrames(Bun::GlobalObject* globalObject, JSC::JSGlobalObj } } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/FormatStackTraceForJS.h b/src/jsc/bindings/FormatStackTraceForJS.h index 5745cd5a77a7..1af1256d7a28 100644 --- a/src/jsc/bindings/FormatStackTraceForJS.h +++ b/src/jsc/bindings/FormatStackTraceForJS.h @@ -44,11 +44,8 @@ class String; class OrdinalNumber; } // namespace WTF -namespace Zig { -class JSCStackTrace; -} // namespace Zig - namespace Bun { +class JSCStackTrace; class GlobalObject; } // namespace Bun @@ -88,13 +85,13 @@ JSC::JSValue computeErrorInfoWrapperToJSValue(JSC::VM& vm, WTF::VectorreportReload(); } -void Bun__LifecycleAgentReportError(Inspector::InspectorLifecycleAgent* agent, ZigException* exception) +void Bun__LifecycleAgentReportError(Inspector::InspectorLifecycleAgent* agent, BunException* exception) { ASSERT(exception); ASSERT(agent); @@ -100,7 +100,7 @@ void InspectorLifecycleAgent::reportReload() m_frontendDispatcher->reload(); } -void InspectorLifecycleAgent::reportError(ZigException& exception) +void InspectorLifecycleAgent::reportError(BunException& exception) { if (!m_enabled) return; @@ -117,7 +117,7 @@ void InspectorLifecycleAgent::reportError(ZigException& exception) } for (size_t i = 0; i < exception.stack.frames_len; i++) { - ZigStackFrame* frame = &exception.stack.frames_ptr[i]; + BunStackFrame* frame = &exception.stack.frames_ptr[i]; lineColumns->addItem(frame->position.line_zero_based + 1); lineColumns->addItem(frame->position.column_zero_based + 1); urls->addItem(frame->source_url.toWTFString()); diff --git a/src/jsc/bindings/InspectorLifecycleAgent.h b/src/jsc/bindings/InspectorLifecycleAgent.h index d598e7013b6f..06e515dcb9ae 100644 --- a/src/jsc/bindings/InspectorLifecycleAgent.h +++ b/src/jsc/bindings/InspectorLifecycleAgent.h @@ -36,7 +36,7 @@ class InspectorLifecycleAgent final : public InspectorAgentBase, public Inspecto // Public API void reportReload(); - void reportError(ZigException&); + void reportError(BunException&); Protocol::ErrorStringOr preventExit(); Protocol::ErrorStringOr stopPreventingExit(); diff --git a/src/jsc/bindings/InspectorTestReporterAgent.cpp b/src/jsc/bindings/InspectorTestReporterAgent.cpp index 0c2e655606ad..6a90402f32da 100644 --- a/src/jsc/bindings/InspectorTestReporterAgent.cpp +++ b/src/jsc/bindings/InspectorTestReporterAgent.cpp @@ -168,19 +168,19 @@ void InspectorTestReporterAgent::reportTestFound(JSC::CallFrame* callFrame, int JSC::SourceID sourceID = 0; String sourceURL; - ZigStackFrame remappedFrame = {}; + BunStackFrame remappedFrame = {}; auto* globalObject = &m_globalObject; auto& vm = JSC::getVM(globalObject); JSC::StackVisitor::visit(callFrame, vm, [&](JSC::StackVisitor& visitor) -> WTF::IterationStatus { - if (Zig::isImplementationVisibilityPrivate(visitor)) + if (Bun::isImplementationVisibilityPrivate(visitor)) return WTF::IterationStatus::Continue; if (visitor->hasLineAndColumnInfo()) { lineColumn = visitor->computeLineAndColumn(); - String sourceURLForFrame = Zig::sourceURL(visitor); + String sourceURLForFrame = Bun::sourceURL(visitor); // Sometimes, the sourceURL is empty. // For example, pages in Next.js. diff --git a/src/jsc/bindings/IsolatedModuleCache.cpp b/src/jsc/bindings/IsolatedModuleCache.cpp index a99c27b8dee5..e01fe779b6c9 100644 --- a/src/jsc/bindings/IsolatedModuleCache.cpp +++ b/src/jsc/bindings/IsolatedModuleCache.cpp @@ -1,8 +1,8 @@ #include "IsolatedModuleCache.h" #include "BunClientData.h" #include "ModuleLoader.h" -#include "ZigGlobalObject.h" -#include "ZigSourceProvider.h" +#include "BunGlobalObject.h" +#include "BunSourceProvider.h" #include "JavaScriptCore/JSCInlines.h" #include @@ -19,17 +19,17 @@ bool IsolatedModuleCache::canUse(JSC::VM&, void* bunVM, const BunString* typeAtt return true; } -Zig::SourceProvider* IsolatedModuleCache::lookup(JSC::VM& vm, const WTF::String& key) +Bun::SourceProvider* IsolatedModuleCache::lookup(JSC::VM& vm, const WTF::String& key) { auto& cache = WebCore::clientData(vm)->isolationSourceProviderCache; auto it = cache.find(key); if (it == cache.end()) return nullptr; ASSERT(it->value); - return static_cast(it->value.get()); + return static_cast(it->value.get()); } -void IsolatedModuleCache::insert(JSC::VM& vm, const WTF::String& key, Zig::SourceProvider& provider) +void IsolatedModuleCache::insert(JSC::VM& vm, const WTF::String& key, Bun::SourceProvider& provider) { if (!isTagCacheable(static_cast(provider.m_resolvedSource.tag))) return; diff --git a/src/jsc/bindings/IsolatedModuleCache.h b/src/jsc/bindings/IsolatedModuleCache.h index bfe618a84cd4..c9d65f56ed77 100644 --- a/src/jsc/bindings/IsolatedModuleCache.h +++ b/src/jsc/bindings/IsolatedModuleCache.h @@ -3,14 +3,14 @@ #include "root.h" #include "headers-handwritten.h" -namespace Zig { +namespace Bun { class GlobalObject; class SourceProvider; } namespace Bun { -// Per-VM cache mapping resolved specifier (absolute path) → Zig::SourceProvider, +// Per-VM cache mapping resolved specifier (absolute path) → Bun::SourceProvider, // populated only under `bun test --isolate`. Survives global swaps so a fresh // global's module fetch reuses an already-transpiled provider (and hits JSC's // CodeCache + Bun__analyzeTranspiledModule for module_info) instead of @@ -18,7 +18,7 @@ namespace Bun { // // Storage lives on JSVMClientData; this class is a stateless facade so the // gating, key, and tag-cacheability decisions live in exactly one place. The -// map stores Zig::SourceProvider directly (not a wrapper struct) — everything +// map stores Bun::SourceProvider directly (not a wrapper struct) — everything // callers need to branch on (sourceType(), m_resolvedSource.tag, module_info) // already lives on the provider. class IsolatedModuleCache { @@ -49,12 +49,12 @@ class IsolatedModuleCache { } } - static Zig::SourceProvider* lookup(JSC::VM&, const WTF::String& key); + static Bun::SourceProvider* lookup(JSC::VM&, const WTF::String& key); // Inserts only when isTagCacheable(provider.m_resolvedSource.tag); no-op // otherwise. Asserts isNewEntry — a duplicate insert means a lookup was // bypassed, which is exactly the gating bug this consolidation prevents. - static void insert(JSC::VM&, const WTF::String& key, Zig::SourceProvider&); + static void insert(JSC::VM&, const WTF::String& key, Bun::SourceProvider&); static void evict(JSC::VM&, const WTF::String& key); static void clear(JSC::VM&); diff --git a/src/jsc/bindings/JSBuffer.cpp b/src/jsc/bindings/JSBuffer.cpp index b468e38e3908..d6f9ce98f003 100644 --- a/src/jsc/bindings/JSBuffer.cpp +++ b/src/jsc/bindings/JSBuffer.cpp @@ -673,7 +673,7 @@ static JSC::EncodedJSValue jsBufferConstructorFunction_allocBody(JSC::JSGlobalOb RELEASE_AND_RETURN(scope, JSC::JSValue::encode(uint8Array)); } - ZigString str = Zig::toZigString(view); + ZigString str = Bun::toZigString(view); if (!Bun__Buffer_fill(&str, startPtr, end - start, encoding)) [[unlikely]] { return Bun::ERR::INVALID_ARG_VALUE(scope, lexicalGlobalObject, "value"_s, value); @@ -1446,7 +1446,7 @@ static JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlobalObjec switch (branch) { case StringBranch: { - ZigString str = Zig::toZigString(stringValue); + ZigString str = Bun::toZigString(stringValue); if (str.len == 0) { memset(startPtr, 0, span); } else if (!Bun__Buffer_fill(&str, startPtr, span, encoding)) [[unlikely]] { diff --git a/src/jsc/bindings/JSBufferList.cpp b/src/jsc/bindings/JSBufferList.cpp index 163458ca16aa..4f3c571de22b 100644 --- a/src/jsc/bindings/JSBufferList.cpp +++ b/src/jsc/bindings/JSBufferList.cpp @@ -467,4 +467,4 @@ JSValue getBufferList(Bun::GlobalObject* globalObject) return static_cast(globalObject)->JSBufferList(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/JSBundlerPlugin.h b/src/jsc/bindings/JSBundlerPlugin.h index 49ab97f1564e..dc0c8386aa45 100644 --- a/src/jsc/bindings/JSBundlerPlugin.h +++ b/src/jsc/bindings/JSBundlerPlugin.h @@ -144,4 +144,4 @@ class BundlerPlugin final { bool tombstoned { false }; }; -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/JSCommonJSModule.cpp b/src/jsc/bindings/JSCommonJSModule.cpp index 8687516e7120..e12121688470 100644 --- a/src/jsc/bindings/JSCommonJSModule.cpp +++ b/src/jsc/bindings/JSCommonJSModule.cpp @@ -67,7 +67,7 @@ #include #include -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include #include "JSCommonJSModule.h" #include @@ -201,7 +201,7 @@ static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Bun::GlobalObject* globalObj if (auto* jsFunction = dynamicDowncast(fn)) { if (jsFunction->jsExecutable()->parameterCount() > 5) { // it expects ImportMetaObject - args.append(Zig::ImportMetaObject::create(globalObject, filename)); + args.append(Bun::ImportMetaObject::create(globalObject, filename)); } } @@ -1373,7 +1373,7 @@ void JSCommonJSModule::evaluate( } } - auto sourceProvider = Zig::SourceProvider::create(globalObject, source, JSC::SourceProviderSourceType::Program, isBuiltIn); + auto sourceProvider = Bun::SourceProvider::create(globalObject, source, JSC::SourceProviderSourceType::Program, isBuiltIn); this->ignoreESModuleAnnotation = source.tag == ResolvedSourceTagPackageJSONTypeModule; if (!isBuiltIn && !globalObject->hasOverriddenModuleWrapper && Bun::IsolatedModuleCache::canUse(vm, globalObject->bunVM())) { Bun::IsolatedModuleCache::insert(vm, key, sourceProvider.get()); @@ -1492,7 +1492,7 @@ std::optional createCommonJSModule( source.source_code = Bun::toStringRef(concat); } - auto sourceProvider = Zig::SourceProvider::create(globalObject, source, JSC::SourceProviderSourceType::Program, isBuiltIn); + auto sourceProvider = Bun::SourceProvider::create(globalObject, source, JSC::SourceProviderSourceType::Program, isBuiltIn); if (!isBuiltIn && !globalObject->hasOverriddenModuleWrapper && Bun::IsolatedModuleCache::canUse(vm, globalObject->bunVM())) { Bun::IsolatedModuleCache::insert(vm, sourceURL, sourceProvider.get()); } @@ -1509,7 +1509,7 @@ std::optional createCommonJSModule( requireMap->set(globalObject, filename, moduleObject); RETURN_IF_EXCEPTION(scope, {}); } else { - sourceOrigin = Zig::toSourceOrigin(sourceURL, isBuiltIn); + sourceOrigin = Bun::toSourceOrigin(sourceURL, isBuiltIn); } moduleObject->ignoreESModuleAnnotation = ignoreESModuleAnnotation; diff --git a/src/jsc/bindings/JSDOMWrapper.h b/src/jsc/bindings/JSDOMWrapper.h index 90437619ed53..10ce4d7ac134 100644 --- a/src/jsc/bindings/JSDOMWrapper.h +++ b/src/jsc/bindings/JSDOMWrapper.h @@ -29,7 +29,7 @@ #include namespace WebCore { -using namespace Zig; +using namespace Bun; #ifndef RENAMED_JSDOM_GLOBAL_OBJECT #define RENAMED_JSDOM_GLOBAL_OBJECT using JSDOMGlobalObject = Bun::GlobalObject; diff --git a/src/jsc/bindings/JSEnvironmentVariableMap.cpp b/src/jsc/bindings/JSEnvironmentVariableMap.cpp index 3830a96ec93e..b915b09b800a 100644 --- a/src/jsc/bindings/JSEnvironmentVariableMap.cpp +++ b/src/jsc/bindings/JSEnvironmentVariableMap.cpp @@ -47,7 +47,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsGetterEnvironmentVariable, (JSGlobalObject * globalOb return JSValue::encode(jsUndefined()); } - JSValue result = jsString(vm, Zig::toStringCopy(value)); + JSValue result = jsString(vm, Bun::toStringCopy(value)); thisObject->putDirect(vm, propertyName, result, 0); return JSValue::encode(result); } @@ -153,7 +153,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsTimeZoneEnvironmentVariableGetter, (JSGlobalObject * return JSValue::encode(jsUndefined()); } - JSValue out = jsString(vm, Zig::toStringCopy(value)); + JSValue out = jsString(vm, Bun::toStringCopy(value)); thisObject->putDirect(vm, clientData->builtinNames().dataPrivateName(), out, 0); return JSValue::encode(out); @@ -235,7 +235,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsNodeTLSRejectUnauthorizedGetter, (JSGlobalObject * gl return JSValue::encode(jsUndefined()); } - return JSValue::encode(jsString(vm, Zig::toStringCopy(value))); + return JSValue::encode(jsString(vm, Bun::toStringCopy(value))); } JSC_DEFINE_CUSTOM_SETTER(jsNodeTLSRejectUnauthorizedSetter, (JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, PropertyName propertyName)) @@ -289,7 +289,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsBunConfigVerboseFetchGetter, (JSGlobalObject * global return JSValue::encode(jsUndefined()); } - return JSValue::encode(jsString(vm, Zig::toStringCopy(value))); + return JSValue::encode(jsString(vm, Bun::toStringCopy(value))); } JSC_DEFINE_CUSTOM_SETTER(jsBunConfigVerboseFetchSetter, (JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, PropertyName propertyName)) @@ -443,7 +443,7 @@ JSValue createEnvironmentVariablesMap(Bun::GlobalObject* globalObject) ZigString valueString = { nullptr, 0 }; ZigString nameStr = toZigString(name); if (Bun__getEnvValue(globalObject, &nameStr, &valueString)) { - JSValue value = jsString(vm, Zig::toStringCopy(valueString)); + JSValue value = jsString(vm, Bun::toStringCopy(valueString)); RETURN_IF_EXCEPTION(scope, {}); object->putDirectIndex(globalObject, *index, value, 0, PutDirectIndexLikePutDirect); RETURN_IF_EXCEPTION(scope, {}); diff --git a/src/jsc/bindings/JSFFIFunction.cpp b/src/jsc/bindings/JSFFIFunction.cpp index 5eb752cef2a5..90860a94fa3a 100644 --- a/src/jsc/bindings/JSFFIFunction.cpp +++ b/src/jsc/bindings/JSFFIFunction.cpp @@ -78,15 +78,15 @@ extern "C" FFICallbackFunctionWrapper* Bun__createFFICallbackFunction( return wrapper; } -extern "C" Zig::JSFFIFunction* Bun__CreateFFIFunctionWithData(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, void* data) +extern "C" Bun::JSFFIFunction* Bun__CreateFFIFunctionWithData(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Bun::FFIFunction functionPointer, void* data) { auto& vm = JSC::getVM(globalObject); - Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, globalObject, argCount, symbolName != nullptr ? Zig::toStringCopy(*symbolName) : String(), functionPointer, JSC::NoIntrinsic); + Bun::JSFFIFunction* function = Bun::JSFFIFunction::create(vm, globalObject, argCount, symbolName != nullptr ? Bun::toStringCopy(*symbolName) : String(), functionPointer, JSC::NoIntrinsic); function->dataPtr = data; return function; } -extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionWithDataValue(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, void* data) +extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionWithDataValue(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Bun::FFIFunction functionPointer, void* data) { return JSC::JSValue::encode(Bun__CreateFFIFunctionWithData(globalObject, symbolName, argCount, functionPointer, data)); } @@ -94,7 +94,7 @@ extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionWithDataValue(Bun::GlobalOb extern "C" void* Bun__FFIFunction_getDataPtr(JSC::EncodedJSValue jsValue) { - Zig::JSFFIFunction* function = dynamicDowncast(JSC::JSValue::decode(jsValue)); + Bun::JSFFIFunction* function = dynamicDowncast(JSC::JSValue::decode(jsValue)); if (!function) return nullptr; @@ -104,17 +104,17 @@ extern "C" void* Bun__FFIFunction_getDataPtr(JSC::EncodedJSValue jsValue) extern "C" void Bun__FFIFunction_setDataPtr(JSC::EncodedJSValue jsValue, void* ptr) { - Zig::JSFFIFunction* function = dynamicDowncast(JSC::JSValue::decode(jsValue)); + Bun::JSFFIFunction* function = dynamicDowncast(JSC::JSValue::decode(jsValue)); if (!function) return; function->dataPtr = ptr; } -extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, bool addPtrField, void* symbolFromDynamicLibrary) +extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Bun::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Bun::FFIFunction functionPointer, bool addPtrField, void* symbolFromDynamicLibrary) { if (addPtrField) { - auto* function = Zig::JSFFIFunction::createForFFI(globalObject->vm(), globalObject, argCount, symbolName != nullptr ? Zig::toStringCopy(*symbolName) : String(), reinterpret_cast(functionPointer)); + auto* function = Bun::JSFFIFunction::createForFFI(globalObject->vm(), globalObject, argCount, symbolName != nullptr ? Bun::toStringCopy(*symbolName) : String(), reinterpret_cast(functionPointer)); auto& vm = JSC::getVM(globalObject); // We should only expose the "ptr" field when it's a JSCallback for bun:ffi. // Not for internal usages of this function type. @@ -127,7 +127,7 @@ extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Bun::GlobalObject* gl return Bun__CreateFFIFunctionWithDataValue(globalObject, symbolName, argCount, functionPointer, nullptr); } -namespace Zig { +namespace Bun { using namespace JSC; const ClassInfo JSFFIFunction::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFFIFunction) }; diff --git a/src/jsc/bindings/JSFFIFunction.h b/src/jsc/bindings/JSFFIFunction.h index 81cd49d17b65..72f81d47210a 100644 --- a/src/jsc/bindings/JSFFIFunction.h +++ b/src/jsc/bindings/JSFFIFunction.h @@ -16,7 +16,7 @@ namespace JSC { class JSGlobalObject; } -namespace Zig { +namespace Bun { using namespace JSC; diff --git a/src/jsc/bindings/JSStringDecoder.cpp b/src/jsc/bindings/JSStringDecoder.cpp index 11bbc905d129..579259747819 100644 --- a/src/jsc/bindings/JSStringDecoder.cpp +++ b/src/jsc/bindings/JSStringDecoder.cpp @@ -614,4 +614,4 @@ void JSStringDecoderConstructor::initializeProperties(VM& vm, JSC::JSGlobalObjec const ClassInfo JSStringDecoderConstructor::s_info = { "StringDecoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStringDecoderConstructor) }; -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/JSWrappingFunction.cpp b/src/jsc/bindings/JSWrappingFunction.cpp index 993033cdc879..7bcba90c215d 100644 --- a/src/jsc/bindings/JSWrappingFunction.cpp +++ b/src/jsc/bindings/JSWrappingFunction.cpp @@ -12,7 +12,7 @@ #include #include -namespace Zig { +namespace Bun { using namespace JSC; const ClassInfo JSWrappingFunction::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWrappingFunction) }; @@ -21,7 +21,7 @@ JS_EXPORT_PRIVATE JSWrappingFunction* JSWrappingFunction::create( VM& vm, Bun::GlobalObject* globalObject, const BunString* symbolName, - Zig::NativeFunctionPtr functionPointer, + Bun::NativeFunctionPtr functionPointer, JSC::JSValue wrappedFnValue) { JSC::JSObject* wrappedFn = wrappedFnValue.getObject(); @@ -63,7 +63,7 @@ DEFINE_VISIT_CHILDREN(JSWrappingFunction); extern "C" JSC::EncodedJSValue Bun__JSWrappingFunction__create( Bun::GlobalObject* globalObject, const BunString* symbolName, - Zig::NativeFunctionPtr functionPointer, + Bun::NativeFunctionPtr functionPointer, JSC::EncodedJSValue wrappedFnEncoded) { auto& vm = JSC::getVM(globalObject); diff --git a/src/jsc/bindings/JSWrappingFunction.h b/src/jsc/bindings/JSWrappingFunction.h index 30a59af4bd64..598a4d8d8645 100644 --- a/src/jsc/bindings/JSWrappingFunction.h +++ b/src/jsc/bindings/JSWrappingFunction.h @@ -16,7 +16,7 @@ namespace JSC { class JSGlobalObject; } -namespace Zig { +namespace Bun { using NativeFunctionPtr = SYSV_ABI JSC::EncodedJSValue (*)(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame); diff --git a/src/jsc/bindings/ModuleLoader.cpp b/src/jsc/bindings/ModuleLoader.cpp index ef90a2fa2f9a..c64fddf6e569 100644 --- a/src/jsc/bindings/ModuleLoader.cpp +++ b/src/jsc/bindings/ModuleLoader.cpp @@ -11,7 +11,7 @@ #include #include -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include #include @@ -45,7 +45,7 @@ namespace Bun { using namespace JSC; -using namespace Zig; +using namespace Bun; using namespace WebCore; class ResolvedSourceCodeHolder { @@ -297,7 +297,7 @@ OnLoadResult handleOnLoadResultNotPromise(Bun::GlobalObject* globalObject, JSC:: if (contentsValue) { if (contentsValue.isString()) { if (JSC::JSString* contentsJSString = contentsValue.toStringOrNull(globalObject)) { - result.value.sourceText.string = Zig::toZigString(contentsJSString, globalObject); + result.value.sourceText.string = Bun::toZigString(contentsJSString, globalObject); result.value.sourceText.value = contentsValue; } } else if (JSC::JSArrayBufferView* view = dynamicDowncast(contentsValue)) { @@ -392,7 +392,7 @@ static JSValue handleVirtualModuleResult( RELEASE_AND_RETURN(scope, reject(JSValue::decode(res->result.err.value))); } - auto provider = Zig::SourceProvider::create(globalObject, res->result.value); + auto provider = Bun::SourceProvider::create(globalObject, res->result.value); return resolve(JSC::JSSourceCode::create(vm, JSC::SourceCode(provider))); } case OnLoadResultTypeError: { @@ -507,7 +507,7 @@ extern "C" void Bun__onFulfillAsyncModule( } } } else { - auto provider = Zig::SourceProvider::create(globalObject, res->result.value); + auto provider = Bun::SourceProvider::create(globalObject, res->result.value); if (Bun::IsolatedModuleCache::canUse(vm, globalObject->bunVM())) { Bun::IsolatedModuleCache::insert(vm, specifier->toWTFString(BunString::ZeroCopy), provider.get()); } @@ -869,7 +869,7 @@ JSValue fetchCommonJSModuleNonBuiltin( RELEASE_AND_RETURN(scope, target); } - auto&& provider = Zig::SourceProvider::create(globalObject, res->result.value); + auto&& provider = Bun::SourceProvider::create(globalObject, res->result.value); if (Bun::IsolatedModuleCache::canUse(vm, bunVM, typeAttribute)) Bun::IsolatedModuleCache::insert(vm, specifierWtfString, provider.get()); // provideFetch() now drives the C++ loader pipeline (parse -> module record) @@ -1015,7 +1015,7 @@ static JSValue fetchESMSourceCode( auto tag = res->result.value.tag; switch (tag) { case SyntheticModuleType::ESM: { - auto&& provider = Zig::SourceProvider::create(globalObject, res->result.value, JSC::SourceProviderSourceType::Module, true); + auto&& provider = Bun::SourceProvider::create(globalObject, res->result.value, JSC::SourceProviderSourceType::Module, true); if (useIsolationCacheForBuiltin) Bun::IsolatedModuleCache::insert(vm, moduleKey, provider.get()); RELEASE_AND_RETURN(scope, rejectOrResolve(JSSourceCode::create(vm, JSC::SourceCode(provider)))); @@ -1036,7 +1036,7 @@ static JSValue fetchESMSourceCode( auto source = JSC::SourceCode(JSC::SyntheticSourceProvider::create(generateInternalModuleSourceCode(globalObject, static_cast(tag & mask)), JSC::SourceOrigin(URL(makeString("builtins://"_s, moduleKey))), moduleKey)); RELEASE_AND_RETURN(scope, rejectOrResolve(JSSourceCode::create(vm, WTF::move(source)))); } else { - auto&& provider = Zig::SourceProvider::create(globalObject, res->result.value, JSC::SourceProviderSourceType::Module, true); + auto&& provider = Bun::SourceProvider::create(globalObject, res->result.value, JSC::SourceProviderSourceType::Module, true); if (useIsolationCacheForBuiltin) Bun::IsolatedModuleCache::insert(vm, moduleKey, provider.get()); RELEASE_AND_RETURN(scope, rejectOrResolve(JSC::JSSourceCode::create(vm, JSC::SourceCode(provider)))); @@ -1177,7 +1177,7 @@ static JSValue fetchESMSourceCode( RELEASE_AND_RETURN(scope, rejectOrResolve(JSSourceCode::create(globalObject->vm(), WTF::move(source)))); } - auto provider = Zig::SourceProvider::create(globalObject, res->result.value); + auto provider = Bun::SourceProvider::create(globalObject, res->result.value); if (useIsolationCache) { Bun::IsolatedModuleCache::insert(vm, specifier->toWTFString(BunString::ZeroCopy), provider.get()); } diff --git a/src/jsc/bindings/NapiClass.cpp b/src/jsc/bindings/NapiClass.cpp index de3593cebbdd..f21828502e12 100644 --- a/src/jsc/bindings/NapiClass.cpp +++ b/src/jsc/bindings/NapiClass.cpp @@ -2,7 +2,7 @@ #include "napi.h" #include -namespace Zig { +namespace Bun { template void NapiClass::visitChildrenImpl(JSCell* cell, Visitor& visitor) diff --git a/src/jsc/bindings/NapiRef.cpp b/src/jsc/bindings/NapiRef.cpp index 03660630b970..962277f678a5 100644 --- a/src/jsc/bindings/NapiRef.cpp +++ b/src/jsc/bindings/NapiRef.cpp @@ -2,7 +2,7 @@ #include "napi.h" #include -namespace Zig { +namespace Bun { WTF_MAKE_TZONE_ALLOCATED_IMPL(NapiRef); diff --git a/src/jsc/bindings/NapiWeakValue.cpp b/src/jsc/bindings/NapiWeakValue.cpp index 0e6927d792a9..e02a0bb47882 100644 --- a/src/jsc/bindings/NapiWeakValue.cpp +++ b/src/jsc/bindings/NapiWeakValue.cpp @@ -1,6 +1,6 @@ #include "napi.h" -namespace Zig { +namespace Bun { NapiWeakValue::~NapiWeakValue() { diff --git a/src/jsc/bindings/Path.cpp b/src/jsc/bindings/Path.cpp index 5d5b9fdc3b00..2adabc3927b6 100644 --- a/src/jsc/bindings/Path.cpp +++ b/src/jsc/bindings/Path.cpp @@ -10,7 +10,7 @@ #pragma mark - Node.js Path -namespace Zig { +namespace Bun { static JSC::JSObject* createPath(JSC::JSGlobalObject* globalThis, bool isWindows); @@ -112,7 +112,7 @@ static JSC::JSObject* createPath(JSGlobalObject* globalThis, bool isWindows) return path; } -} // namespace Zig +} // namespace Bun extern "C" JSC::EncodedJSValue PathParsedObject__create( JSC::JSGlobalObject* globalObject, @@ -144,12 +144,12 @@ JSC::JSValue createNodePathBinding(Bun::GlobalObject* globalObject) binding->putDirectIndex( globalObject, (unsigned)0, - Zig::createPath(globalObject, false)); + Bun::createPath(globalObject, false)); RETURN_IF_EXCEPTION(scope, {}); binding->putDirectIndex( globalObject, (unsigned)1, - Zig::createPath(globalObject, true)); + Bun::createPath(globalObject, true)); RETURN_IF_EXCEPTION(scope, {}); return binding; } diff --git a/src/jsc/bindings/ProcessBindingTTYWrap.cpp b/src/jsc/bindings/ProcessBindingTTYWrap.cpp index e127ca11a778..a45d35dc2bfd 100644 --- a/src/jsc/bindings/ProcessBindingTTYWrap.cpp +++ b/src/jsc/bindings/ProcessBindingTTYWrap.cpp @@ -497,7 +497,7 @@ JSValue createBunTTYFunctions(Bun::GlobalObject* globalObject) auto& vm = JSC::getVM(globalObject); auto* obj = constructEmptyObject(globalObject); - obj->putDirect(vm, PropertyName(Identifier::fromString(vm, "isatty"_s)), JSFunction::create(vm, globalObject, 0, "isatty"_s, Zig::jsFunctionTty_isatty, ImplementationVisibility::Public), 0); + obj->putDirect(vm, PropertyName(Identifier::fromString(vm, "isatty"_s)), JSFunction::create(vm, globalObject, 0, "isatty"_s, Bun::jsFunctionTty_isatty, ImplementationVisibility::Public), 0); obj->putDirect(vm, PropertyName(Identifier::fromString(vm, "setRawMode"_s)), JSFunction::create(vm, globalObject, 0, "ttySetMode"_s, jsTTYSetMode, ImplementationVisibility::Public), 0); @@ -511,7 +511,7 @@ JSValue createNodeTTYWrapObject(JSC::JSGlobalObject* globalObject) auto& vm = JSC::getVM(globalObject); auto* obj = constructEmptyObject(globalObject); - obj->putDirect(vm, PropertyName(Identifier::fromString(vm, "isTTY"_s)), JSFunction::create(vm, globalObject, 0, "isatty"_s, Zig::jsFunctionTty_isatty, ImplementationVisibility::Public), 0); + obj->putDirect(vm, PropertyName(Identifier::fromString(vm, "isTTY"_s)), JSFunction::create(vm, globalObject, 0, "isatty"_s, Bun::jsFunctionTty_isatty, ImplementationVisibility::Public), 0); TTYWrapPrototype* prototype = TTYWrapPrototype::create(vm, globalObject, TTYWrapPrototype::createStructure(vm, globalObject)); TTYWrapConstructor* constructor = TTYWrapConstructor::create(vm, globalObject, TTYWrapConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), prototype); diff --git a/src/jsc/bindings/ServerRouteList.cpp b/src/jsc/bindings/ServerRouteList.cpp index 719403f4e78a..b89245348237 100644 --- a/src/jsc/bindings/ServerRouteList.cpp +++ b/src/jsc/bindings/ServerRouteList.cpp @@ -124,7 +124,7 @@ class ServerRouteList final : public JSC::JSDestructibleObject { for (size_t i = 0; i < paths.size(); i++) { ZigString rawPath = paths[i]; - WTF::String path = Zig::toString(rawPath); + WTF::String path = Bun::toString(rawPath); uint32_t originalIdentifierIndex = m_pathIdentifiers.size(); size_t startOfIdentifier = 0; size_t identifierCount = 0; diff --git a/src/jsc/bindings/URLSearchParams.cpp b/src/jsc/bindings/URLSearchParams.cpp index 7d5f9d225d8e..149205444104 100644 --- a/src/jsc/bindings/URLSearchParams.cpp +++ b/src/jsc/bindings/URLSearchParams.cpp @@ -33,7 +33,7 @@ namespace WebCore { extern "C" JSC::EncodedJSValue URLSearchParams__create(JSDOMGlobalObject* globalObject, const ZigString* input) { - String str = Zig::toString(*input); + String str = Bun::toString(*input); auto result = URLSearchParams::create(str, nullptr); return JSC::JSValue::encode(WebCore::toJSNewlyCreated(globalObject, globalObject, WTF::move(result))); } @@ -49,7 +49,7 @@ typedef void (*URLSearchParams__toStringCallback)(void* ctx, const ZigString* st extern "C" void URLSearchParams__toString(WebCore::URLSearchParams* urlSearchParams, void* ctx, URLSearchParams__toStringCallback callback) { String str = urlSearchParams->toString(); - auto zig = Zig::toZigString(str); + auto zig = Bun::toZigString(str); callback(ctx, &zig); } diff --git a/src/jsc/bindings/bindings.cpp b/src/jsc/bindings/bindings.cpp index 04113247e41b..bfffc7656093 100644 --- a/src/jsc/bindings/bindings.cpp +++ b/src/jsc/bindings/bindings.cpp @@ -581,7 +581,7 @@ AsymmetricMatcherResult matchAsymmetricMatcher(JSGlobalObject* globalObject, JSV } template -static void handlePromise(PromiseType* promise, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue ctx, Zig::FFIFunction resolverFunction, Zig::FFIFunction rejecterFunction) +static void handlePromise(PromiseType* promise, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue ctx, Bun::FFIFunction resolverFunction, Bun::FFIFunction rejecterFunction) { auto globalThis = static_cast(globalObject); @@ -1762,7 +1762,7 @@ void WebCore__FetchHeaders__append(WebCore::FetchHeaders* headers, const ZigStri JSC::JSGlobalObject* lexicalGlobalObject) { auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); - WebCore::propagateException(*lexicalGlobalObject, throwScope, headers->append(Zig::toString(*arg1), Zig::toString(*arg2))); + WebCore::propagateException(*lexicalGlobalObject, throwScope, headers->append(Bun::toString(*arg1), Bun::toString(*arg2))); RELEASE_AND_RETURN(throwScope, ); } WebCore::FetchHeaders* WebCore__FetchHeaders__cast_(JSC::EncodedJSValue JSValue0, JSC::VM* vm) @@ -2046,8 +2046,8 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createValueNotJS(JSC::JSGlobalObje pairs.reserveCapacity(count); ZigString buf = *arg3; for (uint32_t i = 0; i < count; i++) { - WTF::String name = Zig::toStringCopy(buf, arg1[i]); - WTF::String value = Zig::toStringCopy(buf, arg2[i]); + WTF::String name = Bun::toStringCopy(buf, arg1[i]); + WTF::String value = Bun::toStringCopy(buf, arg2[i]); pairs.unsafeAppendWithoutCapacityCheck(KeyValuePair(name, value)); } @@ -2068,8 +2068,8 @@ JSC::EncodedJSValue WebCore__FetchHeaders__createValue(JSC::JSGlobalObject* arg0 pairs.reserveCapacity(count); ZigString buf = *arg3; for (uint32_t i = 0; i < count; i++) { - WTF::String name = Zig::toStringCopy(buf, arg1[i]); - WTF::String value = Zig::toStringCopy(buf, arg2[i]); + WTF::String name = Bun::toStringCopy(buf, arg1[i]); + WTF::String value = Bun::toStringCopy(buf, arg2[i]); pairs.unsafeAppendWithoutCapacityCheck(KeyValuePair(name, value)); } @@ -2086,16 +2086,16 @@ JSC::EncodedJSValue WebCore__FetchHeaders__createValue(JSC::JSGlobalObject* arg0 void WebCore__FetchHeaders__get_(WebCore::FetchHeaders* headers, const ZigString* arg1, ZigString* arg2, JSC::JSGlobalObject* global) { auto throwScope = DECLARE_THROW_SCOPE(global->vm()); - auto result = headers->get(Zig::toString(*arg1)); + auto result = headers->get(Bun::toString(*arg1)); if (result.hasException()) WebCore::propagateException(*global, throwScope, result.releaseException()); else - *arg2 = Zig::toZigString(result.releaseReturnValue()); + *arg2 = Bun::toZigString(result.releaseReturnValue()); } bool WebCore__FetchHeaders__has(WebCore::FetchHeaders* headers, const ZigString* arg1, JSC::JSGlobalObject* global) { auto throwScope = DECLARE_THROW_SCOPE(global->vm()); - auto result = headers->has(Zig::toString(*arg1)); + auto result = headers->has(Bun::toString(*arg1)); if (result.hasException()) { WebCore::propagateException(*global, throwScope, result.releaseException()); return false; @@ -2106,13 +2106,13 @@ extern "C" void WebCore__FetchHeaders__put(WebCore::FetchHeaders* headers, HTTPH { auto throwScope = DECLARE_THROW_SCOPE(global->vm()); throwScope.assertNoException(); // can't throw an exception when there's already one. - WebCore::propagateException(*global, throwScope, headers->set(name, Zig::toStringCopy(*arg2))); + WebCore::propagateException(*global, throwScope, headers->set(name, Bun::toStringCopy(*arg2))); } void WebCore__FetchHeaders__remove(WebCore::FetchHeaders* headers, const ZigString* arg1, JSC::JSGlobalObject* global) { auto throwScope = DECLARE_THROW_SCOPE(global->vm()); WebCore::propagateException(*global, throwScope, - headers->remove(Zig::toString(*arg1))); + headers->remove(Bun::toString(*arg1))); } void WebCore__FetchHeaders__fastRemove_(WebCore::FetchHeaders* headers, unsigned char headerName) @@ -2127,7 +2127,7 @@ void WebCore__FetchHeaders__fastGet_(WebCore::FetchHeaders* headers, unsigned ch return; } - *arg2 = Zig::toZigString(str); + *arg2 = Bun::toZigString(str); } WebCore::DOMURL* WebCore__DOMURL__cast_(JSC::EncodedJSValue JSValue0, JSC::VM* vm) @@ -2138,13 +2138,13 @@ WebCore::DOMURL* WebCore__DOMURL__cast_(JSC::EncodedJSValue JSValue0, JSC::VM* v [[ZIG_EXPORT(nothrow)]] void WebCore__DOMURL__href_(WebCore::DOMURL* domURL, ZigString* arg1) { const WTF::URL& href = domURL->href(); - *arg1 = Zig::toZigString(href.string()); + *arg1 = Bun::toZigString(href.string()); } [[ZIG_EXPORT(nothrow)]] void WebCore__DOMURL__pathname_(WebCore::DOMURL* domURL, ZigString* arg1) { const WTF::URL& href = domURL->href(); const WTF::StringView& pathname = href.path(); - *arg1 = Zig::toZigString(pathname); + *arg1 = Bun::toZigString(pathname); } BunString WebCore__DOMURL__fileSystemPath(WebCore::DOMURL* arg0, int* errorCode) @@ -2198,7 +2198,7 @@ extern "C" JSC::EncodedJSValue JSC__JSValue__unwrapBoxedPrimitive(JSGlobalObject extern "C" JSC::EncodedJSValue ZigString__toJSONObject(const ZigString* strPtr, JSC::JSGlobalObject* globalObject) { ASSERT_NO_PENDING_EXCEPTION(globalObject); - auto str = Zig::toString(*strPtr); + auto str = Bun::toString(*strPtr); auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); if (str.isNull()) { @@ -2628,7 +2628,7 @@ double JSC__JSValue__getLengthIfPropertyExistsInternal(JSC::EncodedJSValue value void JSC__JSObject__putRecord(JSC::JSObject* object, JSC::JSGlobalObject* global, ZigString* key, ZigString* values, size_t valuesLen) { auto scope = DECLARE_THROW_SCOPE(global->vm()); - auto ident = Identifier::fromString(global->vm(), Zig::toStringCopy(*key)); + auto ident = Identifier::fromString(global->vm(), Bun::toStringCopy(*key)); JSC::PropertyDescriptor descriptor; descriptor.setEnumerable(1); @@ -2636,14 +2636,14 @@ void JSC__JSObject__putRecord(JSC::JSObject* object, JSC::JSGlobalObject* global descriptor.setWritable(1); if (valuesLen == 1) { - descriptor.setValue(JSC::jsString(global->vm(), Zig::toStringCopy(values[0]))); + descriptor.setValue(JSC::jsString(global->vm(), Bun::toStringCopy(values[0]))); } else { // Pre-convert all strings to JSValues before entering ObjectInitializationScope, // since jsString() allocates GC cells which is not allowed inside the scope. MarkedArgumentBuffer strings; for (size_t i = 0; i < valuesLen; ++i) { - strings.append(JSC::jsString(global->vm(), Zig::toStringCopy(values[i]))); + strings.append(JSC::jsString(global->vm(), Bun::toStringCopy(values[i]))); } JSC::JSArray* array = nullptr; @@ -2675,7 +2675,7 @@ void JSC__JSValue__putRecord(JSC::EncodedJSValue objectValue, JSC::JSGlobalObjec JSC::JSValue objValue = JSC::JSValue::decode(objectValue); JSC::JSObject* object = objValue.asCell()->getObject(); auto scope = DECLARE_THROW_SCOPE(global->vm()); - auto ident = Zig::toIdentifier(*key, global); + auto ident = Bun::toIdentifier(*key, global); JSC::PropertyDescriptor descriptor; descriptor.setEnumerable(1); @@ -2683,14 +2683,14 @@ void JSC__JSValue__putRecord(JSC::EncodedJSValue objectValue, JSC::JSGlobalObjec descriptor.setWritable(1); if (valuesLen == 1) { - descriptor.setValue(JSC::jsString(global->vm(), Zig::toString(values[0]))); + descriptor.setValue(JSC::jsString(global->vm(), Bun::toString(values[0]))); } else { // Pre-convert all strings to JSValues before entering ObjectInitializationScope, // since jsString() allocates GC cells which is not allowed inside the scope. MarkedArgumentBuffer strings; for (size_t i = 0; i < valuesLen; ++i) { - strings.append(JSC::jsString(global->vm(), Zig::toString(values[i]))); + strings.append(JSC::jsString(global->vm(), Bun::toString(values[i]))); } JSC::JSArray* array = nullptr; @@ -2752,7 +2752,7 @@ bool JSC__JSFunction__getSourceCode(JSC::EncodedJSValue JSValue0, ZigString* out if (JSC::JSFunction* func = dynamicDowncast(value)) { auto* sourceCode = func->sourceCode(); if (sourceCode != nullptr) { // native functions have no source code - *outSourceCode = Zig::toZigString(sourceCode->view()); + *outSourceCode = Bun::toZigString(sourceCode->view()); return true; } return false; @@ -2819,7 +2819,7 @@ JSC::JSPromise* JSC__JSPromise__create(JSC::JSGlobalObject* arg0) } // TODO: prevent this from allocating so much memory -void JSC__JSValue___then(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue arg2, Zig::FFIFunction ArgFn3, Zig::FFIFunction ArgFn4) +void JSC__JSValue___then(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue arg2, Bun::FFIFunction ArgFn3, Bun::FFIFunction ArgFn4) { auto* cell = JSC::JSValue::decode(JSValue0).asCell(); @@ -2833,7 +2833,7 @@ JSC::EncodedJSValue JSC__JSGlobalObject__getCachedObject(JSC::JSGlobalObject* gl { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); - WTF::String string = Zig::toString(*arg1); + WTF::String string = Bun::toString(*arg1); auto symbol = vm.privateSymbolRegistry().symbolForKey(string); JSC::Identifier ident = JSC::Identifier::fromUid(symbol); JSC::JSValue result = globalObject->getIfPropertyExists(globalObject, ident); @@ -2844,7 +2844,7 @@ JSC::EncodedJSValue JSC__JSGlobalObject__getCachedObject(JSC::JSGlobalObject* gl JSC::EncodedJSValue JSC__JSGlobalObject__putCachedObject(JSC::JSGlobalObject* globalObject, const ZigString* arg1, JSC::EncodedJSValue JSValue2) { auto& vm = JSC::getVM(globalObject); - WTF::String string = Zig::toString(*arg1); + WTF::String string = Bun::toString(*arg1); auto symbol = vm.privateSymbolRegistry().symbolForKey(string); JSC::Identifier ident = JSC::Identifier::fromUid(symbol); globalObject->putDirect(vm, ident, JSC::JSValue::decode(JSValue2), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum); @@ -2853,7 +2853,7 @@ JSC::EncodedJSValue JSC__JSGlobalObject__putCachedObject(JSC::JSGlobalObject* gl void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC::JSGlobalObject* global, ZigString* arg1) { - const JSC::Identifier identifier = Zig::toIdentifier(*arg1, global); + const JSC::Identifier identifier = Bun::toIdentifier(*arg1, global); auto* moduleLoader = global->moduleLoader(); // JSModuleLoader::visitChildrenImpl iterates these maps on the GC thread // under cellLock(); take the same lock so the removal can't race it. @@ -3067,12 +3067,12 @@ JSC::EncodedJSValue JSC__JSValue__getDirectIndex(JSC::EncodedJSValue jsValue, JS JSC::EncodedJSValue JSC__JSObject__getDirect(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, const ZigString* arg2) { - return JSC::JSValue::encode(arg0->getDirect(arg1->vm(), Zig::toIdentifier(*arg2, arg1))); + return JSC::JSValue::encode(arg0->getDirect(arg1->vm(), Bun::toIdentifier(*arg2, arg1))); } void JSC__JSObject__putDirect(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, const ZigString* key, JSC::EncodedJSValue value) { - auto prop = Zig::toIdentifier(*key, arg1); + auto prop = Bun::toIdentifier(*key, arg1); arg0->putDirect(arg1->vm(), prop, JSC::JSValue::decode(value)); } @@ -3095,7 +3095,7 @@ JSC::JSObject* JSC__JSCell__toObject(JSC::JSCell* cell, JSC::JSGlobalObject* glo void JSC__JSString__toZigString(JSC::JSString* arg0, JSC::JSGlobalObject* arg1, ZigString* arg2) { auto value = arg0->value(arg1); - *arg2 = Zig::toZigString(value.data.impl()); + *arg2 = Bun::toZigString(value.data.impl()); // We don't need to assert here because ->value returns a reference to the same string as the one owned by the JSString. } @@ -3190,11 +3190,11 @@ JSC::EncodedJSValue JSC__JSValue__createRangeError(const ZigString* message, con { auto& vm = JSC::getVM(globalObject); ZigString code = *arg1; - JSC::JSObject* rangeError = Zig::getRangeErrorInstance(message, globalObject).asCell()->getObject(); + JSC::JSObject* rangeError = Bun::getRangeErrorInstance(message, globalObject).asCell()->getObject(); if (code.len > 0) { auto clientData = WebCore::clientData(vm); - JSC::JSValue codeValue = Zig::toJSString(code, globalObject); + JSC::JSValue codeValue = Bun::toJSString(code, globalObject); rangeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue, JSC::PropertyAttribute::ReadOnly | 0); } @@ -3207,11 +3207,11 @@ JSC::EncodedJSValue JSC__JSValue__createTypeError(const ZigString* message, cons { auto& vm = JSC::getVM(globalObject); ZigString code = *arg1; - JSC::JSObject* typeError = Zig::getTypeErrorInstance(message, globalObject).asCell()->getObject(); + JSC::JSObject* typeError = Bun::getTypeErrorInstance(message, globalObject).asCell()->getObject(); if (code.len > 0) { auto clientData = WebCore::clientData(vm); - JSC::JSValue codeValue = Zig::toJSString(code, globalObject); + JSC::JSValue codeValue = Bun::toJSString(code, globalObject); typeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue, 0); } @@ -3232,14 +3232,14 @@ JSC::EncodedJSValue JSC__JSValue__fromEntries(JSC::JSGlobalObject* globalObject, if (!clone) { for (size_t i = 0; i < initialCapacity; ++i) { object->putDirect( - vm, JSC::PropertyName(JSC::Identifier::fromString(vm, Zig::toString(keys[i]))), - Zig::toJSStringGC(values[i], globalObject), 0); + vm, JSC::PropertyName(JSC::Identifier::fromString(vm, Bun::toString(keys[i]))), + Bun::toJSStringGC(values[i], globalObject), 0); RETURN_IF_EXCEPTION(scope, {}); } } else { for (size_t i = 0; i < initialCapacity; ++i) { - object->putDirect(vm, JSC::PropertyName(Zig::toIdentifier(keys[i], globalObject)), - Zig::toJSStringGC(values[i], globalObject), 0); + object->putDirect(vm, JSC::PropertyName(Bun::toIdentifier(keys[i], globalObject)), + Bun::toJSStringGC(values[i], globalObject), 0); RETURN_IF_EXCEPTION(scope, {}); } } @@ -3459,7 +3459,7 @@ JSC::EncodedJSValue JSC__JSGlobalObject__createAggregateError(JSC::JSGlobalObjec auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); - WTF::String message = Zig::toString(*arg3); + WTF::String message = Bun::toString(*arg3); JSC::JSValue cause = JSC::jsUndefined(); JSC::JSArray* array = nullptr; { @@ -3507,7 +3507,7 @@ JSC::EncodedJSValue ZigString__toAtomicValue(const ZigString* arg0, JSC::JSGloba } } - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), makeAtomString(Zig::toStringCopy(*arg0)))); + return JSC::JSValue::encode(JSC::jsString(arg1->vm(), makeAtomString(Bun::toStringCopy(*arg0)))); } JSC::EncodedJSValue ZigString__to16BitValue(const ZigString* arg0, JSC::JSGlobalObject* arg1) @@ -3534,11 +3534,11 @@ JSC::EncodedJSValue ZigString__toExternalU16(const uint16_t* arg0, size_t len, J if (str.len == 0) { return JSC::JSValue::encode(JSC::jsEmptyString(arg1->vm())); } - if (Zig::isTaggedUTF16Ptr(str.ptr)) { - auto ref = String(ExternalStringImpl::create({ reinterpret_cast(Zig::untag(str.ptr)), str.len }, Zig::untagVoid(str.ptr), free_global_string)); + if (Bun::isTaggedUTF16Ptr(str.ptr)) { + auto ref = String(ExternalStringImpl::create({ reinterpret_cast(Bun::untag(str.ptr)), str.len }, Bun::untagVoid(str.ptr), free_global_string)); return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::move(ref))); } else { - auto ref = String(ExternalStringImpl::create({ Zig::untag(str.ptr), str.len }, Zig::untagVoid(str.ptr), free_global_string)); + auto ref = String(ExternalStringImpl::create({ Bun::untag(str.ptr), str.len }, Bun::untagVoid(str.ptr), free_global_string)); return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::move(ref))); } } @@ -3550,7 +3550,7 @@ __attribute__((__always_inline__)) VirtualMachine* JSC__JSGlobalObject__bunVM(JS JSC::EncodedJSValue ZigString__toValueGC(const ZigString* arg0, JSC::JSGlobalObject* arg1) { - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), Zig::toStringCopy(*arg0))); + return JSC::JSValue::encode(JSC::jsString(arg1->vm(), Bun::toStringCopy(*arg0))); } void JSC__JSValue__toZigString(JSC::EncodedJSValue JSValue0, ZigString* arg1, JSC::JSGlobalObject* arg2) @@ -3576,7 +3576,7 @@ void JSC__JSValue__toZigString(JSC::EncodedJSValue JSValue0, ZigString* arg1, JS if (str->is8Bit()) { arg1->ptr = str->span8().data(); } else { - arg1->ptr = Zig::taggedUTF16Ptr(str->span16().data()); + arg1->ptr = Bun::taggedUTF16Ptr(str->span16().data()); } arg1->len = str->length(); @@ -3586,10 +3586,10 @@ JSC::EncodedJSValue ZigString__external(const ZigString* arg0, JSC::JSGlobalObje { ZigString str = *arg0; - if (Zig::isTaggedUTF16Ptr(str.ptr)) { - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Zig::untag(str.ptr)), str.len }, arg2, ArgFn3)))); + if (Bun::isTaggedUTF16Ptr(str.ptr)) { + return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Bun::untag(str.ptr)), str.len }, arg2, ArgFn3)))); } else { - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Zig::untag(str.ptr)), str.len }, arg2, ArgFn3)))); + return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Bun::untag(str.ptr)), str.len }, arg2, ArgFn3)))); } } @@ -3598,21 +3598,21 @@ JSC::EncodedJSValue ZigString__toExternalValueWithCallback(const ZigString* arg0 ZigString str = *arg0; - if (Zig::isTaggedUTF16Ptr(str.ptr)) { - return JSC::JSValue::encode(JSC::jsOwnedString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Zig::untag(str.ptr)), str.len }, nullptr, ArgFn2)))); + if (Bun::isTaggedUTF16Ptr(str.ptr)) { + return JSC::JSValue::encode(JSC::jsOwnedString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Bun::untag(str.ptr)), str.len }, nullptr, ArgFn2)))); } else { - return JSC::JSValue::encode(JSC::jsOwnedString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Zig::untag(str.ptr)), str.len }, nullptr, ArgFn2)))); + return JSC::JSValue::encode(JSC::jsOwnedString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Bun::untag(str.ptr)), str.len }, nullptr, ArgFn2)))); } } JSC::EncodedJSValue ZigString__toErrorInstance(const ZigString* str, JSC::JSGlobalObject* globalObject) { - return JSC::JSValue::encode(Zig::getErrorInstance(str, globalObject)); + return JSC::JSValue::encode(Bun::getErrorInstance(str, globalObject)); } JSC::EncodedJSValue ZigString__toTypeErrorInstance(const ZigString* str, JSC::JSGlobalObject* globalObject) { - return JSC::JSValue::encode(Zig::getTypeErrorInstance(str, globalObject)); + return JSC::JSValue::encode(Bun::getTypeErrorInstance(str, globalObject)); } JSC::EncodedJSValue ZigString__toDOMExceptionInstance(const ZigString* str, JSC::JSGlobalObject* globalObject, WebCore::ExceptionCode code) @@ -3622,12 +3622,12 @@ JSC::EncodedJSValue ZigString__toDOMExceptionInstance(const ZigString* str, JSC: JSC::EncodedJSValue ZigString__toSyntaxErrorInstance(const ZigString* str, JSC::JSGlobalObject* globalObject) { - return JSC::JSValue::encode(Zig::getSyntaxErrorInstance(str, globalObject)); + return JSC::JSValue::encode(Bun::getSyntaxErrorInstance(str, globalObject)); } JSC::EncodedJSValue ZigString__toRangeErrorInstance(const ZigString* str, JSC::JSGlobalObject* globalObject) { - return JSC::JSValue::encode(Zig::getRangeErrorInstance(str, globalObject)); + return JSC::JSValue::encode(Bun::getRangeErrorInstance(str, globalObject)); } static JSC::EncodedJSValue resolverFunctionCallback(JSC::JSGlobalObject* globalObject, @@ -4030,7 +4030,7 @@ bool JSC__JSValue__isException(JSC::EncodedJSValue JSValue0, JSC::VM* arg1) void JSC__JSValue__put(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, const ZigString* arg2, JSC::EncodedJSValue JSValue3) { JSC::JSObject* object = JSC::JSValue::decode(JSValue0).asCell()->getObject(); - object->putDirect(arg1->vm(), Zig::toIdentifier(*arg2, arg1), JSC::JSValue::decode(JSValue3)); + object->putDirect(arg1->vm(), Bun::toIdentifier(*arg2, arg1), JSC::JSValue::decode(JSValue3)); } void JSC__JSValue__putToPropertyKey(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue arg2, JSC::EncodedJSValue arg3) @@ -4069,7 +4069,7 @@ extern "C" bool JSC__JSValue__deleteProperty(JSC::EncodedJSValue target, JSC::JS auto scope = DECLARE_THROW_SCOPE(vm); JSC::JSObject* object = targetValue.getObject(); - bool result = object->deleteProperty(globalObject, Zig::toIdentifier(*key, globalObject)); + bool result = object->deleteProperty(globalObject, Bun::toIdentifier(*key, globalObject)); RETURN_IF_EXCEPTION(scope, false); return result; } @@ -4347,7 +4347,7 @@ JSC::EncodedJSValue JSC__JSValue__createObject2(JSC::JSGlobalObject* globalObjec auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); JSC::JSObject* object = JSC::constructEmptyObject(globalObject); - auto key1 = Zig::toIdentifier(*arg1, globalObject); + auto key1 = Bun::toIdentifier(*arg1, globalObject); JSC::PropertyDescriptor descriptor1; JSC::PropertyDescriptor descriptor2; @@ -4356,7 +4356,7 @@ JSC::EncodedJSValue JSC__JSValue__createObject2(JSC::JSGlobalObject* globalObjec descriptor1.setWritable(1); descriptor1.setValue(JSC::JSValue::decode(JSValue3)); - auto key2 = Zig::toIdentifier(*arg2, globalObject); + auto key2 = Bun::toIdentifier(*arg2, globalObject); descriptor2.setEnumerable(1); descriptor2.setConfigurable(1); @@ -4603,7 +4603,7 @@ void JSC__JSValue__getSymbolDescription(JSC::EncodedJSValue symbolValue_, JSC::J auto& uid = symbol->uid(); if (!uid.isNullSymbol() && !uid.isEmpty()) { - *arg2 = Zig::toZigString(static_cast(uid)); + *arg2 = Bun::toZigString(static_cast(uid)); } else { *arg2 = ZigStringEmpty; } @@ -4613,7 +4613,7 @@ JSC::EncodedJSValue JSC__JSValue__symbolFor(JSC::JSGlobalObject* globalObject, Z { auto& vm = JSC::getVM(globalObject); - WTF::String string = Zig::toString(*arg2); + WTF::String string = Bun::toString(*arg2); return JSC::JSValue::encode(JSC::Symbol::create(vm, vm.symbolRegistry().symbolForKey(string))); } @@ -4630,7 +4630,7 @@ bool JSC__JSValue__symbolKeyFor(JSC::EncodedJSValue symbolValue_, JSC::JSGlobalO if (!uid.symbolRegistry()) return false; - *arg2 = Zig::toZigString(JSC::jsString(vm, String { uid }), arg1); + *arg2 = Bun::toZigString(JSC::jsString(vm, String { uid }), arg1); return true; } @@ -4759,11 +4759,11 @@ void JSC__JSValue__getClassName(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObjec auto calculated = JSObject::calculatedClassName(obj); if (calculated.length() > 0) { - *arg2 = Zig::toZigString(calculated); + *arg2 = Bun::toZigString(calculated); return; } - *arg2 = Zig::toZigString(view); + *arg2 = Bun::toZigString(view); } bool JSC__JSValue__getClassInfoName(JSValue value, const uint8_t** outPtr, size_t* outLen) @@ -4793,7 +4793,7 @@ void JSC__JSValue__getNameProperty(JSC::EncodedJSValue JSValue0, JSC::JSGlobalOb if (name && name.isString()) { auto str = name.toWTFString(arg1); if (!str.isEmpty()) { - *arg2 = Zig::toZigString(str); + *arg2 = Bun::toZigString(str); return; } } @@ -4802,18 +4802,18 @@ void JSC__JSValue__getNameProperty(JSC::EncodedJSValue JSValue0, JSC::JSGlobalOb WTF::String actualName = function->name(vm); if (!actualName.isEmpty() || function->isHostOrBuiltinFunction()) { - *arg2 = Zig::toZigString(actualName); + *arg2 = Bun::toZigString(actualName); return; } actualName = function->jsExecutable()->name().string(); - *arg2 = Zig::toZigString(actualName); + *arg2 = Bun::toZigString(actualName); return; } if (JSC::InternalFunction* function = dynamicDowncast(obj)) { - *arg2 = Zig::toZigString(function->name()); + *arg2 = Bun::toZigString(function->name()); return; } @@ -6243,17 +6243,17 @@ CPP_DECL void Bun__CallFrame__getCallerSrcLoc(JSC::CallFrame* callFrame, JSC::JS JSC::LineColumn lineColumn; String sourceURL; - ZigStackFrame remappedFrame = {}; + BunStackFrame remappedFrame = {}; JSC::StackVisitor::visit(callFrame, vm, [&](JSC::StackVisitor& visitor) -> WTF::IterationStatus { - if (Zig::isImplementationVisibilityPrivate(visitor)) + if (Bun::isImplementationVisibilityPrivate(visitor)) return WTF::IterationStatus::Continue; if (visitor->hasLineAndColumnInfo()) { lineColumn = visitor->computeLineAndColumn(); - sourceURL = Zig::sourceURL(visitor); + sourceURL = Bun::sourceURL(visitor); return WTF::IterationStatus::Done; } @@ -6388,11 +6388,11 @@ CPP_DECL [[ZIG_EXPORT(nothrow)]] unsigned int Bun__CallFrame__getLineNumber(JSC: String sourceURL; JSC::StackVisitor::visit(callFrame, vm, [&](JSC::StackVisitor& visitor) -> WTF::IterationStatus { - if (Zig::isImplementationVisibilityPrivate(visitor)) + if (Bun::isImplementationVisibilityPrivate(visitor)) return WTF::IterationStatus::Continue; if (visitor->hasLineAndColumnInfo()) { - String currentSourceURL = Zig::sourceURL(visitor); + String currentSourceURL = Bun::sourceURL(visitor); if (!currentSourceURL.startsWith("builtin://"_s) && !currentSourceURL.startsWith("node:"_s)) { lineColumn = visitor->computeLineAndColumn(); @@ -6404,7 +6404,7 @@ CPP_DECL [[ZIG_EXPORT(nothrow)]] unsigned int Bun__CallFrame__getLineNumber(JSC: }); if (!sourceURL.isEmpty() && lineColumn.line > 0) { - ZigStackFrame remappedFrame = {}; + BunStackFrame remappedFrame = {}; remappedFrame.position.line_zero_based = lineColumn.line - 1; remappedFrame.position.column_zero_based = lineColumn.column; remappedFrame.source_url = Bun::toStringRef(sourceURL); diff --git a/src/jsc/bindings/headers-cpp.h b/src/jsc/bindings/headers-cpp.h index 4172b65c4dc4..1aaf252da716 100644 --- a/src/jsc/bindings/headers-cpp.h +++ b/src/jsc/bindings/headers-cpp.h @@ -166,8 +166,8 @@ extern "C" const size_t Bun__Path_object_align_ = alignof(Bun__Path); #include ""ConsoleObject.h"" #endif -extern "C" const size_t Bun__ConsoleObject_object_size_ = sizeof(Zig::ConsoleClient); -extern "C" const size_t Bun__ConsoleObject_object_align_ = alignof(Zig::ConsoleClient); +extern "C" const size_t Bun__ConsoleObject_object_size_ = sizeof(Bun::ConsoleClient); +extern "C" const size_t Bun__ConsoleObject_object_align_ = alignof(Bun::ConsoleClient); #ifndef INCLUDED_ #define INCLUDED_ diff --git a/src/jsc/bindings/headers-handwritten.h b/src/jsc/bindings/headers-handwritten.h index a36fb80aecb2..05e37e1690a4 100644 --- a/src/jsc/bindings/headers-handwritten.h +++ b/src/jsc/bindings/headers-handwritten.h @@ -7,7 +7,7 @@ #ifndef HEADERS_HANDWRITTEN #define HEADERS_HANDWRITTEN -typedef uint16_t ZigErrorCode; +typedef uint16_t BunErrorCode; typedef struct VirtualMachine VirtualMachine; // exists to make headers.h happy typedef struct CppWebSocket CppWebSocket; @@ -96,13 +96,13 @@ typedef struct BunString { } BunString; -typedef struct ZigErrorType { - ZigErrorCode code; +typedef struct BunErrorType { + BunErrorCode code; JSC::EncodedJSValue value; -} ZigErrorType; +} BunErrorType; typedef union ErrorableZigStringResult { ZigString value; - ZigErrorType err; + BunErrorType err; } ErrorableZigStringResult; typedef struct ErrorableZigString { ErrorableZigStringResult result; @@ -110,7 +110,7 @@ typedef struct ErrorableZigString { } ErrorableZigString; typedef union ErrorableStringResult { BunString value; - ZigErrorType err; + BunErrorType err; } ErrorableStringResult; typedef struct ErrorableString { ErrorableStringResult result; @@ -138,7 +138,7 @@ typedef struct ResolvedSource { static const uint32_t ResolvedSourceTagPackageJSONTypeModule = 1; typedef union ErrorableResolvedSourceResult { ResolvedSource value; - ZigErrorType err; + BunErrorType err; } ErrorableResolvedSourceResult; typedef struct ErrorableResolvedSource { ErrorableResolvedSourceResult result; @@ -165,19 +165,19 @@ const BunPluginTarget BunPluginTargetBrowser = 1; const BunPluginTarget BunPluginTargetNode = 2; const BunPluginTarget BunPluginTargetMax = BunPluginTargetNode; -typedef uint8_t ZigStackFrameCode; -const ZigStackFrameCode ZigStackFrameCodeNone = 0; -const ZigStackFrameCode ZigStackFrameCodeEval = 1; -const ZigStackFrameCode ZigStackFrameCodeModule = 2; -const ZigStackFrameCode ZigStackFrameCodeFunction = 3; -const ZigStackFrameCode ZigStackFrameCodeGlobal = 4; -const ZigStackFrameCode ZigStackFrameCodeWasm = 5; -const ZigStackFrameCode ZigStackFrameCodeConstructor = 6; +typedef uint8_t BunStackFrameCode; +const BunStackFrameCode BunStackFrameCodeNone = 0; +const BunStackFrameCode BunStackFrameCodeEval = 1; +const BunStackFrameCode BunStackFrameCodeModule = 2; +const BunStackFrameCode BunStackFrameCodeFunction = 3; +const BunStackFrameCode BunStackFrameCodeGlobal = 4; +const BunStackFrameCode BunStackFrameCodeWasm = 5; +const BunStackFrameCode BunStackFrameCodeConstructor = 6; extern "C" void __attribute((__noreturn__)) Bun__panic(const char* message, size_t length); #define BUN_PANIC(message) Bun__panic(message, sizeof(message) - 1) -typedef struct ZigStackFramePosition { +typedef struct BunStackFramePosition { int32_t line_zero_based; int32_t column_zero_based; int32_t byte_position; @@ -190,18 +190,18 @@ typedef struct ZigStackFramePosition { { return OrdinalNumber::fromZeroBasedInt(this->line_zero_based); } -} ZigStackFramePosition; +} BunStackFramePosition; -typedef struct ZigStackFrame { +typedef struct BunStackFrame { BunString function_name; BunString source_url; - ZigStackFramePosition position; - ZigStackFrameCode code_type; + BunStackFramePosition position; + BunStackFrameCode code_type; bool is_async; bool remapped; int32_t jsc_stack_frame_index; - ZigStackFrame() + BunStackFrame() : function_name {} , source_url {} , position {} @@ -211,20 +211,20 @@ typedef struct ZigStackFrame { , jsc_stack_frame_index(-1) { } -} ZigStackFrame; +} BunStackFrame; -typedef struct ZigStackTrace { +typedef struct BunStackTrace { BunString* source_lines_ptr; OrdinalNumber* source_lines_numbers; uint8_t source_lines_len; uint8_t source_lines_to_collect; - ZigStackFrame* frames_ptr; + BunStackFrame* frames_ptr; uint8_t frames_len; uint8_t frames_cap; JSC::SourceProvider* referenced_source_provider; -} ZigStackTrace; +} BunStackTrace; -typedef struct ZigException { +typedef struct BunException { unsigned char type; uint16_t runtime_type; int errno_; @@ -233,11 +233,11 @@ typedef struct ZigException { BunString path; BunString name; BunString message; - ZigStackTrace stack; + BunStackTrace stack; void* exception; bool remapped; int fd; -} ZigException; +} BunException; typedef uint8_t JSErrorCode; const JSErrorCode JSErrorCodeError = 0; @@ -363,7 +363,7 @@ typedef struct { extern "C" const char* Bun__userAgent; -extern "C" ZigErrorCode Zig_ErrorCodeParserError; +extern "C" BunErrorCode Bun_ErrorCodeParserError; extern "C" void ZigString__free(const unsigned char* ptr, size_t len, void* allocator); @@ -476,7 +476,7 @@ bool Bun__deepMatch( bool replacePropsWithAsymmetricMatchers, bool isMatchingObjectContaining); -extern "C" void Bun__remapStackFramePositions(void*, ZigStackFrame*, size_t); +extern "C" void Bun__remapStackFramePositions(void*, BunStackFrame*, size_t); namespace Inspector { class ScriptArguments; diff --git a/src/jsc/bindings/headers.h b/src/jsc/bindings/headers.h index 727eedebfb07..5f3e6a7b3258 100644 --- a/src/jsc/bindings/headers.h +++ b/src/jsc/bindings/headers.h @@ -294,7 +294,7 @@ CPP_DECL JSC::JSObject* JSC__JSValue__toObject(JSC::EncodedJSValue JSValue0, JSC CPP_DECL JSC::JSString* JSC__JSValue__toString(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::JSString* JSC__JSValue__toStringOrNull(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL uint64_t JSC__JSValue__toUInt64NoTruncate(JSC::EncodedJSValue JSValue0); -CPP_DECL void JSC__JSValue__toZigException(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, ZigException* arg2); +CPP_DECL void JSC__JSValue__toBunException(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, BunException* arg2); CPP_DECL void JSC__JSValue__toZigString(JSC::EncodedJSValue JSValue0, ZigString* arg1, JSC::JSGlobalObject* arg2); #pragma mark - JSC::VM @@ -674,7 +674,7 @@ ZIG_DECL JSC::EncodedJSValue Bun__Process__setCwd(JSC::JSGlobalObject* arg0, Zig ZIG_DECL JSC::EncodedJSValue Bun__Process__getEval(JSC::JSGlobalObject* arg0); #endif -CPP_DECL ZigException ZigException__fromException(JSC::Exception* arg0); +CPP_DECL BunException BunException__fromException(JSC::Exception* arg0); #pragma mark - Bun::ConsoleObject diff --git a/src/jsc/bindings/helpers.h b/src/jsc/bindings/helpers.h index e96615381bbb..1f60d09df77d 100644 --- a/src/jsc/bindings/helpers.h +++ b/src/jsc/bindings/helpers.h @@ -25,7 +25,7 @@ class GlobalObject; extern "C" size_t Bun__stringSyntheticAllocationLimit; extern "C" const char* Bun__errnoName(int); -namespace Zig { +namespace Bun { // 8 bit byte // we tag the final two bits @@ -343,7 +343,7 @@ static WTF::StringView toStringView(ZigString str) return WTF::StringView(std::span { untag(str.ptr), str.len }); } -static void throwException(JSC::ThrowScope& scope, ZigErrorType err, JSC::JSGlobalObject* global) +static void throwException(JSC::ThrowScope& scope, BunErrorType err, JSC::JSGlobalObject* global) { scope.throwException(global, JSC::Exception::create(global->vm(), JSC::JSValue::decode(err.value))); @@ -434,12 +434,12 @@ static const JSC::Identifier toIdentifier(ZigString str, JSC::JSGlobalObject* gl if (str.len == 0 || str.ptr == nullptr) { return global->vm().propertyNames->emptyIdentifier; } - WTF::String wtfstr = Zig::isTaggedExternalPtr(str.ptr) ? toString(str) : Zig::toStringCopy(str); + WTF::String wtfstr = Bun::isTaggedExternalPtr(str.ptr) ? toString(str) : Bun::toStringCopy(str); JSC::Identifier id = JSC::Identifier::fromString(global->vm(), wtfstr); return id; } -}; // namespace Zig +}; // namespace Bun JSC::JSValue createSystemError(JSC::JSGlobalObject* global, ASCIILiteral message, ASCIILiteral syscall, int err); JSC::JSValue createSystemError(JSC::JSGlobalObject* global, ASCIILiteral syscall, int err); diff --git a/src/jsc/bindings/napi.cpp b/src/jsc/bindings/napi.cpp index e8b8e311147b..daa3e75ce09e 100644 --- a/src/jsc/bindings/napi.cpp +++ b/src/jsc/bindings/napi.cpp @@ -77,7 +77,7 @@ #include "AsyncContextFrame.h" using namespace JSC; -using namespace Zig; +using namespace Bun; // Every NAPI function should use this at the start. It does the following: // - if NAPI_VERBOSE is 1, log that the function was called @@ -1794,7 +1794,7 @@ extern "C" napi_status napi_create_typedarray( NAPI_RETURN_SUCCESS(env); } -namespace Zig { +namespace Bun { extern "C" napi_status napi_get_all_property_names( napi_env env, napi_value objectNapi, napi_key_collection_mode key_mode, @@ -2673,7 +2673,7 @@ extern "C" napi_status napi_run_script(napi_env env, napi_value script, JSC::SourceCode sourceCode = makeSource(code, SourceOrigin(), SourceTaintedOrigin::Untainted); - NakedPtr returnedException; + NakedPtr returnedException; JSValue value = JSC::evaluate(globalObject, sourceCode, globalObject->globalThis(), returnedException); if (returnedException) { diff --git a/src/jsc/bindings/napi.h b/src/jsc/bindings/napi.h index 9d8e19f3ba9c..e2aca804d916 100644 --- a/src/jsc/bindings/napi.h +++ b/src/jsc/bindings/napi.h @@ -579,7 +579,7 @@ void executePendingNapiModule(Bun::GlobalObject* globalObject); } -namespace Zig { +namespace Bun { using namespace JSC; static inline JSValue toJS(napi_value val) diff --git a/src/jsc/bindings/napi_external.h b/src/jsc/bindings/napi_external.h index 2d104fceb81b..6525b697d892 100644 --- a/src/jsc/bindings/napi_external.h +++ b/src/jsc/bindings/napi_external.h @@ -104,4 +104,4 @@ class NapiExternal : public JSC::JSDestructibleObject { #endif }; -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/objects.h b/src/jsc/bindings/objects.h index 246cc3fc5773..15453b51ad35 100644 --- a/src/jsc/bindings/objects.h +++ b/src/jsc/bindings/objects.h @@ -7,7 +7,7 @@ // // #include -// namespace Zig { +// namespace Bun { // class ModulePrototype final : public JSC::JSNonFinalObject { // public: @@ -91,7 +91,7 @@ // } -// namespace Zig { +// namespace Bun { // class HeadersPrototype final : public JSC::JSNonFinalObject { // public: diff --git a/src/jsc/bindings/webcore/SerializedScriptValue.cpp b/src/jsc/bindings/webcore/SerializedScriptValue.cpp index 68731de03038..5a4a928e015d 100644 --- a/src/jsc/bindings/webcore/SerializedScriptValue.cpp +++ b/src/jsc/bindings/webcore/SerializedScriptValue.cpp @@ -2703,7 +2703,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) // a DataCloneError. // NapiPrototype is allowed because napi_create_object should behave // like a plain object from JS's perspective (matches Node.js). - if (inObject->classInfo() != JSFinalObject::info() && inObject->classInfo() != Zig::NapiPrototype::info()) + if (inObject->classInfo() != JSFinalObject::info() && inObject->classInfo() != Bun::NapiPrototype::info()) return SerializationReturnCode::DataCloneError; inputObjectStack.append(inObject); indexStack.append(0); diff --git a/src/jsc/bindings/webcore/WebSocket.cpp b/src/jsc/bindings/webcore/WebSocket.cpp index fa4b6688c823..c7f700a887b2 100644 --- a/src/jsc/bindings/webcore/WebSocket.cpp +++ b/src/jsc/bindings/webcore/WebSocket.cpp @@ -885,14 +885,14 @@ void WebSocket::sendWebSocketString(const String& message, const Opcode op) { switch (m_connectedWebSocketKind) { case ConnectedWebSocketKind::Client: { - auto zigStr = Zig::toZigString(message); + auto zigStr = Bun::toZigString(message); Bun__WebSocketClient__writeString(this->m_connectedWebSocket.client, &zigStr, static_cast(op)); // this->m_connectedWebSocket.client->send({ baseAddress, length }, opCode); // this->m_bufferedAmount = this->m_connectedWebSocket.client->getBufferedAmount(); break; } case ConnectedWebSocketKind::ClientSSL: { - auto zigStr = Zig::toZigString(message); + auto zigStr = Bun::toZigString(message); Bun__WebSocketClientTLS__writeString(this->m_connectedWebSocket.clientSSL, &zigStr, static_cast(op)); break; } @@ -991,14 +991,14 @@ ExceptionOr WebSocket::close(std::optional optionalCode, c m_state = CLOSING; switch (m_connectedWebSocketKind) { case ConnectedWebSocketKind::Client: { - ZigString reasonZigStr = Zig::toZigString(reason); + ZigString reasonZigStr = Bun::toZigString(reason); Bun__WebSocketClient__close(this->m_connectedWebSocket.client, code, &reasonZigStr); updateHasPendingActivity(); // this->m_bufferedAmount = this->m_connectedWebSocket.client->getBufferedAmount(); break; } case ConnectedWebSocketKind::ClientSSL: { - ZigString reasonZigStr = Zig::toZigString(reason); + ZigString reasonZigStr = Bun::toZigString(reason); Bun__WebSocketClientTLS__close(this->m_connectedWebSocket.clientSSL, code, &reasonZigStr); updateHasPendingActivity(); // this->m_bufferedAmount = this->m_connectedWebSocket.clientSSL->getBufferedAmount(); @@ -1904,7 +1904,7 @@ extern "C" void WebSocket__didClose(WebCore::WebSocket* webSocket, uint16_t erro extern "C" void WebSocket__didReceiveText(WebCore::WebSocket* webSocket, bool clone, const ZigString* str) { - WTF::String wtf_str = clone ? Zig::toStringCopy(*str) : Zig::toString(*str); + WTF::String wtf_str = clone ? Bun::toStringCopy(*str) : Bun::toString(*str); webSocket->didReceiveMessage(WTF::move(wtf_str)); } extern "C" void WebSocket__didReceiveBytes(WebCore::WebSocket* webSocket, const uint8_t* bytes, size_t len, const uint8_t op) diff --git a/src/jsc/host_fn.rs b/src/jsc/host_fn.rs index d65bf77c1760..37693d4be50d 100644 --- a/src/jsc/host_fn.rs +++ b/src/jsc/host_fn.rs @@ -960,7 +960,7 @@ pub enum DomEffectId { pub struct DomCall { pub class_name: &'static str, pub function_name: &'static str, - /// `____put` — generated in `ZigLazyStaticFunctions-inlines.h`. + /// `____put` — generated in `BunLazyStaticFunctions-inlines.h`. pub put: unsafe extern "C" fn(*mut JSGlobalObject, JSValue), } diff --git a/src/jsc/lib.rs b/src/jsc/lib.rs index 1162bfcf6e76..c250a7ebf3b3 100644 --- a/src/jsc/lib.rs +++ b/src/jsc/lib.rs @@ -99,17 +99,17 @@ pub mod text_codec; pub mod url_search_params; #[path = "WTF.rs"] pub mod wtf; -#[path = "ZigErrorType.rs"] -pub mod zig_error_type; -#[path = "ZigStackFrameCode.rs"] -pub mod zig_stack_frame_code; -#[path = "ZigStackFramePosition.rs"] -pub mod zig_stack_frame_position; - -/// `bun.schema.api` types that reference `ZigStackFramePosition` (this crate) +#[path = "BunErrorType.rs"] +pub mod bun_error_type; +#[path = "BunStackFrameCode.rs"] +pub mod bun_stack_frame_code; +#[path = "BunStackFramePosition.rs"] +pub mod bun_stack_frame_position; + +/// `bun.schema.api` types that reference `BunStackFramePosition` (this crate) /// and so cannot live in `bun_options_types::schema::api` without a dep cycle. pub mod schema_api { - use crate::ZigStackFramePosition; + use crate::BunStackFramePosition; /// Non-exhaustive stack-frame scope tag. Newtype keeps any-u8 FFI-safe. #[repr(transparent)] @@ -127,7 +127,7 @@ pub mod schema_api { } /// Line/column position of a stack frame (FFI layout shared with C++). - pub type StackFramePosition = ZigStackFramePosition; + pub type StackFramePosition = BunStackFramePosition; /// One captured stack frame: function name, file, position, and scope (FFI layout shared with C++). #[derive(Clone)] @@ -172,7 +172,7 @@ pub mod schema_api { } /// Lives here (not `bun_options_types::schema::api`) because `stack`'s - /// [`StackTrace`] transitively names `ZigStackFramePosition` from this + /// [`StackTrace`] transitively names `BunStackFramePosition` from this /// crate; the `bun_options_types` copy omits `stack` to avoid the cycle. #[derive(Clone, Default)] pub struct JsException { @@ -454,9 +454,9 @@ pub use self::source_provider::SourceProvider; pub use self::source_type::SourceType; pub use self::text_codec::TextCodec; pub use self::url_search_params::URLSearchParams; -pub use self::zig_error_type::ZigErrorType; -pub use self::zig_stack_frame_code::ZigStackFrameCode; -pub use self::zig_stack_frame_position::ZigStackFramePosition; +pub use self::bun_error_type::BunErrorType; +pub use self::bun_stack_frame_code::BunStackFrameCode; +pub use self::bun_stack_frame_position::BunStackFramePosition; #[path = "GarbageCollectionController.rs"] pub mod garbage_collection_controller; @@ -516,12 +516,12 @@ pub mod system_error; pub mod url; #[path = "VM.rs"] pub mod vm; -#[path = "ZigException.rs"] -pub mod zig_exception; -#[path = "ZigStackFrame.rs"] -pub mod zig_stack_frame; -#[path = "ZigStackTrace.rs"] -pub mod zig_stack_trace; +#[path = "BunException.rs"] +pub mod bun_exception; +#[path = "BunStackFrame.rs"] +pub mod bun_stack_frame; +#[path = "BunStackTrace.rs"] +pub mod bun_stack_trace; // `generated_classes_list.rs` is mounted by `bun_runtime` (see its lib.rs) — // every aliased type lives in api/webcore/test_runner/bake, so mounting it // here would create a `bun_jsc → bun_runtime` cycle. @@ -988,8 +988,8 @@ pub use self::cached_bytecode::CachedBytecode; pub use self::deferred_error::DeferredError; pub use self::dom_form_data::DOMFormData; pub use self::url::URL; -pub use self::zig_stack_frame::ZigStackFrame; -pub use self::zig_stack_trace::ZigStackTrace; +pub use self::bun_stack_frame::BunStackFrame; +pub use self::bun_stack_trace::BunStackTrace; pub use abort_signal::{AbortSignal, AbortSignalRef}; // `VM` / `JSGlobalObject` — opaque FFI handles to C++-owned objects. Defined @@ -1227,7 +1227,7 @@ pub use self::js_promise::Strong as JSPromiseStrong; pub use self::js_promise::Status as PromiseStatus; /// `bun_ptr::RefPtr` — intrusive refcounted smart pointer. Re-exported here so -/// `crate::RefPtr` (ZigStackTrace.rs) resolves without every +/// `crate::RefPtr` (BunStackTrace.rs) resolves without every /// submodule taking a direct `bun_ptr` dep. pub use bun_ptr::RefPtr; @@ -1986,7 +1986,7 @@ where } // ────────────────────────────────────────────────────────────────────────── -// BuildMessage / ResolveMessage / ZigException::Holder / JsClass. +// BuildMessage / ResolveMessage / BunException::Holder / JsClass. // ────────────────────────────────────────────────────────────────────────── #[path = "BuildMessage.rs"] pub mod build_message; @@ -1996,7 +1996,7 @@ pub use self::build_message::BuildMessage; pub mod resolve_message; pub use self::resolve_message::ResolveMessage; -pub use self::zig_exception::ZigException; +pub use self::bun_exception::BunException; /// Trait implemented by `#[bun_jsc::JsClass]`-derived types. The proc-macro /// emits `to_js`/`from_js`/`from_js_direct` per type; this is the trait shape. diff --git a/src/jsc/modules/AbortControllerModuleModule.h b/src/jsc/modules/AbortControllerModuleModule.h index f27146d76c86..000a69919fa7 100644 --- a/src/jsc/modules/AbortControllerModuleModule.h +++ b/src/jsc/modules/AbortControllerModuleModule.h @@ -6,7 +6,7 @@ using namespace JSC; using namespace WebCore; -namespace Zig { +namespace Bun { inline void generateNativeModule_AbortControllerModule( JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, @@ -49,4 +49,4 @@ inline void generateNativeModule_AbortControllerModule( vm, vm.propertyNames->defaultKeyword, abortController, static_cast(PropertyAttribute::DontDelete)); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/BunAppModule.h b/src/jsc/modules/BunAppModule.h index 6b46ec3bc455..755219153bc0 100644 --- a/src/jsc/modules/BunAppModule.h +++ b/src/jsc/modules/BunAppModule.h @@ -4,7 +4,7 @@ #include "_NativeModule.h" #include "BakeAdditionsToGlobalObject.h" -namespace Zig { +namespace Bun { using namespace WebCore; using namespace JSC; @@ -20,4 +20,4 @@ DEFINE_NATIVE_MODULE(BunApp) RETURN_NATIVE_MODULE(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/BunJSCModule.h b/src/jsc/modules/BunJSCModule.h index 1fab1bc16585..ffeebfc94383 100644 --- a/src/jsc/modules/BunJSCModule.h +++ b/src/jsc/modules/BunJSCModule.h @@ -44,7 +44,7 @@ #endif #include "JSDOMConvertBase.h" -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include "mimalloc.h" extern "C" char* mi_stats_get_json(size_t, char*); extern "C" char* mi_heap_dump_json(bool include_blocks, bool hash_addresses); @@ -891,7 +891,7 @@ JSC_DEFINE_HOST_FUNCTION(functionCodeCoverageForFile, RETURN_IF_EXCEPTION(throwScope, {}); bool ignoreSourceMap = callFrame->argument(1).toBoolean(globalObject); - auto sourceID = Zig::sourceIDForSourceURL(fileName); + auto sourceID = Bun::sourceIDForSourceURL(fileName); if (!sourceID) { throwException(globalObject, throwScope, createError(globalObject, "No source for file"_s)); @@ -997,7 +997,7 @@ JSC_DEFINE_HOST_FUNCTION(functionPercentAvailableMemoryInUse, (JSGlobalObject * @end */ -namespace Zig { +namespace Bun { DEFINE_NATIVE_MODULE(BunJSC) { INIT_NATIVE_MODULE(36); @@ -1044,4 +1044,4 @@ DEFINE_NATIVE_MODULE(BunJSC) RETURN_NATIVE_MODULE(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/BunObjectModule.h b/src/jsc/modules/BunObjectModule.h index c5aefa3e94a2..47afce9921ba 100644 --- a/src/jsc/modules/BunObjectModule.h +++ b/src/jsc/modules/BunObjectModule.h @@ -1,8 +1,8 @@ -namespace Zig { +namespace Bun { void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, JSC::MarkedArgumentBuffer& exportValues); -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/BunTestModule.h b/src/jsc/modules/BunTestModule.h index e33bed4a66ee..8e58c526311b 100644 --- a/src/jsc/modules/BunTestModule.h +++ b/src/jsc/modules/BunTestModule.h @@ -1,5 +1,5 @@ -namespace Zig { +namespace Bun { void generateNativeModule_BunTest( JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, @@ -37,4 +37,4 @@ void generateNativeModule_BunTest( } } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeBufferModule.h b/src/jsc/modules/NodeBufferModule.h index dad58afda71f..22cbdc22dadd 100644 --- a/src/jsc/modules/NodeBufferModule.h +++ b/src/jsc/modules/NodeBufferModule.h @@ -10,7 +10,7 @@ #include "wtf/SIMDUTF.h" #include -namespace Zig { +namespace Bun { using namespace WebCore; using namespace JSC; @@ -216,4 +216,4 @@ DEFINE_NATIVE_MODULE(NodeBuffer) put(JSC::Identifier::fromString(vm, "isUtf8"_s), JSC::JSFunction::create(vm, globalObject, 1, "isUtf8"_s, jsBufferConstructorFunction_isUtf8, ImplementationVisibility::Public, NoIntrinsic, jsBufferConstructorFunction_isUtf8)); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeConstantsModule.h b/src/jsc/modules/NodeConstantsModule.h index 4a2b1d6f33df..3782b754ae2d 100644 --- a/src/jsc/modules/NodeConstantsModule.h +++ b/src/jsc/modules/NodeConstantsModule.h @@ -54,7 +54,7 @@ #include #endif -namespace Zig { +namespace Bun { using namespace WebCore; DEFINE_NATIVE_MODULE(NodeConstants) @@ -999,4 +999,4 @@ DEFINE_NATIVE_MODULE(NodeConstants) // RETURN_NATIVE_MODULE(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeModuleModule.cpp b/src/jsc/modules/NodeModuleModule.cpp index 4b5c83ec8da1..989906b2d688 100644 --- a/src/jsc/modules/NodeModuleModule.cpp +++ b/src/jsc/modules/NodeModuleModule.cpp @@ -1135,7 +1135,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsModuleResolveFilenameSlowPathEnabled, } // namespace Bun -namespace Zig { +namespace Bun { void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, @@ -1177,4 +1177,4 @@ void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, } } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeModuleModule.h b/src/jsc/modules/NodeModuleModule.h index c47af8bebfb8..7b29e1d106a9 100644 --- a/src/jsc/modules/NodeModuleModule.h +++ b/src/jsc/modules/NodeModuleModule.h @@ -13,7 +13,7 @@ #include #include -using namespace Zig; +using namespace Bun; using namespace JSC; namespace Bun { @@ -33,7 +33,7 @@ JSC::JSValue resolveLookupPaths(JSC::JSGlobalObject* globalObject, String reques } -namespace Zig { +namespace Bun { void generateNativeModule_NodeModule( JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey, @@ -41,4 +41,4 @@ void generateNativeModule_NodeModule( JSC::MarkedArgumentBuffer &exportValues); -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeProcessModule.h b/src/jsc/modules/NodeProcessModule.h index fd0f813370a5..7bec9b31e2aa 100644 --- a/src/jsc/modules/NodeProcessModule.h +++ b/src/jsc/modules/NodeProcessModule.h @@ -4,7 +4,7 @@ #include #include "BunProcess.h" -namespace Zig { +namespace Bun { DEFINE_NATIVE_MODULE(NodeProcess) { @@ -44,4 +44,4 @@ DEFINE_NATIVE_MODULE(NodeProcess) } } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeStringDecoderModule.h b/src/jsc/modules/NodeStringDecoderModule.h index cad22c468641..4e5820756ba1 100644 --- a/src/jsc/modules/NodeStringDecoderModule.h +++ b/src/jsc/modules/NodeStringDecoderModule.h @@ -2,7 +2,7 @@ #include "../bindings/BunGlobalObject.h" #include -namespace Zig { +namespace Bun { DEFINE_NATIVE_MODULE(NodeStringDecoder) { @@ -14,4 +14,4 @@ DEFINE_NATIVE_MODULE(NodeStringDecoder) RETURN_NATIVE_MODULE(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeTTYModule.cpp b/src/jsc/modules/NodeTTYModule.cpp index b5a870a4a42c..7fdd6c4e8c8a 100644 --- a/src/jsc/modules/NodeTTYModule.cpp +++ b/src/jsc/modules/NodeTTYModule.cpp @@ -4,7 +4,7 @@ using namespace JSC; -namespace Zig { +namespace Bun { JSC_DEFINE_HOST_FUNCTION(jsFunctionTty_isatty, (JSGlobalObject * globalObject, CallFrame* callFrame)) { @@ -44,4 +44,4 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplementedYet, return {}; } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeTTYModule.h b/src/jsc/modules/NodeTTYModule.h index 5b897a3a48cb..18cf2a7305f8 100644 --- a/src/jsc/modules/NodeTTYModule.h +++ b/src/jsc/modules/NodeTTYModule.h @@ -7,7 +7,7 @@ #include #endif -namespace Zig { +namespace Bun { using namespace WebCore; JSC_DECLARE_HOST_FUNCTION(jsFunctionTty_isatty); @@ -29,4 +29,4 @@ DEFINE_NATIVE_MODULE(NodeTTY) RETURN_NATIVE_MODULE(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeUtilTypesModule.cpp b/src/jsc/modules/NodeUtilTypesModule.cpp index 00c0423c019f..ed0027bf79ae 100644 --- a/src/jsc/modules/NodeUtilTypesModule.cpp +++ b/src/jsc/modules/NodeUtilTypesModule.cpp @@ -461,7 +461,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsEventTarget, return JSValue::encode(jsBoolean(cell->inherits())); } -namespace Zig { +namespace Bun { // Hardcoded module "node:util/types" DEFINE_NATIVE_MODULE_NOINLINE(NodeUtilTypes) @@ -516,4 +516,4 @@ DEFINE_NATIVE_MODULE_NOINLINE(NodeUtilTypes) RETURN_NATIVE_MODULE(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeUtilTypesModule.h b/src/jsc/modules/NodeUtilTypesModule.h index 73a668236c18..58f56c8d2c65 100644 --- a/src/jsc/modules/NodeUtilTypesModule.h +++ b/src/jsc/modules/NodeUtilTypesModule.h @@ -9,9 +9,9 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsError, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)); -namespace Zig { +namespace Bun { // Hardcoded module "node:util/types" DEFINE_NATIVE_MODULE_NOINLINE(NodeUtilTypes); -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/ObjectModule.cpp b/src/jsc/modules/ObjectModule.cpp index 49eedb54ca7a..ed902c27db7b 100644 --- a/src/jsc/modules/ObjectModule.cpp +++ b/src/jsc/modules/ObjectModule.cpp @@ -1,6 +1,6 @@ #include "ObjectModule.h" -namespace Zig { +namespace Bun { JSC::SyntheticSourceProvider::SyntheticSourceGenerator generateObjectModuleSourceCode(JSC::JSGlobalObject* globalObject, JSC::JSObject* object) @@ -106,4 +106,4 @@ generateJSValueExportDefaultObjectSourceCode(JSC::JSGlobalObject* globalObject, gcUnprotectNullTolerant(value.asCell()); }; } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/ObjectModule.h b/src/jsc/modules/ObjectModule.h index c4e18e022d59..8eacccb24c40 100644 --- a/src/jsc/modules/ObjectModule.h +++ b/src/jsc/modules/ObjectModule.h @@ -3,7 +3,7 @@ #include "../bindings/BunGlobalObject.h" #include -namespace Zig { +namespace Bun { JSC::SyntheticSourceProvider::SyntheticSourceGenerator generateObjectModuleSourceCode(JSC::JSGlobalObject* globalObject, JSC::JSObject* object); @@ -20,4 +20,4 @@ JSC::SyntheticSourceProvider::SyntheticSourceGenerator generateJSValueExportDefaultObjectSourceCode(JSC::JSGlobalObject* globalObject, JSC::JSValue value); -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/UTF8ValidateModule.h b/src/jsc/modules/UTF8ValidateModule.h index e5d12b93a250..585bade91feb 100644 --- a/src/jsc/modules/UTF8ValidateModule.h +++ b/src/jsc/modules/UTF8ValidateModule.h @@ -2,7 +2,7 @@ using namespace JSC; using namespace WebCore; -namespace Zig { +namespace Bun { inline void generateNativeModule_UTF8Validate(JSC::JSGlobalObject* globalObject, JSC::Identifier moduleKey, @@ -18,4 +18,4 @@ generateNativeModule_UTF8Validate(JSC::JSGlobalObject* globalObject, jsBufferConstructorFunction_isUtf8)); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/_NativeModule.h b/src/jsc/modules/_NativeModule.h index 32b364da03c8..07ed0dd84230 100644 --- a/src/jsc/modules/_NativeModule.h +++ b/src/jsc/modules/_NativeModule.h @@ -107,11 +107,11 @@ while (0) { \ } -namespace Zig { +namespace Bun { #define FORWARD_DECL_GENERATOR(id, enumName) \ void generateNativeModule_##enumName( \ JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey, \ Vector &exportNames, \ JSC::MarkedArgumentBuffer &exportValues); BUN_FOREACH_ESM_NATIVE_MODULE(FORWARD_DECL_GENERATOR) -} // namespace Zig \ No newline at end of file +} // namespace Bun \ No newline at end of file diff --git a/src/runtime/api/BunObject.rs b/src/runtime/api/BunObject.rs index 36ff7be17128..2c51b75bfd36 100644 --- a/src/runtime/api/BunObject.rs +++ b/src/runtime/api/BunObject.rs @@ -725,7 +725,7 @@ pub(crate) fn inspect(global_this: &JSGlobalObject, callframe: &CallFrame) -> Js // NOTE: this is *not* the fix for error-gc-test.test.js timing out under // debug+ASAN — that test does 100k `Bun.inspect(new Error)` and the cost // is spread across ASAN-instrumented memcpy/memset, mimalloc zero-checks - // and the source-file re-read in `remap_zig_exception`, none of which a + // and the source-file re-read in `remap_bun_exception`, none of which a // 32-byte alloc elision can recover. The test is classified `[TIMEOUT]` // for ASAN in test/expectations.txt instead. let args_buf = scopeguard::guard(args_buf, |buf| { diff --git a/src/runtime/bake/BakeSourceProvider.cpp b/src/runtime/bake/BakeSourceProvider.cpp index b337c9f3f218..ceac67bfb06a 100644 --- a/src/runtime/bake/BakeSourceProvider.cpp +++ b/src/runtime/bake/BakeSourceProvider.cpp @@ -49,7 +49,7 @@ extern "C" JSC::EncodedJSValue BakeLoadInitialServerCode(JSC::JSGlobalObject* gl JSC::MarkedArgumentBuffer args; args.append(JSC::jsBoolean(separateSSRGraph)); // separateSSRGraph - args.append(Zig::ImportMetaObject::create(global, "bake://server-runtime.js"_s)); // importMeta + args.append(Bun::ImportMetaObject::create(global, "bake://server-runtime.js"_s)); // importMeta RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::profiledCall(global, JSC::ProfilingReason::API, fn, callData, JSC::jsUndefined(), args))); } diff --git a/src/runtime/bake/DevServer/ErrorReportRequest.rs b/src/runtime/bake/DevServer/ErrorReportRequest.rs index 9d35c13c0e80..3cbfb15343da 100644 --- a/src/runtime/bake/DevServer/ErrorReportRequest.rs +++ b/src/runtime/bake/DevServer/ErrorReportRequest.rs @@ -24,8 +24,8 @@ use bun_core::{Ordinal, Output}; use bun_core::{String as BunString, strings}; use bun_io::Write as _; use bun_jsc::{ - JSErrorCode, JSRuntimeType, ZigException, ZigStackFrame, ZigStackFrameCode, - ZigStackFramePosition, ZigStackTrace, + JSErrorCode, JSRuntimeType, BunException, BunStackFrame, BunStackFrameCode, + BunStackFramePosition, BunStackTrace, }; use bun_paths::path_buffer_pool; use bun_uws::{self as uws, AnyResponse, Request}; @@ -123,22 +123,22 @@ impl ErrorReportRequest { // SAFETY: `ctx` is the live heap allocation from `run` (caller contract). let dev: &DevServer = unsafe { &*ctx }.dev.get(); - // Read payload, assemble ZigException + // Read payload, assemble BunException let name = sanitize_for_terminal(read_string32(&mut reader)?, &arena); let message = sanitize_for_terminal(read_string32(&mut reader)?, &arena); let browser_url = sanitize_for_terminal(read_string32(&mut reader)?, &arena); let stack_count = reader.read_int_le::()?.min(255); // does not support more than 255 - let mut frames: Vec = Vec::with_capacity(stack_count as usize); + let mut frames: Vec = Vec::with_capacity(stack_count as usize); for _ in 0..stack_count { let line = reader.read_int_le::()?; let column = reader.read_int_le::()?; let function_name = sanitize_for_terminal(read_string32(&mut reader)?, &arena); let file_name = sanitize_for_terminal(read_string32(&mut reader)?, &arena); - frames.push(ZigStackFrame { + frames.push(BunStackFrame { function_name: BunString::init(function_name), source_url: BunString::init(file_name), position: if line > 0 { - ZigStackFramePosition { + BunStackFramePosition { line: Ordinal::from_one_based(line), column: if column < 1 { Ordinal::INVALID @@ -148,13 +148,13 @@ impl ErrorReportRequest { line_start_byte: 0, } } else { - ZigStackFramePosition { + BunStackFramePosition { line: Ordinal::INVALID, column: Ordinal::INVALID, line_start_byte: 0, } }, - code_type: ZigStackFrameCode::NONE, + code_type: BunStackFrameCode::NONE, is_async: false, remapped: false, jsc_stack_frame_index: -1, @@ -178,7 +178,7 @@ impl ErrorReportRequest { let mut runtime_lines: Option<[&[u8]; 5]> = None; let mut first_line_of_interest: usize = 0; - let mut top_frame_position = ZigStackFramePosition::INVALID; + let mut top_frame_position = BunStackFramePosition::INVALID; let mut region_of_interest_line: u32 = 0; for frame in frames.iter_mut() { // Every `source_url` here is `Tag::ZigString` (built via @@ -230,7 +230,7 @@ impl ErrorReportRequest { || frame.position.line.zero_based() < generated_mappings[1].lines.zero_based() { frame.source_url = BunString::init(RUNTIME_NAME); // matches value in source map - frame.position = ZigStackFramePosition::INVALID; + frame.position = BunStackFramePosition::INVALID; continue; } @@ -239,7 +239,7 @@ impl ErrorReportRequest { .mappings .find(frame.position.line, frame.position.column); if let Some(remapped_position) = &remapped { - frame.position = ZigStackFramePosition { + frame.position = BunStackFramePosition { line: Ordinal::from_zero_based(remapped_position.original_line()), column: Ordinal::from_zero_based(remapped_position.original_column()), line_start_byte: 0, @@ -274,7 +274,7 @@ impl ErrorReportRequest { } else if index == 0 { // Should be picked up by above but just in case. frame.source_url = BunString::init(RUNTIME_NAME); - frame.position = ZigStackFramePosition::INVALID; + frame.position = BunStackFramePosition::INVALID; } } } @@ -303,12 +303,12 @@ impl ErrorReportRequest { }); } - let mut exception = ZigException { + let mut exception = BunException { r#type: JSErrorCode::Error, runtime_type: JSRuntimeType::NOTHING, name: BunString::init(name), message: BunString::init(message), - stack: ZigStackTrace::from_frames(&mut frames), + stack: BunStackTrace::from_frames(&mut frames), exception: core::ptr::null_mut(), remapped: false, browser_url: BunString::init(browser_url), @@ -322,7 +322,7 @@ impl ErrorReportRequest { { let stderr = Output::error_writer_buffered(); let _flush = Output::flush_guard(); - // `print_externally_remapped_zig_exception` takes a runtime + // `print_externally_remapped_bun_exception` takes a runtime // `allow_ansi_color` flag. let ansi_colors = Output::enable_ansi_colors_stderr(); // `dev.vm` is `*const` (shared-ref provenance from `Options.vm`); @@ -330,7 +330,7 @@ impl ErrorReportRequest { // singleton (`VirtualMachine::get() -> *mut`), which carries // mutable provenance. Single JS thread — no aliasing `&mut`. let vm = dev.vm_mut(); - let _ = vm.print_externally_remapped_zig_exception( + let _ = vm.print_externally_remapped_bun_exception( &mut exception, None, stderr, diff --git a/src/runtime/ffi/mod.rs b/src/runtime/ffi/mod.rs index 1e5800bf823c..82a204c4bd06 100644 --- a/src/runtime/ffi/mod.rs +++ b/src/runtime/ffi/mod.rs @@ -59,7 +59,7 @@ mod dom_call_slowpath { arguments_len: usize, ) -> JSValue { // SAFETY: C++ DOMJIT slowpath caller passes a live global and a - // valid `[JSValue; arguments_len]` span (ZigLazyStaticFunctions). + // valid `[JSValue; arguments_len]` span (BunLazyStaticFunctions). let (global, arguments) = unsafe { (&*global, core::slice::from_raw_parts(arguments_ptr, arguments_len)) }; diff --git a/src/runtime/hw_exports.rs b/src/runtime/hw_exports.rs index 352a2f7ae658..3ca8c5cbb4f6 100644 --- a/src/runtime/hw_exports.rs +++ b/src/runtime/hw_exports.rs @@ -23,7 +23,7 @@ use core::ffi::c_void; use bun_jsc::virtual_machine::VirtualMachine; -use bun_jsc::{CallFrame, JSGlobalObject, JSInternalPromise, JSValue, ZigStackFrame}; +use bun_jsc::{CallFrame, JSGlobalObject, JSInternalPromise, JSValue, BunStackFrame}; // ─── VirtualMachine ────────────────────────────────────────────────────────── // @@ -73,13 +73,13 @@ pub fn log_unhandled_exception(exception: JSValue) { /// underlying method serializes on `remap_stack_frames_mutex`. /// /// # Safety -/// `frames` must point to a live array of `frames_count` `ZigStackFrame`s. +/// `frames` must point to a live array of `frames_count` `BunStackFrame`s. // HOST_EXPORT(Bun__remapStackFramePositions, c) // Forwards `frames` to the C++-side remapper without dereferencing; not_unsafe_ptr_arg_deref is a false positive on opaque-token forwarding. #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn remap_stack_frame_positions( vm: &mut VirtualMachine, - frames: *mut ZigStackFrame, + frames: *mut BunStackFrame, frames_count: usize, ) { // SAFETY: `frames[..frames_count]` is a live C++ array; the method takes diff --git a/src/runtime/jsc_hooks.rs b/src/runtime/jsc_hooks.rs index 8a166e62220c..86a0ef9d1090 100644 --- a/src/runtime/jsc_hooks.rs +++ b/src/runtime/jsc_hooks.rs @@ -3513,7 +3513,7 @@ fn get_hardcoded_module( Some(OwnedResolvedSource::from(ResolvedSource { source_code: bun_core::String::clone_utf8(&ep.contents), // +1 each: ~SourceProvider() derefs `specifier` and - // `source_url` once all uses are done (see ZigSourceProvider.cpp). + // `source_url` once all uses are done (see BunSourceProvider.cpp). specifier: specifier.dupe_ref(), source_url: specifier.dupe_ref(), tag: Tag::Esm, diff --git a/src/runtime/test_runner/diff_format.rs b/src/runtime/test_runner/diff_format.rs index cc2650028c9b..51550ce7e39a 100644 --- a/src/runtime/test_runner/diff_format.rs +++ b/src/runtime/test_runner/diff_format.rs @@ -92,7 +92,7 @@ impl<'a> fmt::Display for DiffFormatter<'a> { /// the `extern "C"` symbol resolves the same at link time regardless of which /// crate defines it. #[unsafe(no_mangle)] -pub(crate) extern "C" fn zig__renderDiff( +pub(crate) extern "C" fn bun__renderDiff( expected_ptr: *const core::ffi::c_char, expected_len: usize, received_ptr: *const core::ffi::c_char, diff --git a/src/runtime/webview/ChromeBackend.cpp b/src/runtime/webview/ChromeBackend.cpp index 5ff06db7f4ad..0397438b2815 100644 --- a/src/runtime/webview/ChromeBackend.cpp +++ b/src/runtime/webview/ChromeBackend.cpp @@ -653,7 +653,7 @@ static void settle(JSGlobalObject* g, JSWebView* view, PendingSlot slot, bool ok // WTF::JSON parses to a C++ tree — no JSValue allocation, no GC pressure. // The tree is small (exceptionDetails is error-path only, ~200B). Stamp // .stack with description directly; Bun's V8StackTraceIterator -// (ZigException.cpp) already parses V8 stacks when it needs frames. +// (BunException.cpp) already parses V8 stacks when it needs frames. // ErrorInstance::create stackString overload sets .stack without capturing // a JSC-side trace (which would show ChromeBackend.cpp, not page frames). static JSValue errorFromExceptionDetails(JSGlobalObject* g, std::span excDetails) diff --git a/src/sourcemap/lib.rs b/src/sourcemap/lib.rs index 2d58dd7c90bc..bb7dfc335ebb 100644 --- a/src/sourcemap/lib.rs +++ b/src/sourcemap/lib.rs @@ -440,7 +440,7 @@ impl core::fmt::Display for DebugIDFormatter { } } -// This is a pointer to a ZigSourceProvider that may or may not have a `//# sourceMappingURL` comment +// This is a pointer to a BunSourceProvider that may or may not have a `//# sourceMappingURL` comment // when we want to lookup this data, we will then resolve it to a ParsedSourceMap if it does. // // This is used for files that were pre-bundled with `bun build --target=bun --sourcemap` @@ -451,12 +451,12 @@ unsafe extern "C" { // bytes of it), so `&SourceProviderMap` carries no `readonly`/`noalias` — // the foreign side owns all state behind the handle and may mutate it. The // only param is that handle reference, so this is a `safe fn`. - safe fn ZigSourceProvider__getSourceSlice(this: &SourceProviderMap) -> bun_core::String; + safe fn BunSourceProvider__getSourceSlice(this: &SourceProviderMap) -> bun_core::String; } impl SourceProviderMap { pub fn get_source_slice(&self) -> bun_core::String { - ZigSourceProvider__getSourceSlice(self) + BunSourceProvider__getSourceSlice(self) } pub fn to_source_content_ptr(&self) -> SourceContentPtr { diff --git a/test/js/bun/util/reportError.test.ts b/test/js/bun/util/reportError.test.ts index 3075af55f04f..5405e63c3a0d 100644 --- a/test/js/bun/util/reportError.test.ts +++ b/test/js/bun/util/reportError.test.ts @@ -81,8 +81,8 @@ test("native error printer handles lone surrogates in message and stack frame na // path formatting around it. const fixture = String.raw` function thrower() { throw new Error("MSG_PRE\uD800MSG_POST"); } - // Force the native ZigStackFrame NameFormatter path: give the frame a - // function_name containing a lone high surrogate. (src/jsc/ZigStackFrame.zig + // Force the native BunStackFrame NameFormatter path: give the frame a + // function_name containing a lone high surrogate. (src/jsc/BunStackFrame.zig // NameFormatter.format -> "{f}" on bun.String) Object.defineProperty(thrower, "name", { value: "FN_PRE\uD800FN_POST" }); thrower(); diff --git a/test/leaksan.supp b/test/leaksan.supp index 11deb28350c3..52ca91b3dcd4 100644 --- a/test/leaksan.supp +++ b/test/leaksan.supp @@ -24,7 +24,7 @@ leak:CRYPTO_set_thread_local leak:BIO_new leak:_tlv_get_addr leak:Bun::generateModule -leak:Zig::ImportMetaObject::createFromSpecifier +leak:Bun::ImportMetaObject::createFromSpecifier leak:Bun::GlobalObject::moduleLoaderResolve leak:JSModuleLoader__import leak:dyld::ThreadLocalVariables @@ -54,7 +54,7 @@ leak:JSC::moduleLoaderModuleDeclarationInstantiation leak:JSC::arrayProtoFuncSort leak:bindgen_Fmt_jsFmtString leak:runtime.dns_jsc.dns.GetAddrInfoRequest.run -leak:Zig::ImportMetaObject::finishCreation +leak:Bun::ImportMetaObject::finishCreation leak:uws_add_server_name_with_options leak:runtime.webcore.Body.Value.fromJS leak:sys_jsc.error_jsc.errorToSystemError @@ -95,12 +95,12 @@ leak:Bun__canonicalizeIP leak:dlopen leak:Bun::evaluateCommonJSModuleOnce leak:fse_run_loop -leak:Zig::NapiClass_ConstructorFunction +leak:Bun::NapiClass_ConstructorFunction leak:runtime.webcore.fetch.FetchTasklet.toResponse leak:JSC::jsonProtoFuncStringify leak:lolhtml_sys.lol_html.HTMLString.toString leak:libarchive_sys.bindings.Archive.readNew -leak:Zig::SourceProvider::create +leak:Bun::SourceProvider::create leak:fromErrorInstance diff --git a/test/no-validate-leaksan.txt b/test/no-validate-leaksan.txt index 8dde0b650a6c..77a0f80a66c8 100644 --- a/test/no-validate-leaksan.txt +++ b/test/no-validate-leaksan.txt @@ -275,7 +275,7 @@ test/js/bun/http/serve-body-leak.test.ts test/cli/install/migration/yarn-lock-migration.test.ts test/regression/issue/test_env_loader_threading.test.ts -# Zig::SourceProvider::~SourceProvider() +# Bun::SourceProvider::~SourceProvider() test/bundler/bundler_bun.test.ts test/bundler/bundler_cjs2esm.test.ts test/bundler/bundler_edgecase.test.ts From 57d1bc23e8beec7662b87cdcbace855a988c6a28 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 22:28:08 +0000 Subject: [PATCH 04/20] [autofix.ci] apply automated fixes --- src/jsc/BunException.rs | 2 +- src/jsc/BunStackTrace.rs | 2 +- src/jsc/Debugger.rs | 2 +- src/jsc/Errorable.rs | 2 +- src/jsc/Exception.rs | 2 +- src/jsc/JSValue.rs | 4 +-- src/jsc/VirtualMachine.rs | 3 +- src/jsc/lib.rs | 34 +++++++++---------- .../bake/DevServer/ErrorReportRequest.rs | 4 +-- src/runtime/hw_exports.rs | 2 +- 10 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/jsc/BunException.rs b/src/jsc/BunException.rs index ffdf952c1a4d..0b9c2a200c28 100644 --- a/src/jsc/BunException.rs +++ b/src/jsc/BunException.rs @@ -8,7 +8,7 @@ use bun_url::URL as ZigURL; use crate::module_loader::ModuleLoader; use crate::virtual_machine::VirtualMachine; -use crate::{JSErrorCode, JSGlobalObject, JSRuntimeType, JSValue, BunStackFrame, BunStackTrace}; +use crate::{BunStackFrame, BunStackTrace, JSErrorCode, JSGlobalObject, JSRuntimeType, JSValue}; // SAFETY (safe fn): `JSValue` is a by-value scalar; `JSGlobalObject` is an // opaque `UnsafeCell`-backed handle (`&` is ABI-identical to non-null `*mut`); diff --git a/src/jsc/BunStackTrace.rs b/src/jsc/BunStackTrace.rs index 8afbcff56a30..193c3178b36d 100644 --- a/src/jsc/BunStackTrace.rs +++ b/src/jsc/BunStackTrace.rs @@ -6,8 +6,8 @@ use bun_core::String as BunString; use bun_core::ZigStringSlice; use bun_url::URL as ZigURL; -use crate::SourceProvider; use crate::BunStackFrame; +use crate::SourceProvider; /// Represents a JavaScript stack trace #[repr(C)] diff --git a/src/jsc/Debugger.rs b/src/jsc/Debugger.rs index bb22ed90f818..e64ec2abd22b 100644 --- a/src/jsc/Debugger.rs +++ b/src/jsc/Debugger.rs @@ -16,7 +16,7 @@ use bun_io::KeepAlive; use bun_io::posix_event_loop::{AllocatorType, get_vm_ctx}; use crate::virtual_machine::{VirtualMachine, runtime_hooks}; -use crate::{self as jsc, CallFrame, JSGlobalObject, BunException}; +use crate::{self as jsc, BunException, CallFrame, JSGlobalObject}; bun_core::declare_scope!(debugger, visible); bun_core::declare_scope!(TestReporterAgent, visible); diff --git a/src/jsc/Errorable.rs b/src/jsc/Errorable.rs index 80e839fffd07..71c5d8723faf 100644 --- a/src/jsc/Errorable.rs +++ b/src/jsc/Errorable.rs @@ -1,6 +1,6 @@ use crate::JSValue; -use crate::error_code::ErrorCode; use crate::bun_error_type::BunErrorType; +use crate::error_code::ErrorCode; #[repr(C)] pub struct Errorable { diff --git a/src/jsc/Exception.rs b/src/jsc/Exception.rs index e5976fa68683..365f1c35981e 100644 --- a/src/jsc/Exception.rs +++ b/src/jsc/Exception.rs @@ -1,4 +1,4 @@ -use crate::{JSGlobalObject, JSValue, BunStackTrace}; +use crate::{BunStackTrace, JSGlobalObject, JSValue}; bun_opaque::opaque_ffi! { /// Opaque representation of a JavaScript exception diff --git a/src/jsc/JSValue.rs b/src/jsc/JSValue.rs index b8f4d204e23e..cd510574c517 100644 --- a/src/jsc/JSValue.rs +++ b/src/jsc/JSValue.rs @@ -11,8 +11,8 @@ use core::marker::PhantomData; use crate::array_buffer::MarkedArrayBuffer_deallocator; use crate::{ - AnyPromise, ArrayBuffer, BuiltinName, JSArrayIterator, JSGlobalObject, JSInternalPromise, - JSObject, JSPromise, JSString, JSType, JsClass, JsError, JsResult, BunException, + AnyPromise, ArrayBuffer, BuiltinName, BunException, JSArrayIterator, JSGlobalObject, + JSInternalPromise, JSObject, JSPromise, JSString, JSType, JsClass, JsError, JsResult, bun_string_jsc, ffi, host_fn, }; diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index 432dd6f589cf..6f12139c8f25 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -18,9 +18,8 @@ use crate::module_loader::{self as ModuleLoader, FetchFlags}; use crate::rare_data::RareData; use crate::saved_source_map::SavedSourceMap; use crate::{ - self as jsc, ErrorableResolvedSource, ErrorableString, Exception, JSGlobalObject, + self as jsc, BunException, ErrorableResolvedSource, ErrorableString, Exception, JSGlobalObject, JSInternalPromise, JSValue, JsResult, OpaqueCallback, PlatformEventLoop, ResolvedSource, VM, - BunException, }; pub use crate::process_auto_killer as ProcessAutoKiller; diff --git a/src/jsc/lib.rs b/src/jsc/lib.rs index c250a7ebf3b3..8b49ba40bef0 100644 --- a/src/jsc/lib.rs +++ b/src/jsc/lib.rs @@ -57,6 +57,12 @@ pub const CONV: &str = "C"; // Submodules. Each `#[path]` points at the actual PascalCase / snake_case // .rs file. // ────────────────────────────────────────────────────────────────────────── +#[path = "BunErrorType.rs"] +pub mod bun_error_type; +#[path = "BunStackFrameCode.rs"] +pub mod bun_stack_frame_code; +#[path = "BunStackFramePosition.rs"] +pub mod bun_stack_frame_position; #[path = "CommonAbortReason.rs"] pub mod common_abort_reason; #[path = "CustomGetterSetter.rs"] @@ -99,12 +105,6 @@ pub mod text_codec; pub mod url_search_params; #[path = "WTF.rs"] pub mod wtf; -#[path = "BunErrorType.rs"] -pub mod bun_error_type; -#[path = "BunStackFrameCode.rs"] -pub mod bun_stack_frame_code; -#[path = "BunStackFramePosition.rs"] -pub mod bun_stack_frame_position; /// `bun.schema.api` types that reference `BunStackFramePosition` (this crate) /// and so cannot live in `bun_options_types::schema::api` without a dep cycle. @@ -433,6 +433,9 @@ pub use self::common_strings::CommonStrings; pub use self::dom_url::DOMURL; pub use self::js_big_int::JSBigInt; +pub use self::bun_error_type::BunErrorType; +pub use self::bun_stack_frame_code::BunStackFrameCode; +pub use self::bun_stack_frame_position::BunStackFramePosition; pub use self::common_abort_reason::{CommonAbortReason, CommonAbortReasonExt}; pub use self::custom_getter_setter::CustomGetterSetter; /// Some drafts spell this `jsc::ErrCode` — keep both until call-sites converge. @@ -454,9 +457,6 @@ pub use self::source_provider::SourceProvider; pub use self::source_type::SourceType; pub use self::text_codec::TextCodec; pub use self::url_search_params::URLSearchParams; -pub use self::bun_error_type::BunErrorType; -pub use self::bun_stack_frame_code::BunStackFrameCode; -pub use self::bun_stack_frame_position::BunStackFramePosition; #[path = "GarbageCollectionController.rs"] pub mod garbage_collection_controller; @@ -494,6 +494,12 @@ pub mod virtual_machine_exports; #[path = "host_fn.rs"] pub mod host_fn; #[path = "AnyPromise.rs"] pub mod any_promise; +#[path = "BunException.rs"] +pub mod bun_exception; +#[path = "BunStackFrame.rs"] +pub mod bun_stack_frame; +#[path = "BunStackTrace.rs"] +pub mod bun_stack_trace; #[path = "javascript_core_c_api.rs"] pub mod c_api; #[path = "CachedBytecode.rs"] @@ -516,12 +522,6 @@ pub mod system_error; pub mod url; #[path = "VM.rs"] pub mod vm; -#[path = "BunException.rs"] -pub mod bun_exception; -#[path = "BunStackFrame.rs"] -pub mod bun_stack_frame; -#[path = "BunStackTrace.rs"] -pub mod bun_stack_trace; // `generated_classes_list.rs` is mounted by `bun_runtime` (see its lib.rs) — // every aliased type lives in api/webcore/test_runner/bake, so mounting it // here would create a `bun_jsc → bun_runtime` cycle. @@ -984,12 +984,12 @@ mod __macro_smoke { // above with `#[path = "…"] pub mod …;`). These were previously placeholder // newtypes; the real opaque-FFI structs now live in their own files and are // surfaced here at the crate root. +pub use self::bun_stack_frame::BunStackFrame; +pub use self::bun_stack_trace::BunStackTrace; pub use self::cached_bytecode::CachedBytecode; pub use self::deferred_error::DeferredError; pub use self::dom_form_data::DOMFormData; pub use self::url::URL; -pub use self::bun_stack_frame::BunStackFrame; -pub use self::bun_stack_trace::BunStackTrace; pub use abort_signal::{AbortSignal, AbortSignalRef}; // `VM` / `JSGlobalObject` — opaque FFI handles to C++-owned objects. Defined diff --git a/src/runtime/bake/DevServer/ErrorReportRequest.rs b/src/runtime/bake/DevServer/ErrorReportRequest.rs index 3cbfb15343da..9106f2e78acb 100644 --- a/src/runtime/bake/DevServer/ErrorReportRequest.rs +++ b/src/runtime/bake/DevServer/ErrorReportRequest.rs @@ -24,8 +24,8 @@ use bun_core::{Ordinal, Output}; use bun_core::{String as BunString, strings}; use bun_io::Write as _; use bun_jsc::{ - JSErrorCode, JSRuntimeType, BunException, BunStackFrame, BunStackFrameCode, - BunStackFramePosition, BunStackTrace, + BunException, BunStackFrame, BunStackFrameCode, BunStackFramePosition, BunStackTrace, + JSErrorCode, JSRuntimeType, }; use bun_paths::path_buffer_pool; use bun_uws::{self as uws, AnyResponse, Request}; diff --git a/src/runtime/hw_exports.rs b/src/runtime/hw_exports.rs index 3ca8c5cbb4f6..ab98e0f79786 100644 --- a/src/runtime/hw_exports.rs +++ b/src/runtime/hw_exports.rs @@ -23,7 +23,7 @@ use core::ffi::c_void; use bun_jsc::virtual_machine::VirtualMachine; -use bun_jsc::{CallFrame, JSGlobalObject, JSInternalPromise, JSValue, BunStackFrame}; +use bun_jsc::{BunStackFrame, CallFrame, JSGlobalObject, JSInternalPromise, JSValue}; // ─── VirtualMachine ────────────────────────────────────────────────────────── // From 5f35938adb61b320a973ba7b81526dfee9f7918d Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 4 Jun 2026 22:38:49 +0000 Subject: [PATCH 05/20] Fix stale ZigGlobalObject mention and zig reference-file paths CLAUDE.md gained another ZigGlobalObject mention upstream between the two rename passes; update it. Also restore the "ported from" and inline comment references in the renamed Rust exception files to point at the Zig*.zig reference files, which keep their original names until they are deleted. --- CLAUDE.md | 2 +- test/js/bun/util/reportError.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f5aaa6d1158b..4256f54a7834 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -335,7 +335,7 @@ Distilled from the review history of ~2,500 merged PRs where review feedback led ### Architecture & layering - **Fix bugs at the layer that owns the violated invariant, never where the symptom appears.** If a shared helper produces wrong output, fix the helper, not one call site. Escaping/serialization lives in the output layer that sees every producer. A platform-specific patch for a cross-platform bug is the wrong layer. A downstream null-check or isDead() probe on a possibly-freed object is papering over the defect. Don't take a bug report's suggested fix at face value — verify it's the right layer. Prove the mechanism, don't correlate: "the crash goes away" is not a root cause — reproduce the hypothesized path and be able to explain why the fix works; a fix you can't explain hides an adjacent unhandled case. Before changing anything shared, enumerate every consumer first — crash handlers, --watch restore paths, workers, and the WebSocket client share infrastructure; prefer scoping the change to your one caller via an explicit flag. Never change a Bun-native default to fix Node compatibility — that fix belongs in the node: compat layer. -- **One implementation, in the right place.** Never copy a helper or constant table between modules or between the read and write sides of a format — move to a shared module, or derive mirrored lists from the existing source of truth. When adding a variant of existing behavior, parameterize the existing path rather than cloning a parallel branch; when your change supersedes a mechanism, delete the old path in the same PR — the unfixed twin silently misses every future fix. Place new code in the module that owns the feature, never god files (no new fields on ZigGlobalObject, no bindings in monolithic bindings.cpp). Substantial subsystems get their own globally-unique filename (unique names make CMD+F work). No re-export shim files. +- **One implementation, in the right place.** Never copy a helper or constant table between modules or between the read and write sides of a format — move to a shared module, or derive mirrored lists from the existing source of truth. When adding a variant of existing behavior, parameterize the existing path rather than cloning a parallel branch; when your change supersedes a mechanism, delete the old path in the same PR — the unfixed twin silently misses every future fix. Place new code in the module that owns the feature, never god files (no new fields on BunGlobalObject, no bindings in monolithic bindings.cpp). Substantial subsystems get their own globally-unique filename (unique names make CMD+F work). No re-export shim files. - **Store state on the object whose lifetime matches it.** Per-VM state goes on VirtualMachine/RareData, never process globals or thread-locals (workers share globals; pool threads are reused — a "per-thread" lazy buffer leaks under churn). Per-connection facts live on the socket, never a shared context ("last writer wins" under concurrency was an intermittent TLS race). Reset per-operation state at the start of each use of a reusable object (a flag "only ever set and never reset" made reused HTTP clients skip chunked framing — invisible to single-shot tests). Update every lifecycle method (reset/init/drop/clone) when adding mutable state. Prune bookkeeping keyed by recyclable identifiers (PIDs, fds) on every path that learns of death — stale PID + reuse meant SIGSTOPing an unrelated process. Capture absolute paths at acquisition (cwd changes before cleanup). Don't add fields mirroring recoverable information — compute from the source of truth at use. - **Use the simplest mechanism the invariants allow.** No vtables when the implementation set is closed at compile time; no bit-packing or lock-free tricks when a stated invariant makes plain code correct; no speculative edge-case handling nobody filed an issue for ("let's wait for someone to file an issue before we add more complexity"). When a heuristic keeps sprouting counterexamples in review, redesign structurally instead of adding tie-breakers. Treat reviewer confusion as a simplification signal: if a maintainer doesn't understand your logic after one explanation, delete or simplify rather than writing a longer justification. New cross-cutting abstractions need maintainer agreement before appearing inside a feature PR. diff --git a/test/js/bun/util/reportError.test.ts b/test/js/bun/util/reportError.test.ts index 5405e63c3a0d..42c802417035 100644 --- a/test/js/bun/util/reportError.test.ts +++ b/test/js/bun/util/reportError.test.ts @@ -82,7 +82,7 @@ test("native error printer handles lone surrogates in message and stack frame na const fixture = String.raw` function thrower() { throw new Error("MSG_PRE\uD800MSG_POST"); } // Force the native BunStackFrame NameFormatter path: give the frame a - // function_name containing a lone high surrogate. (src/jsc/BunStackFrame.zig + // function_name containing a lone high surrogate. (src/jsc/ZigStackFrame.zig // NameFormatter.format -> "{f}" on bun.String) Object.defineProperty(thrower, "name", { value: "FN_PRE\uD800FN_POST" }); thrower(); From bb72ffa0c854fbb3870561f2f21f50b9e6f56f80 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 4 Jun 2026 23:45:56 +0000 Subject: [PATCH 06/20] Clean up remaining rename artifacts Restore the two quoted zig_exception enum spellings in VirtualMachine.rs doc comments, correct the closing-brace comments on WebCore namespace blocks in JSBufferList.cpp and JSStringDecoder.cpp, and drop the self-referential using namespace Bun directives in ModuleLoader.cpp and KeyObject.cpp that the namespace merge made no-ops. --- src/jsc/bindings/IsolatedModuleCache.cpp | 2 +- src/jsc/bindings/IsolatedModuleCache.h | 2 +- src/jsc/bindings/JSBufferList.cpp | 2 +- src/jsc/bindings/JSStringDecoder.cpp | 2 +- src/jsc/bindings/ModuleLoader.cpp | 1 - src/jsc/bindings/node/crypto/KeyObject.cpp | 1 - 6 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/jsc/bindings/IsolatedModuleCache.cpp b/src/jsc/bindings/IsolatedModuleCache.cpp index e01fe779b6c9..76e3897ca3e4 100644 --- a/src/jsc/bindings/IsolatedModuleCache.cpp +++ b/src/jsc/bindings/IsolatedModuleCache.cpp @@ -77,7 +77,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsolatedModuleCacheSourceType, (JSC::JSGlobal } } -JSC::JSValue createIsolatedModuleCacheSourceTypeForTesting(Zig::GlobalObject* globalObject) +JSC::JSValue createIsolatedModuleCacheSourceTypeForTesting(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); return JSC::JSFunction::create(vm, globalObject, 1, "isolatedModuleCacheSourceType"_s, jsFunctionIsolatedModuleCacheSourceType, JSC::ImplementationVisibility::Public); diff --git a/src/jsc/bindings/IsolatedModuleCache.h b/src/jsc/bindings/IsolatedModuleCache.h index c9d65f56ed77..cca203fa9d27 100644 --- a/src/jsc/bindings/IsolatedModuleCache.h +++ b/src/jsc/bindings/IsolatedModuleCache.h @@ -62,6 +62,6 @@ class IsolatedModuleCache { // bun:internal-for-testing — returns the cached provider's sourceType name // for a resolved specifier, or null when not cached. -JSC::JSValue createIsolatedModuleCacheSourceTypeForTesting(Zig::GlobalObject* globalObject); +JSC::JSValue createIsolatedModuleCacheSourceTypeForTesting(Bun::GlobalObject* globalObject); } // namespace Bun diff --git a/src/jsc/bindings/JSBufferList.cpp b/src/jsc/bindings/JSBufferList.cpp index 4f3c571de22b..d29eddad7b6c 100644 --- a/src/jsc/bindings/JSBufferList.cpp +++ b/src/jsc/bindings/JSBufferList.cpp @@ -467,4 +467,4 @@ JSValue getBufferList(Bun::GlobalObject* globalObject) return static_cast(globalObject)->JSBufferList(); } -} // namespace Bun +} // namespace WebCore diff --git a/src/jsc/bindings/JSStringDecoder.cpp b/src/jsc/bindings/JSStringDecoder.cpp index 579259747819..3755bef802dd 100644 --- a/src/jsc/bindings/JSStringDecoder.cpp +++ b/src/jsc/bindings/JSStringDecoder.cpp @@ -614,4 +614,4 @@ void JSStringDecoderConstructor::initializeProperties(VM& vm, JSC::JSGlobalObjec const ClassInfo JSStringDecoderConstructor::s_info = { "StringDecoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStringDecoderConstructor) }; -} // namespace Bun +} // namespace WebCore diff --git a/src/jsc/bindings/ModuleLoader.cpp b/src/jsc/bindings/ModuleLoader.cpp index c64fddf6e569..8d625d33fa83 100644 --- a/src/jsc/bindings/ModuleLoader.cpp +++ b/src/jsc/bindings/ModuleLoader.cpp @@ -45,7 +45,6 @@ namespace Bun { using namespace JSC; -using namespace Bun; using namespace WebCore; class ResolvedSourceCodeHolder { diff --git a/src/jsc/bindings/node/crypto/KeyObject.cpp b/src/jsc/bindings/node/crypto/KeyObject.cpp index f9e714a4d471..1b408bcdf883 100644 --- a/src/jsc/bindings/node/crypto/KeyObject.cpp +++ b/src/jsc/bindings/node/crypto/KeyObject.cpp @@ -19,7 +19,6 @@ namespace Bun { -using namespace Bun; using namespace JSC; using namespace ncrypto; using namespace WebCore; From 63d2bdb69cecd533d4ba39a50b904759bedf2b44 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 5 Jun 2026 03:14:52 +0000 Subject: [PATCH 07/20] ci: retrigger From 909d51c84fd62dd3610810044fdc80e8d8393930 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 5 Jun 2026 03:34:15 +0000 Subject: [PATCH 08/20] Update BunException.cpp header prose for the renamed type --- src/jsc/bindings/BunException.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsc/bindings/BunException.cpp b/src/jsc/bindings/BunException.cpp index f5869aef05e9..fccf6c0c234a 100644 --- a/src/jsc/bindings/BunException.cpp +++ b/src/jsc/bindings/BunException.cpp @@ -1,7 +1,7 @@ /** * BunException handling and error processing utilities. * - * This file contains functions for converting JavaScript exceptions to ZigException, + * This file contains functions for converting JavaScript exceptions to BunException structs, * processing stack traces, and collecting source lines. */ #include "root.h" From 426c007ed90b00fa37afa7df73ff2d42088dab27 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 5 Jun 2026 03:53:28 +0000 Subject: [PATCH 09/20] Apply review cleanups after rebase Rename the remaining lowercase zigGlobalObject/zigGlobal locals to bunGlobalObject/bunGlobal, drop the redundant self-cast in getBufferList, and update comments that still referenced renamed files and symbols. --- src/jsc/VirtualMachine.rs | 2 +- src/jsc/bindings/BunObject.cpp | 32 ++++++++--------- src/jsc/bindings/BunProcess.cpp | 32 ++++++++--------- src/jsc/bindings/ErrorCode.cpp | 4 +-- src/jsc/bindings/ImportMetaObject.cpp | 12 +++---- src/jsc/bindings/JSBakeResponse.cpp | 10 +++--- src/jsc/bindings/JSBufferList.cpp | 2 +- src/jsc/bindings/JSCommonJSModule.cpp | 8 ++--- src/jsc/bindings/JSDOMFile.cpp | 6 ++-- ...dePerformanceHooksHistogramConstructor.cpp | 4 +-- ...NodePerformanceHooksHistogramPrototype.cpp | 8 ++--- src/jsc/bindings/JSPropertyIterator.cpp | 6 ++-- src/jsc/bindings/JSX509Certificate.cpp | 10 +++--- src/jsc/bindings/NodeDirent.cpp | 6 ++-- src/jsc/bindings/NodeVM.cpp | 34 +++++++++---------- src/jsc/bindings/NodeVMScript.cpp | 10 +++--- src/jsc/bindings/NodeVMSourceTextModule.cpp | 4 +-- src/jsc/bindings/NodeVMSyntheticModule.cpp | 4 +-- src/jsc/bindings/SQLClient.cpp | 8 ++--- src/jsc/bindings/ServerRouteList.cpp | 4 +-- .../node/crypto/JSCipherConstructor.cpp | 4 +-- .../crypto/JSDiffieHellmanConstructor.cpp | 4 +-- .../JSDiffieHellmanGroupConstructor.cpp | 6 ++-- .../node/crypto/JSECDHConstructor.cpp | 4 +-- src/jsc/bindings/node/crypto/JSHash.cpp | 10 +++--- src/jsc/bindings/node/crypto/JSHmac.cpp | 6 ++-- src/jsc/bindings/node/crypto/JSSign.cpp | 6 ++-- src/jsc/bindings/webcore/JSMIMEParams.cpp | 6 ++-- src/jsc/bindings/webcore/JSMIMEType.cpp | 8 ++--- src/jsc/modules/NodeModuleModule.cpp | 12 +++---- src/runtime/bake/BakeSourceProvider.h | 4 +-- src/runtime/bake/DevServerSourceProvider.h | 6 ++-- src/runtime/ffi/FFIObject.rs | 8 ++--- src/runtime/jsc_hooks.rs | 2 +- src/runtime/socket/tls_socket_functions.rs | 2 +- src/runtime/webview/JSWebViewConstructor.cpp | 6 ++-- 36 files changed, 150 insertions(+), 150 deletions(-) diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index 6f12139c8f25..705e00a61f68 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -3702,7 +3702,7 @@ impl VirtualMachine { }; // Note: shares the console / log / event-loop wiring with `init`; // the only delta is the global is created via `BakeCreateProdGlobal` - // instead of `BunGlobalObject__create`. Route through `init` then + // instead of `Bun__GlobalObject__create`. Route through `init` then // swap the global. let vm = Self::init(init_opts)?; // SAFETY: `vm` is the unique live VM on this thread. diff --git a/src/jsc/bindings/BunObject.cpp b/src/jsc/bindings/BunObject.cpp index d8787edd6d44..5e940c545454 100644 --- a/src/jsc/bindings/BunObject.cpp +++ b/src/jsc/bindings/BunObject.cpp @@ -620,8 +620,8 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionJSONLParseChunk, (JSGlobalObject * globalObje errorValue = createSyntaxError(globalObject, "Failed to parse JSONL"_s); } - auto* zigGlobalObject = uncheckedDowncast(globalObject); - JSObject* resultObj = constructEmptyObject(vm, zigGlobalObject->jsonlParseResultStructure()); + auto* bunGlobalObject = uncheckedDowncast(globalObject); + JSObject* resultObj = constructEmptyObject(vm, bunGlobalObject->jsonlParseResultStructure()); resultObj->putDirectOffset(vm, 0, array); resultObj->putDirectOffset(vm, 1, jsNumber(readBytes)); resultObj->putDirectOffset(vm, 2, jsBoolean(result.status == JSC::StreamingJSONParseResult::Status::Complete)); @@ -1098,20 +1098,20 @@ static JSC_DEFINE_CUSTOM_SETTER(setBunObjectMain, (JSC::JSGlobalObject * globalO // LazyProperty wrappers for stdin/stderr/stdout static JSValue BunObject_lazyPropCb_wrap_stdin(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); - return zigGlobalObject->m_bunStdin.getInitializedOnMainThread(zigGlobalObject); + auto* bunGlobalObject = uncheckedDowncast(bunObject->globalObject()); + return bunGlobalObject->m_bunStdin.getInitializedOnMainThread(bunGlobalObject); } static JSValue BunObject_lazyPropCb_wrap_stderr(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); - return zigGlobalObject->m_bunStderr.getInitializedOnMainThread(zigGlobalObject); + auto* bunGlobalObject = uncheckedDowncast(bunObject->globalObject()); + return bunGlobalObject->m_bunStderr.getInitializedOnMainThread(bunGlobalObject); } static JSValue BunObject_lazyPropCb_wrap_stdout(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); - return zigGlobalObject->m_bunStdout.getInitializedOnMainThread(zigGlobalObject); + auto* bunGlobalObject = uncheckedDowncast(bunObject->globalObject()); + return bunGlobalObject->m_bunStdout.getInitializedOnMainThread(bunGlobalObject); } #include "BunObject.lut.h" @@ -1128,26 +1128,26 @@ const JSC::ClassInfo JSBunObject::s_info = { "Bun"_s, &Base::s_info, &bunObjectT static JSValue constructCookieObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); - return WebCore::JSCookie::getConstructor(vm, zigGlobalObject); + auto* bunGlobalObject = uncheckedDowncast(bunObject->globalObject()); + return WebCore::JSCookie::getConstructor(vm, bunGlobalObject); } static JSValue constructCookieMapObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); - return WebCore::JSCookieMap::getConstructor(vm, zigGlobalObject); + auto* bunGlobalObject = uncheckedDowncast(bunObject->globalObject()); + return WebCore::JSCookieMap::getConstructor(vm, bunGlobalObject); } static JSValue constructSecretsObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); - return Bun::createSecretsObject(vm, zigGlobalObject); + auto* bunGlobalObject = uncheckedDowncast(bunObject->globalObject()); + return Bun::createSecretsObject(vm, bunGlobalObject); } static JSValue constructWebViewObject(VM& vm, JSObject* bunObject) { - auto* zigGlobalObject = uncheckedDowncast(bunObject->globalObject()); - return zigGlobalObject->m_JSWebViewClassStructure.constructor(zigGlobalObject); + auto* bunGlobalObject = uncheckedDowncast(bunObject->globalObject()); + return bunGlobalObject->m_JSWebViewClassStructure.constructor(bunGlobalObject); } JSC::JSObject* createBunObject(VM& vm, JSObject* globalObject) diff --git a/src/jsc/bindings/BunProcess.cpp b/src/jsc/bindings/BunProcess.cpp index 28e3a17079cb..e3852091951f 100644 --- a/src/jsc/bindings/BunProcess.cpp +++ b/src/jsc/bindings/BunProcess.cpp @@ -862,16 +862,16 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionExit, (JSC::JSGlobalObject * globalObje { auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobal = defaultGlobalObject(globalObject); - auto process = zigGlobal->processObject(); + auto* bunGlobal = defaultGlobalObject(globalObject); + auto process = bunGlobal->processObject(); auto code = callFrame->argument(0); setProcessExitCodeInner(globalObject, process, code); RETURN_IF_EXCEPTION(throwScope, {}); - auto exitCode = Bun__getExitCode(bunVM(zigGlobal)); - Process__dispatchOnExit(zigGlobal, exitCode); + auto exitCode = Bun__getExitCode(bunVM(bunGlobal)); + Process__dispatchOnExit(bunGlobal, exitCode); // process.reallyExit(exitCode); auto reallyExitVal = process->get(globalObject, Identifier::fromString(vm, "reallyExit"_s)); @@ -911,8 +911,8 @@ JSC_DEFINE_HOST_FUNCTION(Process_setUncaughtExceptionCaptureCallback, (JSC::JSGl JSC_DEFINE_HOST_FUNCTION(Process_hasUncaughtExceptionCaptureCallback, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { - auto* zigGlobal = defaultGlobalObject(globalObject); - JSValue cb = zigGlobal->processObject()->getUncaughtExceptionCaptureCallback(); + auto* bunGlobal = defaultGlobalObject(globalObject); + JSValue cb = bunGlobal->processObject()->getUncaughtExceptionCaptureCallback(); if (cb.isEmpty() || !cb.isCell()) { return JSValue::encode(jsBoolean(false)); } @@ -3249,8 +3249,8 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObj RETURN_IF_EXCEPTION(throwScope, {}); } - auto* zigGlobal = defaultGlobalObject(globalObject); - Bun__Process__exit(zigGlobal, exitCode); + auto* bunGlobal = defaultGlobalObject(globalObject); + Bun__Process__exit(bunGlobal, exitCode); // Main-thread Bun__Process__exit is noreturn. In a worker it returns; the // WebWorker exit path it called requests JSC termination (guarded so it's a // no-op when re-entered from a process.on('exit') handler). @@ -3347,9 +3347,9 @@ static Process* getProcessObject(JSC::JSGlobalObject* lexicalGlobalObject, JSVal // Handle "var memoryUsage = process.memoryUsage; memoryUsage()" if (!process) [[unlikely]] { // Handle calling this function from inside a node:vm - Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* bunGlobalObject = defaultGlobalObject(lexicalGlobalObject); - return zigGlobalObject->processObject(); + return bunGlobalObject->processObject(); } return process; @@ -4181,8 +4181,8 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionKill, (JSC::JSGlobalObject * globalObje JSC_DEFINE_HOST_FUNCTION(Process_functionLoadBuiltinModule, (JSGlobalObject * globalObject, CallFrame* callFrame)) { - auto* zigGlobalObject = uncheckedDowncast(globalObject); - VM& vm = zigGlobalObject->vm(); + auto* bunGlobalObject = uncheckedDowncast(globalObject); + VM& vm = bunGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSValue id = callFrame->argument(0); @@ -4190,11 +4190,11 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionLoadBuiltinModule, (JSGlobalObject * gl return Bun::ERR::INVALID_ARG_TYPE(scope, globalObject, "moduleName"_s, "string"_s, id); } - String idWtfStr = id.toWTFString(zigGlobalObject); + String idWtfStr = id.toWTFString(bunGlobalObject); RETURN_IF_EXCEPTION(scope, {}); BunString idStr = Bun::toString(idWtfStr); - JSValue fetchResult = Bun::resolveAndFetchBuiltinModule(zigGlobalObject, &idStr); + JSValue fetchResult = Bun::resolveAndFetchBuiltinModule(bunGlobalObject, &idStr); if (fetchResult) { RELEASE_AND_RETURN(scope, JSC::JSValue::encode(fetchResult)); } @@ -4205,8 +4205,8 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionLoadBuiltinModule, (JSGlobalObject * gl JSC_DEFINE_HOST_FUNCTION(Process_functionEmitHelper, (JSGlobalObject * globalObject, CallFrame* callFrame)) { auto& vm = JSC::getVM(globalObject); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - auto* process = zigGlobalObject->processObject(); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + auto* process = bunGlobalObject->processObject(); auto scope = DECLARE_THROW_SCOPE(vm); auto emit = process->get(globalObject, Identifier::fromString(vm, "emit"_s)); RETURN_IF_EXCEPTION(scope, {}); diff --git a/src/jsc/bindings/ErrorCode.cpp b/src/jsc/bindings/ErrorCode.cpp index 8f07f863d820..03929e998e06 100644 --- a/src/jsc/bindings/ErrorCode.cpp +++ b/src/jsc/bindings/ErrorCode.cpp @@ -234,8 +234,8 @@ JSObject* createError(VM& vm, JSC::JSGlobalObject* globalObject, ErrorCode code, JSObject* createError(VM& vm, JSC::JSGlobalObject* globalObject, ErrorCode code, JSValue message) { - if (auto* zigGlobalObject = dynamicDowncast(globalObject)) - return createError(vm, zigGlobalObject, code, message, jsUndefined()); + if (auto* bunGlobalObject = dynamicDowncast(globalObject)) + return createError(vm, bunGlobalObject, code, message, jsUndefined()); auto* structure = createErrorStructure(vm, globalObject, errors[static_cast(code)].type, errors[static_cast(code)].name, errors[static_cast(code)].code); return JSC::ErrorInstance::create(globalObject, structure, message, jsUndefined(), nullptr, JSC::RuntimeType::TypeNothing, errors[static_cast(code)].type, true); diff --git a/src/jsc/bindings/ImportMetaObject.cpp b/src/jsc/bindings/ImportMetaObject.cpp index 5cbccbb2fb01..0c1c50fc06bf 100644 --- a/src/jsc/bindings/ImportMetaObject.cpp +++ b/src/jsc/bindings/ImportMetaObject.cpp @@ -73,9 +73,9 @@ static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObj JSC::JSValue moduleName = callFrame->argument(0); auto doIt = [&](const WTF::String& fromStr) -> JSC::EncodedJSValue { - Bun::GlobalObject* zigGlobalObject = uncheckedDowncast(globalObject); - if (zigGlobalObject->onLoadPlugins.hasVirtualModules()) { - if (auto result = zigGlobalObject->onLoadPlugins.resolveVirtualModule(fromStr, String())) { + Bun::GlobalObject* bunGlobalObject = uncheckedDowncast(globalObject); + if (bunGlobalObject->onLoadPlugins.hasVirtualModules()) { + if (auto result = bunGlobalObject->onLoadPlugins.resolveVirtualModule(fromStr, String())) { if (fromStr == result.value()) return JSC::JSValue::encode(moduleName); @@ -143,13 +143,13 @@ ImportMetaObject* ImportMetaObject::create(JSC::VM& vm, JSC::JSGlobalObject* glo ImportMetaObject* ImportMetaObject::create(JSC::JSGlobalObject* globalObject, const WTF::String& url) { VM& vm = globalObject->vm(); - Bun::GlobalObject* zigGlobalObject = uncheckedDowncast(globalObject); + Bun::GlobalObject* bunGlobalObject = uncheckedDowncast(globalObject); bool isBake = url.startsWith("bake:"_s); // Get the appropriate structure Structure* structure = isBake - ? zigGlobalObject->ImportMetaBakeObjectStructure() - : zigGlobalObject->ImportMetaObjectStructure(); + ? bunGlobalObject->ImportMetaBakeObjectStructure() + : bunGlobalObject->ImportMetaObjectStructure(); return create(vm, globalObject, structure, url); } diff --git a/src/jsc/bindings/JSBakeResponse.cpp b/src/jsc/bindings/JSBakeResponse.cpp index 9d88e3403cd8..3d332ad59937 100644 --- a/src/jsc/bindings/JSBakeResponse.cpp +++ b/src/jsc/bindings/JSBakeResponse.cpp @@ -43,7 +43,7 @@ extern JSC_CALLCONV size_t Response__estimatedSize(void* ptr); bool isJSXElement(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* globalObject) { - auto* zigGlobal = static_cast(globalObject); + auto* bunGlobal = static_cast(globalObject); auto& vm = JSC::getVM(globalObject); // React does this: @@ -63,7 +63,7 @@ bool isJSXElement(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* globalObjec JSC::JSValue typeofValue = object->get(globalObject, typeofProperty); RETURN_IF_EXCEPTION(scope, false); - if (typeofValue.isSymbol() && (typeofValue == zigGlobal->bakeAdditions().reactLegacyElementSymbol(zigGlobal) || typeofValue == zigGlobal->bakeAdditions().reactElementSymbol(zigGlobal))) { + if (typeofValue.isSymbol() && (typeofValue == bunGlobal->bakeAdditions().reactLegacyElementSymbol(bunGlobal) || typeofValue == bunGlobal->bakeAdditions().reactElementSymbol(bunGlobal))) { return true; } } @@ -300,13 +300,13 @@ Structure* createJSBakeResponseStructure(JSC::VM& vm, Bun::GlobalObject* globalO void setupJSBakeResponseClassStructure(JSC::LazyClassStructure::Initializer& init) { - auto* zigGlobal = static_cast(init.global); - auto* prototype = JSC::constructEmptyObject(zigGlobal, zigGlobal->JSResponsePrototype()); + auto* bunGlobal = static_cast(init.global); + auto* prototype = JSC::constructEmptyObject(bunGlobal, bunGlobal->JSResponsePrototype()); auto* constructorStructure = JSBakeResponseConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()); auto* constructor = JSBakeResponseConstructor::create(init.vm, constructorStructure, prototype); - auto* structure = createJSBakeResponseStructure(init.vm, zigGlobal, prototype); + auto* structure = createJSBakeResponseStructure(init.vm, bunGlobal, prototype); init.setPrototype(prototype); init.setStructure(structure); init.setConstructor(constructor); diff --git a/src/jsc/bindings/JSBufferList.cpp b/src/jsc/bindings/JSBufferList.cpp index d29eddad7b6c..b097277f7e7a 100644 --- a/src/jsc/bindings/JSBufferList.cpp +++ b/src/jsc/bindings/JSBufferList.cpp @@ -464,7 +464,7 @@ const ClassInfo JSBufferListConstructor::s_info = { "BufferList"_s, &Base::s_inf JSValue getBufferList(Bun::GlobalObject* globalObject) { - return static_cast(globalObject)->JSBufferList(); + return globalObject->JSBufferList(); } } // namespace WebCore diff --git a/src/jsc/bindings/JSCommonJSModule.cpp b/src/jsc/bindings/JSCommonJSModule.cpp index e12121688470..ab5ff83c00f4 100644 --- a/src/jsc/bindings/JSCommonJSModule.cpp +++ b/src/jsc/bindings/JSCommonJSModule.cpp @@ -710,12 +710,12 @@ JSC_DEFINE_HOST_FUNCTION(functionJSCommonJSModule_compile, (JSGlobalObject * glo RETURN_IF_EXCEPTION(throwScope, {}); String wrappedString; - auto* zigGlobalObject = uncheckedDowncast(globalObject); - if (zigGlobalObject->hasOverriddenModuleWrapper) [[unlikely]] { + auto* bunGlobalObject = uncheckedDowncast(globalObject); + if (bunGlobalObject->hasOverriddenModuleWrapper) [[unlikely]] { wrappedString = makeString( - zigGlobalObject->m_moduleWrapperStart, + bunGlobalObject->m_moduleWrapperStart, sourceString, - zigGlobalObject->m_moduleWrapperEnd); + bunGlobalObject->m_moduleWrapperEnd); } else { wrappedString = makeString( "(function(exports,require,module,__filename,__dirname){"_s, diff --git a/src/jsc/bindings/JSDOMFile.cpp b/src/jsc/bindings/JSDOMFile.cpp index 438d785418b7..de9e36bfd964 100644 --- a/src/jsc/bindings/JSDOMFile.cpp +++ b/src/jsc/bindings/JSDOMFile.cpp @@ -42,13 +42,13 @@ class JSDOMFile : public JSC::InternalFunction { static JSDOMFile* create(JSC::VM& vm, JSGlobalObject* globalObject) { - auto* zigGlobal = defaultGlobalObject(globalObject); - auto structure = createStructure(vm, globalObject, zigGlobal->functionPrototype()); + auto* bunGlobal = defaultGlobalObject(globalObject); + auto structure = createStructure(vm, globalObject, bunGlobal->functionPrototype()); auto* object = new (NotNull, JSC::allocateCell(vm)) JSDOMFile(vm, structure); object->finishCreation(vm); // This is not quite right. But we'll fix it if someone files an issue about it. - object->putDirect(vm, vm.propertyNames->prototype, zigGlobal->JSBlobPrototype(), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0); + object->putDirect(vm, vm.propertyNames->prototype, bunGlobal->JSBlobPrototype(), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0); return object; } diff --git a/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp b/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp index dd9ce70c2651..5cb31ed84d86 100644 --- a/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp +++ b/src/jsc/bindings/JSNodePerformanceHooksHistogramConstructor.cpp @@ -66,8 +66,8 @@ static JSNodePerformanceHooksHistogram* createHistogramInternal(JSGlobalObject* } } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - Structure* structure = zigGlobalObject->m_JSNodePerformanceHooksHistogramClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Structure* structure = bunGlobalObject->m_JSNodePerformanceHooksHistogramClassStructure.get(bunGlobalObject); RETURN_IF_EXCEPTION(scope, nullptr); return JSNodePerformanceHooksHistogram::create(vm, structure, globalObject, lowest, highest, figures); diff --git a/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.cpp b/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.cpp index 7b54af25fc6b..f9e6eafb4fa8 100644 --- a/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.cpp +++ b/src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.cpp @@ -413,8 +413,8 @@ JSC_DEFINE_HOST_FUNCTION(jsFunction_createHistogram, (JSGlobalObject * globalObj } } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - Structure* structure = zigGlobalObject->m_JSNodePerformanceHooksHistogramClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Structure* structure = bunGlobalObject->m_JSNodePerformanceHooksHistogramClassStructure.get(bunGlobalObject); RETURN_IF_EXCEPTION(scope, {}); JSNodePerformanceHooksHistogram* histogram = JSNodePerformanceHooksHistogram::create(vm, structure, globalObject, lowest, highest, figures); @@ -445,8 +445,8 @@ JSC_DEFINE_HOST_FUNCTION(jsFunction_monitorEventLoopDelay, (JSGlobalObject * glo } // Create histogram with range for event loop delays (1ns to 1 hour) - auto* zigGlobalObject = defaultGlobalObject(globalObject); - Structure* structure = zigGlobalObject->m_JSNodePerformanceHooksHistogramClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Structure* structure = bunGlobalObject->m_JSNodePerformanceHooksHistogramClassStructure.get(bunGlobalObject); RETURN_IF_EXCEPTION(scope, {}); JSNodePerformanceHooksHistogram* histogram = JSNodePerformanceHooksHistogram::create( diff --git a/src/jsc/bindings/JSPropertyIterator.cpp b/src/jsc/bindings/JSPropertyIterator.cpp index be069c74992f..7609142255c8 100644 --- a/src/jsc/bindings/JSPropertyIterator.cpp +++ b/src/jsc/bindings/JSPropertyIterator.cpp @@ -55,9 +55,9 @@ extern "C" JSPropertyIterator* Bun__JSPropertyIterator__create(JSC::JSGlobalObje #if OS(WINDOWS) if (object->type() == JSC::ProxyObjectType) [[unlikely]] { // Check if we're actually iterating through the JSEnvironmentVariableMap's proxy. - auto* zigGlobal = defaultGlobalObject(globalObject); - if (zigGlobal->m_processEnvObject.isInitialized()) { - if (object == zigGlobal->m_processEnvObject.get(zigGlobal)) { + auto* bunGlobal = defaultGlobalObject(globalObject); + if (bunGlobal->m_processEnvObject.isInitialized()) { + if (object == bunGlobal->m_processEnvObject.get(bunGlobal)) { object->methodTable()->getOwnPropertyNames( object, globalObject, diff --git a/src/jsc/bindings/JSX509Certificate.cpp b/src/jsc/bindings/JSX509Certificate.cpp index 7b120460ca92..a6838b00510d 100644 --- a/src/jsc/bindings/JSX509Certificate.cpp +++ b/src/jsc/bindings/JSX509Certificate.cpp @@ -176,10 +176,10 @@ JSC_DEFINE_HOST_FUNCTION(x509CertificateConstructorConstruct, (JSGlobalObject * return {}; } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - Structure* structure = zigGlobalObject->m_JSX509CertificateClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Structure* structure = bunGlobalObject->m_JSX509CertificateClassStructure.get(bunGlobalObject); JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSX509CertificateClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSX509CertificateClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor X509Certificate cannot be invoked without 'new'"_s); return {}; @@ -1195,8 +1195,8 @@ extern "C" EncodedJSValue Bun__X509__toJSLegacyEncoding(X509* cert, JSGlobalObje extern "C" EncodedJSValue Bun__X509__toJS(X509* cert, JSGlobalObject* globalObject) { ncrypto::X509Pointer cert_ptr(cert); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - return JSValue::encode(JSX509Certificate::create(zigGlobalObject->vm(), zigGlobalObject->m_JSX509CertificateClassStructure.get(zigGlobalObject), globalObject, WTF::move(cert_ptr))); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + return JSValue::encode(JSX509Certificate::create(bunGlobalObject->vm(), bunGlobalObject->m_JSX509CertificateClassStructure.get(bunGlobalObject), globalObject, WTF::move(cert_ptr))); } JSC_DEFINE_HOST_FUNCTION(jsIsX509Certificate, (JSGlobalObject * globalObject, CallFrame* callFrame)) diff --git a/src/jsc/bindings/NodeDirent.cpp b/src/jsc/bindings/NodeDirent.cpp index 7ddbae57efc7..769bdd92d923 100644 --- a/src/jsc/bindings/NodeDirent.cpp +++ b/src/jsc/bindings/NodeDirent.cpp @@ -164,11 +164,11 @@ JSC_DEFINE_HOST_FUNCTION(constructDirent, (JSC::JSGlobalObject * globalObject, J JSValue type = callFrame->argument(1); JSValue path = callFrame->argument(2); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - Structure* structure = zigGlobalObject->m_JSDirentClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Structure* structure = bunGlobalObject->m_JSDirentClassStructure.get(bunGlobalObject); auto* originalStructure = structure; JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSDirentClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSDirentClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { auto scope = DECLARE_THROW_SCOPE(vm); if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor Dirent cannot be invoked without 'new'"_s); diff --git a/src/jsc/bindings/NodeVM.cpp b/src/jsc/bindings/NodeVM.cpp index 75afd8b211d9..2a7474d93f16 100644 --- a/src/jsc/bindings/NodeVM.cpp +++ b/src/jsc/bindings/NodeVM.cpp @@ -273,8 +273,8 @@ JSPromise* importModule(JSGlobalObject* globalObject, JSString* moduleName, RefP if (isUseMainContextDefaultLoaderConstant(globalObject, dynamicImportCallback)) { auto defer = fetcher->temporarilyUseDefaultLoader(); - Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); - RELEASE_AND_RETURN(scope, zigGlobalObject->moduleLoaderImportModule(zigGlobalObject, zigGlobalObject->moduleLoader(), moduleName, WTF::move(parameters), sourceOrigin, false)); + Bun::GlobalObject* bunGlobalObject = defaultGlobalObject(globalObject); + RELEASE_AND_RETURN(scope, bunGlobalObject->moduleLoaderImportModule(bunGlobalObject, bunGlobalObject->moduleLoader(), moduleName, WTF::move(parameters), sourceOrigin, false)); } else if (!dynamicImportCallback || !dynamicImportCallback.isCallable()) { throwException(globalObject, scope, createError(globalObject, ErrorCode::ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING, "A dynamic import callback was not specified."_s)); return nullptr; @@ -601,8 +601,8 @@ NodeVMGlobalObject* getGlobalObjectFromContext(JSGlobalObject* globalObject, JSV } JSObject* context = asObject(contextValue); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSValue scopeValue = zigGlobalObject->vmModuleContextMap()->get(context); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSValue scopeValue = bunGlobalObject->vmModuleContextMap()->get(context); if (scopeValue.isUndefined()) { if (auto* specialSandbox = dynamicDowncast(context)) { return specialSandbox->parentGlobal(); @@ -647,9 +647,9 @@ JSC::EncodedJSValue INVALID_ARG_VALUE_VM_VARIATION(JSC::ThrowScope& throwScope, bool isContext(JSGlobalObject* globalObject, JSValue value) { - auto* zigGlobalObject = defaultGlobalObject(globalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); - if (zigGlobalObject->vmModuleContextMap()->has(asObject(value))) { + if (bunGlobalObject->vmModuleContextMap()->has(asObject(value))) { return true; } @@ -669,8 +669,8 @@ bool getContextArg(JSGlobalObject* globalObject, JSValue& contextArg) if (contextArg.isUndefined()) { contextArg = JSC::constructEmptyObject(globalObject); } else if (contextArg.isSymbol()) { - Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); - if (contextArg == zigGlobalObject->m_nodeVMDontContextify.get(zigGlobalObject)) { + Bun::GlobalObject* bunGlobalObject = defaultGlobalObject(globalObject); + if (contextArg == bunGlobalObject->m_nodeVMDontContextify.get(bunGlobalObject)) { contextArg = JSC::constructEmptyObject(globalObject); return true; } @@ -682,8 +682,8 @@ bool getContextArg(JSGlobalObject* globalObject, JSValue& contextArg) bool isUseMainContextDefaultLoaderConstant(JSGlobalObject* globalObject, JSValue value) { if (value.isSymbol()) { - Bun::GlobalObject* zigGlobalObject = defaultGlobalObject(globalObject); - if (value == zigGlobalObject->m_nodeVMUseMainContextDefaultLoader.get(zigGlobalObject)) { + Bun::GlobalObject* bunGlobalObject = defaultGlobalObject(globalObject); + if (value == bunGlobalObject->m_nodeVMUseMainContextDefaultLoader.get(bunGlobalObject)) { return true; } } @@ -787,8 +787,8 @@ static void promiseRejectionTrackerForNodeVM(JSGlobalObject* globalObject, JSC:: { // Delegate to the parent global object so that unhandled rejections // in VM contexts are reported to the main process (matching Node.js behavior) - auto* zigGlobalObject = defaultGlobalObject(globalObject); - Bun::GlobalObject::promiseRejectionTracker(zigGlobalObject, promise, operation); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Bun::GlobalObject::promiseRejectionTracker(bunGlobalObject, promise, operation); } const JSC::GlobalObjectMethodTable& NodeVMGlobalObject::globalObjectMethodTable() @@ -1394,10 +1394,10 @@ JSC_DEFINE_HOST_FUNCTION(vmModule_createContext, (JSGlobalObject * globalObject, return JSValue::encode(sandbox); } - auto* zigGlobalObject = defaultGlobalObject(globalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); auto* targetContext = NodeVMGlobalObject::create(vm, - zigGlobalObject->NodeVMGlobalObjectStructure(), + bunGlobalObject->NodeVMGlobalObjectStructure(), contextOptions, importer); RETURN_IF_EXCEPTION(scope, {}); @@ -1406,7 +1406,7 @@ JSC_DEFINE_HOST_FUNCTION(vmModule_createContext, (JSGlobalObject * globalObject, targetContext->setContextifiedObject(sandbox); // Store context in WeakMap for isContext checks - zigGlobalObject->vmModuleContextMap()->set(vm, sandbox, targetContext); + bunGlobalObject->vmModuleContextMap()->set(vm, sandbox, targetContext); if (notContextified) { auto* specialSandbox = NodeVMSpecialSandbox::create(vm, targetContext); @@ -1789,8 +1789,8 @@ bool CompileFunctionOptions::fromJS(JSC::JSGlobalObject* globalObject, JSC::VM& return ERR::INVALID_ARG_INSTANCE(scope, globalObject, "options.parsingContext"_s, "Context"_s, parsingContextValue); JSObject* context = asObject(parsingContextValue); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSValue scopeValue = zigGlobalObject->vmModuleContextMap()->get(context); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSValue scopeValue = bunGlobalObject->vmModuleContextMap()->get(context); if (scopeValue.isUndefined()) return ERR::INVALID_ARG_INSTANCE(scope, globalObject, "options.parsingContext"_s, "Context"_s, parsingContextValue); diff --git a/src/jsc/bindings/NodeVMScript.cpp b/src/jsc/bindings/NodeVMScript.cpp index 178c0ea82ff6..133916b46cdc 100644 --- a/src/jsc/bindings/NodeVMScript.cpp +++ b/src/jsc/bindings/NodeVMScript.cpp @@ -111,9 +111,9 @@ constructScript(JSGlobalObject* globalObject, CallFrame* callFrame, JSValue newT RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - Structure* structure = zigGlobalObject->NodeVMScriptStructure(); - if (zigGlobalObject->NodeVMScript() != newTarget) [[unlikely]] { + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Structure* structure = bunGlobalObject->NodeVMScriptStructure(); + if (bunGlobalObject->NodeVMScript() != newTarget) [[unlikely]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor Script cannot be invoked without 'new'"_s); return {}; @@ -585,10 +585,10 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInNewContext, (JSGlobalObject * globalObject, contextOptions.notContextified = notContextified; - auto* zigGlobalObject = defaultGlobalObject(globalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); JSObject* context = asObject(contextObjectValue); auto* targetContext = NodeVMGlobalObject::create(vm, - zigGlobalObject->NodeVMGlobalObjectStructure(), + bunGlobalObject->NodeVMGlobalObjectStructure(), contextOptions, importer); RETURN_IF_EXCEPTION(scope, {}); diff --git a/src/jsc/bindings/NodeVMSourceTextModule.cpp b/src/jsc/bindings/NodeVMSourceTextModule.cpp index 7a22aef9bac5..9e191ff95b54 100644 --- a/src/jsc/bindings/NodeVMSourceTextModule.cpp +++ b/src/jsc/bindings/NodeVMSourceTextModule.cpp @@ -103,11 +103,11 @@ NodeVMSourceTextModule* NodeVMSourceTextModule::create(VM& vm, JSGlobalObject* g SourceCode sourceCode(WTF::move(sourceProvider), lineOffset, columnOffset); - auto* zigGlobalObject = defaultGlobalObject(globalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); WTF::String identifier = identifierValue.toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, nullptr); NodeVMSourceTextModule* ptr = new (NotNull, allocateCell(vm)) NodeVMSourceTextModule( - vm, zigGlobalObject->NodeVMSourceTextModuleStructure(), WTF::move(identifier), contextValue, + vm, bunGlobalObject->NodeVMSourceTextModuleStructure(), WTF::move(identifier), contextValue, WTF::move(sourceCode), moduleWrapper, initializeImportMeta); RETURN_IF_EXCEPTION(scope, nullptr); ptr->finishCreation(vm); diff --git a/src/jsc/bindings/NodeVMSyntheticModule.cpp b/src/jsc/bindings/NodeVMSyntheticModule.cpp index 444b0b465a4b..702bc2982149 100644 --- a/src/jsc/bindings/NodeVMSyntheticModule.cpp +++ b/src/jsc/bindings/NodeVMSyntheticModule.cpp @@ -76,8 +76,8 @@ NodeVMSyntheticModule* NodeVMSyntheticModule::create(VM& vm, JSGlobalObject* glo RETURN_IF_EXCEPTION(scope, nullptr); } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - auto* structure = zigGlobalObject->NodeVMSyntheticModuleStructure(); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + auto* structure = bunGlobalObject->NodeVMSyntheticModuleStructure(); WTF::String identifier = identifierValue.toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, nullptr); auto* ptr = new (NotNull, allocateCell(vm)) NodeVMSyntheticModule(vm, structure, WTF::move(identifier), contextValue, moduleWrapperValue, WTF::move(exportNames), syntheticEvaluationStepsValue); diff --git a/src/jsc/bindings/SQLClient.cpp b/src/jsc/bindings/SQLClient.cpp index 4b26abd7b129..13e19f139b8a 100644 --- a/src/jsc/bindings/SQLClient.cpp +++ b/src/jsc/bindings/SQLClient.cpp @@ -135,8 +135,8 @@ static JSC::JSValue toJS(JSC::VM& vm, JSC::JSGlobalObject* globalObject, DataCel return jsNull(); break; case DataCellTag::Raw: { - Bun::GlobalObject* zigGlobal = uncheckedDowncast(globalObject); - auto* subclassStructure = zigGlobal->JSBufferSubclassStructure(); + Bun::GlobalObject* bunGlobal = uncheckedDowncast(globalObject); + auto* subclassStructure = bunGlobal->JSBufferSubclassStructure(); auto* uint8Array = JSC::JSUint8Array::createUninitialized(globalObject, subclassStructure, cell.value.raw.length); RETURN_IF_EXCEPTION(scope, {}); @@ -175,8 +175,8 @@ static JSC::JSValue toJS(JSC::VM& vm, JSC::JSGlobalObject* globalObject, DataCel break; } case DataCellTag::Bytea: { - Bun::GlobalObject* zigGlobal = uncheckedDowncast(globalObject); - auto* subclassStructure = zigGlobal->JSBufferSubclassStructure(); + Bun::GlobalObject* bunGlobal = uncheckedDowncast(globalObject); + auto* subclassStructure = bunGlobal->JSBufferSubclassStructure(); auto* uint8Array = JSC::JSUint8Array::createUninitialized(globalObject, subclassStructure, cell.value.bytea[1]); RETURN_IF_EXCEPTION(scope, {}); diff --git a/src/jsc/bindings/ServerRouteList.cpp b/src/jsc/bindings/ServerRouteList.cpp index b89245348237..02fdb3df2410 100644 --- a/src/jsc/bindings/ServerRouteList.cpp +++ b/src/jsc/bindings/ServerRouteList.cpp @@ -183,8 +183,8 @@ Structure* ServerRouteList::structureForParamsObject(JSC::VM& vm, JSC::JSGlobalO } if (!m_paramsObjectStructures.at(index)) { - auto* zigGlobalObject = defaultGlobalObject(globalObject); - auto* prototype = zigGlobalObject->m_JSBunRequestParamsPrototype.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + auto* prototype = bunGlobalObject->m_JSBunRequestParamsPrototype.get(bunGlobalObject); unsigned inlineCapacity = std::min(identifiers.size(), static_cast(JSC::JSFinalObject::maxInlineCapacity)); auto* structure = Structure::create(vm, globalObject, prototype, TypeInfo(FinalObjectType, StructureFlags), JSFinalObject::info(), NonArray, inlineCapacity); diff --git a/src/jsc/bindings/node/crypto/JSCipherConstructor.cpp b/src/jsc/bindings/node/crypto/JSCipherConstructor.cpp index fef1972bcea1..df012502bf32 100644 --- a/src/jsc/bindings/node/crypto/JSCipherConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSCipherConstructor.cpp @@ -221,8 +221,8 @@ JSC_DEFINE_HOST_FUNCTION(constructCipher, (JSC::JSGlobalObject * globalObject, J throwCryptoError(globalObject, scope, ERR_get_error(), "Failed to initialize cipher"_s); } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSCipherClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSCipherClassStructure.get(bunGlobalObject); return JSC::JSValue::encode(JSCipher::create(vm, structure, globalObject, cipherKind, WTF::move(ctx), authTagLength, maxMessageSize)); } diff --git a/src/jsc/bindings/node/crypto/JSDiffieHellmanConstructor.cpp b/src/jsc/bindings/node/crypto/JSDiffieHellmanConstructor.cpp index 8c281c45ce90..4e2408fb133e 100644 --- a/src/jsc/bindings/node/crypto/JSDiffieHellmanConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSDiffieHellmanConstructor.cpp @@ -167,8 +167,8 @@ JSC_DEFINE_HOST_FUNCTION(constructDiffieHellman, (JSC::JSGlobalObject * globalOb } // Get the appropriate structure and create the DiffieHellman object - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSDiffieHellmanClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSDiffieHellmanClassStructure.get(bunGlobalObject); return JSC::JSValue::encode(JSDiffieHellman::create(vm, structure, globalObject, WTF::move(dh))); } diff --git a/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp b/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp index b4e9c2a9dd4c..d5ce73c0b3ca 100644 --- a/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSDiffieHellmanGroupConstructor.cpp @@ -44,11 +44,11 @@ JSC_DEFINE_HOST_FUNCTION(constructDiffieHellmanGroup, (JSC::JSGlobalObject * glo } // Get the appropriate structure and create the DiffieHellmanGroup object - auto* zigGlobalObject = dynamicDowncast(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSDiffieHellmanGroupClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = dynamicDowncast(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSDiffieHellmanGroupClassStructure.get(bunGlobalObject); JSC::JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSDiffieHellmanGroupClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSDiffieHellmanGroupClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { auto scope = DECLARE_THROW_SCOPE(vm); if (!newTarget) { throwError(globalObject, scope, ErrorCode::ERR_INVALID_THIS, "Class constructor DiffieHellmanGroup cannot be invoked without 'new'"_s); diff --git a/src/jsc/bindings/node/crypto/JSECDHConstructor.cpp b/src/jsc/bindings/node/crypto/JSECDHConstructor.cpp index f65e45710dee..b9a432af2b38 100644 --- a/src/jsc/bindings/node/crypto/JSECDHConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSECDHConstructor.cpp @@ -68,8 +68,8 @@ JSC_DEFINE_HOST_FUNCTION(constructECDH, (JSC::JSGlobalObject * globalObject, JSC return Bun::ERR::CRYPTO_OPERATION_FAILED(scope, globalObject, "Failed to create key using named curve"_s); } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSECDHClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSECDHClassStructure.get(bunGlobalObject); const EC_GROUP* group = key.getGroup(); return JSC::JSValue::encode(JSECDH::create(vm, structure, globalObject, WTF::move(key), group)); diff --git a/src/jsc/bindings/node/crypto/JSHash.cpp b/src/jsc/bindings/node/crypto/JSHash.cpp index 6904da49c1d4..3951b1cb39a4 100644 --- a/src/jsc/bindings/node/crypto/JSHash.cpp +++ b/src/jsc/bindings/node/crypto/JSHash.cpp @@ -289,12 +289,12 @@ JSC_DEFINE_HOST_FUNCTION(constructHash, (JSC::JSGlobalObject * globalObject, JSC JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSHashClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSHashClassStructure.get(bunGlobalObject); // Handle new target JSC::JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSHashClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSHashClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor Hash cannot be invoked without 'new'"_s); return {}; @@ -321,7 +321,7 @@ JSC_DEFINE_HOST_FUNCTION(constructHash, (JSC::JSGlobalObject * globalObject, JSC } if (original->m_zigHasher) { - zigHasher = ExternZigHash::getFromOther(zigGlobalObject, original->m_zigHasher); + zigHasher = ExternZigHash::getFromOther(bunGlobalObject, original->m_zigHasher); } else { md = original->m_ctx.getDigest(); } @@ -334,7 +334,7 @@ JSC_DEFINE_HOST_FUNCTION(constructHash, (JSC::JSGlobalObject * globalObject, JSC md = ncrypto::getDigestByName(algorithm); if (!md) { - zigHasher = ExternZigHash::getByName(zigGlobalObject, algorithm); + zigHasher = ExternZigHash::getByName(bunGlobalObject, algorithm); } } diff --git a/src/jsc/bindings/node/crypto/JSHmac.cpp b/src/jsc/bindings/node/crypto/JSHmac.cpp index 1cbf2ab2df34..a08efe9e046f 100644 --- a/src/jsc/bindings/node/crypto/JSHmac.cpp +++ b/src/jsc/bindings/node/crypto/JSHmac.cpp @@ -235,12 +235,12 @@ JSC_DEFINE_HOST_FUNCTION(constructHmac, (JSC::JSGlobalObject * globalObject, JSC JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSHmacClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSHmacClassStructure.get(bunGlobalObject); // Handle new target JSC::JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSHmacClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSHmacClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor Hmac cannot be invoked without 'new'"_s); return {}; diff --git a/src/jsc/bindings/node/crypto/JSSign.cpp b/src/jsc/bindings/node/crypto/JSSign.cpp index 724e83843e70..9b1a2b35d6a5 100644 --- a/src/jsc/bindings/node/crypto/JSSign.cpp +++ b/src/jsc/bindings/node/crypto/JSSign.cpp @@ -491,11 +491,11 @@ JSC_DEFINE_HOST_FUNCTION(constructSign, (JSC::JSGlobalObject * globalObject, JSC JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSSignClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSSignClassStructure.get(bunGlobalObject); JSC::JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSSignClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSSignClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor Sign cannot be invoked without 'new'"_s); return {}; diff --git a/src/jsc/bindings/webcore/JSMIMEParams.cpp b/src/jsc/bindings/webcore/JSMIMEParams.cpp index a05ce0b7584f..bbed71333b9f 100644 --- a/src/jsc/bindings/webcore/JSMIMEParams.cpp +++ b/src/jsc/bindings/webcore/JSMIMEParams.cpp @@ -657,11 +657,11 @@ JSC_DEFINE_HOST_FUNCTION(constructMIMEParams, (JSGlobalObject * globalObject, Ca JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSMIMEParamsClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSMIMEParamsClassStructure.get(bunGlobalObject); JSC::JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSMIMEParamsClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSMIMEParamsClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor MIMEParams cannot be invoked without 'new'"_s); return {}; diff --git a/src/jsc/bindings/webcore/JSMIMEType.cpp b/src/jsc/bindings/webcore/JSMIMEType.cpp index 16a46815b4af..610f1f93a46b 100644 --- a/src/jsc/bindings/webcore/JSMIMEType.cpp +++ b/src/jsc/bindings/webcore/JSMIMEType.cpp @@ -539,11 +539,11 @@ JSC_DEFINE_HOST_FUNCTION(constructMIMEType, (JSGlobalObject * globalObject, Call JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSC::Structure* structure = zigGlobalObject->m_JSMIMETypeClassStructure.get(zigGlobalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSC::Structure* structure = bunGlobalObject->m_JSMIMETypeClassStructure.get(bunGlobalObject); JSC::JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSMIMETypeClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSMIMETypeClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor MIMEType cannot be invoked without 'new'"_s); return {}; @@ -570,7 +570,7 @@ JSC_DEFINE_HOST_FUNCTION(constructMIMEType, (JSGlobalObject * globalObject, Call // 3. Create and parse parameters // We need the structure for JSMIMEParams to create the map and the instance - JSC::Structure* paramsStructure = zigGlobalObject->m_JSMIMEParamsClassStructure.get(zigGlobalObject); + JSC::Structure* paramsStructure = bunGlobalObject->m_JSMIMEParamsClassStructure.get(bunGlobalObject); JSMap* paramsMap = JSMap::create(vm, globalObject->mapStructure()); RETURN_IF_EXCEPTION(scope, {}); // OOM check for map diff --git a/src/jsc/modules/NodeModuleModule.cpp b/src/jsc/modules/NodeModuleModule.cpp index 989906b2d688..909abe849495 100644 --- a/src/jsc/modules/NodeModuleModule.cpp +++ b/src/jsc/modules/NodeModuleModule.cpp @@ -648,10 +648,10 @@ static JSValue getPathCacheObject(VM& vm, JSObject* moduleObject) static JSValue getSourceMapFunction(VM& vm, JSObject* moduleObject) { auto* globalObject = defaultGlobalObject(moduleObject->globalObject()); - auto* zigGlobalObject = globalObject; + auto* bunGlobalObject = globalObject; // Return the actual SourceMap constructor from code generation - return zigGlobalObject->JSSourceMapConstructor(); + return bunGlobalObject->JSSourceMapConstructor(); } static JSValue getBuiltinModulesObject(VM& vm, JSObject* moduleObject) @@ -1005,8 +1005,8 @@ extern "C" JSC::EncodedJSValue Bun__createNodeModuleSourceMapEntryObject( JSC::EncodedJSValue encodedName) { auto& vm = globalObject->vm(); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSObject* object = JSC::constructEmptyObject(vm, zigGlobalObject->m_nodeModuleSourceMapEntryStructure.getInitializedOnMainThread(zigGlobalObject)); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSObject* object = JSC::constructEmptyObject(vm, bunGlobalObject->m_nodeModuleSourceMapEntryStructure.getInitializedOnMainThread(bunGlobalObject)); object->putDirectOffset(vm, 0, JSC::JSValue::decode(encodedGeneratedLine)); object->putDirectOffset(vm, 1, JSC::JSValue::decode(encodedGeneratedColumn)); object->putDirectOffset(vm, 2, JSC::JSValue::decode(encodedOriginalLine)); @@ -1041,8 +1041,8 @@ extern "C" JSC::EncodedJSValue Bun__createNodeModuleSourceMapOriginObject( JSC::EncodedJSValue encodedSource) { auto& vm = globalObject->vm(); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSObject* object = JSC::constructEmptyObject(vm, zigGlobalObject->m_nodeModuleSourceMapOriginStructure.getInitializedOnMainThread(zigGlobalObject)); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSObject* object = JSC::constructEmptyObject(vm, bunGlobalObject->m_nodeModuleSourceMapOriginStructure.getInitializedOnMainThread(bunGlobalObject)); object->putDirectOffset(vm, 0, JSC::JSValue::decode(encodedName)); object->putDirectOffset(vm, 1, JSC::JSValue::decode(encodedLine)); object->putDirectOffset(vm, 2, JSC::JSValue::decode(encodedColumn)); diff --git a/src/runtime/bake/BakeSourceProvider.h b/src/runtime/bake/BakeSourceProvider.h index 2eb52ee0637c..4f4cc1c0d293 100644 --- a/src/runtime/bake/BakeSourceProvider.h +++ b/src/runtime/bake/BakeSourceProvider.h @@ -21,9 +21,9 @@ class SourceProvider final : public JSC::StringSourceProvider { JSC::SourceProviderSourceType sourceType) { auto provider = adoptRef(*new SourceProvider(source, sourceOrigin, WTF::move(sourceURL), startPosition, sourceType)); - auto* zigGlobalObject = uncheckedDowncast(globalObject); + auto* bunGlobalObject = uncheckedDowncast(globalObject); auto specifier = Bun::toString(provider->sourceURL()); - Bun__addBakeSourceProviderSourceMap(zigGlobalObject->bunVM(), provider.ptr(), &specifier); + Bun__addBakeSourceProviderSourceMap(bunGlobalObject->bunVM(), provider.ptr(), &specifier); return provider; } diff --git a/src/runtime/bake/DevServerSourceProvider.h b/src/runtime/bake/DevServerSourceProvider.h index deb137b045f5..945f8007e554 100644 --- a/src/runtime/bake/DevServerSourceProvider.h +++ b/src/runtime/bake/DevServerSourceProvider.h @@ -26,11 +26,11 @@ class DevServerSourceProvider final : public JSC::StringSourceProvider { JSC::SourceProviderSourceType sourceType) { auto provider = adoptRef(*new DevServerSourceProvider(source, sourceMapJSONPtr, sourceMapJSONLength, sourceOrigin, WTF::move(sourceURL), startPosition, sourceType)); - auto* zigGlobalObject = uncheckedDowncast<::Bun::GlobalObject>(globalObject); + auto* bunGlobalObject = uncheckedDowncast<::Bun::GlobalObject>(globalObject); auto specifier = Bun::toString(provider->sourceURL()); - provider->m_globalObject = zigGlobalObject; + provider->m_globalObject = bunGlobalObject; provider->m_specifier = specifier; - Bun__addDevServerSourceProvider(zigGlobalObject->bunVM(), provider.ptr(), &specifier); + Bun__addDevServerSourceProvider(bunGlobalObject->bunVM(), provider.ptr(), &specifier); return provider; } diff --git a/src/runtime/ffi/FFIObject.rs b/src/runtime/ffi/FFIObject.rs index 463fee704dcf..414abf2878ee 100644 --- a/src/runtime/ffi/FFIObject.rs +++ b/src/runtime/ffi/FFIObject.rs @@ -57,7 +57,7 @@ fn create_buffer_with_ctx( } } -// ── DOM-call C++ put helpers (generated in ZigLazyStaticFunctions-inlines.h) ── +// ── DOM-call C++ put helpers (generated in BunLazyStaticFunctions-inlines.h) ── #[allow(non_snake_case)] unsafe extern "C" { fn FFI__ptr__put(global: *mut JSGlobalObject, value: JSValue); @@ -94,7 +94,7 @@ pub(crate) fn new_cstring( // DOMJIT fast-path descriptor + slow-path host fn, represented here as a const // descriptor. The `DOMEffect.forRead(.TypedArrayProperties)` argument is consumed // by the C++ codegen, not the runtime descriptor; it lives in the generated -// `ZigLazyStaticFunctions-inlines.h` already. +// `BunLazyStaticFunctions-inlines.h` already. pub(crate) const DOM_CALL: DomCall = DomCall { class_name: "FFI", function_name: "ptr", @@ -145,7 +145,7 @@ pub mod reader { // Same DOMCall shape as `DOM_CALL` above. The // `DOMEffect.forRead(.World)` argument is encoded on the C++ side - // (generated `Reader__*__put` in ZigLazyStaticFunctions-inlines.h); the + // (generated `Reader__*__put` in BunLazyStaticFunctions-inlines.h); the // runtime descriptor here only needs the `put` extern. pub(crate) const DOM_CALLS: &[(&str, DomCall)] = &[ ( @@ -408,7 +408,7 @@ pub mod reader { // The DOMJIT fast-path (no type checks) readers — called directly from // JIT code — live on the C++ side (generated - // `ZigLazyStaticFunctions-inlines.h`); only the slow paths above are here. + // `BunLazyStaticFunctions-inlines.h`); only the slow paths above are here. } pub(crate) fn ptr(global_this: &JSGlobalObject, _: JSValue, arguments: &[JSValue]) -> JSValue { diff --git a/src/runtime/jsc_hooks.rs b/src/runtime/jsc_hooks.rs index 86a0ef9d1090..bbf78f033ddb 100644 --- a/src/runtime/jsc_hooks.rs +++ b/src/runtime/jsc_hooks.rs @@ -3025,7 +3025,7 @@ fn transpile_source_code_inner( // `module_info.asDeserialized()`: finalize the // printer-filled record into the FFI shape consumed by C++ // (freed by C++ `~SourceProvider` via - // `zig__ModuleInfoDeserialized__deinit` — ZigSourceProvider.cpp; + // `bun__ModuleInfoDeserialized__deinit` — BunSourceProvider.cpp; // `ResolvedSource`/`OwnedResolvedSource` never free it, see the // ownership note in ResolvedSource.rs). let module_info: *mut core::ffi::c_void = module_info diff --git a/src/runtime/socket/tls_socket_functions.rs b/src/runtime/socket/tls_socket_functions.rs index 72065cffb71a..f9366e91c5d4 100644 --- a/src/runtime/socket/tls_socket_functions.rs +++ b/src/runtime/socket/tls_socket_functions.rs @@ -1174,7 +1174,7 @@ fn get_ssl_exception(global: &JSGlobalObject, default_message: &[u8]) -> JSValue // `zig_str` borrows `formatted`, which lives until this function // returns. The UTF-8 tag is what makes `to_error_instance` clone the // bytes (untagged strings are wrapped without copying — see - // Zig::toString in src/jsc/bindings/helpers.h), matching the + // Bun::toString in src/jsc/bindings/helpers.h), matching the // "Ensure we clone it" pattern in JSGlobalObject::create_error_instance. zig_str = ZigString::init_utf8(&formatted); diff --git a/src/runtime/webview/JSWebViewConstructor.cpp b/src/runtime/webview/JSWebViewConstructor.cpp index 2fd7fcf71602..30e6de940bdf 100644 --- a/src/runtime/webview/JSWebViewConstructor.cpp +++ b/src/runtime/webview/JSWebViewConstructor.cpp @@ -101,7 +101,7 @@ JSC_DEFINE_HOST_FUNCTION(constructWebView, (JSGlobalObject * globalObject, CallF VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobalObject = defaultGlobalObject(globalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); uint32_t width = 800, height = 600; WTF::String persistDir; @@ -330,9 +330,9 @@ JSC_DEFINE_HOST_FUNCTION(constructWebView, (JSGlobalObject * globalObject, CallF if (height == 0 || height > 16384) return Bun::ERR::OUT_OF_RANGE(scope, globalObject, "height"_s, 1, 16384, jsNumber(height)); - Structure* structure = zigGlobalObject->m_JSWebViewClassStructure.get(zigGlobalObject); + Structure* structure = bunGlobalObject->m_JSWebViewClassStructure.get(bunGlobalObject); JSValue newTarget = callFrame->newTarget(); - if (zigGlobalObject->m_JSWebViewClassStructure.constructor(zigGlobalObject) != newTarget) [[unlikely]] { + if (bunGlobalObject->m_JSWebViewClassStructure.constructor(bunGlobalObject) != newTarget) [[unlikely]] { auto* functionGlobalObject = defaultGlobalObject(getFunctionRealm(globalObject, newTarget.getObject())); RETURN_IF_EXCEPTION(scope, {}); structure = InternalFunction::createSubclassStructure(globalObject, newTarget.getObject(), From ca257e7cd5db9de5b30f6d1a7b6300755196330b Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 5 Jun 2026 04:19:43 +0000 Subject: [PATCH 10/20] Rename remaining bare zig locals to bunGlobal Finish the local-variable sweep: Bun::GlobalObject locals and parameters still named zig in BakeAdditionsToGlobalObject.cpp, BunAppModule.h, and the webview backends are renamed to bunGlobal, matching the earlier zigGlobal/zigGlobalObject rename. ZigString-typed identifiers (BunStringImpl.zig, toZigString locals) stay as-is since the ZigString rename is reserved for #30747. --- .../bindings/BakeAdditionsToGlobalObject.cpp | 32 +++++++++---------- src/jsc/modules/BunAppModule.h | 4 +-- src/runtime/webview/ChromeBackend.cpp | 12 +++---- src/runtime/webview/JSWebView.cpp | 22 ++++++------- src/runtime/webview/WebKitBackend.cpp | 6 ++-- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp b/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp index acf8a72031a0..04c5bed988c7 100644 --- a/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp +++ b/src/jsc/bindings/BakeAdditionsToGlobalObject.cpp @@ -38,8 +38,8 @@ extern "C" SYSV_ABI EncodedJSValue Bake__createDevServerFrameworkRequestArgsObje auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); auto& vm = globalObject->vm(); - auto* zig = uncheckedDowncast(globalObject); - auto* object = JSFinalObject::create(vm, zig->bakeAdditions().m_DevServerFrameworkRequestArgsClassStructure.get(zig)); + auto* bunGlobal = uncheckedDowncast(globalObject); + auto* object = JSFinalObject::create(vm, bunGlobal->bakeAdditions().m_DevServerFrameworkRequestArgsClassStructure.get(bunGlobal)); RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); object->putDirectOffset(vm, 0, JSValue::decode(routerTypeMain)); @@ -58,46 +58,46 @@ extern "C" SYSV_ABI EncodedJSValue Bake__createDevServerFrameworkRequestArgsObje extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getAsyncLocalStorage(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); - auto value = zig->bakeAdditions().getAsyncLocalStorage(zig); + auto* bunGlobal = static_cast(globalObject); + auto value = bunGlobal->bakeAdditions().getAsyncLocalStorage(bunGlobal); return JSValue::encode(value); } extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getEnsureAsyncLocalStorageInstanceJSFunction(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); - return JSValue::encode(zig->bakeAdditions().ensureAsyncLocalStorageInstanceJSFunction(globalObject)); + auto* bunGlobal = static_cast(globalObject); + return JSValue::encode(bunGlobal->bakeAdditions().ensureAsyncLocalStorageInstanceJSFunction(globalObject)); } extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getSSRResponseConstructor(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); - return JSValue::encode(zig->bakeAdditions().JSBakeResponseConstructor(globalObject)); + auto* bunGlobal = static_cast(globalObject); + return JSValue::encode(bunGlobal->bakeAdditions().JSBakeResponseConstructor(globalObject)); } BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeGetAsyncLocalStorage, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { - auto* zig = static_cast(globalObject); - return JSValue::encode(zig->bakeAdditions().getAsyncLocalStorage(zig)); + auto* bunGlobal = static_cast(globalObject); + return JSValue::encode(bunGlobal->bakeAdditions().getAsyncLocalStorage(bunGlobal)); } BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeEnsureAsyncLocalStorage, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - auto* zig = static_cast(globalObject); + auto* bunGlobal = static_cast(globalObject); if (callframe->argumentCount() < 1) { Bun::throwError(globalObject, scope, ErrorCode::ERR_MISSING_ARGS, "bakeEnsureAsyncLocalStorage requires at least one argument"_s); return JSValue::encode(jsUndefined()); } - zig->bakeAdditions().ensureAsyncLocalStorageInstance(zig, callframe->argument(0)); + bunGlobal->bakeAdditions().ensureAsyncLocalStorageInstance(bunGlobal, callframe->argument(0)); RETURN_IF_EXCEPTION(scope, {}); return JSValue::encode(jsUndefined()); } extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getBundleNewRouteJSFunction(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); - auto value = zig->bakeAdditions().getBundleNewRouteJSFunction(zig); + auto* bunGlobal = static_cast(globalObject); + auto value = bunGlobal->bakeAdditions().getBundleNewRouteJSFunction(bunGlobal); return JSValue::encode(value); } @@ -136,8 +136,8 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeGetBundleNewRouteJSFunction, (JSC::JSGlob extern "C" SYSV_ABI JSC::EncodedJSValue Bake__getNewRouteParamsJSFunction(JSC::JSGlobalObject* globalObject) { - auto* zig = static_cast(globalObject); - auto value = zig->bakeAdditions().getNewRouteParamsJSFunction(zig); + auto* bunGlobal = static_cast(globalObject); + auto value = bunGlobal->bakeAdditions().getNewRouteParamsJSFunction(bunGlobal); return JSValue::encode(value); } diff --git a/src/jsc/modules/BunAppModule.h b/src/jsc/modules/BunAppModule.h index 755219153bc0..97b60a2a063a 100644 --- a/src/jsc/modules/BunAppModule.h +++ b/src/jsc/modules/BunAppModule.h @@ -12,8 +12,8 @@ DEFINE_NATIVE_MODULE(BunApp) { INIT_NATIVE_MODULE(1); - auto* zig = static_cast(globalObject); - JSValue ssrResponseConstructor = zig->bakeAdditions().JSBakeResponseConstructor(zig); + auto* bunGlobal = static_cast(globalObject); + JSValue ssrResponseConstructor = bunGlobal->bakeAdditions().JSBakeResponseConstructor(bunGlobal); put(JSC::Identifier::fromString(vm, "Response"_s), ssrResponseConstructor); diff --git a/src/runtime/webview/ChromeBackend.cpp b/src/runtime/webview/ChromeBackend.cpp index 0397438b2815..3caaeeb45bdb 100644 --- a/src/runtime/webview/ChromeBackend.cpp +++ b/src/runtime/webview/ChromeBackend.cpp @@ -279,7 +279,7 @@ static constexpr us_socket_vtable_t s_cdpVTable = { .on_handshake = nullptr, }; -bool Transport::ensureSpawned(Bun::GlobalObject* zig, const WTF::String& userDataDir, +bool Transport::ensureSpawned(Bun::GlobalObject* bunGlobal, const WTF::String& userDataDir, const WTF::String& path, const WTF::Vector& extraArgv, bool stdoutInherit, bool stderrInherit) { @@ -305,7 +305,7 @@ bool Transport::ensureSpawned(Bun::GlobalObject* zig, const WTF::String& userDat argvC.append(s.utf8()); argvPtrs.append(argvC.last().data()); } - int32_t fd = Bun__Chrome__ensure(zig, + int32_t fd = Bun__Chrome__ensure(bunGlobal, dir.length() ? dir.data() : nullptr, pathC.length() ? pathC.data() : nullptr, argvPtrs.isEmpty() ? nullptr : argvPtrs.span().data(), @@ -319,7 +319,7 @@ bool Transport::ensureSpawned(Bun::GlobalObject* zig, const WTF::String& userDat // fd 3 and fd 4; read(3)+write(4) both hit our socketpair peer. usockets' // bsd_recv calls recv() which needs a real socket (pipe fds broke here // with ENOTSOCK silently misread as EOF). - m_global = zig; + m_global = bunGlobal; if (!s_cdpGroup.loop) { us_socket_group_init(&s_cdpGroup, uws_get_loop(), &s_cdpVTable, nullptr); @@ -450,7 +450,7 @@ static void wsOnClose(void* ctx, unsigned short code) t.rejectAllAndMarkDead(makeString("Chrome WebSocket closed (code "_s, code, ')')); } -bool Transport::ensureConnected(Bun::GlobalObject* zig, const WTF::String& wsUrl, bool autoDetected, +bool Transport::ensureConnected(Bun::GlobalObject* bunGlobal, const WTF::String& wsUrl, bool autoDetected, const WTF::String& userDataDir, bool stdoutInherit, bool stderrInherit) { // Already connected — singleton semantics, first call wins. @@ -463,7 +463,7 @@ bool Transport::ensureConnected(Bun::GlobalObject* zig, const WTF::String& wsUrl m_rx.clear(); m_txQueue.clear(); } - m_global = zig; + m_global = bunGlobal; m_mode = TransportMode::WebSocket; m_wasAutoDetected = autoDetected; if (autoDetected) { @@ -472,7 +472,7 @@ bool Transport::ensureConnected(Bun::GlobalObject* zig, const WTF::String& wsUrl m_fallbackStderrInherit = stderrInherit; } - auto* ctx = zig->scriptExecutionContext(); + auto* ctx = bunGlobal->scriptExecutionContext(); auto result = WebCore::WebSocket::create(*ctx, wsUrl); if (result.hasException()) { m_dead = true; diff --git a/src/runtime/webview/JSWebView.cpp b/src/runtime/webview/JSWebView.cpp index a8f2d0acfb85..da7b02dd02e9 100644 --- a/src/runtime/webview/JSWebView.cpp +++ b/src/runtime/webview/JSWebView.cpp @@ -296,12 +296,12 @@ JSWebView* JSWebView::createAndSend(JSGlobalObject* g, Structure* structure, uint32_t width, uint32_t height, const WTF::String& persistDir, bool stdoutInherit, bool stderrInherit) { - auto* zig = defaultGlobalObject(g); + auto* bunGlobal = defaultGlobalObject(g); auto& c = WK::client(); - if (!c.ensureSpawned(zig, stdoutInherit, stderrInherit)) return nullptr; + if (!c.ensureSpawned(bunGlobal, stdoutInherit, stderrInherit)) return nullptr; - auto impl = WebViewEventTarget::create(*zig->scriptExecutionContext()); - JSWebView* view = create(structure, zig, WTF::move(impl)); + auto impl = WebViewEventTarget::create(*bunGlobal->scriptExecutionContext()); + JSWebView* view = create(structure, bunGlobal, WTF::move(impl)); view->m_viewId = c.nextViewId++; c.viewsById.emplace(view->m_viewId, Weak(view, &webViewWeakOwner())); c.updateKeepAlive(); @@ -328,7 +328,7 @@ JSWebView* JSWebView::createChrome(JSGlobalObject* g, Structure* structure, const WTF::String& path, const WTF::Vector& extraArgv, bool stdoutInherit, bool stderrInherit, const WTF::String& wsUrl, bool skipAutoDetect) { - auto* zig = defaultGlobalObject(g); + auto* bunGlobal = defaultGlobalObject(g); auto& t = CDP::transport(); // Transport selection, in priority order: @@ -342,26 +342,26 @@ JSWebView* JSWebView::createChrome(JSGlobalObject* g, Structure* structure, // sync/instant so the constructor stays synchronous. bool ok; if (!wsUrl.isEmpty()) { - ok = t.ensureConnected(zig, wsUrl, /* autoDetected */ false); + ok = t.ensureConnected(bunGlobal, wsUrl, /* autoDetected */ false); } else if (skipAutoDetect || !path.isEmpty() || !extraArgv.isEmpty()) { - ok = t.ensureSpawned(zig, userDataDir, path, extraArgv, stdoutInherit, stderrInherit); + ok = t.ensureSpawned(bunGlobal, userDataDir, path, extraArgv, stdoutInherit, stderrInherit); } else { // Auto-detect. DevToolsActivePort URL caps at // ws://127.0.0.1:65535/devtools/browser/<36-char-uuid> ≈ 70B. char buf[128]; size_t len = Bun__Chrome__autoDetect(buf, sizeof(buf)); if (len > 0) { - ok = t.ensureConnected(zig, + ok = t.ensureConnected(bunGlobal, WTF::String::fromUTF8(std::span(buf, len)), /* autoDetected */ true, userDataDir, stdoutInherit, stderrInherit); } else { - ok = t.ensureSpawned(zig, userDataDir, path, extraArgv, stdoutInherit, stderrInherit); + ok = t.ensureSpawned(bunGlobal, userDataDir, path, extraArgv, stdoutInherit, stderrInherit); } } if (!ok) return nullptr; - auto impl = WebViewEventTarget::create(*zig->scriptExecutionContext()); - JSWebView* view = create(structure, zig, WTF::move(impl)); + auto impl = WebViewEventTarget::create(*bunGlobal->scriptExecutionContext()); + JSWebView* view = create(structure, bunGlobal, WTF::move(impl)); view->m_backend = WebViewBackend::Chrome; view->m_width = width; view->m_height = height; diff --git a/src/runtime/webview/WebKitBackend.cpp b/src/runtime/webview/WebKitBackend.cpp index 661691066775..c40f2efec1f6 100644 --- a/src/runtime/webview/WebKitBackend.cpp +++ b/src/runtime/webview/WebKitBackend.cpp @@ -127,7 +127,7 @@ void HostClient::updateKeepAlive() WebCore::clientData(global->vm())->bunVM, want ? 1 : -1); } -bool HostClient::ensureSpawned(Bun::GlobalObject* zig, bool stdoutInherit, bool stderrInherit) +bool HostClient::ensureSpawned(Bun::GlobalObject* bunGlobal, bool stdoutInherit, bool stderrInherit) { if (sock && !dead) return true; @@ -142,12 +142,12 @@ bool HostClient::ensureSpawned(Bun::GlobalObject* zig, bool stdoutInherit, bool txQueue.clear(); } - int fd = Bun__WebViewHost__ensure(zig, stdoutInherit, stderrInherit); + int fd = Bun__WebViewHost__ensure(bunGlobal, stdoutInherit, stderrInherit); if (fd < 0) { dead = true; return false; } - global = zig; + global = bunGlobal; // Socket group — once. Embedded; lazily linked into the loop on first // socket. on_open won't fire (us_socket_from_fd doesn't call it) but a From 93d2cf88ae97666cc9aaa906a5bb3571d7bdfcbf Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Wed, 10 Jun 2026 00:27:54 +0000 Subject: [PATCH 11/20] Address review: delete stale commented-out GlobalObject block, fix doc references - Drop the commented-out legacy destroy/visitChildrenImpl block in BunGlobalObject.cpp; the real implementations live earlier in the file and the rename had only been rewriting names inside dead comments. - Correct the bun__renderDiff home-path comment in phase_c_exports.rs (defined in src/runtime/test_runner/diff_format.rs) and remove the duplicate trailing notes. - Rename the stale 'Expose to Zig' heading in the JSC class skill doc. --- .../implementing-jsc-classes-cpp/SKILL.md | 2 +- src/bun_bin/phase_c_exports.rs | 5 ++- src/jsc/bindings/BunGlobalObject.cpp | 31 ------------------- 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/.claude/skills/implementing-jsc-classes-cpp/SKILL.md b/.claude/skills/implementing-jsc-classes-cpp/SKILL.md index cb17e5881076..b1be8bba5149 100644 --- a/.claude/skills/implementing-jsc-classes-cpp/SKILL.md +++ b/.claude/skills/implementing-jsc-classes-cpp/SKILL.md @@ -168,7 +168,7 @@ Visit in `visitChildrenImpl`: m_JSFooClassStructure.visit(visitor); ``` -## Expose to Zig +## Expose to Rust ```cpp extern "C" JSC::EncodedJSValue Bun__JSFooConstructor(Bun::GlobalObject* globalObject) { diff --git a/src/bun_bin/phase_c_exports.rs b/src/bun_bin/phase_c_exports.rs index cbdb05894b15..0b80484be8fd 100644 --- a/src/bun_bin/phase_c_exports.rs +++ b/src/bun_bin/phase_c_exports.rs @@ -248,6 +248,8 @@ pub(crate) extern "C" fn Bun__VM__scriptExecutionStatus(_vm: *const VirtualMachi // REAL: src/bundler_jsc/analyze_jsc.rs // bun__ModuleInfoDeserialized__toJSModuleRecord + +// REAL: src/runtime/test_runner/diff_format.rs // bun__renderDiff // ════════════════════════════════════════════════════════════════════════════ @@ -291,6 +293,3 @@ pub(crate) extern "C" fn Bun__LifecycleAgentStopPreventingExit(_agent: *mut c_vo pub(crate) extern "C" fn DNSResolver__getConstructor(_global: *mut JSGlobalObject) -> JSValue { unreachable!("DNSResolver has no JS-visible constructor (no `construct` in .classes.ts)") } - -// (bun__renderDiff now defined in src/runtime/test_runner/diff_format.rs.) -// (bun__ModuleInfoDeserialized__toJSModuleRecord now defined in src/bundler_jsc/analyze_jsc.rs.) diff --git a/src/jsc/bindings/BunGlobalObject.cpp b/src/jsc/bindings/BunGlobalObject.cpp index 4fce06eea839..e389ee125d14 100644 --- a/src/jsc/bindings/BunGlobalObject.cpp +++ b/src/jsc/bindings/BunGlobalObject.cpp @@ -3291,37 +3291,6 @@ void GlobalObject::visitOutputConstraints(JSCell* cell, Visitor& visitor) template void GlobalObject::visitOutputConstraints(JSCell*, AbstractSlotVisitor&); template void GlobalObject::visitOutputConstraints(JSCell*, SlotVisitor&); -// void GlobalObject::destroy(JSCell* cell) -// { -// uncheckedDowncast(cell)->Bun::GlobalObject::~Bun::GlobalObject(); -// } - -// template -// void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) -// { -// Bun::GlobalObject* thisObject = uncheckedDowncast(cell); -// ASSERT_GC_OBJECT_INHERITS(thisObject, info()); -// Base::visitChildren(thisObject, visitor); - -// { -// // The GC thread has to grab the GC lock even though it is not mutating the containers. -// Locker locker { thisObject->m_gcLock }; - -// for (auto& structure : thisObject->m_structures.values()) -// visitor.append(structure); - -// for (auto& guarded : thisObject->m_guardedObjects) -// guarded->visitAggregate(visitor); -// } - -// for (auto& constructor : thisObject->constructors().array()) -// visitor.append(constructor); - -// thisObject->m_builtinInternalFunctions.visit(visitor); -// } - -// DEFINE_VISIT_CHILDREN(Bun::GlobalObject); - void GlobalObject::reload() { auto& vm = this->vm(); From 8d42ec7d75437c9472965ad87813b3ace0880ae8 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 11 Jun 2026 22:42:23 +0000 Subject: [PATCH 12/20] Merge redundant adjacent namespace Bun blocks --- src/jsc/bindings/BunGlobalObject.h | 4 ---- src/jsc/bindings/BunObject.cpp | 3 --- src/jsc/bindings/BunPlugin.h | 5 +---- src/jsc/bindings/FormatStackTraceForJS.cpp | 4 ---- src/jsc/bindings/FormatStackTraceForJS.h | 3 --- src/jsc/modules/NodeModuleModule.cpp | 3 --- 6 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/jsc/bindings/BunGlobalObject.h b/src/jsc/bindings/BunGlobalObject.h index a13a6d3baf8c..314cf83f61fb 100644 --- a/src/jsc/bindings/BunGlobalObject.h +++ b/src/jsc/bindings/BunGlobalObject.h @@ -798,10 +798,6 @@ class EvalGlobalObject : public GlobalObject { } }; -} // namespace Bun - -namespace Bun { - ALWAYS_INLINE void* vm(Bun::GlobalObject* globalObject) { return globalObject->bunVM(); diff --git a/src/jsc/bindings/BunObject.cpp b/src/jsc/bindings/BunObject.cpp index 5e940c545454..5c49b8ac002d 100644 --- a/src/jsc/bindings/BunObject.cpp +++ b/src/jsc/bindings/BunObject.cpp @@ -1183,9 +1183,6 @@ static void exportBunObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC: } } -} // namespace Bun - -namespace Bun { void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, diff --git a/src/jsc/bindings/BunPlugin.h b/src/jsc/bindings/BunPlugin.h index 6df95766e489..afcfc0ea02cc 100644 --- a/src/jsc/bindings/BunPlugin.h +++ b/src/jsc/bindings/BunPlugin.h @@ -99,10 +99,7 @@ class BunPlugin { }; }; -} // namespace Bun - -namespace Bun { class GlobalObject; JSC::JSValue runVirtualModule(Bun::GlobalObject*, BunString* specifier, bool& wasModuleMock); JSC::Structure* createModuleMockStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype); -} +} // namespace Bun diff --git a/src/jsc/bindings/FormatStackTraceForJS.cpp b/src/jsc/bindings/FormatStackTraceForJS.cpp index ed79d17acf72..a072ea24dcb6 100644 --- a/src/jsc/bindings/FormatStackTraceForJS.cpp +++ b/src/jsc/bindings/FormatStackTraceForJS.cpp @@ -794,10 +794,6 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb return JSC::JSValue::encode(JSC::jsUndefined()); } -} // namespace Bun - -namespace Bun { - void createCallSitesFromFrames(Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, JSCStackTrace& stackTrace, MarkedArgumentBuffer& callSites) { /* From v8's "Stack Trace API" (https://github.com/v8/v8/wiki/Stack-Trace-API): diff --git a/src/jsc/bindings/FormatStackTraceForJS.h b/src/jsc/bindings/FormatStackTraceForJS.h index 1af1256d7a28..633d833de5fa 100644 --- a/src/jsc/bindings/FormatStackTraceForJS.h +++ b/src/jsc/bindings/FormatStackTraceForJS.h @@ -83,9 +83,6 @@ JSC_DECLARE_CUSTOM_SETTER(errorInstanceLazyStackCustomSetter); WTF::String computeErrorInfoWrapperToString(JSC::VM& vm, WTF::Vector& stackTrace, unsigned int& line_in, unsigned int& column_in, WTF::String& sourceURL, void* bunErrorData); JSC::JSValue computeErrorInfoWrapperToJSValue(JSC::VM& vm, WTF::Vector& stackTrace, unsigned int& line_in, unsigned int& column_in, WTF::String& sourceURL, JSC::JSObject* errorInstance, void* bunErrorData); void computeLineColumnWithSourcemap(JSC::VM& vm, JSC::SourceProvider* _Nonnull sourceProvider, JSC::LineColumn& lineColumn, WTF::String& remappedSourceURL); -} // namespace Bun - -namespace Bun { // GlobalObject member function for creating CallSite objects void createCallSitesFromFrames( diff --git a/src/jsc/modules/NodeModuleModule.cpp b/src/jsc/modules/NodeModuleModule.cpp index 909abe849495..5f49a58964c3 100644 --- a/src/jsc/modules/NodeModuleModule.cpp +++ b/src/jsc/modules/NodeModuleModule.cpp @@ -1133,9 +1133,6 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsModuleResolveFilenameSlowPathEnabled, ->hasOverriddenModuleResolveFilenameFunction)); } -} // namespace Bun - -namespace Bun { void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, From 5737a4bbaade355937838c98e2d4ebde970750c1 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 11 Jun 2026 23:16:01 +0000 Subject: [PATCH 13/20] Merge one more redundant adjacent namespace Bun block in NodeModuleModule.h --- src/jsc/modules/NodeModuleModule.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/jsc/modules/NodeModuleModule.h b/src/jsc/modules/NodeModuleModule.h index 7b29e1d106a9..e3f4ce64b9e5 100644 --- a/src/jsc/modules/NodeModuleModule.h +++ b/src/jsc/modules/NodeModuleModule.h @@ -31,10 +31,6 @@ struct PathResolveModule { }; JSC::JSValue resolveLookupPaths(JSC::JSGlobalObject* globalObject, String request, PathResolveModule parent); -} - -namespace Bun { - void generateNativeModule_NodeModule( JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey, Vector &exportNames, From 1a1febc127eb26e310304ab6e74dfa9013e56153 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:45:07 +0000 Subject: [PATCH 14/20] [autofix.ci] apply automated fixes --- src/jsc/modules/NodeModuleModule.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jsc/modules/NodeModuleModule.cpp b/src/jsc/modules/NodeModuleModule.cpp index 84e49527d6d2..2f3e91e3fa21 100644 --- a/src/jsc/modules/NodeModuleModule.cpp +++ b/src/jsc/modules/NodeModuleModule.cpp @@ -1143,7 +1143,6 @@ JSC::JSValue createStreamIterEnabledFlag(Bun::GlobalObject*) return JSC::jsBoolean(Bun__streamIterEnabled()); } - void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, From f28363bd2e23294ee03d2f69bf68caafb6f51d6f Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Wed, 17 Jun 2026 23:06:02 +0000 Subject: [PATCH 15/20] Rename Zig::GlobalObject in broadcast-channel-worker-gc test comments --- .../broadcastchannel/broadcast-channel-worker-gc.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/js/web/broadcastchannel/broadcast-channel-worker-gc.test.ts b/test/js/web/broadcastchannel/broadcast-channel-worker-gc.test.ts index 01e7c8d5b6ea..190a953c530d 100644 --- a/test/js/web/broadcastchannel/broadcast-channel-worker-gc.test.ts +++ b/test/js/web/broadcastchannel/broadcast-channel-worker-gc.test.ts @@ -186,7 +186,7 @@ test( ); // SEGV in TypeCastTraits::isType reached from -// Zig::GlobalObject::visitChildrenImpl on a concurrent GC helper thread. The +// Bun::GlobalObject::visitChildrenImpl on a concurrent GC helper thread. The // visit used `clientData(thisObject->vm())` (raw JSGlobalObject::m_vm deref) // and `httpHeaderIdentifiers()` did an unsynchronized std::optional::emplace() // that both the mutator and parallel marker threads could enter. Observed in @@ -195,7 +195,7 @@ test( // // This stress maximises the race surface: // - extra ShadowRealm globals so multiple parallel marker helpers each visit -// a distinct Zig::GlobalObject and all dereference vm.clientData +// a distinct Bun::GlobalObject and all dereference vm.clientData // - continuous allocation so the concurrent collector is always active // - worker spawn/terminate churn for the reported correlation // @@ -208,7 +208,7 @@ test( async () => { const script = /* js */ ` const workerCode = \` - // Extra Zig::GlobalObject cells in this VM so parallel GC helper + // Extra Bun::GlobalObject cells in this VM so parallel GC helper // threads each get one to visit and all call clientData(vm). const realms = []; for (let i = 0; i < 6; i++) { try { realms.push(new ShadowRealm()); } catch {} } From f0420a53974bac9f1153a02c6d9c04dea55f2651 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Tue, 23 Jun 2026 23:37:42 +0000 Subject: [PATCH 16/20] Fix mismatched namespace-closer trailers in JSFFIFunction and drop dead .gitattributes entry --- .gitattributes | 1 - src/jsc/bindings/JSFFIFunction.cpp | 2 +- src/jsc/bindings/JSFFIFunction.h | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 06ea6a42fa5d..0f80d1cc6d30 100644 --- a/.gitattributes +++ b/.gitattributes @@ -30,7 +30,6 @@ src/api/schema.d.ts linguist-generated fixture.*.c linguist-generated src/api/schema.js linguist-generated *-fixture* linguist-generated -src/jsc/bindings/BunGeneratedCode.h linguist-generated src/jsc/bindings/BunGeneratedCode.cpp linguist-generated src/jsc/bindings/headers.h linguist-generated src/jsc/bindings/headers.zig linguist-generated diff --git a/src/jsc/bindings/JSFFIFunction.cpp b/src/jsc/bindings/JSFFIFunction.cpp index 40d82275edcd..af49f1404b7a 100644 --- a/src/jsc/bindings/JSFFIFunction.cpp +++ b/src/jsc/bindings/JSFFIFunction.cpp @@ -182,7 +182,7 @@ JSFFIFunction* JSFFIFunction::createForFFI(VM& vm, Bun::GlobalObject* globalObje return function; } -} // namespace JSC +} // namespace Bun extern "C" JSC::EncodedJSValue FFI_Callback_call(FFICallbackFunctionWrapper& wrapper, size_t argCount, JSC::EncodedJSValue* args) diff --git a/src/jsc/bindings/JSFFIFunction.h b/src/jsc/bindings/JSFFIFunction.h index 340ab0c95619..0aeb9729073c 100644 --- a/src/jsc/bindings/JSFFIFunction.h +++ b/src/jsc/bindings/JSFFIFunction.h @@ -96,4 +96,4 @@ class JSFFIFunction final : public JSC::JSFunction { CFFIFunction m_function; }; -} // namespace JSC +} // namespace Bun From 9be0356d7588b18b5edfe1ee9e090923968f3832 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 26 Jun 2026 11:50:09 +0000 Subject: [PATCH 17/20] Point the reportError test comment at BunStackFrame.rs Line 84 of this comment block was already renamed to BunStackFrame, but line 85 still cited src/jsc/ZigStackFrame.zig. That file was one of the uncompiled .zig porting references, which were kept under their original names on the earlier revisions of this branch until they were deleted. The merge of #32621 deleted all of them, so the reference now points at src/jsc/BunStackFrame.rs, where NameFormatter actually lives. This was the last ZigStackFrame mention in the tree. --- test/js/bun/util/reportError.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/bun/util/reportError.test.ts b/test/js/bun/util/reportError.test.ts index 42c802417035..cf6d5a4a6821 100644 --- a/test/js/bun/util/reportError.test.ts +++ b/test/js/bun/util/reportError.test.ts @@ -82,7 +82,7 @@ test("native error printer handles lone surrogates in message and stack frame na const fixture = String.raw` function thrower() { throw new Error("MSG_PRE\uD800MSG_POST"); } // Force the native BunStackFrame NameFormatter path: give the frame a - // function_name containing a lone high surrogate. (src/jsc/ZigStackFrame.zig + // function_name containing a lone high surrogate. (src/jsc/BunStackFrame.rs // NameFormatter.format -> "{f}" on bun.String) Object.defineProperty(thrower, "name", { value: "FN_PRE\uD800FN_POST" }); thrower(); From a552c6bd3b418e122ec0dcb8cdeb12bd52683673 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 7 Jul 2026 13:17:31 +0000 Subject: [PATCH 18/20] [autofix.ci] apply automated fixes --- src/jsc/bindings/BunGlobalObject.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jsc/bindings/BunGlobalObject.cpp b/src/jsc/bindings/BunGlobalObject.cpp index e9811b24c50c..3aaaa282557e 100644 --- a/src/jsc/bindings/BunGlobalObject.cpp +++ b/src/jsc/bindings/BunGlobalObject.cpp @@ -1156,7 +1156,6 @@ WebCore::EventTarget& GlobalObject::eventTarget() return globalEventScope; } - JSC_DEFINE_CUSTOM_GETTER(JSBuffer_getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) From c579e0bac9468bc55f1b771db62bb7ae10e56d92 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 15 Jul 2026 06:50:38 +0000 Subject: [PATCH 19/20] [autofix.ci] apply automated fixes --- src/jsc/Errorable.rs | 2 +- src/jsc/VirtualMachine.rs | 6 +++--- src/jsc/lib.rs | 34 +++++++++++++++++----------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/jsc/Errorable.rs b/src/jsc/Errorable.rs index e6e6e039b34a..52747788cac6 100644 --- a/src/jsc/Errorable.rs +++ b/src/jsc/Errorable.rs @@ -1,6 +1,6 @@ use crate::JSValue; -use crate::error_code::ErrorCode; use crate::bun_error_type::BunErrorType; +use crate::error_code::ErrorCode; #[repr(C)] pub struct Errorable { diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index b928bf48daf9..1a833635f8c0 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -18,9 +18,9 @@ use crate::module_loader::{self as ModuleLoader, FetchFlags}; use crate::rare_data::RareData; use crate::saved_source_map::SavedSourceMap; use crate::{ - self as jsc, ErrorCode, ErrorableResolvedSource, ErrorableString, Exception, JSGlobalObject, - JSInternalPromise, JSValue, JsResult, OpaqueCallback, PlatformEventLoop, ResolvedSource, VM, - BunException, + self as jsc, BunException, ErrorCode, ErrorableResolvedSource, ErrorableString, Exception, + JSGlobalObject, JSInternalPromise, JSValue, JsResult, OpaqueCallback, PlatformEventLoop, + ResolvedSource, VM, }; pub use crate::process_auto_killer as ProcessAutoKiller; diff --git a/src/jsc/lib.rs b/src/jsc/lib.rs index ef08c4071fcd..7bca9a3555d7 100644 --- a/src/jsc/lib.rs +++ b/src/jsc/lib.rs @@ -59,6 +59,12 @@ pub const CONV: &str = "C"; // ────────────────────────────────────────────────────────────────────────── pub mod error; pub use error::{Error as CrateError, Result as CrateResult}; +#[path = "BunErrorType.rs"] +pub mod bun_error_type; +#[path = "BunStackFrameCode.rs"] +pub mod bun_stack_frame_code; +#[path = "BunStackFramePosition.rs"] +pub mod bun_stack_frame_position; #[path = "CommonAbortReason.rs"] pub mod common_abort_reason; #[path = "CustomGetterSetter.rs"] @@ -101,12 +107,6 @@ pub mod text_codec; pub mod url_search_params; #[path = "WTF.rs"] pub mod wtf; -#[path = "BunErrorType.rs"] -pub mod bun_error_type; -#[path = "BunStackFrameCode.rs"] -pub mod bun_stack_frame_code; -#[path = "BunStackFramePosition.rs"] -pub mod bun_stack_frame_position; /// `bun.schema.api` types that reference `BunStackFramePosition` (this crate) /// and so cannot live in `bun_options_types::schema::api` without a dep cycle. @@ -435,6 +435,9 @@ pub use self::common_strings::CommonStrings; pub use self::dom_url::DOMURL; pub use self::js_big_int::JSBigInt; +pub use self::bun_error_type::BunErrorType; +pub use self::bun_stack_frame_code::BunStackFrameCode; +pub use self::bun_stack_frame_position::BunStackFramePosition; pub use self::common_abort_reason::{CommonAbortReason, CommonAbortReasonExt}; pub use self::custom_getter_setter::CustomGetterSetter; /// Some drafts spell this `jsc::ErrCode` — keep both until call-sites converge. @@ -456,9 +459,6 @@ pub use self::source_provider::SourceProvider; pub use self::source_type::SourceType; pub use self::text_codec::TextCodec; pub use self::url_search_params::URLSearchParams; -pub use self::bun_error_type::BunErrorType; -pub use self::bun_stack_frame_code::BunStackFrameCode; -pub use self::bun_stack_frame_position::BunStackFramePosition; #[path = "GarbageCollectionController.rs"] pub mod garbage_collection_controller; @@ -496,6 +496,12 @@ pub mod virtual_machine_exports; #[path = "host_fn.rs"] pub mod host_fn; #[path = "AnyPromise.rs"] pub mod any_promise; +#[path = "BunException.rs"] +pub mod bun_exception; +#[path = "BunStackFrame.rs"] +pub mod bun_stack_frame; +#[path = "BunStackTrace.rs"] +pub mod bun_stack_trace; #[path = "CachedBytecode.rs"] pub mod cached_bytecode; #[path = "DeferredError.rs"] @@ -516,12 +522,6 @@ pub mod system_error; pub mod url; #[path = "VM.rs"] pub mod vm; -#[path = "BunException.rs"] -pub mod bun_exception; -#[path = "BunStackFrame.rs"] -pub mod bun_stack_frame; -#[path = "BunStackTrace.rs"] -pub mod bun_stack_trace; // `generated_classes_list.rs` is mounted by `bun_runtime` (see its lib.rs) — // every aliased type lives in api/webcore/test_runner/bake, so mounting it // here would create a `bun_jsc → bun_runtime` cycle. @@ -984,12 +984,12 @@ mod __macro_smoke { // above with `#[path = "…"] pub mod …;`). These were previously placeholder // newtypes; the real opaque-FFI structs now live in their own files and are // surfaced here at the crate root. +pub use self::bun_stack_frame::BunStackFrame; +pub use self::bun_stack_trace::BunStackTrace; pub use self::cached_bytecode::CachedBytecode; pub use self::deferred_error::DeferredError; pub use self::dom_form_data::DOMFormData; pub use self::url::URL; -pub use self::bun_stack_frame::BunStackFrame; -pub use self::bun_stack_trace::BunStackTrace; pub use abort_signal::{AbortSignal, AbortSignalRef}; // `VM` / `JSGlobalObject` — opaque FFI handles to C++-owned objects. Defined From c6065fcf64cb2044961d944f664203a7bf86b54c Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Wed, 15 Jul 2026 07:09:14 +0000 Subject: [PATCH 20/20] Restore the Bun__GlobalObject__create spelling in the bake-init comment The 2a510e77 merge overwrote VirtualMachine.rs with main's version and re-applied the rename sed. Main's copy of this comment has the pre-existing single-underscore typo ZigGlobalObject__create, so the sed produced BunGlobalObject__create, regressing 50d99c9d which had corrected the comment to name the actual Bun__GlobalObject__create symbol (matching lines 105, 113, 1944, 2137, 2163, 3100 and the definition in BunGlobalObject.cpp). This was the only such occurrence. --- src/jsc/VirtualMachine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index 1a833635f8c0..f53776b2a382 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -3747,7 +3747,7 @@ impl VirtualMachine { }; // Note: shares the console / log / event-loop wiring with `init`; // the only delta is the global is created via `BakeCreateProdGlobal` - // instead of `BunGlobalObject__create`. Route through `init` then + // instead of `Bun__GlobalObject__create`. Route through `init` then // swap the global. let vm = Self::init(init_opts)?; // SAFETY: `vm` is the unique live VM on this thread.