diff --git a/src/Global.zig b/src/Global.zig index d56b5fc269..16882e0cae 100644 --- a/src/Global.zig +++ b/src/Global.zig @@ -101,11 +101,6 @@ pub fn runExitCallbacks() void { on_exit_callbacks.items.len = 0; } -/// Flushes stdout and stderr and exits with the given code. -pub fn exit(code: u8) noreturn { - exitWide(@as(u32, code)); -} - var is_exiting = std.atomic.Value(bool).init(false); export fn bun_is_exiting() c_int { return @intFromBool(isExiting()); @@ -114,7 +109,8 @@ pub fn isExiting() bool { return is_exiting.load(.monotonic); } -pub fn exitWide(code: u32) noreturn { +/// Flushes stdout and stderr (in exit/quick_exit callback) and exits with the given code. +pub fn exit(code: u32) noreturn { is_exiting.store(true, .monotonic); if (comptime Environment.isMac) { diff --git a/src/bun.js/api/js_brotli.zig b/src/bun.js/api/js_brotli.zig index 925579d26e..92eeb8a496 100644 --- a/src/bun.js/api/js_brotli.zig +++ b/src/bun.js/api/js_brotli.zig @@ -272,6 +272,9 @@ pub const BrotliEncoder = struct { { this.input_lock.lock(); defer this.input_lock.unlock(); + + // need to protect because no longer on the stack. unprotected in FreeList.deinit + input_to_queue.protect(); this.input.writeItem(input_to_queue) catch bun.outOfMemory(); } JSC.WorkPool.schedule(&task.task); @@ -314,6 +317,8 @@ pub const BrotliEncoder = struct { this.input_lock.lock(); defer this.input_lock.unlock(); + // need to protect because no longer on the stack. unprotected in FreeList.deinit + input_to_queue.protect(); this.input.writeItem(input_to_queue) catch bun.outOfMemory(); } task.run(); @@ -489,6 +494,8 @@ pub const BrotliDecoder = struct { this.input_lock.lock(); defer this.input_lock.unlock(); + // need to protect because no longer on the stack. unprotected in FreeList.deinit + input_to_queue.protect(); this.input.writeItem(input_to_queue) catch bun.outOfMemory(); } JSC.WorkPool.schedule(&task.task); @@ -531,6 +538,8 @@ pub const BrotliDecoder = struct { this.input_lock.lock(); defer this.input_lock.unlock(); + // need to protect because no longer on the stack. unprotected in FreeList.deinit + input_to_queue.protect(); this.input.writeItem(input_to_queue) catch bun.outOfMemory(); } task.run(); diff --git a/src/bun.js/javascript_core_c_api.zig b/src/bun.js/javascript_core_c_api.zig index b4faa3f722..e900e54af8 100644 --- a/src/bun.js/javascript_core_c_api.zig +++ b/src/bun.js/javascript_core_c_api.zig @@ -173,101 +173,4 @@ pub extern fn JSRemoteInspectorSetLogToSystemConsole(enabled: bool) void; pub extern fn JSRemoteInspectorGetInspectionEnabledByDefault(void) bool; pub extern fn JSRemoteInspectorSetInspectionEnabledByDefault(enabled: bool) void; -// -- Manual -- - -const size_t = usize; - -pub const CellType = enum(u8) { - pub const LastMaybeFalsyCellPrimitive = 2; - pub const LastJSCObjectType = 73; - - CellType = 0, - StringType = 1, - HeapBigIntType = 2, - - SymbolType = 3, - GetterSetterType = 4, - CustomGetterSetterType = 5, - APIValueWrapperType = 6, - NativeExecutableType = 7, - ProgramExecutableType = 8, - ModuleProgramExecutableType = 9, - EvalExecutableType = 10, - FunctionExecutableType = 11, - UnlinkedFunctionExecutableType = 12, - UnlinkedProgramCodeBlockType = 13, - UnlinkedModuleProgramCodeBlockType = 14, - UnlinkedEvalCodeBlockType = 15, - UnlinkedFunctionCodeBlockType = 16, - CodeBlockType = 17, - JSImmutableButterflyType = 18, - JSSourceCodeType = 19, - JSScriptFetcherType = 20, - JSScriptFetchParametersType = 21, - ObjectType = 22, - FinalObjectType = 23, - JSCalleeType = 24, - JSFunctionType = 25, - InternalFunctionType = 26, - NullSetterFunctionType = 27, - BooleanObjectType = 28, - NumberObjectType = 29, - ErrorInstanceType = 30, - GlobalProxyType = 31, - DirectArgumentsType = 32, - ScopedArgumentsType = 33, - ClonedArgumentsType = 34, - ArrayType = 35, - DerivedArrayType = 36, - ArrayBufferType = 37, - Int8ArrayType = 38, - Uint8ArrayType = 39, - Uint8ClampedArrayType = 40, - Int16ArrayType = 41, - Uint16ArrayType = 42, - Int32ArrayType = 43, - Uint32ArrayType = 44, - Float32ArrayType = 45, - Float64ArrayType = 46, - BigInt64ArrayType = 47, - BigUint64ArrayType = 48, - DataViewType = 49, - GlobalObjectType = 50, - GlobalLexicalEnvironmentType = 51, - LexicalEnvironmentType = 52, - ModuleEnvironmentType = 53, - StrictEvalActivationType = 54, - WithScopeType = 55, - ModuleNamespaceObjectType = 56, - RegExpObjectType = 57, - JSDateType = 58, - ProxyObjectType = 59, - JSGeneratorType = 60, - JSAsyncGeneratorType = 61, - JSArrayIteratorType = 62, - JSMapIteratorType = 63, - JSSetIteratorType = 64, - JSStringIteratorType = 65, - JSPromiseType = 66, - JSMapType = 67, - JSSetType = 68, - JSWeakMapType = 69, - JSWeakSetType = 70, - WebAssemblyModuleType = 71, - WebAssemblyInstanceType = 72, - WebAssemblyGCObjectType = 73, - StringObjectType = 74, - DerivedStringObjectType = 75, - - MaxJSType = 255, - _, - - pub fn isString(this: CellType) bool { - return switch (this) { - .StringType => true, - else => false, - }; - } -}; - pub extern "c" fn JSObjectGetProxyTarget(JSObjectRef) JSObjectRef; diff --git a/src/bun.zig b/src/bun.zig index 55977d53e1..3d156f8542 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -2330,7 +2330,7 @@ pub const win32 = struct { if (exit_code == watcher_reload_exit) { continue; } else { - Global.exitWide(exit_code); + Global.exit(exit_code); } } } diff --git a/src/bun_js.zig b/src/bun_js.zig index 9bf2448f26..842a8a445f 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -177,7 +177,7 @@ pub const Run = struct { // JSC initialization costs 1-3ms. We skip this if we know it's a shell script. if (strings.endsWithComptime(entry_path, ".sh")) { const exit_code = try bootBunShell(ctx, entry_path); - Global.exitWide(exit_code); + Global.exit(exit_code); return; } diff --git a/src/cli/exec_command.zig b/src/cli/exec_command.zig index de51c9c20d..5ea2fd36cc 100644 --- a/src/cli/exec_command.zig +++ b/src/cli/exec_command.zig @@ -50,7 +50,7 @@ pub const ExecCommand = struct { // Output.flush(); // } - Global.exitWide(code); + Global.exit(code); // } } }; diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index 846c149f06..e735b5ff0a 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -328,7 +328,7 @@ pub const RunCommand = struct { Output.flush(); } - Global.exitWide(code); + Global.exit(code); } return true; diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 86e04c4ddb..39a3558f41 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -1105,7 +1105,7 @@ pub const TestCommand = struct { if (reporter.summary.fail > 0 or (coverage.enabled and coverage.fractions.failing and coverage.fail_on_low_coverage)) { Global.exit(1); } else if (reporter.jest.unhandled_errors_between_tests > 0) { - Global.exitWide(@intCast(reporter.jest.unhandled_errors_between_tests)); + Global.exit(reporter.jest.unhandled_errors_between_tests); } }