diff --git a/.claude/skills/implementing-jsc-classes-cpp/SKILL.md b/.claude/skills/implementing-jsc-classes-cpp/SKILL.md index de5269026b6a..b1be8bba5149 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) { @@ -168,14 +168,14 @@ Visit in `visitChildrenImpl`: m_JSFooClassStructure.visit(visitor); ``` -## Expose to Zig +## Expose to Rust ```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/.gitattributes b/.gitattributes index 94af433ee123..da6e3e9b124f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -29,8 +29,7 @@ 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.cpp linguist-generated src/jsc/bindings/headers.h linguist-generated packages/bun-uws/fuzzing/seed-corpus/**/* linguist-generated diff --git a/CLAUDE.md b/CLAUDE.md index 017447949842..54f09169473b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -157,7 +157,7 @@ When implementing JavaScript classes in C++: - `class FooConstructor : public JSC::InternalFunction` 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 @@ -241,7 +241,7 @@ Several situational sections live in `.claude/docs/landing-prs.md` — read the ### 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 downstream null-check or isDead() probe on a possibly-freed object is papering over the defect. Prove the mechanism, don't correlate — "the crash goes away" is not a root cause, and a fix you can't explain hides an adjacent unhandled case. Before changing anything shared, enumerate every consumer; prefer scoping the change to your one caller via an explicit flag. Never change a Bun-native default to fix Node compatibility — that 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 — share or derive it. Parameterize the existing path rather than cloning a parallel branch; when your change supersedes a mechanism, delete the old path in the same PR. 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. 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 — share or derive it. Parameterize the existing path rather than cloning a parallel branch; when your change supersedes a mechanism, delete the old path in the same PR. 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. 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). Per-connection facts live on the socket, never a shared context. Reset per-operation state at the start of each use of a reusable object; 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. 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. When a heuristic keeps sprouting counterexamples in review, redesign structurally instead of adding tie-breakers. If a maintainer doesn't understand your logic after one explanation, simplify rather than justify. New cross-cutting abstractions need maintainer agreement before appearing inside a feature PR. diff --git a/scripts/build/codegen.ts b/scripts/build/codegen.ts index 9bc82dc3acfe..e4c1af9bceaf 100644 --- a/scripts/build/codegen.ts +++ b/scripts/build/codegen.ts @@ -946,7 +946,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 f6c848be3018..67ae10b05301 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/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_core/string/mod.rs b/src/bun_core/string/mod.rs index ef9c0306bea3..eb7042895201 100644 --- a/src/bun_core/string/mod.rs +++ b/src/bun_core/string/mod.rs @@ -1455,7 +1455,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 26d90add685f..f995f4f1615d 100644 --- a/src/bundler/analyze_transpiled_module.rs +++ b/src/bundler/analyze_transpiled_module.rs @@ -519,11 +519,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. @@ -531,7 +531,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/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 b3f10957ae40..14259ddec257 100644 --- a/src/codegen/cppbind.ts +++ b/src/codegen/cppbind.ts @@ -454,8 +454,8 @@ const rustSharedTypes: Record = { "JSC::EncodedJSValue": "crate::JSValue", "EncodedJSValue": "crate::JSValue", "JSC::JSGlobalObject": "crate::JSGlobalObject", - "Zig::GlobalObject": "crate::JSGlobalObject", - "ZigException": "crate::zig_exception::ZigException", + "Bun::GlobalObject": "crate::JSGlobalObject", + "BunException": "crate::bun_exception::BunException", "ZigString": "bun_core::ZigString", "JSC::VM": "crate::VM", "JSC::JSPromise": "crate::JSPromise", @@ -577,7 +577,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") ); } @@ -589,7 +589,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 07320db5a1cd..460d0847445f 100644 --- a/src/codegen/generate-classes.ts +++ b/src/codegen/generate-classes.ts @@ -638,7 +638,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); @@ -692,7 +692,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()); @@ -750,7 +750,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()); }` : "" @@ -988,7 +988,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]] { @@ -1011,7 +1011,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 @@ -1108,7 +1108,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); @@ -1130,7 +1130,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]] { @@ -1781,7 +1781,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; @@ -1842,7 +1842,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); @@ -1858,7 +1858,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); @@ -1881,7 +1881,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("")}); @@ -1899,7 +1899,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); @@ -2615,7 +2615,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 @@ -2638,7 +2638,7 @@ const GENERATED_CLASSES_HEADER = [ #include "root.h" -namespace Zig { +namespace Bun { JSC_DECLARE_HOST_FUNCTION(jsFunctionInherits); @@ -2652,7 +2652,7 @@ JSC_DECLARE_HOST_FUNCTION(jsFunctionInherits); ` namespace WebCore { -using namespace Zig; +using namespace Bun; using namespace JSC; `, @@ -2665,7 +2665,7 @@ const GENERATED_CLASSES_IMPL_HEADER_PRE = ` #include "headers.h" #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -2703,7 +2703,7 @@ const GENERATED_CLASSES_IMPL_HEADER_POST = ` namespace WebCore { using namespace JSC; -using namespace Zig; +using namespace Bun; #include "ZigGeneratedClasses.lut.h" @@ -2723,7 +2723,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 0c04102bd080..829d86df9663 100644 --- a/src/codegen/generate-host-exports.ts +++ b/src/codegen/generate-host-exports.ts @@ -265,7 +265,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. @@ -499,7 +499,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"], ["crate::bake::dev_server::inspector_agent", "InspectorBunFrontendDevServerAgentHandle"], ["bun_jsc::debugger", "LifecycleHandle"], diff --git a/src/codegen/generate-js2native.ts b/src/codegen/generate-js2native.ts index 2143557ef408..eea00b3a6e3d 100644 --- a/src/codegen/generate-js2native.ts +++ b/src/codegen/generate-js2native.ts @@ -203,9 +203,9 @@ export function getJS2NativeCPP() { .filter(x => x.type === "rust") .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", ] @@ -224,7 +224,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({ @@ -254,10 +254,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 dea2a643525c..f4ff46d1f3f2 100644 --- a/src/codegen/generate-jssink.ts +++ b/src/codegen/generate-jssink.ts @@ -285,6 +285,7 @@ using namespace JSC; ${classes.map(name => `extern "C" size_t ${name}__memoryCost(void* sinkPtr);`).join("\n")} ${classes.map(name => `extern "C" void ${name}__controllerDetached(void* sinkPtr, JSC::EncodedJSValue controllerValue);`).join("\n")} + `; var templ = head; @@ -347,7 +348,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}()); } @@ -380,7 +381,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)); @@ -427,7 +428,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)); @@ -477,7 +478,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)); @@ -498,7 +499,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)); @@ -922,7 +923,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)); } @@ -955,7 +956,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/event_loop/README.md b/src/event_loop/README.md index c5c569ddd5a7..c738fca2d34b 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/http_jsc/websocket_client.rs b/src/http_jsc/websocket_client.rs index b5c43240de97..40a955e1ca8a 100644 --- a/src/http_jsc/websocket_client.rs +++ b/src/http_jsc/websocket_client.rs @@ -425,7 +425,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/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/internal/worker/messaging.ts b/src/js/internal/worker/messaging.ts index 8281a0c986e4..b5d55b52c5de 100644 --- a/src/js/internal/worker/messaging.ts +++ b/src/js/internal/worker/messaging.ts @@ -216,7 +216,7 @@ function setupMainThreadPort(port: any, setEntryEvaluatedHook: (hook: () => void mainThreadPort = port; mainThreadPort.on("message", handleMessageFromMainThreadGated); - // Stored on ZigGlobalObject (WriteBarrier), not on globalThis, so user code + // Stored on BunGlobalObject (WriteBarrier), not on globalThis, so user code // can't observe or clobber it. WebWorker__dispatchOnline calls it once. setEntryEvaluatedHook(() => { entryEvaluated = true; diff --git a/src/js/node/worker_threads.ts b/src/js/node/worker_threads.ts index 7262da0f30f7..812f425ef315 100644 --- a/src/js/node/worker_threads.ts +++ b/src/js/node/worker_threads.ts @@ -764,7 +764,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/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 83% rename from src/jsc/ZigException.rs rename to src/jsc/BunException.rs index f33b10be84c1..39bb076caef5 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::{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`); -// `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 90% rename from src/jsc/ZigStackFramePosition.rs rename to src/jsc/BunStackFramePosition.rs index 97426c8519d9..4087ab44b9de 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..193c3178b36d 100644 --- a/src/jsc/ZigStackTrace.rs +++ b/src/jsc/BunStackTrace.rs @@ -6,18 +6,18 @@ use bun_core::String as BunString; use bun_core::ZigStringSlice; use bun_url::URL as ZigURL; +use crate::BunStackFrame; use crate::SourceProvider; -use crate::ZigStackFrame; /// 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 96dae5137792..68641d9ed5e8 100644 --- a/src/jsc/ConsoleObject.rs +++ b/src/jsc/ConsoleObject.rs @@ -1205,7 +1205,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(); @@ -1213,15 +1213,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, @@ -1233,7 +1233,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/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/Debugger.rs b/src/jsc/Debugger.rs index 92eea89bf629..42d5b6cb9fda 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, BunException, CallFrame, JSGlobalObject}; bun_core::declare_scope!(debugger, visible); bun_core::declare_scope!(TestReporterAgent, visible); @@ -874,13 +874,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, ); } @@ -890,7 +890,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) } @@ -926,7 +926,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 bd407042747f..5ef3407321ab 100644 --- a/src/jsc/ErrorCode.rs +++ b/src/jsc/ErrorCode.rs @@ -184,12 +184,12 @@ 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). #[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 68254b447493..52747788cac6 100644 --- a/src/jsc/Errorable.rs +++ b/src/jsc/Errorable.rs @@ -1,6 +1,6 @@ use crate::JSValue; +use crate::bun_error_type::BunErrorType; use crate::error_code::ErrorCode; -use crate::zig_error_type::ZigErrorType; #[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: ErrorCode, err_value: JSValue) -> Self { Self { result: Result { - err: ZigErrorType { + err: BunErrorType { code, value: err_value, }, diff --git a/src/jsc/Exception.rs b/src/jsc/Exception.rs index 4e690c116684..365f1c35981e 100644 --- a/src/jsc/Exception.rs +++ b/src/jsc/Exception.rs @@ -1,4 +1,4 @@ -use crate::{JSGlobalObject, JSValue, ZigStackTrace}; +use crate::{BunStackTrace, JSGlobalObject, JSValue}; 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/FetchHeaders.rs b/src/jsc/FetchHeaders.rs index 2bec550f166b..576b688a8781 100644 --- a/src/jsc/FetchHeaders.rs +++ b/src/jsc/FetchHeaders.rs @@ -43,7 +43,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 bf7b9441fe03..688317a9bd2e 100644 --- a/src/jsc/JSGlobalObject.rs +++ b/src/jsc/JSGlobalObject.rs @@ -1165,27 +1165,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 @@ -1193,7 +1193,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] @@ -1412,7 +1412,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, @@ -1430,17 +1430,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) { @@ -1552,7 +1552,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, @@ -1575,7 +1575,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 { @@ -1592,7 +1592,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"); @@ -1601,7 +1601,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`. @@ -1687,27 +1687,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; @@ -1724,10 +1724,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, @@ -1738,15 +1738,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/JSValue.rs b/src/jsc/JSValue.rs index a729fc0a7af3..d602a656e7ea 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, ZigException, + AnyPromise, ArrayBuffer, BuiltinName, BunException, JSArrayIterator, JSGlobalObject, + JSInternalPromise, JSObject, JSPromise, JSString, JSType, JsClass, JsError, JsResult, bun_string_jsc, ffi, host_fn, }; @@ -915,8 +915,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); @@ -2001,10 +2001,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/ModuleLoader.rs b/src/jsc/ModuleLoader.rs index 14ba0e5b9e3c..a6ca038bc92c 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/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 8ba138599be3..3001f7d22b0e 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/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 2dc03fbd4246..f53776b2a382 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, - ZigException, + self as jsc, BunException, ErrorCode, ErrorableResolvedSource, ErrorableString, Exception, + JSGlobalObject, JSInternalPromise, JSValue, JsResult, OpaqueCallback, PlatformEventLoop, + ResolvedSource, VM, }; 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; @@ -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; @@ -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 @@ -1600,7 +1600,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 @@ -1939,9 +1939,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, @@ -2134,7 +2134,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. @@ -2155,12 +2155,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, @@ -2574,7 +2574,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( @@ -3097,7 +3097,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; @@ -3699,7 +3699,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), @@ -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 `ZigGlobalObject__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. @@ -4909,19 +4909,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); } @@ -5028,7 +5028,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, ) -> crate::CrateResult<()> { let stack = trace.frames(); @@ -5099,10 +5099,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 { @@ -5117,7 +5117,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 { @@ -5160,9 +5160,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, @@ -5172,7 +5172,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. @@ -5188,7 +5188,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, @@ -5199,7 +5199,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)] { @@ -5243,7 +5243,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 = @@ -5256,7 +5256,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 { @@ -5265,7 +5265,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) }; @@ -5295,7 +5295,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. @@ -5453,11 +5453,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) }; @@ -5518,9 +5518,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, @@ -5529,7 +5529,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, @@ -5555,7 +5555,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 @@ -5567,7 +5567,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 { @@ -5584,19 +5584,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, @@ -5612,7 +5612,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, @@ -5623,7 +5623,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 @@ -5637,7 +5637,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, @@ -5679,10 +5679,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) { @@ -5731,7 +5731,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); @@ -5843,7 +5843,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() @@ -6270,7 +6270,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/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..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/bindings/BunAnalyzeTranspiledModule.cpp b/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp index 71538245abbd..a1caab1f5868 100644 --- a/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp +++ b/src/jsc/bindings/BunAnalyzeTranspiledModule.cpp @@ -10,8 +10,8 @@ #include #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/ExceptionScope.h" -#include "ZigSourceProvider.h" -#include "ZigGlobalObject.h" +#include "BunSourceProvider.h" +#include "BunGlobalObject.h" #include "headers-handwritten.h" #include "IsolatedModuleCache.h" #include "BunAnalyzeTranspiledModule.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); + if (!Bun::IsolatedModuleCache::canUse(vm, uncheckedDowncast(globalObject)->bunVM())) { + 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/BunCPUProfiler.cpp b/src/jsc/bindings/BunCPUProfiler.cpp index 978ab5660494..222187294912 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 031428729e72..365e5b4ddafe 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 dfa5cbc23251..aceae00a3ceb 100644 --- a/src/jsc/bindings/BunClientData.h +++ b/src/jsc/bindings/BunClientData.h @@ -26,13 +26,13 @@ class DOMWrapperWorld; #include #include "JSCTaskScheduler.h" #include "HTTPHeaderIdentifiers.h" -namespace Zig { +namespace Bun { class GlobalObject; } namespace WebCore { using namespace JSC; -using namespace Zig; +using namespace Bun; enum class UseCustomHeapCellType { Yes, No }; @@ -112,7 +112,7 @@ class JSVMClientData : public JSC::VM::ClientData { JSC::GCClient::IsoSubspace& domBuiltinConstructorSpace() { return m_domBuiltinConstructorSpace; } // Constructed eagerly so the concurrent GC marker - // (Zig::GlobalObject::visitChildrenImpl) never races the mutator on a + // (Bun::GlobalObject::visitChildrenImpl) never races the mutator on a // lazy std::optional::emplace(). The ctor only calls // LazyProperty::initLater ~90 times (stores a tagged function pointer), // so there is no startup cost worth deferring. @@ -129,7 +129,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 42e51363445a..49165620f917 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,12 +138,12 @@ 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)); } -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(Zig::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(Zig::GlobalObject* globalObject, CommonStringsForZig co } } -extern "C" JSC::EncodedJSValue Bun__CommonStringsForZig__toJS(CommonStringsForZig commonString, Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue Bun__CommonStringsForBun__toJS(CommonStringsForBun 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/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 ea84d276eda9..7b991fb74096 100644 --- a/src/jsc/bindings/ZigException.cpp +++ b/src/jsc/bindings/BunException.cpp @@ -1,7 +1,7 @@ /** - * ZigException handling and error processing utilities. + * 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" @@ -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" @@ -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]; if (frame.jsc_stack_frame_index < 0 || static_cast(frame.jsc_stack_frame_index) >= frames.size()) continue; populateStackFrame(vm, trace, frames[frame.jsc_stack_frame_index], frame, i == 0, &trace.referenced_source_provider, globalObject, flags, finalizerSafety); @@ -471,7 +471,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) { @@ -616,9 +616,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; @@ -698,7 +698,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]] { @@ -826,12 +826,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 {}) { @@ -866,7 +866,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/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 1df82470bfe0..298e1d13d89f 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" @@ -169,7 +169,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" @@ -272,7 +272,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) @@ -282,7 +282,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. @@ -357,7 +357,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*); @@ -421,7 +421,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) { @@ -440,7 +440,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); @@ -485,32 +485,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); } @@ -527,7 +527,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); @@ -593,10 +593,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); @@ -621,11 +621,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"); } @@ -635,7 +635,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 @@ -662,7 +662,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); @@ -766,7 +766,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); @@ -855,7 +855,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 @@ -863,22 +863,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() @@ -894,20 +894,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); @@ -915,9 +915,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: @@ -930,7 +930,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() { @@ -952,7 +952,7 @@ const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable() nullptr, // defaultLanguage &compileStreaming, &instantiateStreaming, - &Zig::deriveShadowRealmGlobalObject, + &Bun::deriveShadowRealmGlobalObject, &codeForEval, // codeForEval &canCompileStrings, // canCompileStrings &trustedScriptStructure, // trustedScriptStructure @@ -980,7 +980,7 @@ const JSC::GlobalObjectMethodTable& EvalGlobalObject::globalObjectMethodTable() nullptr, // defaultLanguage &compileStreaming, &instantiateStreaming, - &Zig::deriveShadowRealmGlobalObject, + &Bun::deriveShadowRealmGlobalObject, &codeForEval, // codeForEval &canCompileStrings, // canCompileStrings &trustedScriptStructure, // trustedScriptStructure @@ -1054,7 +1054,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) @@ -1097,7 +1097,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()); } @@ -1110,7 +1110,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(); @@ -1127,7 +1127,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())); } @@ -1135,7 +1135,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())); } @@ -1145,7 +1145,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); @@ -1158,7 +1158,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); @@ -1174,10 +1174,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); @@ -1467,7 +1467,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, {}); @@ -1572,7 +1572,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); @@ -1598,10 +1598,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); @@ -1627,10 +1627,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); @@ -1647,12 +1647,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); @@ -1839,7 +1839,7 @@ JSC_DEFINE_HOST_FUNCTION(jsWebStreamClosedPromise, (JSGlobalObject * globalObjec } 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); @@ -1848,7 +1848,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(); } @@ -2107,7 +2107,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( @@ -2148,7 +2148,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( @@ -2175,7 +2175,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( @@ -2199,7 +2199,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(); @@ -2208,7 +2208,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(); @@ -2222,7 +2222,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)); @@ -2249,7 +2249,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); @@ -2370,17 +2370,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) { @@ -2407,7 +2407,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(); @@ -2418,7 +2418,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( @@ -2453,13 +2453,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( @@ -2474,7 +2474,7 @@ void GlobalObject::finishCreation(VM& vm) m_streamsRuntime.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(WebCore::JSStreamsRuntime::create(init.vm, static_cast(init.owner))); + init.set(WebCore::JSStreamsRuntime::create(init.vm, static_cast(init.owner))); }); m_requireMap.initLater( @@ -2547,12 +2547,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( @@ -2630,7 +2630,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); @@ -2680,7 +2680,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 @@ -2707,7 +2707,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()); } @@ -2750,7 +2750,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)); @@ -2765,7 +2765,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)); @@ -2791,7 +2791,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); \ } @@ -2873,6 +2873,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionCheckBufferRead, (JSC::JSGlobalObject * globa } return JSValue::encode(jsUndefined()); } + EncodedJSValue GlobalObject::assignToStream(JSValue stream, JSValue controller) { auto& vm = this->vm(); @@ -2900,7 +2901,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) @@ -2920,12 +2921,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. @@ -3073,7 +3074,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()); } @@ -3134,12 +3135,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) { @@ -3163,7 +3164,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. @@ -3217,7 +3218,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; } @@ -3250,7 +3251,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()); } @@ -3285,7 +3286,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() { @@ -3356,37 +3357,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)->Zig::GlobalObject::~Zig::GlobalObject(); -// } - -// template -// void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) -// { -// Zig::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(Zig::GlobalObject); - void GlobalObject::reload() { auto& vm = this->vm(); @@ -3408,11 +3378,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(); @@ -3432,7 +3402,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; @@ -3491,7 +3461,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(); @@ -3521,7 +3491,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); @@ -3591,7 +3561,7 @@ JSC::JSPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* jsGlobalO BunString queryString = { BunStringTag::Empty, nullptr }; 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]] { @@ -3694,7 +3664,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, @@ -3709,7 +3679,7 @@ JSC::JSPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, } JSValue result = Bun::fetchESMSourceCodeAsync( - static_cast(globalObject), + static_cast(globalObject), moduleKeyJS, &res, &moduleKeyBun, @@ -3730,7 +3700,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, @@ -3750,7 +3720,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); @@ -3790,7 +3760,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) { @@ -3816,7 +3786,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]] { @@ -3853,7 +3823,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; @@ -4011,9 +3981,9 @@ void GlobalObject::setNodeWorkerEntryEvaluatedHook(JSObject* hook) m_nodeWorkerEntryEvaluatedHook.clear(); } -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) { @@ -4053,12 +4023,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 9f2e8298df95..4cdcb7b5c064 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; @@ -90,17 +89,17 @@ 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 { +namespace Bun { class JSCStackTrace; 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; @@ -354,7 +353,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 +465,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) @@ -714,8 +713,8 @@ class GlobalObject : public Bun::GlobalScope { String agentClusterID() const; static String defaultAgentClusterID(); - BunPlugin::OnLoad onLoadPlugins {}; - 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 @@ -813,11 +812,7 @@ class EvalGlobalObject : public GlobalObject { } }; -} // namespace Zig - -namespace Bun { - -ALWAYS_INLINE void* vm(Zig::GlobalObject* globalObject) +ALWAYS_INLINE void* vm(Bun::GlobalObject* globalObject) { return globalObject->bunVM(); } @@ -837,42 +832,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(); } @@ -880,10 +875,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 98% rename from src/jsc/bindings/ZigGlobalObject.lut.txt rename to src/jsc/bindings/BunGlobalObject.lut.txt index 5d6354de3ec8..e9cf6bf2abb8 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/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 73% rename from src/jsc/bindings/ZigLazyStaticFunctions.h rename to src/jsc/bindings/BunLazyStaticFunctions.h index 38033b52d19c..42872c450734 100644 --- a/src/jsc/bindings/ZigLazyStaticFunctions.h +++ b/src/jsc/bindings/BunLazyStaticFunctions.h @@ -2,13 +2,16 @@ #pragma once #include "root.h" -namespace Zig { +namespace Bun { class GlobalObject; +} + +namespace Bun { class JSFFIFunction; class LazyStaticFunctions { public: - void init(Zig::GlobalObject* globalObject); + void init(Bun::GlobalObject* globalObject); template void visit(Visitor& visitor); @@ -18,4 +21,4 @@ class LazyStaticFunctions { /* -- END FUNCTION DEFINITIONS-- */ }; -} // namespace Zig +} // namespace Bun 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 02a1127e00df..a4707525289f 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" @@ -97,7 +97,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); @@ -107,7 +107,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(); } JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Array(JSGlobalObject* lexicalGlobalObject, JSValue arrayValue, size_t maxLength, bool asUint8Array) @@ -301,7 +301,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) @@ -350,7 +350,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); @@ -359,7 +359,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); @@ -621,8 +621,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)); @@ -1092,20 +1092,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" @@ -1114,31 +1114,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()); - 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) { - 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) @@ -1169,16 +1169,13 @@ static void exportBunObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC: } } -} // namespace Bun - -namespace Zig { void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, 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(); @@ -1193,4 +1190,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 3352c3f6896a..2e1e9f2d6d0e 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 @@ -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); @@ -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; @@ -398,7 +398,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; @@ -507,7 +507,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)); @@ -897,14 +897,14 @@ EncodedJSValue BunPlugin::OnResolve::run(JSC::JSGlobalObject* globalObject, BunS return JSValue::encode(JSC::jsUndefined()); } -} // namespace Zig +} // namespace Bun -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); } @@ -913,10 +913,10 @@ 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(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)); @@ -935,7 +935,7 @@ JSC::JSValue runVirtualModule(Zig::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); @@ -978,7 +978,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..afcfc0ea02cc 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; @@ -100,10 +100,6 @@ class BunPlugin { }; class GlobalObject; - -} // namespace Zig - -namespace Bun { -JSC::JSValue runVirtualModule(Zig::GlobalObject*, BunString* specifier, bool& wasModuleMock); +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/BunProcess.cpp b/src/jsc/bindings/BunProcess.cpp index 498fdcf9278f..89ac1bc12fc3 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" @@ -170,8 +170,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(); @@ -390,7 +390,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); @@ -822,7 +822,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; @@ -841,7 +841,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; @@ -864,16 +864,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)); @@ -888,7 +888,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); @@ -913,8 +913,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)); } @@ -926,7 +926,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); @@ -982,7 +982,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())))); } @@ -995,7 +995,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, {}); @@ -1162,7 +1162,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(); @@ -1196,7 +1196,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 @@ -1207,9 +1207,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); @@ -1341,9 +1341,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); @@ -1364,9 +1364,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); @@ -1667,7 +1667,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); @@ -1899,7 +1899,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( @@ -1912,7 +1912,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(); @@ -1943,7 +1943,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(); @@ -2011,7 +2011,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, {}); @@ -2025,7 +2025,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); @@ -2094,7 +2094,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) @@ -2472,7 +2472,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(); @@ -2485,7 +2485,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)) @@ -2551,7 +2551,7 @@ static JSValue constructProcessConfigObject(VM& vm, JSObject* processObject) JSC::JSArray* shareableBuiltins = JSC::constructEmptyArray(globalObject, nullptr); if (auto* exception = scope.exception()) [[unlikely]] { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return JSC::jsUndefined(); } variables->putDirect(vm, JSC::Identifier::fromString(vm, "v8_enable_i8n_support"_s), JSC::jsNumber(1), 0); @@ -2688,7 +2688,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(); } @@ -2749,7 +2749,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; @@ -2814,7 +2814,7 @@ static JSValue constructProcessChannel(VM& vm, JSObject* processObject) auto result = JSC::profiledCall(globalObject, ProfilingReason::API, getControl, callData, globalObject->globalThis(), args); if (auto* exception = scope.exception()) [[unlikely]] { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return jsUndefined(); } return result; @@ -3009,14 +3009,14 @@ static JSValue constructRevision(VM& vm, JSObject* processObject) static JSValue constructEnv(VM& vm, JSObject* processObject) { - auto* globalObject = uncheckedDowncast(processObject->globalObject()); + auto* globalObject = uncheckedDowncast(processObject->globalObject()); // Lazy property builder: exceptions must not propagate into // reifyStaticProperty, which performs no exception check. auto scope = DECLARE_TOP_EXCEPTION_SCOPE(vm); JSValue env = globalObject->processEnvObject(); if (auto* exception = scope.exception()) [[unlikely]] { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return JSC::jsUndefined(); } return env; @@ -3271,12 +3271,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 @@ -3307,7 +3307,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, {}); @@ -3358,8 +3358,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). @@ -3456,9 +3456,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 - Zig::GlobalObject* zigGlobalObject = defaultGlobalObject(lexicalGlobalObject); + Bun::GlobalObject* bunGlobalObject = defaultGlobalObject(lexicalGlobalObject); - return zigGlobalObject->processObject(); + return bunGlobalObject->processObject(); } return process; @@ -3759,7 +3759,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)); @@ -3859,7 +3859,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); @@ -3885,7 +3885,7 @@ static JSValue Process_stubEmptyArray(VM& vm, JSObject* processObject) JSC::JSArray* array = JSC::constructEmptyArray(processObject->globalObject(), nullptr); if (auto* exception = scope.exception()) [[unlikely]] { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(processObject->globalObject(), exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(processObject->globalObject(), exception); return JSC::jsUndefined(); } return array; @@ -3987,7 +3987,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); @@ -4023,20 +4023,20 @@ static JSValue constructMainModuleProperty(VM& vm, JSObject* processObject) JSValue mainValue = bun->get(globalObject, builtinNames.mainPublicName()); if (auto* exception = scope.exception()) [[unlikely]] { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return JSC::jsUndefined(); } auto* requireMap = globalObject->requireMap(); JSValue mainModule = requireMap->get(globalObject, mainValue); if (auto* exception = scope.exception()) [[unlikely]] { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return JSC::jsUndefined(); } 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) { @@ -4060,7 +4060,7 @@ JSValue Process::constructNextTickFn(JSC::VM& vm, Zig::GlobalObject* globalObjec JSValue nextTickFunction = JSC::profiledCall(globalObject, ProfilingReason::API, initializer, JSC::getCallData(initializer), globalObject->globalThis(), args); if (auto* exception = scope.exception()) [[unlikely]] { (void)scope.tryClearException(); - Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); + Bun::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); return JSC::jsUndefined(); } if (nextTickFunction && nextTickFunction.isObject()) { @@ -4073,7 +4073,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); } @@ -4309,7 +4309,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, {}); @@ -4338,8 +4338,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); @@ -4347,11 +4347,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)); } @@ -4362,8 +4362,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, {}); @@ -4377,7 +4377,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); @@ -4391,7 +4391,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); @@ -4402,7 +4402,7 @@ extern "C" void Process__emitDisconnectEvent(Zig::GlobalObject* global) } } -extern "C" void Process__emitMemoryPressureEvent(Zig::GlobalObject* global, int level) +extern "C" void Process__emitMemoryPressureEvent(Bun::GlobalObject* global, int level) { auto* process = global->processObject(); auto& vm = JSC::getVM(global); @@ -4415,7 +4415,7 @@ extern "C" void Process__emitMemoryPressureEvent(Zig::GlobalObject* global, int } } -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 92d70e747f21..f02fe55cf318 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; } @@ -58,7 +58,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); @@ -68,7 +68,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 6d6e4428f3e6..b97116e6d2e3 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" @@ -41,7 +41,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/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 fa3778b481d1..ac2187088cb4 100644 --- a/src/jsc/bindings/ZigSourceProvider.cpp +++ b/src/jsc/bindings/BunSourceProvider.cpp @@ -2,12 +2,12 @@ #include "helpers.h" -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include "MimallocWTFMalloc.h" #include "BunAnalyzeTranspiledModule.h" #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "wtf/Assertions.h" #include @@ -18,7 +18,7 @@ #include #include -namespace Zig { +namespace Bun { using Base = JSC::SourceProvider; using BytecodeCacheGenerator = JSC::BytecodeCacheGenerator; @@ -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) @@ -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 97% rename from src/jsc/bindings/ZigSourceProvider.h rename to src/jsc/bindings/BunSourceProvider.h index ccbb659c734e..c53d060613cb 100644 --- a/src/jsc/bindings/ZigSourceProvider.h +++ b/src/jsc/bindings/BunSourceProvider.h @@ -16,9 +16,11 @@ class SourceProvider; #include #include -namespace Zig { - +namespace Bun { class GlobalObject; +} + +namespace Bun { 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); @@ -79,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 ec85cc75cb3a..900f00fcfb32 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" @@ -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(); @@ -568,14 +568,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; } @@ -603,7 +603,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); @@ -795,13 +795,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); } @@ -817,7 +817,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; } @@ -827,13 +827,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); @@ -856,25 +856,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/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..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) }; @@ -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..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; @@ -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/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/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 abe3a18f09b0..015cd4760fd4 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)) - 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); } -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); } @@ -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); @@ -496,7 +496,7 @@ extern "C" BunString Bun__ErrorCode__inspectForErrorMessage(JSC::JSGlobalObject* auto scope = DECLARE_TOP_EXCEPTION_SCOPE(JSC::getVM(globalObject)); WTF::StringBuilder builder; JSValueToStringSafe(globalObject, builder, JSValue::decode(value), true); - RETURN_IF_EXCEPTION(scope, Zig::BunStringEmpty); + RETURN_IF_EXCEPTION(scope, Bun::BunStringEmpty); return Bun::toStringRef(builder.toString()); } diff --git a/src/jsc/bindings/ErrorCode.h b/src/jsc/bindings/ErrorCode.h index 57e9009fbd9e..9492f14604da 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/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 17c9dc6822ea..e2c024952529 100644 --- a/src/jsc/bindings/ErrorStackTrace.h +++ b/src/jsc/bindings/ErrorStackTrace.h @@ -9,12 +9,12 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" 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/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 44905bd58102..aee6621ab0d8 100644 --- a/src/jsc/bindings/ExposeNodeModuleGlobals.cpp +++ b/src/jsc/bindings/ExposeNodeModuleGlobals.cpp @@ -12,7 +12,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "InternalModuleRegistry.h" #pragma push_macro("assert") @@ -65,7 +65,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)); \ } @@ -74,7 +74,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); @@ -97,7 +97,7 @@ extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__ExposeNodeModuleGlobals(Zig::Global // Called from VirtualMachine::reload_entry_point when argv carries a // Node.js `--trace-*` flag. The registry caches the module, so repeat calls // (hot reload, workers) are cheap. -extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__preExecutionBootstrap(Zig::GlobalObject* globalObject) +extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__preExecutionBootstrap(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_TOP_EXCEPTION_SCOPE(vm); @@ -111,7 +111,7 @@ extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__preExecutionBootstrap(Zig::GlobalOb // 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 d622679f31aa..6325bfd31456 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" @@ -32,7 +32,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); @@ -81,7 +81,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); @@ -120,10 +120,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; } @@ -140,7 +140,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, @@ -184,15 +184,15 @@ 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; 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()) { @@ -241,19 +241,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. @@ -273,7 +273,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); @@ -296,7 +296,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; @@ -308,7 +308,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 = {}; @@ -396,7 +396,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, @@ -428,7 +428,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); @@ -438,24 +438,24 @@ static JSValue computeErrorInfoWithPrepareStackTrace(JSC::VM& vm, Zig::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; @@ -496,7 +496,7 @@ static JSValue computeErrorInfoWithPrepareStackTrace(JSC::VM& vm, Zig::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)); @@ -519,7 +519,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); @@ -529,10 +529,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 @@ -623,7 +623,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); @@ -656,7 +656,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); @@ -758,7 +758,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); @@ -817,11 +817,7 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb return JSC::JSValue::encode(JSC::jsUndefined()); } -} // namespace Bun - -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 @@ -845,4 +841,4 @@ void createCallSitesFromFrames(Zig::GlobalObject* globalObject, JSC::JSGlobalObj } } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/bindings/FormatStackTraceForJS.h b/src/jsc/bindings/FormatStackTraceForJS.h index fc9515a4668b..633d833de5fa 100644 --- a/src/jsc/bindings/FormatStackTraceForJS.h +++ b/src/jsc/bindings/FormatStackTraceForJS.h @@ -44,10 +44,10 @@ class String; class OrdinalNumber; } // namespace WTF -namespace Zig { -class GlobalObject; +namespace Bun { class JSCStackTrace; -} // namespace Zig +class GlobalObject; +} // namespace Bun using JSC::EncodedJSValue; using JSC::PropertyName; @@ -60,7 +60,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, @@ -83,15 +83,12 @@ 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 Zig { // GlobalObject member function for creating CallSite objects void createCallSitesFromFrames( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSGlobalObject* lexicalGlobalObject, - Zig::JSCStackTrace& stackTrace, + Bun::JSCStackTrace& stackTrace, JSC::MarkedArgumentBuffer& callSites); -} // namespace Zig +} // namespace Bun 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/H2HeadersMaterializer.cpp b/src/jsc/bindings/H2HeadersMaterializer.cpp index 481b5250572d..eda9788e7d63 100644 --- a/src/jsc/bindings/H2HeadersMaterializer.cpp +++ b/src/jsc/bindings/H2HeadersMaterializer.cpp @@ -6,7 +6,7 @@ // interned header-name strings so known header names allocate nothing. #include "root.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "helpers.h" #include #include 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..0c1c50fc06bf 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" @@ -53,7 +53,7 @@ #include "isBuiltinModule.h" #include "WebCoreJSBuiltins.h" -namespace Zig { +namespace Bun { using namespace JSC; using namespace WebCore; @@ -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 { - Zig::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(); - Zig::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); } @@ -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..d2a55aacb33e 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" @@ -16,7 +16,7 @@ extern "C" JSC::EncodedJSValue Bun__resolveSyncWithPaths(JSC::JSGlobalObject* gl extern "C" JSC::EncodedJSValue Bun__resolveSyncWithSource(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, BunString* from, bool is_esm, bool isUserRequireResolve); extern "C" JSC::EncodedJSValue Bun__resolveSyncWithStrings(JSC::JSGlobalObject* global, BunString* specifier, BunString* from, bool is_esm); -namespace Zig { +namespace Bun { using namespace JSC; using namespace WebCore; 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 4b6bf8862536..22e3836d6190 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 @@ -36,7 +36,7 @@ void Bun__LifecycleAgentReportReload(Inspector::InspectorLifecycleAgent* agent) agent->reportReload(); } -void Bun__LifecycleAgentReportError(Inspector::InspectorLifecycleAgent* agent, ZigException* exception) +void Bun__LifecycleAgentReportError(Inspector::InspectorLifecycleAgent* agent, BunException* exception) { ASSERT(exception); ASSERT(agent); @@ -97,7 +97,7 @@ void InspectorLifecycleAgent::reportReload() m_frontendDispatcher->reload(); } -void InspectorLifecycleAgent::reportError(ZigException& exception) +void InspectorLifecycleAgent::reportError(BunException& exception) { if (!m_enabled) return; @@ -114,7 +114,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 f10a8693c1d4..6a90402f32da 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 @@ -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/InternalForTesting.cpp b/src/jsc/bindings/InternalForTesting.cpp index 69121a0e5b28..0d184e45eb93 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 e16a2a98b6c1..734b472655d7 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/IsolatedModuleCache.cpp b/src/jsc/bindings/IsolatedModuleCache.cpp index a99c27b8dee5..76e3897ca3e4 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; @@ -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 bfe618a84cd4..cca203fa9d27 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&); @@ -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/JS2Native.cpp b/src/jsc/bindings/JS2Native.cpp index 93880c9af271..29045b4c517c 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" @@ -27,7 +27,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..3d332ad59937 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* 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; } } @@ -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,13 +300,13 @@ Structure* createJSBakeResponseStructure(JSC::VM& vm, Zig::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/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 31248929e024..a08ebdfd273a 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" @@ -705,7 +705,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); @@ -1484,7 +1484,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]] { @@ -2651,7 +2651,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..b097277f7e7a 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 globalObject->JSBufferList(); } -} // namespace Zig +} // namespace WebCore 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 b914573eed47..2688d19147b6 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); @@ -293,7 +293,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 8c87b28467d3..a1332ea37b41 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 @@ -592,7 +592,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/JSBundlerPlugin.h b/src/jsc/bindings/JSBundlerPlugin.h index 9ab506e4654c..2c96d6477efe 100644 --- a/src/jsc/bindings/JSBundlerPlugin.h +++ b/src/jsc/bindings/JSBundlerPlugin.h @@ -147,4 +147,4 @@ class BundlerPlugin final { bool tombstoned { false }; }; -} // namespace Zig +} // namespace Bun 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 e18cc0c15b55..261ba29c98de 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 @@ -67,7 +67,7 @@ #include #include -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include #include "JSCommonJSModule.h" #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); @@ -216,7 +216,7 @@ static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Zig::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)); } } @@ -232,7 +232,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()) { @@ -264,7 +264,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* @@ -338,7 +338,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()); } @@ -356,7 +356,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()); } @@ -418,7 +418,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; } @@ -725,12 +725,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, @@ -759,7 +759,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)); @@ -883,11 +883,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, @@ -929,7 +929,7 @@ JSCommonJSModule* JSCommonJSModule::create( } JSCommonJSModule* JSCommonJSModule::create( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, JSValue exportsObject, bool hasEvaluated, @@ -1170,7 +1170,7 @@ void JSCommonJSModule::setExportsObject(JSC::JSValue exportsObject) } Structure* createCommonJSModuleStructure( - Zig::GlobalObject* globalObject) + Bun::GlobalObject* globalObject) { return JSCommonJSModule::createStructure(globalObject); } @@ -1245,7 +1245,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); @@ -1266,7 +1266,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); @@ -1328,7 +1328,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); @@ -1363,7 +1363,7 @@ void RequireResolveFunctionPrototype::finishCreation(JSC::VM& vm) } void JSCommonJSModule::evaluate( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, ResolvedSource& source, bool isBuiltIn) @@ -1388,7 +1388,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()); @@ -1402,7 +1402,7 @@ void JSCommonJSModule::evaluate( } void JSCommonJSModule::evaluate( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, Ref&& sourceProvider, bool ignoreESModuleAnnotation) { @@ -1415,7 +1415,7 @@ void JSCommonJSModule::evaluate( } void JSCommonJSModule::evaluateWithPotentiallyOverriddenCompile( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const WTF::String& key, JSValue keyJSString, ResolvedSource& source) @@ -1464,7 +1464,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) @@ -1507,7 +1507,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()); } @@ -1524,7 +1524,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; @@ -1540,7 +1540,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); @@ -1582,7 +1582,7 @@ static JSC::SourceCode commonJSModuleSyntheticSourceCode(const SourceOrigin& sou } std::optional createCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* requireMapKey, Ref&& sourceProvider, bool ignoreESModuleAnnotation) @@ -1637,7 +1637,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..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; } @@ -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 395b4df3ff32..11818858b316 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" @@ -29,10 +29,10 @@ #include namespace WebCore { -using namespace Zig; +using namespace Bun; #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 098900c78a41..f5ded743f48d 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" @@ -56,7 +56,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); } @@ -162,7 +162,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); @@ -246,7 +246,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)) @@ -296,7 +296,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)) @@ -379,7 +379,7 @@ static ALWAYS_INLINE void syncWindowsEnv(SharedEnvStore* store, const String& ke // The store for the tree this global belongs to, or null if it's in none. The // context can be gone during teardown, when a surviving process.env is read. -static SharedEnvStore* sharedEnvStoreFor(Zig::GlobalObject* globalObject) +static SharedEnvStore* sharedEnvStoreFor(Bun::GlobalObject* globalObject) { auto* context = globalObject->scriptExecutionContext(); return context ? context->sharedEnvStore() : nullptr; @@ -390,7 +390,7 @@ static SharedEnvStore* sharedEnvStoreFor(Zig::GlobalObject* globalObject) // defaultGlobalObject(), which would silently retarget the thread's default tree. static SharedEnvStore* sharedEnvStoreFor(JSC::JSObject* object) { - auto* globalObject = dynamicDowncast(object->globalObject()); + auto* globalObject = dynamicDowncast(object->globalObject()); return globalObject ? sharedEnvStoreFor(globalObject) : nullptr; } @@ -668,14 +668,14 @@ bool JSSharedEnvMap::deletePropertyByIndex(JSCell* cell, JSGlobalObject* globalO return Base::deletePropertyByIndex(cell, globalObject, index); } -JSValue createSharedEnvironmentVariablesMap(Zig::GlobalObject* globalObject) +JSValue createSharedEnvironmentVariablesMap(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); auto* structure = JSSharedEnvMap::createStructure(vm, globalObject, globalObject->objectPrototype()); return JSSharedEnvMap::create(vm, structure); } -RefPtr ensureSharedEnvStoreForWorker(Zig::GlobalObject* globalObject) +RefPtr ensureSharedEnvStoreForWorker(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -743,7 +743,7 @@ RefPtr ensureSharedEnvStoreForWorker(Zig::GlobalObject* globalOb return store; } -JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject) +JSValue createEnvironmentVariablesMap(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -835,7 +835,7 @@ JSValue createEnvironmentVariablesMap(Zig::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/JSEnvironmentVariableMap.h b/src/jsc/bindings/JSEnvironmentVariableMap.h index 0c77d82ac27e..30d70d057cc4 100644 --- a/src/jsc/bindings/JSEnvironmentVariableMap.h +++ b/src/jsc/bindings/JSEnvironmentVariableMap.h @@ -1,7 +1,7 @@ #include "root.h" #include "SharedEnvStore.h" -namespace Zig { +namespace Bun { class GlobalObject; } @@ -11,16 +11,16 @@ class JSValue; namespace Bun { -JSC::JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject); +JSC::JSValue createEnvironmentVariablesMap(Bun::GlobalObject* globalObject); // worker_threads SHARE_ENV: a `process.env` whose reads/writes/enumeration go // through the SharedEnvStore of the tree its global belongs to. -JSC::JSValue createSharedEnvironmentVariablesMap(Zig::GlobalObject* globalObject); +JSC::JSValue createSharedEnvironmentVariablesMap(Bun::GlobalObject* globalObject); // Resolve the SHARE_ENV store for a worker spawned from `globalObject`: the // spawning thread's existing store if it has one, otherwise a fresh store seeded // from its `process.env` (which is then swapped to a write-through view). // Returns null if seeding threw. -RefPtr ensureSharedEnvStoreForWorker(Zig::GlobalObject* globalObject); +RefPtr ensureSharedEnvStoreForWorker(Bun::GlobalObject* globalObject); } diff --git a/src/jsc/bindings/JSFFIFunction.cpp b/src/jsc/bindings/JSFFIFunction.cpp index d5c2fd50dc3c..3d5de1b6e408 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,15 +78,15 @@ 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" 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(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, 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(Zig::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(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, 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(Zig::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) }; @@ -150,7 +150,7 @@ void JSFFIFunction::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(JSFFIFunction); -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, length, name); Structure* structure = globalObject->FFIFunctionStructure(); @@ -169,7 +169,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, length, name); @@ -182,12 +182,12 @@ JSFFIFunction* JSFFIFunction::createForFFI(VM& vm, Zig::GlobalObject* globalObje return function; } -} // namespace JSC +} // namespace Bun // Shared tail for the FFI_Callback_* entry points: call back into JS and leave any exception // pending on the VM, like any other host function. Never clear and re-throw here: re-installing // the TerminationException once the termination request is retired trips VM::setException. -static JSC::EncodedJSValue invokeFFICallback(Zig::GlobalObject* globalObject, JSC::JSFunction* function, JSC::MarkedArgumentBuffer& arguments) +static JSC::EncodedJSValue invokeFFICallback(Bun::GlobalObject* globalObject, JSC::JSFunction* function, JSC::MarkedArgumentBuffer& arguments) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -218,7 +218,7 @@ FFI_Callback_threadsafe_call(FFICallbackFunctionWrapper& wrapper, size_t argCoun // can only happen on the JS thread. On a dead/terminating context nothing is destroyed here. WebCore::ScriptExecutionContext::postTaskTo(wrapper.m_contextId, [&wrapper] { wrapper.ref(); }, [argsVec = WTF::move(argsVec), wrapper = &wrapper](WebCore::ScriptExecutionContext& ctx) mutable { auto protectedWrapper = adoptRef(*wrapper); - auto* globalObject = uncheckedDowncast(ctx.jsGlobalObject()); + auto* globalObject = uncheckedDowncast(ctx.jsGlobalObject()); JSC::MarkedArgumentBuffer arguments; for (size_t i = 0; i < argsVec.size(); ++i) arguments.appendWithCrashOnOverflow(JSC::JSValue::decode(argsVec[i])); diff --git a/src/jsc/bindings/JSFFIFunction.h b/src/jsc/bindings/JSFFIFunction.h index fde3e215adbf..0aeb9729073c 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; } @@ -16,7 +16,7 @@ namespace JSC { class JSGlobalObject; } -namespace Zig { +namespace Bun { using namespace JSC; @@ -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) { @@ -96,4 +96,4 @@ class JSFFIFunction final : public JSC::JSFunction { CFFIFunction m_function; }; -} // namespace JSC +} // namespace Bun diff --git a/src/jsc/bindings/JSMockFunction.cpp b/src/jsc/bindings/JSMockFunction.cpp index bbe197002249..10a5f3073ea0 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 @@ -234,7 +234,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); @@ -325,7 +325,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); @@ -510,7 +510,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)) { @@ -530,7 +530,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); @@ -639,19 +639,19 @@ static void forEachMockInSet(JSC::Strong& mockSet, const Functor& } } -extern "C" void JSMock__resetSpies(Zig::GlobalObject* globalObject) +extern "C" void JSMock__resetSpies(Bun::GlobalObject* globalObject) { forEachMockInSet(globalObject->mockModule.activeSpies, [](JSMockFunction* spy) { spy->clearSpy(); }); globalObject->mockModule.activeSpies.clear(); } -extern "C" void JSMock__clearAllMocks(Zig::GlobalObject* globalObject) +extern "C" void JSMock__clearAllMocks(Bun::GlobalObject* globalObject) { // mockClear() on every mock: only clears calls, contexts, instances and results. forEachMockInSet(globalObject->mockModule.activeMocks, [](JSMockFunction* mock) { mock->clear(); }); } -extern "C" void JSMock__resetAllMocks(Zig::GlobalObject* globalObject) +extern "C" void JSMock__resetAllMocks(Bun::GlobalObject* globalObject) { // mockReset() on every mock: drops the recorded calls *and* the implementations, // without restoring the original of a spy. @@ -670,7 +670,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(), @@ -712,7 +712,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 @@ -811,7 +811,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); @@ -823,7 +823,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); @@ -1110,7 +1110,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); @@ -1132,7 +1132,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); @@ -1331,7 +1331,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; } @@ -1353,7 +1353,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); @@ -1462,19 +1462,19 @@ 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()); } BUN_DEFINE_HOST_FUNCTION(JSMock__jsResetAllMocks, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { - JSMock__resetAllMocks(uncheckedDowncast(globalObject)); + JSMock__resetAllMocks(uncheckedDowncast(globalObject)); return JSValue::encode(jsUndefined()); } @@ -1483,7 +1483,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 {}; @@ -1607,7 +1607,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..5cb31ed84d86 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" @@ -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/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..7609142255c8 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" @@ -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/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 39a7e8904fae..6c274de3e630 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/JSSocketHandlers.cpp b/src/jsc/bindings/JSSocketHandlers.cpp index 8ac210105262..d117401efd64 100644 --- a/src/jsc/bindings/JSSocketHandlers.cpp +++ b/src/jsc/bindings/JSSocketHandlers.cpp @@ -2,7 +2,7 @@ #include "JavaScriptCore/JSCJSValueInlines.h" #include "JSSocketHandlers.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/JSStringDecoder.cpp b/src/jsc/bindings/JSStringDecoder.cpp index 7ba39e9249ea..cdda3d713030 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" @@ -498,7 +498,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)); } @@ -581,7 +581,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(); @@ -616,4 +616,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 WebCore diff --git a/src/jsc/bindings/JSWrappingFunction.cpp b/src/jsc/bindings/JSWrappingFunction.cpp index 57f53d111b23..5be55f0cf26b 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 @@ -12,16 +12,16 @@ #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) }; JS_EXPORT_PRIVATE JSWrappingFunction* JSWrappingFunction::create( VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, const BunString* symbolName, - Zig::NativeFunctionPtr functionPointer, + Bun::NativeFunctionPtr functionPointer, JSC::JSValue wrappedFnValue) { JSC::JSObject* wrappedFn = wrappedFnValue.getObject(); @@ -55,7 +55,7 @@ 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, JSC::EncodedJSValue wrappedFnEncoded) @@ -68,7 +68,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 18aa6d3aaeda..f2e3841d5858 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; } @@ -16,7 +16,7 @@ namespace JSC { class JSGlobalObject; } -namespace Zig { +namespace Bun { using NativeFunctionPtr = SYSV_ABI JSC::EncodedJSValue (*)(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame); @@ -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 c61470862f0e..6abe91bdd09f 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" @@ -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 {}; @@ -1205,8 +1205,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/JSX509Certificate.h b/src/jsc/bindings/JSX509Certificate.h index 8f7e566d2a33..6483528ec3ea 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 e1b18c475c6e..a6b80cbfe287 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 7c5ba80bb6a3..ea8ef13fe780 100644 --- a/src/jsc/bindings/ModuleLoader.cpp +++ b/src/jsc/bindings/ModuleLoader.cpp @@ -4,14 +4,14 @@ #include "JavaScriptCore/JSGlobalObject.h" #include "ModuleLoader.h" #include "JavaScriptCore/Identifier.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include #include #include -#include "ZigSourceProvider.h" +#include "BunSourceProvider.h" #include #include @@ -45,7 +45,6 @@ namespace Bun { using namespace JSC; -using namespace Zig; using namespace WebCore; class ResolvedSourceCodeHolder { @@ -130,7 +129,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 +198,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; @@ -297,7 +296,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::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)) { @@ -317,7 +316,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 +331,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, @@ -392,7 +391,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: { @@ -458,7 +457,7 @@ static JSValue handleVirtualModuleResult( } extern "C" void Bun__onFulfillAsyncModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::EncodedJSValue encodedPromiseValue, ErrorableResolvedSource* res, BunString* specifier, @@ -507,7 +506,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()); } @@ -517,7 +516,7 @@ extern "C" void Bun__onFulfillAsyncModule( } JSValue fetchBuiltinModuleWithoutResolution( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, ErrorableResolvedSource* res) { @@ -567,7 +566,7 @@ JSValue fetchBuiltinModuleWithoutResolution( } JSValue resolveAndFetchBuiltinModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier) { void* bunVM = globalObject->bunVM(); @@ -614,7 +613,7 @@ JSValue resolveAndFetchBuiltinModule( } void evaluateCommonJSCustomExtension( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSCommonJSModule* target, String filename, JSValue filenameValue, @@ -639,7 +638,7 @@ void evaluateCommonJSCustomExtension( } JSValue fetchCommonJSModule( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSCommonJSModule* target, JSValue specifierValue, String specifierWtfString, @@ -799,7 +798,7 @@ template JSValue fetchCommonJSModuleNonBuiltin( void* bunVM, JSC::VM& vm, - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, BunString* specifier, JSC::JSValue specifierValue, BunString* referrer, @@ -869,7 +868,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) @@ -893,7 +892,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 +905,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 +920,7 @@ extern "C" bool isBunTest; template static JSValue fetchESMSourceCode( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -1015,7 +1014,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 +1035,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 +1176,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()); } @@ -1185,7 +1184,7 @@ static JSValue fetchESMSourceCode( } JSValue fetchESMSourceCodeSync( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -1196,7 +1195,7 @@ JSValue fetchESMSourceCodeSync( } JSValue fetchESMSourceCodeAsync( - Zig::GlobalObject* globalObject, + Bun::GlobalObject* globalObject, JSC::JSString* specifierJS, ErrorableResolvedSource* res, BunString* specifier, @@ -1242,7 +1241,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 7b458aff7090..b7fdee893917 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) @@ -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); @@ -111,7 +111,7 @@ napi_status NapiClass::finishCreation(VM& vm, const String& name, napi_callback Base::finishCreation(vm); 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/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/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 d1af85114c28..532dfa680235 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); } @@ -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]] { if (!newTarget) { throwTypeError(globalObject, scope, "Class constructor Dirent cannot be invoked without 'new'"_s); return {}; @@ -196,7 +196,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]] { @@ -322,12 +322,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 05c7e88408a5..9de33ae1d8a1 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" @@ -501,7 +501,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, @@ -843,7 +843,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, @@ -866,7 +866,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, @@ -1163,7 +1163,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 fd006bcc3ad1..ff171b058240 100644 --- a/src/jsc/bindings/NodeVM.cpp +++ b/src/jsc/bindings/NodeVM.cpp @@ -287,8 +287,8 @@ JSPromise* importModule(JSGlobalObject* globalObject, JSString* moduleName, RefP if (isUseMainContextDefaultLoaderConstant(globalObject, dynamicImportCallback)) { auto defer = fetcher->temporarilyUseDefaultLoader(); - Zig::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; @@ -698,8 +698,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(); @@ -744,9 +744,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; } @@ -766,8 +766,8 @@ bool getContextArg(JSGlobalObject* globalObject, JSValue& contextArg) if (contextArg.isUndefined()) { contextArg = JSC::constructEmptyObject(globalObject); } else if (contextArg.isSymbol()) { - Zig::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; } @@ -779,8 +779,8 @@ bool getContextArg(JSGlobalObject* globalObject, JSValue& contextArg) bool isUseMainContextDefaultLoaderConstant(JSGlobalObject* globalObject, JSValue value) { if (value.isSymbol()) { - Zig::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; } } @@ -884,8 +884,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); - Zig::GlobalObject::promiseRejectionTracker(zigGlobalObject, promise, operation); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + Bun::GlobalObject::promiseRejectionTracker(bunGlobalObject, promise, operation); } const JSC::GlobalObjectMethodTable& NodeVMGlobalObject::globalObjectMethodTable() @@ -1625,10 +1625,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, {}); @@ -1637,7 +1637,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); @@ -1748,7 +1748,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); @@ -1809,7 +1809,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)); @@ -2038,8 +2038,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/NodeVM.h b/src/jsc/bindings/NodeVM.h index 590f3ce69451..04310bb60524 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 @@ -160,9 +160,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/NodeVMScript.cpp b/src/jsc/bindings/NodeVMScript.cpp index 90d1df51b524..58ebcfad1a51 100644 --- a/src/jsc/bindings/NodeVMScript.cpp +++ b/src/jsc/bindings/NodeVMScript.cpp @@ -112,9 +112,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 {}; @@ -613,10 +613,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 67b09a97e8a9..738f76778d27 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 42ef186a5069..7b80bc274db1 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/NodeValidator.cpp b/src/jsc/bindings/NodeValidator.cpp index 673c77b281af..8b9cbe55cdf5 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..2adabc3927b6 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 @@ -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, @@ -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); @@ -144,12 +144,12 @@ JSC::JSValue createNodePathBinding(Zig::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/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..a45d35dc2bfd 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,12 +492,12 @@ 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); - 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/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 edb8a94ba05e..23f04064cc3a 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,8 +135,8 @@ static JSC::JSValue toJS(JSC::VM& vm, JSC::JSGlobalObject* globalObject, DataCel return jsNull(); break; case DataCellTag::Raw: { - Zig::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: { - Zig::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/ScriptExecutionContext.cpp b/src/jsc/bindings/ScriptExecutionContext.cpp index d5ada4518581..db58c9d4ccb4 100644 --- a/src/jsc/bindings/ScriptExecutionContext.cpp +++ b/src/jsc/bindings/ScriptExecutionContext.cpp @@ -263,18 +263,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..02fdb3df2410 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); @@ -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; @@ -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); @@ -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/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/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/bindings.cpp b/src/jsc/bindings/bindings.cpp index e694c218f38b..a1a00c35ba71 100644 --- a/src/jsc/bindings/bindings.cpp +++ b/src/jsc/bindings/bindings.cpp @@ -79,7 +79,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" @@ -585,10 +585,10 @@ 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); + auto globalThis = static_cast(globalObject); if constexpr (!isInternal) { JSFunction* performPromiseThenFunction = globalObject->performPromiseThenFunction(); @@ -1554,7 +1554,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); @@ -1766,7 +1766,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) @@ -1830,7 +1830,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(); @@ -1848,7 +1848,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))); @@ -2055,8 +2055,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)); } @@ -2077,15 +2077,15 @@ 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)); } 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(); @@ -2095,16 +2095,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; @@ -2122,7 +2122,7 @@ void WebCore__FetchHeaders__remove(WebCore::FetchHeaders* headers, const ZigStri { 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) @@ -2137,7 +2137,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) @@ -2148,13 +2148,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) @@ -2208,7 +2208,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()) { @@ -2480,7 +2480,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); @@ -2488,14 +2488,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; @@ -2527,7 +2527,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); @@ -2535,14 +2535,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; @@ -2604,7 +2604,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; @@ -2671,7 +2671,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(); @@ -2685,7 +2685,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); @@ -2696,7 +2696,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); @@ -2705,7 +2705,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. @@ -2880,12 +2880,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)); } @@ -2908,7 +2908,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. } @@ -2981,11 +2981,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); } @@ -2998,11 +2998,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); } @@ -3023,14 +3023,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, {}); } } @@ -3264,7 +3264,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; { @@ -3312,7 +3312,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) @@ -3339,11 +3339,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))); } } @@ -3355,7 +3355,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) @@ -3381,7 +3381,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(); @@ -3391,10 +3391,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)))); } } @@ -3403,21 +3403,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) @@ -3427,12 +3427,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, @@ -3606,7 +3606,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); @@ -3791,7 +3791,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 @@ -3835,7 +3835,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) @@ -3875,7 +3875,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; } @@ -4153,7 +4153,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; @@ -4162,7 +4162,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); @@ -4409,7 +4409,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; } @@ -4419,7 +4419,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))); } @@ -4436,7 +4436,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; } @@ -4565,11 +4565,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) @@ -4599,7 +4599,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; } } @@ -4608,18 +4608,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; } @@ -5487,7 +5487,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), @@ -5533,7 +5533,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(); @@ -5541,7 +5541,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); @@ -5825,7 +5825,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 @@ -5841,7 +5841,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))); } @@ -5932,18 +5932,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( @@ -6092,17 +6092,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; } @@ -6237,11 +6237,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(); @@ -6253,7 +6253,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); @@ -6397,7 +6397,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..1aaf252da716 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 @@ -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_ @@ -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-handwritten.h b/src/jsc/bindings/headers-handwritten.h index e421d79b93f7..c9bbd5b34773 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 { inline constexpr uint32_t ResolvedSourceTagPackageJSONTypeModule = 1; typedef union ErrorableResolvedSourceResult { ResolvedSource value; - ZigErrorType err; + BunErrorType err; } ErrorableResolvedSourceResult; typedef struct ErrorableResolvedSource { ErrorableResolvedSourceResult result; @@ -165,19 +165,19 @@ inline constexpr BunPluginTarget BunPluginTargetBrowser = 1; inline constexpr BunPluginTarget BunPluginTargetNode = 2; inline constexpr BunPluginTarget BunPluginTargetMax = BunPluginTargetNode; -typedef uint8_t ZigStackFrameCode; -inline constexpr ZigStackFrameCode ZigStackFrameCodeNone = 0; -inline constexpr ZigStackFrameCode ZigStackFrameCodeEval = 1; -inline constexpr ZigStackFrameCode ZigStackFrameCodeModule = 2; -inline constexpr ZigStackFrameCode ZigStackFrameCodeFunction = 3; -inline constexpr ZigStackFrameCode ZigStackFrameCodeGlobal = 4; -inline constexpr ZigStackFrameCode ZigStackFrameCodeWasm = 5; -inline constexpr ZigStackFrameCode ZigStackFrameCodeConstructor = 6; +typedef uint8_t BunStackFrameCode; +inline constexpr BunStackFrameCode BunStackFrameCodeNone = 0; +inline constexpr BunStackFrameCode BunStackFrameCodeEval = 1; +inline constexpr BunStackFrameCode BunStackFrameCodeModule = 2; +inline constexpr BunStackFrameCode BunStackFrameCodeFunction = 3; +inline constexpr BunStackFrameCode BunStackFrameCodeGlobal = 4; +inline constexpr BunStackFrameCode BunStackFrameCodeWasm = 5; +inline constexpr 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; inline constexpr 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 750b3ac81d6b..085199539dc5 100644 --- a/src/jsc/bindings/headers.h +++ b/src/jsc/bindings/headers.h @@ -293,7 +293,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 @@ -429,19 +429,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 @@ -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 cb9bc987755c..1f60d09df77d 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; } @@ -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 e6f7f7844a99..a26033b721a1 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" @@ -78,7 +78,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 @@ -296,7 +296,7 @@ void Napi::NapiRefSelfDeletingWeakHandleOwner::finalize(JSC::HandleglobalObject(); + Bun::GlobalObject* globalObject = env->globalObject(); JSC::VM& vm = JSC::getVM(globalObject); void* dataPtr = property.data; @@ -625,7 +625,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); RefPtr arrayBuffer = ArrayBuffer::tryCreate(byte_length, 1); @@ -708,7 +708,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); @@ -793,7 +793,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 @@ -901,7 +901,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); @@ -936,7 +936,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); @@ -954,7 +954,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(); @@ -983,7 +983,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); @@ -994,7 +994,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); @@ -1154,7 +1154,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); @@ -1280,7 +1280,7 @@ extern "C" napi_status napi_detach_arraybuffer(napi_env env, NAPI_PREAMBLE_NO_PENDING_CHECK(env); NAPI_CHECK_ENV_NOT_IN_GC(env); NAPI_CHECK_ARG(env, arraybuffer); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSC::JSArrayBuffer* jsArrayBuffer = dynamicDowncast(toJS(arraybuffer)); @@ -1470,7 +1470,7 @@ node_api_create_external_string_latin1(napi_env env, NAPI_RETURN_EARLY_IF_FALSE(env, !env->hasPendingException(), napi_pending_exception); length = length == NAPI_AUTO_LENGTH ? strlen(str) : length; - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); if (copied) { *copied = false; @@ -1515,7 +1515,7 @@ node_api_create_external_string_utf16(napi_env env, NAPI_RETURN_EARLY_IF_FALSE(env, !env->hasPendingException(), napi_pending_exception); length = length == NAPI_AUTO_LENGTH ? std::char_traits::length(str) : length; - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); if (copied) { *copied = false; @@ -1621,7 +1621,7 @@ extern "C" JS_EXPORT napi_status node_api_set_prototype(napi_env env, NAPI_CHECK_ARG(env, value); NAPI_CHECK_ARG(env, object); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSObject* obj = toJS(object).getObject(); @@ -1653,7 +1653,7 @@ extern "C" JS_EXPORT napi_status node_api_create_object_with_properties(napi_env NAPI_CHECK_ARG(env, property_values); } - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); for (size_t i = 0; i < property_count; i++) { @@ -1704,7 +1704,7 @@ extern "C" JS_EXPORT napi_status node_api_create_sharedarraybuffer(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); JSC::VM& vm = JSC::getVM(globalObject); RefPtr arrayBuffer = ArrayBuffer::tryCreate(byte_length, 1); @@ -1763,7 +1763,7 @@ extern "C" JS_EXPORT napi_status node_api_create_external_sharedarraybuffer(napi NAPI_CHECK_ARG(env, result); 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); Ref destructor = adoptRef(*new NapiNoEnvExternalBufferDestructor(finalize_cb, finalize_hint)); @@ -1800,7 +1800,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); @@ -1815,7 +1815,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); @@ -1829,7 +1829,7 @@ extern "C" napi_status napi_get_global(napi_env env, napi_value* result) NAPI_PREAMBLE_NO_PENDING_CHECK(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); @@ -1868,7 +1868,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)); NAPI_RETURN_IF_EXCEPTION_WITH_SCOPE(env, scope); NAPI_CHECK_ARG(env, arraybuffer); @@ -1920,7 +1920,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, @@ -1966,7 +1966,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_CHECK_ARG(env, arraybuffer); NAPI_CHECK_ARG(env, result); JSValue arraybufferValue = toJS(arraybuffer); @@ -1999,7 +1999,7 @@ extern "C" napi_status napi_create_typedarray( NAPI_RETURN_SUCCESS(env); } -namespace Zig { +namespace Bun { // Walk the prototype chain collecting property names without touching JSC's // per-Structure own-keys cache. JSC::allPropertyKeys() stores the chain-walked @@ -2150,7 +2150,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) { @@ -2180,7 +2180,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); @@ -2200,7 +2200,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 @@ -2217,7 +2217,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 @@ -2234,7 +2234,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 @@ -2252,7 +2252,7 @@ extern "C" napi_status napi_get_property_names(napi_env env, napi_value object, NAPI_CHECK_ARG(env, object); NAPI_CHECK_ARG(env, result); JSValue jsValue = toJS(object); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); NAPI_CHECK_TO_OBJECT(env, globalObject, jsObject, jsValue); JSC::EnsureStillAliveScope ensureStillAlive(jsObject); @@ -2271,7 +2271,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. @@ -2328,7 +2328,7 @@ extern "C" napi_status napi_create_external_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); JSC::VM& vm = JSC::getVM(globalObject); auto* subclassStructure = globalObject->JSBufferSubclassStructure(); @@ -2373,7 +2373,7 @@ extern "C" napi_status napi_create_external_arraybuffer(napi_env env, void* exte NAPI_PREAMBLE(env); NAPI_CHECK_ARG(env, result); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); // Uses NapiExternalBufferDestructor instead of createSharedTask so that @@ -2504,7 +2504,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); @@ -2676,7 +2676,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())); @@ -2695,7 +2695,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(); @@ -2930,7 +2930,7 @@ extern "C" napi_status napi_run_script(napi_env env, napi_value script, napi_value* result) { NAPI_PREAMBLE_NO_THROW_SCOPE(env); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto& vm = JSC::getVM(globalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); NAPI_RETURN_IF_EXCEPTION_WITH_SCOPE(env, throwScope); @@ -2944,7 +2944,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) { @@ -3002,7 +3002,7 @@ extern "C" napi_status napi_create_bigint_words(napi_env env, napi_value* result) { NAPI_PREAMBLE_NO_THROW_SCOPE(env); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); auto& vm = env->vm(); auto scope = DECLARE_THROW_SCOPE(vm); NAPI_RETURN_IF_EXCEPTION_WITH_SCOPE(env, scope); @@ -3041,7 +3041,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); @@ -3079,7 +3079,7 @@ extern "C" napi_status napi_new_instance(napi_env env, napi_value constructor, // napi_invalid_arg (not napi_function_expected) for non-callables. NAPI_RETURN_EARLY_IF_FALSE(env, constructorValue.isCallable(), napi_invalid_arg); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSC::VM& vm = JSC::getVM(globalObject); JSC::CallData constructData = getConstructData(constructorValue); @@ -3112,7 +3112,7 @@ extern "C" napi_status napi_instanceof(napi_env env, napi_value object, napi_val NAPI_CHECK_ARG(env, constructor); - Zig::GlobalObject* globalObject = toJS(env); + Bun::GlobalObject* globalObject = toJS(env); JSValue objectValue = toJS(object); JSValue constructorValue = toJS(constructor); @@ -3154,7 +3154,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; @@ -3184,7 +3184,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); @@ -3204,7 +3204,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 27df4c1dab35..8cfec2802b97 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" @@ -177,7 +177,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)) @@ -185,7 +185,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)); } @@ -457,8 +457,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 @@ -468,7 +468,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; @@ -581,7 +581,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. @@ -679,11 +679,11 @@ 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); } -namespace Zig { +namespace Bun { using namespace JSC; static inline JSValue toJS(napi_value val) @@ -691,12 +691,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()) { @@ -1045,7 +1045,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_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/napi_handle_scope.cpp b/src/jsc/bindings/napi_handle_scope.cpp index 7c4be7ec19a6..f2fb9236c295 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 { @@ -92,7 +92,7 @@ void NapiHandleScopeImpl::releaseHandles() m_parent = nullptr; } -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 @@ -115,7 +115,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 @@ -132,7 +132,7 @@ void NapiHandleScope::close(Zig::GlobalObject* globalObject, NapiHandleScopeImpl current->releaseHandles(); } -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 97aecb854e41..5dfb43953116 100644 --- a/src/jsc/bindings/napi_handle_scope.h +++ b/src/jsc/bindings/napi_handle_scope.h @@ -76,19 +76,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 28c0c4144511..3cdaccd70275 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); @@ -150,7 +150,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)); @@ -204,7 +204,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; } @@ -256,7 +256,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; } @@ -365,7 +365,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 16b0375a8076..22fad3e58521 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 257ad7298487..6bbfe14d2f7f 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 f10295bbc8ad..c72f9de28c8a 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 be0386ac01be..9e377c2bdb0a 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/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/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/JSDiffieHellmanConstructor.cpp b/src/jsc/bindings/node/crypto/JSDiffieHellmanConstructor.cpp index acafc96f82d7..ddd2bc41162e 100644 --- a/src/jsc/bindings/node/crypto/JSDiffieHellmanConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSDiffieHellmanConstructor.cpp @@ -170,8 +170,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/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..d5ce73c0b3ca 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,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/JSECDH.cpp b/src/jsc/bindings/node/crypto/JSECDH.cpp index 5a2f16240073..d4ea6f5fd942 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/JSECDHConstructor.cpp b/src/jsc/bindings/node/crypto/JSECDHConstructor.cpp index 71024bd0dd97..33a923400848 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 16e421663a78..6b7ee6cdae09 100644 --- a/src/jsc/bindings/node/crypto/JSHash.cpp +++ b/src/jsc/bindings/node/crypto/JSHash.cpp @@ -304,12 +304,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 {}; @@ -336,7 +336,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(); } @@ -349,7 +349,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 c7e6b470787e..169e0798dc78 100644 --- a/src/jsc/bindings/node/crypto/JSHmac.cpp +++ b/src/jsc/bindings/node/crypto/JSHmac.cpp @@ -254,12 +254,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/JSKeyObject.cpp b/src/jsc/bindings/node/crypto/JSKeyObject.cpp index e74f45052a88..bbe0452d3853 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 23092dc03b14..1513845ddfdc 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 @@ -504,11 +504,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/node/crypto/JSVerify.cpp b/src/jsc/bindings/node/crypto/JSVerify.cpp index c2cd28bb120c..e4bebf165054 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 5939598cf527..7d243eec15cc 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" @@ -19,7 +19,6 @@ namespace Bun { -using namespace Bun; using namespace JSC; using namespace ncrypto; using namespace WebCore; 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/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/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 3e118500e5a6..9f9731c3fd07 100644 --- a/src/jsc/bindings/sqlite/JSSQLStatement.cpp +++ b/src/jsc/bindings/sqlite/JSSQLStatement.cpp @@ -1676,7 +1676,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(); @@ -1943,7 +1943,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); @@ -2922,7 +2922,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 4ab770f33d4a..4cfbeb710ecd 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); @@ -125,7 +125,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 80f740bbcc50..ee082d3cbdc5 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 784c93e77bce..4e8560a3cd84 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; // Padding so that m_roots is at Internals::kIsolateRootsOffset (688 on 64-bit: 16 bytes of // fields above plus 84 words). V8 14.x inserted kIsolateJSDispatchTableOffset 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 1bf00a097ce4..fc75142ad6d4 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); HandleScope hs(isolate); @@ -107,7 +107,7 @@ JSC::EncodedJSValue FunctionTemplate::functionCall(JSC::JSGlobalObject* globalOb // GetIsolate() reads this slot as a raw, untagged pointer slot(Info::kIsolateIndex) = TaggedPointer::fromRaw(reinterpret_cast(isolate)); slot(Info::kReturnValueIndex) = TaggedPointer(); - // Context is always a reinterpret pointer to Zig::GlobalObject + // Context is always a reinterpret pointer to Bun::GlobalObject slot(Info::kContextIndex) = TaggedPointer::fromRaw(reinterpret_cast(globalObject)); // target holds the Function being called, which contains the FunctionTemplate slot(Info::kTargetIndex) = target.tagged(); 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 2387e6d7f6a6..846125764897 100644 --- a/src/jsc/bindings/v8/shim/GlobalInternals.h +++ b/src/jsc/bindings/v8/shim/GlobalInternals.h @@ -19,7 +19,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) { @@ -91,7 +91,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; @@ -108,7 +108,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 a41aeebac944..cce72cb032d7 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 bf2a7239d15f..91272e355552 100644 --- a/src/jsc/bindings/webcore/DOMIsoSubspaces.h +++ b/src/jsc/bindings/webcore/DOMIsoSubspaces.h @@ -953,7 +953,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..bbed71333b9f 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" @@ -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 {}; @@ -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..610f1f93a46b 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" @@ -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/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/JSStructuredSerializeOptions.cpp b/src/jsc/bindings/webcore/JSStructuredSerializeOptions.cpp index a01a846fc216..5bf110d90fc7 100644 --- a/src/jsc/bindings/webcore/JSStructuredSerializeOptions.cpp +++ b/src/jsc/bindings/webcore/JSStructuredSerializeOptions.cpp @@ -25,7 +25,7 @@ #include "ErrorCode.h" #include "JSDOMExceptionHandling.h" #include "JSDOMException.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "JSDOMConvertSequences.h" #include #include diff --git a/src/jsc/bindings/webcore/JSWebSocket.cpp b/src/jsc/bindings/webcore/JSWebSocket.cpp index b4b497f20b53..0d21369e0cad 100644 --- a/src/jsc/bindings/webcore/JSWebSocket.cpp +++ b/src/jsc/bindings/webcore/JSWebSocket.cpp @@ -205,7 +205,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); @@ -1043,7 +1043,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 a59c83b8c29b..29a43f54ed93 100644 --- a/src/jsc/bindings/webcore/MessagePort.cpp +++ b/src/jsc/bindings/webcore/MessagePort.cpp @@ -39,7 +39,7 @@ #include "WebCoreOpaqueRoot.h" #include -extern "C" void Bun__Process__emitWarning(Zig::GlobalObject*, JSC::EncodedJSValue warning, JSC::EncodedJSValue type, JSC::EncodedJSValue code, JSC::EncodedJSValue ctor); +extern "C" void Bun__Process__emitWarning(Bun::GlobalObject*, JSC::EncodedJSValue warning, JSC::EncodedJSValue type, JSC::EncodedJSValue code, JSC::EncodedJSValue ctor); extern "C" void Bun__eventLoop__incrementRefConcurrently(void* bunVM, int delta); @@ -171,7 +171,7 @@ void MessagePort::flushQueuedMessagesBeforeClose() auto* globalObject = defaultGlobalObject(context->globalObject()); // Only deliver while JS can run; during teardown the queue is left for // m_pipe->close() to drop (it unwinds nested port chains iteratively). - if (Zig::GlobalObject::scriptExecutionStatus(globalObject, globalObject) != ScriptExecutionStatus::Running) + if (Bun::GlobalObject::scriptExecutionStatus(globalObject, globalObject) != ScriptExecutionStatus::Running) return; // Cap iterations like drainAndDispatch() so a 'message' handler re-injecting @@ -264,7 +264,7 @@ void MessagePort::dispatchCloseEvent() auto* globalObject = defaultGlobalObject(context->globalObject()); // Bypass the m_isDetached guard in MessagePort::dispatchEvent — the deferred // close task runs after m_isDetached is set. - if (Zig::GlobalObject::scriptExecutionStatus(globalObject, globalObject) == ScriptExecutionStatus::Running) + if (Bun::GlobalObject::scriptExecutionStatus(globalObject, globalObject) == ScriptExecutionStatus::Running) EventTarget::dispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No)); } @@ -353,7 +353,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/SerializedScriptValue.cpp b/src/jsc/bindings/webcore/SerializedScriptValue.cpp index 97b92658c7ad..9eb11dac7aa8 100644 --- a/src/jsc/bindings/webcore/SerializedScriptValue.cpp +++ b/src/jsc/bindings/webcore/SerializedScriptValue.cpp @@ -108,7 +108,7 @@ #include #include -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "blob.h" #include "ZigGeneratedClasses.h" #include "JSX509Certificate.h" @@ -2812,7 +2812,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) // like a plain object from JS's perspective (matches Node.js). // ObjectPrototype is allowed because %Object.prototype% is an immutable // prototype exotic object that the spec carves out of this rejection. - if (inObject->classInfo() != JSFinalObject::info() && inObject->classInfo() != Zig::NapiPrototype::info() && inObject->classInfo() != JSC::ObjectPrototype::info()) + if (inObject->classInfo() != JSFinalObject::info() && inObject->classInfo() != Bun::NapiPrototype::info() && inObject->classInfo() != JSC::ObjectPrototype::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 d3afe63e0b90..8be53aa9c3e7 100644 --- a/src/jsc/bindings/webcore/WebSocket.cpp +++ b/src/jsc/bindings/webcore/WebSocket.cpp @@ -894,14 +894,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; } @@ -1000,14 +1000,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(); @@ -1512,7 +1512,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; @@ -1922,7 +1922,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/bindings/webcore/Worker.cpp b/src/jsc/bindings/webcore/Worker.cpp index 142bd56baf62..4f413d1c09fe 100644 --- a/src/jsc/bindings/webcore/Worker.cpp +++ b/src/jsc/bindings/webcore/Worker.cpp @@ -279,7 +279,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; @@ -332,7 +332,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); @@ -446,7 +446,7 @@ void Worker::rejectAllCrossVMRequests(JSC::JSGlobalObject* globalObject) // ---- 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 @@ -494,7 +494,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); @@ -528,7 +528,7 @@ void Worker::dispatchErrorWithMessage(WTF::String message) }); } -bool Worker::dispatchErrorWithValue(Zig::GlobalObject* workerGlobalObject, JSValue value) +bool Worker::dispatchErrorWithValue(Bun::GlobalObject* workerGlobalObject, JSValue value) { // This is the top of the stack for the worker's error dispatch: both the // structured clone below (even in NonThrowing mode, serialization can run @@ -639,7 +639,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(); @@ -667,7 +667,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 @@ -688,7 +688,7 @@ extern "C" void WebWorker__dispatchExit(Worker* worker, int32_t exitCode) // loading. Called from spin() on EVERY post-evaluation path (including entry // throw / TLA reject / TLA unsettled) so a buffered postMessageToThread never // leaves its sender's Atomics.waitAsync unresolved. -extern "C" void WebWorker__entrySettled(Zig::GlobalObject* globalObject) +extern "C" void WebWorker__entrySettled(Bun::GlobalObject* globalObject) { auto* hook = globalObject->nodeWorkerEntryEvaluatedHook(); if (!hook) @@ -708,18 +708,18 @@ extern "C" void WebWorker__entrySettled(Zig::GlobalObject* globalObject) CLEAR_IF_EXCEPTION(scope); } -extern "C" void WebWorker__dispatchOnline(Worker* worker, Zig::GlobalObject* globalObject) +extern "C" void WebWorker__dispatchOnline(Worker* worker, Bun::GlobalObject* globalObject) { WebWorker__entrySettled(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(); @@ -820,7 +820,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionSetEntryEvaluatedHook, (JSC::JSGlobalObject * return JSC::JSValue::encode(jsUndefined()); } -JSValue createNodeWorkerThreadsBinding(Zig::GlobalObject* globalObject) +JSValue createNodeWorkerThreadsBinding(Bun::GlobalObject* globalObject) { VM& vm = globalObject->vm(); @@ -899,7 +899,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 657597d84ec5..a0154a741a3c 100644 --- a/src/jsc/bindings/webcore/Worker.h +++ b/src/jsc/bindings/webcore/Worker.h @@ -130,10 +130,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. @@ -208,7 +208,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/webcore/streams/BunAsyncIterableSource.cpp b/src/jsc/bindings/webcore/streams/BunAsyncIterableSource.cpp index b1ad57ae63ff..694390899a9b 100644 --- a/src/jsc/bindings/webcore/streams/BunAsyncIterableSource.cpp +++ b/src/jsc/bindings/webcore/streams/BunAsyncIterableSource.cpp @@ -15,7 +15,7 @@ #include "WebCoreJSClientData.h" #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -544,7 +544,7 @@ JSReadableStream* readableStreamFromAsyncIterator(JSGlobalObject* globalObject, auto& vm = getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); auto* runtime = JSStreamsRuntime::from(globalObject); - auto* zigGlobalObject = defaultGlobalObject(globalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); auto& names = WebCore::builtinNames(vm); JSValue target = jsUndefined(); @@ -571,7 +571,7 @@ JSReadableStream* readableStreamFromAsyncIterator(JSGlobalObject* globalObject, return nullptr; } - auto* op = JSAsyncIteratorSourceOperation::create(vm, runtime->asyncIteratorSourceOperationStructure(zigGlobalObject)); + auto* op = JSAsyncIteratorSourceOperation::create(vm, runtime->asyncIteratorSourceOperationStructure(bunGlobalObject)); op->m_iterator.set(vm, op, iterator); auto* source = constructEmptyObject(globalObject); @@ -586,7 +586,7 @@ JSReadableStream* readableStreamFromAsyncIterator(JSGlobalObject* globalObject, RETURN_IF_EXCEPTION(scope, nullptr); source->putDirect(vm, names.closePublicName(), closeFunction, 0); - auto* stream = JSReadableStream::create(vm, WebCore::getDOMStructure(vm, *zigGlobalObject)); + auto* stream = JSReadableStream::create(vm, WebCore::getDOMStructure(vm, *bunGlobalObject)); initializeReadableStream(stream); stream->m_bunMode = WebCore::BunStreamMode::DirectPending; stream->m_directUnderlyingSource.set(vm, stream, source); diff --git a/src/jsc/bindings/webcore/streams/BunStreamConsumers.cpp b/src/jsc/bindings/webcore/streams/BunStreamConsumers.cpp index c84c2c32f0d7..5420f8cd7bbb 100644 --- a/src/jsc/bindings/webcore/streams/BunStreamConsumers.cpp +++ b/src/jsc/bindings/webcore/streams/BunStreamConsumers.cpp @@ -20,7 +20,7 @@ #include "JSStreamsRuntime.h" #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/BunStreamSource.cpp b/src/jsc/bindings/webcore/streams/BunStreamSource.cpp index aec8e66f7638..dee2b6535523 100644 --- a/src/jsc/bindings/webcore/streams/BunStreamSource.cpp +++ b/src/jsc/bindings/webcore/streams/BunStreamSource.cpp @@ -20,7 +20,7 @@ #include "JSStreamsRuntime.h" #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSByteLengthQueuingStrategy.cpp b/src/jsc/bindings/webcore/streams/JSByteLengthQueuingStrategy.cpp index 7a2af0ac784e..f7ee8bb73922 100644 --- a/src/jsc/bindings/webcore/streams/JSByteLengthQueuingStrategy.cpp +++ b/src/jsc/bindings/webcore/streams/JSByteLengthQueuingStrategy.cpp @@ -10,7 +10,7 @@ #include "WebCoreJSClientData.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSCountQueuingStrategy.cpp b/src/jsc/bindings/webcore/streams/JSCountQueuingStrategy.cpp index 24ed41cafed6..b19760c796f8 100644 --- a/src/jsc/bindings/webcore/streams/JSCountQueuingStrategy.cpp +++ b/src/jsc/bindings/webcore/streams/JSCountQueuingStrategy.cpp @@ -10,7 +10,7 @@ #include "WebCoreJSClientData.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSDirectStreamController.cpp b/src/jsc/bindings/webcore/streams/JSDirectStreamController.cpp index ecc1738463f6..c8ac00e0da44 100644 --- a/src/jsc/bindings/webcore/streams/JSDirectStreamController.cpp +++ b/src/jsc/bindings/webcore/streams/JSDirectStreamController.cpp @@ -13,7 +13,7 @@ #include "WebCoreJSClientData.h" #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -946,9 +946,9 @@ void setUpDirectStreamController(JSC::JSGlobalObject* globalObject, JSReadableSt auto& vm = getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); - auto* zigGlobalObject = defaultGlobalObject(globalObject); + auto* bunGlobalObject = defaultGlobalObject(globalObject); auto* runtime = JSStreamsRuntime::from(globalObject); - auto* controller = JSDirectStreamController::create(vm, runtime->directStreamControllerStructure(zigGlobalObject), sinkKind); + auto* controller = JSDirectStreamController::create(vm, runtime->directStreamControllerStructure(bunGlobalObject), sinkKind); controller->m_stream.set(vm, controller, stream); if (JSObject* underlyingSource = stream->m_directUnderlyingSource.get()) { controller->m_underlyingSource.set(vm, controller, underlyingSource); @@ -960,7 +960,7 @@ void setUpDirectStreamController(JSC::JSGlobalObject* globalObject, JSReadableSt switch (sinkKind) { case DirectSinkKind::ArrayBuffer: { - JSObject* sinkConstructor = zigGlobalObject->ArrayBufferSink(); + JSObject* sinkConstructor = bunGlobalObject->ArrayBufferSink(); auto constructData = JSC::getConstructData(sinkConstructor); MarkedArgumentBuffer constructArgs; JSObject* sink = JSC::construct(globalObject, sinkConstructor, constructData, constructArgs); diff --git a/src/jsc/bindings/webcore/streams/JSReadableByteStreamController.cpp b/src/jsc/bindings/webcore/streams/JSReadableByteStreamController.cpp index 20c346e55826..b670daeec625 100644 --- a/src/jsc/bindings/webcore/streams/JSReadableByteStreamController.cpp +++ b/src/jsc/bindings/webcore/streams/JSReadableByteStreamController.cpp @@ -16,7 +16,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -435,8 +435,8 @@ void JSReadableByteStreamController::pullSteps(JSGlobalObject* globalObject, JSR auto* error = JSC::createOutOfMemoryError(globalObject); RELEASE_AND_RETURN(scope, readRequest->errorSteps(globalObject, error)); } - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSPullIntoDescriptor* pullIntoDescriptor = JSPullIntoDescriptor::create(vm, JSStreamsRuntime::from(globalObject)->pullIntoDescriptorStructure(zigGlobalObject)); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSPullIntoDescriptor* pullIntoDescriptor = JSPullIntoDescriptor::create(vm, JSStreamsRuntime::from(globalObject)->pullIntoDescriptorStructure(bunGlobalObject)); RETURN_IF_EXCEPTION(scope, void()); pullIntoDescriptor->m_buffer = WTF::move(buffer); pullIntoDescriptor->m_bufferByteLength = static_cast(m_autoAllocateChunkSize); @@ -956,8 +956,8 @@ JSReadableStreamBYOBRequest* readableByteStreamControllerGetBYOBRequest(JSGlobal const size_t bytesFilled = firstDescriptor->m_bytesFilled; JSArrayBufferView* view = constructViewOfType(globalObject, JSC::TypeUint8, firstDescriptor->m_buffer, firstDescriptor->m_byteOffset + bytesFilled, firstDescriptor->m_byteLength - bytesFilled); RETURN_IF_EXCEPTION(scope, nullptr); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSReadableStreamBYOBRequest* byobRequest = JSReadableStreamBYOBRequest::create(vm, getDOMStructure(vm, *zigGlobalObject)); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSReadableStreamBYOBRequest* byobRequest = JSReadableStreamBYOBRequest::create(vm, getDOMStructure(vm, *bunGlobalObject)); byobRequest->m_controller.set(vm, byobRequest, controller); byobRequest->m_view.set(vm, byobRequest, view); controller->m_byobRequest.set(vm, controller, byobRequest); @@ -1060,8 +1060,8 @@ void readableByteStreamControllerPullInto(JSGlobalObject* globalObject, JSReadab } if (!transferAbruptCompletion.isEmpty()) [[unlikely]] RELEASE_AND_RETURN(scope, readIntoRequest->errorSteps(globalObject, transferAbruptCompletion)); - auto* zigGlobalObject = defaultGlobalObject(globalObject); - JSPullIntoDescriptor* pullIntoDescriptor = JSPullIntoDescriptor::create(vm, JSStreamsRuntime::from(globalObject)->pullIntoDescriptorStructure(zigGlobalObject)); + auto* bunGlobalObject = defaultGlobalObject(globalObject); + JSPullIntoDescriptor* pullIntoDescriptor = JSPullIntoDescriptor::create(vm, JSStreamsRuntime::from(globalObject)->pullIntoDescriptorStructure(bunGlobalObject)); pullIntoDescriptor->m_bufferByteLength = buffer->byteLength(); pullIntoDescriptor->m_buffer = WTF::move(buffer); pullIntoDescriptor->m_byteOffset = byteOffset; diff --git a/src/jsc/bindings/webcore/streams/JSReadableStream.cpp b/src/jsc/bindings/webcore/streams/JSReadableStream.cpp index 5d2ad3da3e8e..493ed605eea7 100644 --- a/src/jsc/bindings/webcore/streams/JSReadableStream.cpp +++ b/src/jsc/bindings/webcore/streams/JSReadableStream.cpp @@ -20,7 +20,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSReadableStreamAsyncIterator.cpp b/src/jsc/bindings/webcore/streams/JSReadableStreamAsyncIterator.cpp index 1f5b26254201..9ca144fb645c 100644 --- a/src/jsc/bindings/webcore/streams/JSReadableStreamAsyncIterator.cpp +++ b/src/jsc/bindings/webcore/streams/JSReadableStreamAsyncIterator.cpp @@ -14,7 +14,7 @@ #include "WebCoreJSClientData.h" #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBReader.cpp b/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBReader.cpp index 8ca7f2367647..6a2476b57133 100644 --- a/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBReader.cpp +++ b/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBReader.cpp @@ -19,7 +19,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBRequest.cpp b/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBRequest.cpp index 27894c2fd2c0..4bff74ca2d02 100644 --- a/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBRequest.cpp +++ b/src/jsc/bindings/webcore/streams/JSReadableStreamBYOBRequest.cpp @@ -15,7 +15,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSReadableStreamDefaultReader.cpp b/src/jsc/bindings/webcore/streams/JSReadableStreamDefaultReader.cpp index f69e4ce9a099..d8f55e4f0a93 100644 --- a/src/jsc/bindings/webcore/streams/JSReadableStreamDefaultReader.cpp +++ b/src/jsc/bindings/webcore/streams/JSReadableStreamDefaultReader.cpp @@ -20,7 +20,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSStreamPipeToOperation.cpp b/src/jsc/bindings/webcore/streams/JSStreamPipeToOperation.cpp index 7e00776d198c..b201a66c26bf 100644 --- a/src/jsc/bindings/webcore/streams/JSStreamPipeToOperation.cpp +++ b/src/jsc/bindings/webcore/streams/JSStreamPipeToOperation.cpp @@ -16,7 +16,7 @@ #include "JSWritableStreamDefaultWriter.h" #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSStreamsRuntime.cpp b/src/jsc/bindings/webcore/streams/JSStreamsRuntime.cpp index 4664d701a77d..5ad8ff9e82d8 100644 --- a/src/jsc/bindings/webcore/streams/JSStreamsRuntime.cpp +++ b/src/jsc/bindings/webcore/streams/JSStreamsRuntime.cpp @@ -22,7 +22,7 @@ #include "JSStreamTeeState.h" #include "WebCoreJSClientData.h" #include "WebStreamsHeapAnalyzer.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -45,7 +45,7 @@ Structure* JSStreamsRuntime::createStructure(VM& vm, JSGlobalObject* globalObjec return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); } -JSStreamsRuntime* JSStreamsRuntime::create(VM& vm, Zig::GlobalObject* globalObject) +JSStreamsRuntime* JSStreamsRuntime::create(VM& vm, Bun::GlobalObject* globalObject) { auto* structure = createStructure(vm, globalObject, jsNull()); auto* cell = new (NotNull, allocateCell(vm)) JSStreamsRuntime(vm, structure); @@ -68,7 +68,7 @@ GCClient::IsoSubspace* JSStreamsRuntime::subspaceForImpl(VM& vm) [](auto& spaces, auto&& space) { spaces.m_subspaceForStreamsRuntime = std::forward(space); }); } -void JSStreamsRuntime::finishCreation(VM& vm, Zig::GlobalObject*) +void JSStreamsRuntime::finishCreation(VM& vm, Bun::GlobalObject*) { Base::finishCreation(vm); ASSERT(inherits(info())); @@ -215,25 +215,25 @@ void JSStreamsRuntime::armEndOfTickFlush(JSGlobalObject* globalObject, JSDirectS Bun__EventLoop__postDeferredTask(bunVM(globalObject), this, &Bun__StreamsRuntime__endOfTickFlush); } -JSFunction* JSStreamsRuntime::byteLengthQueuingStrategySizeFunction(const Zig::GlobalObject*) +JSFunction* JSStreamsRuntime::byteLengthQueuingStrategySizeFunction(const Bun::GlobalObject*) { return m_byteLengthQueuingStrategySizeFunction.get(this); } -JSFunction* JSStreamsRuntime::countQueuingStrategySizeFunction(const Zig::GlobalObject*) +JSFunction* JSStreamsRuntime::countQueuingStrategySizeFunction(const Bun::GlobalObject*) { return m_countQueuingStrategySizeFunction.get(this); } #define WEB_STREAMS_DEFINE_STRUCTURE_ACCESSOR(memberName, ClassName) \ - Structure* JSStreamsRuntime::memberName(const Zig::GlobalObject*) \ + Structure* JSStreamsRuntime::memberName(const Bun::GlobalObject*) \ { \ return m_##memberName.get(this); \ } FOR_EACH_WEB_STREAMS_INTERNAL_STRUCTURE(WEB_STREAMS_DEFINE_STRUCTURE_ACCESSOR) #undef WEB_STREAMS_DEFINE_STRUCTURE_ACCESSOR -Structure* JSStreamsRuntime::readManyResultStructure(const Zig::GlobalObject*) +Structure* JSStreamsRuntime::readManyResultStructure(const Bun::GlobalObject*) { return m_readManyResultStructure.get(this); } diff --git a/src/jsc/bindings/webcore/streams/JSStreamsRuntime.h b/src/jsc/bindings/webcore/streams/JSStreamsRuntime.h index c89bc2535dfe..5e00915fc6b9 100644 --- a/src/jsc/bindings/webcore/streams/JSStreamsRuntime.h +++ b/src/jsc/bindings/webcore/streams/JSStreamsRuntime.h @@ -1,8 +1,8 @@ // JSStreamsRuntime — the ONE per-global cell holding every piece of per-global Web Streams // state: the two CLOSED handler-function lists, the per-realm queuing-strategy `size` // functions, and the cached Structures of every internal (prototype-less) cell class. It is -// reached through ONE LazyProperty on Zig::GlobalObject (`globalObject->streamsRuntime()`); -// do NOT add per-function fields to ZigGlobalObject. Every handler / size function / +// reached through ONE LazyProperty on Bun::GlobalObject (`globalObject->streamsRuntime()`); +// do NOT add per-function fields to BunGlobalObject. Every handler / size function / // Structure is a LazyProperty materialized on first use via `m_NAME.get(this)`. // // THE TWO CALLABLE MECHANISMS — the ONLY two. Anything else (a per-stream JSFunction, ANY @@ -337,12 +337,12 @@ class JSStreamsRuntime final : public JSC::JSNonFinalObject { static constexpr unsigned StructureFlags = Base::StructureFlags; static constexpr JSC::DestructionMode needsDestruction = JSC::DoesNotNeedDestruction; - // Zig::GlobalObject holds ONE LazyProperty whose initializer calls this. - static JSStreamsRuntime* create(JSC::VM&, Zig::GlobalObject*); + // Bun::GlobalObject holds ONE LazyProperty whose initializer calls this. + static JSStreamsRuntime* create(JSC::VM&, Bun::GlobalObject*); static JSC::Structure* createStructure(JSC::VM&, JSC::JSGlobalObject*, JSC::JSValue prototype); // The one accessor everything uses: `defaultGlobalObject(global)->streamsRuntime()` - // behind a free function so streams .cpp files do not include ZigGlobalObject.h. + // behind a free function so streams .cpp files do not include BunGlobalObject.h. static JSStreamsRuntime* from(JSC::JSGlobalObject*); // End-of-tick flush service for JS-facing direct controllers: the runtime (a @@ -378,22 +378,22 @@ class JSStreamsRuntime final : public JSC::JSNonFinalObject { // The per-realm queuing-strategy size functions (spec: same function object per realm; // %ByteLengthQueuingStrategy%.prototype.size / %CountQueuingStrategy%.prototype.size). - JSC::JSFunction* byteLengthQueuingStrategySizeFunction(const Zig::GlobalObject*); - JSC::JSFunction* countQueuingStrategySizeFunction(const Zig::GlobalObject*); + JSC::JSFunction* byteLengthQueuingStrategySizeFunction(const Bun::GlobalObject*); + JSC::JSFunction* countQueuingStrategySizeFunction(const Bun::GlobalObject*); // The cached Structures of the internal cells. #define WEB_STREAMS_DECLARE_STRUCTURE_ACCESSOR(memberName, ClassName) \ - JSC::Structure* memberName(const Zig::GlobalObject*); + JSC::Structure* memberName(const Bun::GlobalObject*); FOR_EACH_WEB_STREAMS_INTERNAL_STRUCTURE(WEB_STREAMS_DECLARE_STRUCTURE_ACCESSOR) #undef WEB_STREAMS_DECLARE_STRUCTURE_ACCESSOR // The readMany `{value, size, done}` result shape, so results are built with // putDirectOffset instead of three transitioning putDirects. - JSC::Structure* readManyResultStructure(const Zig::GlobalObject*); + JSC::Structure* readManyResultStructure(const Bun::GlobalObject*); private: JSStreamsRuntime(JSC::VM&, JSC::Structure*); - void finishCreation(JSC::VM&, Zig::GlobalObject*); + void finishCreation(JSC::VM&, Bun::GlobalObject*); #define WEB_STREAMS_DECLARE_HANDLER_MEMBER(name) \ JSC::LazyProperty m_##name; diff --git a/src/jsc/bindings/webcore/streams/JSTextDecoderStream.cpp b/src/jsc/bindings/webcore/streams/JSTextDecoderStream.cpp index 9f6e640e39d3..b9b18dd0ec18 100644 --- a/src/jsc/bindings/webcore/streams/JSTextDecoderStream.cpp +++ b/src/jsc/bindings/webcore/streams/JSTextDecoderStream.cpp @@ -15,7 +15,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSTextEncoderStream.cpp b/src/jsc/bindings/webcore/streams/JSTextEncoderStream.cpp index 60346492a548..069c42c34edb 100644 --- a/src/jsc/bindings/webcore/streams/JSTextEncoderStream.cpp +++ b/src/jsc/bindings/webcore/streams/JSTextEncoderStream.cpp @@ -15,7 +15,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSTransformStream.cpp b/src/jsc/bindings/webcore/streams/JSTransformStream.cpp index b54538631b4c..27afc1508778 100644 --- a/src/jsc/bindings/webcore/streams/JSTransformStream.cpp +++ b/src/jsc/bindings/webcore/streams/JSTransformStream.cpp @@ -16,7 +16,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSWritableStream.cpp b/src/jsc/bindings/webcore/streams/JSWritableStream.cpp index f060f25d6b99..ad618dd857d4 100644 --- a/src/jsc/bindings/webcore/streams/JSWritableStream.cpp +++ b/src/jsc/bindings/webcore/streams/JSWritableStream.cpp @@ -15,7 +15,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/JSWritableStreamDefaultWriter.cpp b/src/jsc/bindings/webcore/streams/JSWritableStreamDefaultWriter.cpp index 32ef0fd1669a..5551d99f2e65 100644 --- a/src/jsc/bindings/webcore/streams/JSWritableStreamDefaultWriter.cpp +++ b/src/jsc/bindings/webcore/streams/JSWritableStreamDefaultWriter.cpp @@ -17,7 +17,7 @@ #include "WebStreamsHeapAnalyzer.h" #include "WebStreamsInspectCustom.h" #include "WebStreamsInternals.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/ReadableStreamOperations.cpp b/src/jsc/bindings/webcore/streams/ReadableStreamOperations.cpp index 96ef04355654..073ac49a4a62 100644 --- a/src/jsc/bindings/webcore/streams/ReadableStreamOperations.cpp +++ b/src/jsc/bindings/webcore/streams/ReadableStreamOperations.cpp @@ -22,7 +22,7 @@ #include "JSStreamsRuntime.h" #include "JSWritableStream.h" #include "JSWritableStreamDefaultWriter.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include diff --git a/src/jsc/bindings/webcore/streams/StreamsForward.h b/src/jsc/bindings/webcore/streams/StreamsForward.h index 633e7a7aa059..2b35e6eadcac 100644 --- a/src/jsc/bindings/webcore/streams/StreamsForward.h +++ b/src/jsc/bindings/webcore/streams/StreamsForward.h @@ -26,7 +26,7 @@ class Structure; class InternalFieldTuple; } -namespace Zig { +namespace Bun { class GlobalObject; } @@ -34,8 +34,8 @@ namespace WebCore { class AbortSignal; // NOTE: JSDOMGlobalObject is deliberately NOT forward-declared here. In Bun it is not a -// class but a type alias (`using JSDOMGlobalObject = Zig::GlobalObject;` in -// ZigGlobalObject.h), so `class JSDOMGlobalObject;` is a typedef-redefinition error. +// class but a type alias (`using JSDOMGlobalObject = Bun::GlobalObject;` in +// BunGlobalObject.h), so `class JSDOMGlobalObject;` is a typedef-redefinition error. // Any header that names it must `#include "JSDOMGlobalObject.h"` (they all already do). // The public (globalThis-exposed) classes. diff --git a/src/jsc/bindings/webcore/streams/TransformStreamOperations.cpp b/src/jsc/bindings/webcore/streams/TransformStreamOperations.cpp index c3e1b45e5939..13fb39e597cc 100644 --- a/src/jsc/bindings/webcore/streams/TransformStreamOperations.cpp +++ b/src/jsc/bindings/webcore/streams/TransformStreamOperations.cpp @@ -13,7 +13,7 @@ #include "JSTransformStreamDefaultController.h" #include "JSWritableStream.h" #include "JSWritableStreamDefaultController.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/WebStreamsExports.cpp b/src/jsc/bindings/webcore/streams/WebStreamsExports.cpp index b9fe8315aeac..401e4c46dee3 100644 --- a/src/jsc/bindings/webcore/streams/WebStreamsExports.cpp +++ b/src/jsc/bindings/webcore/streams/WebStreamsExports.cpp @@ -9,7 +9,7 @@ #include "JSReadableStream.h" #include "WebCoreJSBuiltins.h" #include "ZigGeneratedClasses.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include @@ -28,7 +28,7 @@ using namespace JSC; using WebCore::JSReadableStream; // Shared brand check of every consumer entry point; throws ERR_INVALID_ARG_TYPE. -static JSReadableStream* toReadableStream(Zig::GlobalObject* globalObject, ThrowScope& scope, EncodedJSValue encodedStream) +static JSReadableStream* toReadableStream(Bun::GlobalObject* globalObject, ThrowScope& scope, EncodedJSValue encodedStream) { JSValue streamValue = JSValue::decode(encodedStream); auto* stream = dynamicDowncast(streamValue); @@ -44,7 +44,7 @@ using namespace JSC; using namespace WebCore; using namespace Bun::WebStreams; -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) { *ptr = nullptr; JSValue value = JSValue::decode(*possibleReadableStream); @@ -91,7 +91,7 @@ extern "C" int32_t ReadableStreamTag__tagged(Zig::GlobalObject* globalObject, JS return 0; } -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* stream = dynamicDowncast(JSValue::decode(possibleReadableStream)); if (!stream) [[unlikely]] @@ -112,19 +112,19 @@ extern "C" bool ReadableStream__is(JSC::EncodedJSValue value) return !!dynamicDowncast(JSValue::decode(value)); } -extern "C" bool ReadableStream__isDisturbed(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*) +extern "C" bool ReadableStream__isDisturbed(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*) { auto* stream = dynamicDowncast(JSValue::decode(possibleReadableStream)); return stream && stream->m_disturbed; } -extern "C" bool ReadableStream__isLocked(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*) +extern "C" bool ReadableStream__isLocked(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*) { auto* stream = dynamicDowncast(JSValue::decode(possibleReadableStream)); return stream && isReadableStreamLocked(stream); } -extern "C" void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject) +extern "C" void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject) { auto* stream = dynamicDowncast(JSValue::decode(possibleReadableStream)); if (!stream) [[unlikely]] @@ -151,7 +151,7 @@ extern "C" void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStrea markPromiseAsHandled(vm, result); } -extern "C" void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject, JSC::EncodedJSValue reason) +extern "C" void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject, JSC::EncodedJSValue reason) { auto* stream = dynamicDowncast(JSValue::decode(possibleReadableStream)); if (!stream) [[unlikely]] @@ -168,7 +168,7 @@ extern "C" void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleRea markPromiseAsHandled(vm, result); } -extern "C" void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject* globalObject) +extern "C" void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject* globalObject) { auto* stream = dynamicDowncast(JSValue::decode(possibleReadableStream)); if (!stream) [[unlikely]] @@ -178,7 +178,7 @@ extern "C" void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStrea stream->m_disturbed = true; } -extern "C" JSC::EncodedJSValue ReadableStream__empty(Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue ReadableStream__empty(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -189,7 +189,7 @@ extern "C" JSC::EncodedJSValue ReadableStream__empty(Zig::GlobalObject* globalOb return JSValue::encode(stream); } -extern "C" JSC::EncodedJSValue ReadableStream__used(Zig::GlobalObject* globalObject) +extern "C" JSC::EncodedJSValue ReadableStream__used(Bun::GlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -200,7 +200,7 @@ extern "C" JSC::EncodedJSValue ReadableStream__used(Zig::GlobalObject* globalObj return JSValue::encode(stream); } -extern "C" JSC::EncodedJSValue ReadableStream__errored(Zig::GlobalObject* globalObject, JSC::EncodedJSValue reason) +extern "C" JSC::EncodedJSValue ReadableStream__errored(Bun::GlobalObject* globalObject, JSC::EncodedJSValue reason) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -211,7 +211,7 @@ extern "C" JSC::EncodedJSValue ReadableStream__errored(Zig::GlobalObject* global return JSValue::encode(stream); } -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); @@ -224,7 +224,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__createNativeReadableStream(Zig:: return JSValue::encode(stream); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToArrayBuffer(Bun::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -233,7 +233,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig: RELEASE_AND_RETURN(scope, JSValue::encode(readableStreamToArrayBuffer(globalObject, stream))); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBytes(Zig::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToBytes(Bun::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -242,7 +242,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBytes(Zig::Globa RELEASE_AND_RETURN(scope, JSValue::encode(readableStreamToBytes(globalObject, stream))); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToText(Zig::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToText(Bun::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -251,7 +251,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToText(Zig::Global RELEASE_AND_RETURN(scope, JSValue::encode(readableStreamToText(globalObject, stream))); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToJSON(Zig::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToJSON(Bun::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -260,7 +260,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToJSON(Zig::Global RELEASE_AND_RETURN(scope, JSValue::encode(readableStreamToJSON(globalObject, stream))); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBlob(Zig::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToBlob(Bun::GlobalObject* globalObject, JSC::EncodedJSValue streamValue) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -269,7 +269,7 @@ extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToBlob(Zig::Global RELEASE_AND_RETURN(scope, JSValue::encode(readableStreamToBlob(globalObject, stream))); } -extern "C" JSC::EncodedJSValue ZigGlobalObject__readableStreamToFormData(Zig::GlobalObject* globalObject, JSC::EncodedJSValue streamValue, JSC::EncodedJSValue contentType) +extern "C" JSC::EncodedJSValue BunGlobalObject__readableStreamToFormData(Bun::GlobalObject* globalObject, JSC::EncodedJSValue streamValue, JSC::EncodedJSValue contentType) { auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/src/jsc/bindings/webcore/streams/WebStreamsInspectCustom.cpp b/src/jsc/bindings/webcore/streams/WebStreamsInspectCustom.cpp index a253a35afa8a..d6ec2118d451 100644 --- a/src/jsc/bindings/webcore/streams/WebStreamsInspectCustom.cpp +++ b/src/jsc/bindings/webcore/streams/WebStreamsInspectCustom.cpp @@ -2,7 +2,7 @@ #include "WebStreamsInspectCustom.h" #include "BunClientData.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include diff --git a/src/jsc/bindings/webcore/streams/WebStreamsInternals.h b/src/jsc/bindings/webcore/streams/WebStreamsInternals.h index cd988120cef4..f59d0355351b 100644 --- a/src/jsc/bindings/webcore/streams/WebStreamsInternals.h +++ b/src/jsc/bindings/webcore/streams/WebStreamsInternals.h @@ -576,27 +576,27 @@ extern "C" { // THE tag protocol. Writes the out-params; the async-iterator arm may REPLACE // *possibleReadableStream with a newly-built DirectPending stream. userJS: yes. -int32_t ReadableStreamTag__tagged(Zig::GlobalObject*, JSC::EncodedJSValue* possibleReadableStream, void** ptr); +int32_t ReadableStreamTag__tagged(Bun::GlobalObject*, JSC::EncodedJSValue* possibleReadableStream, void** ptr); // The ReadableStream__* set. -bool ReadableStream__tee(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*, JSC::EncodedJSValue* possibleReadableStream1, JSC::EncodedJSValue* possibleReadableStream2); // userJS: yes -bool ReadableStream__isDisturbed(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*); // userJS: no -bool ReadableStream__isLocked(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*); // userJS: no +bool ReadableStream__tee(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*, JSC::EncodedJSValue* possibleReadableStream1, JSC::EncodedJSValue* possibleReadableStream2); // userJS: yes +bool ReadableStream__isDisturbed(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*); // userJS: no +bool ReadableStream__isLocked(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*); // userJS: no // no-op unless the reader slot holds a REAL reader (the direct/native lock is a no-op here). -void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*); // userJS: yes +void ReadableStream__cancel(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*); // userJS: yes // NO sentinel guard (reachable on a NativeSink-controlled stream). -void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*, JSC::EncodedJSValue reason); // userJS: yes -void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStream, Zig::GlobalObject*); // userJS: no -JSC::EncodedJSValue ReadableStream__empty(Zig::GlobalObject*); // userJS: no -JSC::EncodedJSValue ReadableStream__used(Zig::GlobalObject*); // userJS: no -JSC::EncodedJSValue ReadableStream__errored(Zig::GlobalObject*, JSC::EncodedJSValue reason); // userJS: no -JSC::EncodedJSValue ZigGlobalObject__createNativeReadableStream(Zig::GlobalObject*, JSC::EncodedJSValue nativePtr); // userJS: no -JSC::EncodedJSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes -JSC::EncodedJSValue ZigGlobalObject__readableStreamToBytes(Zig::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes -JSC::EncodedJSValue ZigGlobalObject__readableStreamToText(Zig::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes -JSC::EncodedJSValue ZigGlobalObject__readableStreamToJSON(Zig::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes -JSC::EncodedJSValue ZigGlobalObject__readableStreamToBlob(Zig::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes -JSC::EncodedJSValue ZigGlobalObject__readableStreamToFormData(Zig::GlobalObject*, JSC::EncodedJSValue stream, JSC::EncodedJSValue contentType); // userJS: yes +void ReadableStream__cancelWithReason(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*, JSC::EncodedJSValue reason); // userJS: yes +void ReadableStream__detach(JSC::EncodedJSValue possibleReadableStream, Bun::GlobalObject*); // userJS: no +JSC::EncodedJSValue ReadableStream__empty(Bun::GlobalObject*); // userJS: no +JSC::EncodedJSValue ReadableStream__used(Bun::GlobalObject*); // userJS: no +JSC::EncodedJSValue ReadableStream__errored(Bun::GlobalObject*, JSC::EncodedJSValue reason); // userJS: no +JSC::EncodedJSValue BunGlobalObject__createNativeReadableStream(Bun::GlobalObject*, JSC::EncodedJSValue nativePtr); // userJS: no +JSC::EncodedJSValue BunGlobalObject__readableStreamToArrayBuffer(Bun::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes +JSC::EncodedJSValue BunGlobalObject__readableStreamToBytes(Bun::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes +JSC::EncodedJSValue BunGlobalObject__readableStreamToText(Bun::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes +JSC::EncodedJSValue BunGlobalObject__readableStreamToJSON(Bun::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes +JSC::EncodedJSValue BunGlobalObject__readableStreamToBlob(Bun::GlobalObject*, JSC::EncodedJSValue stream); // userJS: yes +JSC::EncodedJSValue BunGlobalObject__readableStreamToFormData(Bun::GlobalObject*, JSC::EncodedJSValue stream, JSC::EncodedJSValue contentType); // userJS: yes // Caller: ResumableSink.rs; returns encoded undefined. JSC::EncodedJSValue Bun__assignStreamIntoResumableSink(JSC::JSGlobalObject*, JSC::EncodedJSValue stream, JSC::EncodedJSValue sink); // userJS: yes diff --git a/src/jsc/bindings/webcore/streams/WritableStreamOperations.cpp b/src/jsc/bindings/webcore/streams/WritableStreamOperations.cpp index 27f4e9cabc98..14d969f55039 100644 --- a/src/jsc/bindings/webcore/streams/WritableStreamOperations.cpp +++ b/src/jsc/bindings/webcore/streams/WritableStreamOperations.cpp @@ -10,7 +10,7 @@ #include "JSWritableStreamDefaultController.h" #include "JSWritableStreamDefaultWriter.h" #include "StreamQueue.h" -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include #include #include 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/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 85c8c8df5f3c..7bca9a3555d7 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`. //! @@ -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,17 +107,11 @@ 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) + +/// `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)] @@ -129,7 +129,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)] @@ -174,7 +174,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 { @@ -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::zig_error_type::ZigErrorType; -pub use self::zig_stack_frame_code::ZigStackFrameCode; -pub use self::zig_stack_frame_position::ZigStackFramePosition; #[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 = "ZigException.rs"] -pub mod zig_exception; -#[path = "ZigStackFrame.rs"] -pub mod zig_stack_frame; -#[path = "ZigStackTrace.rs"] -pub mod zig_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. @@ -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`. @@ -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::zig_stack_frame::ZigStackFrame; -pub use self::zig_stack_trace::ZigStackTrace; 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; @@ -1984,7 +1984,7 @@ where } // ────────────────────────────────────────────────────────────────────────── -// BuildMessage / ResolveMessage / ZigException::Holder / JsClass. +// BuildMessage / ResolveMessage / BunException::Holder / JsClass. // ────────────────────────────────────────────────────────────────────────── #[path = "BuildMessage.rs"] pub mod build_message; @@ -1994,7 +1994,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 0f97df6ddc82..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, @@ -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(); @@ -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 e4c82f4e5e86..97b60a2a063a 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; @@ -12,12 +12,12 @@ 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); RETURN_NATIVE_MODULE(); } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/BunJSCModule.h b/src/jsc/modules/BunJSCModule.h index deb683bb80d7..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); @@ -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)); @@ -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 b5c5c84b6701..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, @@ -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(); @@ -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 c679ae05d490..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; @@ -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); @@ -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 1749ab1b64f4..2f3e91e3fa21 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,9 @@ 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) + // 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 @@ -622,13 +623,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(); } @@ -647,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) @@ -701,7 +702,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 +814,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 +945,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()); @@ -1004,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)); @@ -1040,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)); @@ -1050,26 +1051,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 +1079,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 +1088,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 +1097,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 +1116,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; @@ -1137,20 +1138,17 @@ extern "C" bool Bun__streamIterEnabled(); // $cpp("NodeModuleModule.cpp", "createStreamIterEnabledFlag"): the write-once // `--experimental-stream-iter` CLI bit, so builtins don't have to consult the // user-mutable `process.execArgv`. -JSC::JSValue createStreamIterEnabledFlag(Zig::GlobalObject*) +JSC::JSValue createStreamIterEnabledFlag(Bun::GlobalObject*) { return JSC::jsBoolean(Bun__streamIterEnabled()); } -} // namespace Bun - -namespace Zig { void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, 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); @@ -1186,4 +1184,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 64a261e66dd8..d1893038eceb 100644 --- a/src/jsc/modules/NodeModuleModule.h +++ b/src/jsc/modules/NodeModuleModule.h @@ -13,13 +13,13 @@ #include #include -using namespace Zig; +using namespace Bun; using namespace JSC; namespace Bun { JSC_DECLARE_HOST_FUNCTION(jsFunctionIsModuleResolveFilenameSlowPathEnabled); -JSC::JSValue createStreamIterEnabledFlag(Zig::GlobalObject*); -void addNodeModuleConstructorProperties(JSC::VM &vm, Zig::GlobalObject *globalObject); +JSC::JSValue createStreamIterEnabledFlag(Bun::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); @@ -32,14 +32,10 @@ struct PathResolveModule { }; JSC::JSValue resolveLookupPaths(JSC::JSGlobalObject* globalObject, String request, PathResolveModule parent); -} - -namespace Zig { - void generateNativeModule_NodeModule( JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey, Vector &exportNames, JSC::MarkedArgumentBuffer &exportValues); -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeProcessModule.h b/src/jsc/modules/NodeProcessModule.h index 80ac581d48c2..37b2d8834818 100644 --- a/src/jsc/modules/NodeProcessModule.h +++ b/src/jsc/modules/NodeProcessModule.h @@ -1,10 +1,10 @@ -#include "ZigGlobalObject.h" +#include "BunGlobalObject.h" #include "_NativeModule.h" #include #include #include "BunProcess.h" -namespace Zig { +namespace Bun { DEFINE_NATIVE_MODULE(NodeProcess) { @@ -45,4 +45,4 @@ DEFINE_NATIVE_MODULE(NodeProcess) } } -} // namespace Zig +} // namespace Bun diff --git a/src/jsc/modules/NodeStringDecoderModule.h b/src/jsc/modules/NodeStringDecoderModule.h index d4ffdc85a3e5..4e5820756ba1 100644 --- a/src/jsc/modules/NodeStringDecoderModule.h +++ b/src/jsc/modules/NodeStringDecoderModule.h @@ -1,8 +1,8 @@ #include "../bindings/JSStringDecoder.h" -#include "../bindings/ZigGlobalObject.h" +#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 442e1e4f7a9d..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) @@ -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, @@ -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 9e4807a8c4d9..8eacccb24c40 100644 --- a/src/jsc/modules/ObjectModule.h +++ b/src/jsc/modules/ObjectModule.h @@ -1,9 +1,9 @@ #pragma once -#include "../bindings/ZigGlobalObject.h" +#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 82beb9692e08..07ed0dd84230 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); \ @@ -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/jsc/virtual_machine_exports.rs b/src/jsc/virtual_machine_exports.rs index 89258ef3d574..c595ea67805e 100644 --- a/src/jsc/virtual_machine_exports.rs +++ b/src/jsc/virtual_machine_exports.rs @@ -12,7 +12,7 @@ use bun_event_loop::ManagedTask::ManagedTask; use bun_sourcemap::SourceProviderMap; use bun_sourcemap::parsed_source_map::AnySourceProvider; -// `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 @@ -215,7 +215,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/web_worker.rs b/src/jsc/web_worker.rs index e94c6266d17b..0173acdccd82 100644 --- a/src/jsc/web_worker.rs +++ b/src/jsc/web_worker.rs @@ -738,7 +738,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/api/BunObject.rs b/src/runtime/api/BunObject.rs index c592c826915e..ff27baeeb917 100644 --- a/src/runtime/api/BunObject.rs +++ b/src/runtime/api/BunObject.rs @@ -736,7 +736,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/BakeGlobalObject.cpp b/src/runtime/bake/BakeGlobalObject.cpp index 140c32c5600d..dc2ddbf48cd5 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.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/BakeSourceProvider.h b/src/runtime/bake/BakeSourceProvider.h index 0da0fcaa8282..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 29cd4b272be1..173b32aec50e 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,9 +26,9 @@ 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* bunGlobalObject = uncheckedDowncast<::Bun::GlobalObject>(globalObject); auto specifier = Bun::toString(provider->sourceURL()); - provider->m_bunVM = zigGlobalObject->bunVM(); + provider->m_bunVM = bunGlobalObject->bunVM(); provider->m_specifier = specifier; Bun__addDevServerSourceProvider(provider->m_bunVM, provider.ptr(), &specifier); return provider; @@ -68,7 +68,7 @@ class DevServerSourceProvider final : public JSC::StringSourceProvider { MiString m_sourceMapJSON; // The Rust VirtualMachine, captured at creation. Not the GC-allocated - // Zig::GlobalObject: this destructor runs from JSC sweep, by which point + // Bun::GlobalObject: this destructor runs from JSC sweep, by which point // the global object cell may already have been swept. void* m_bunVM { nullptr }; BunString m_specifier; diff --git a/src/runtime/bake/dev_server/error_report_request.rs b/src/runtime/bake/dev_server/error_report_request.rs index 43aaed631675..d133fd5a1e0a 100644 --- a/src/runtime/bake/dev_server/error_report_request.rs +++ b/src/runtime/bake/dev_server/error_report_request.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, + BunException, BunStackFrame, BunStackFrameCode, BunStackFramePosition, BunStackTrace, + JSErrorCode, JSRuntimeType, }; use bun_paths::path_buffer_pool; use bun_uws::{self as uws, AnyResponse, Request}; @@ -119,22 +119,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 @@ -144,13 +144,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, @@ -174,7 +174,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 @@ -226,7 +226,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; } @@ -235,7 +235,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, @@ -270,7 +270,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; } } } @@ -299,12 +299,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), @@ -318,7 +318,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`); @@ -326,7 +326,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/cli/repl_command.rs b/src/runtime/cli/repl_command.rs index faf25548c8fd..b79db22b59ba 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/FFIObject.rs b/src/runtime/ffi/FFIObject.rs index 01d678418cea..8048f1d8d12a 100644 --- a/src/runtime/ffi/FFIObject.rs +++ b/src/runtime/ffi/FFIObject.rs @@ -56,7 +56,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); @@ -93,7 +93,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", @@ -144,7 +144,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)] = &[ ( @@ -411,7 +411,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/ffi/mod.rs b/src/runtime/ffi/mod.rs index 5b23b53c7747..a1136aa7bcbe 100644 --- a/src/runtime/ffi/mod.rs +++ b/src/runtime/ffi/mod.rs @@ -58,7 +58,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 dd343b1a658c..ab98e0f79786 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` @@ -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::{BunStackFrame, CallFrame, JSGlobalObject, JSInternalPromise, JSValue}; // ─── 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 @@ -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 8c8cf9ae1c20..52e50b47208e 100644 --- a/src/runtime/jsc_hooks.rs +++ b/src/runtime/jsc_hooks.rs @@ -3041,7 +3041,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 @@ -3536,7 +3536,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, @@ -4757,7 +4757,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 43a8b24f750a..43409a3bcb83 100644 --- a/src/runtime/server/RequestContext.rs +++ b/src/runtime/server/RequestContext.rs @@ -536,7 +536,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/tls_socket_functions.rs b/src/runtime/socket/tls_socket_functions.rs index 3cad8ade2d8d..7cf01bff585a 100644 --- a/src/runtime/socket/tls_socket_functions.rs +++ b/src/runtime/socket/tls_socket_functions.rs @@ -1399,7 +1399,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/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/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/timer/mod.rs b/src/runtime/timer/mod.rs index b6926a22e19a..a7d40383345f 100644 --- a/src/runtime/timer/mod.rs +++ b/src/runtime/timer/mod.rs @@ -1150,7 +1150,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 4a17e701fc50..cb96a49d4bf8 100644 --- a/src/runtime/webcore/FileSink.rs +++ b/src/runtime/webcore/FileSink.rs @@ -1484,7 +1484,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 b130fb9dc77c..913c6e10636a 100644 --- a/src/runtime/webcore/ReadableStream.rs +++ b/src/runtime/webcore/ReadableStream.rs @@ -117,7 +117,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; @@ -309,7 +309,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/wasm_streaming.rs b/src/runtime/webcore/wasm_streaming.rs index 839d1aa19356..72a8c9f1af39 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`). @@ -161,7 +161,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 16a82f9e7514..edba1949eb64 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* bunGlobal, const WTF::String& userDataDir, const WTF::String& path, const WTF::Vector& extraArgv, bool stdoutInherit, bool stderrInherit) { @@ -305,7 +305,7 @@ bool Transport::ensureSpawned(Zig::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(Zig::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(Zig::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(Zig::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(Zig::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; @@ -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/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 d897048f0365..b22de3bac7e5 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" @@ -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/JSWebViewConstructor.cpp b/src/runtime/webview/JSWebViewConstructor.cpp index 64111d5431d8..30e6de940bdf 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 @@ -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(), 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 eeb408562f0a..3443e3d1ef05 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* bunGlobal, bool stdoutInherit, bool stderrInherit) { if (sock && !dead) return true; @@ -142,12 +142,12 @@ bool HostClient::ensureSpawned(Zig::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 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/src/sourcemap/lib.rs b/src/sourcemap/lib.rs index bd4f20bfd85f..8ce70b81e304 100644 --- a/src/sourcemap/lib.rs +++ b/src/sourcemap/lib.rs @@ -368,7 +368,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` @@ -379,12 +379,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/bake/dev/server-sourcemap.test.ts b/test/bake/dev/server-sourcemap.test.ts index 2d217df091ea..4c43907aff03 100644 --- a/test/bake/dev/server-sourcemap.test.ts +++ b/test/bake/dev/server-sourcemap.test.ts @@ -202,7 +202,7 @@ devTest("server-side source maps stay correct across repeated reloads", { timeoutMultiplier: 2, }); -// ~DevServerSourceProvider ran after the Zig::GlobalObject cell was swept. +// ~DevServerSourceProvider ran after the Bun::GlobalObject cell was swept. // BUN_DESTRUCT_VM_ON_EXIT=1 triggers that teardown; Malloc=1 puts JSC cells // under system malloc so ASAN poisons the freed cell and the UAF is deterministic. if (isASAN) { diff --git a/test/js/bun/util/reportError.test.ts b/test/js/bun/util/reportError.test.ts index 3075af55f04f..cf6d5a4a6821 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.rs // NameFormatter.format -> "{f}" on bun.String) Object.defineProperty(thrower, "name", { value: "FN_PRE\uD800FN_POST" }); thrower(); 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 {} } diff --git a/test/leaksan.supp b/test/leaksan.supp index 95ddaf7e864a..83f0b0548fa6 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 @@ -24,8 +24,8 @@ leak:CRYPTO_set_thread_local leak:BIO_new leak:_tlv_get_addr leak:Bun::generateModule -leak:Zig::ImportMetaObject::createFromSpecifier -leak:Zig::GlobalObject::moduleLoaderResolve +leak:Bun::ImportMetaObject::createFromSpecifier +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 @@ -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 @@ -94,11 +94,11 @@ 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: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 334b94e568ce..c0639422288f 100644 --- a/test/no-validate-leaksan.txt +++ b/test/no-validate-leaksan.txt @@ -273,7 +273,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 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 ba6f6fc362f4..afd82e550502 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