diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index cf9c98faec..fedfb07c8b 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -143,7 +143,7 @@ const { values: options, positionals: filters } = parseArgs({ }, ["retries"]: { type: "string", - default: isCI ? "0" : "0", // N retries = N+1 attempts + default: isCI ? "3" : "0", // N retries = N+1 attempts }, ["junit"]: { type: "boolean", diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig index 60a9ff00c7..1729332ffd 100644 --- a/src/bun.js/api/JSTranspiler.zig +++ b/src/bun.js/api/JSTranspiler.zig @@ -793,6 +793,7 @@ pub fn scan(this: *JSTranspiler, globalThis: *jsc.JSGlobalObject, callframe: *js } var arena = MimallocArena.init(); + defer arena.deinit(); const prev_allocator = this.transpiler.allocator; const allocator = arena.allocator(); this.transpiler.setAllocator(allocator); @@ -1067,6 +1068,7 @@ pub fn scanImports(this: *JSTranspiler, globalThis: *jsc.JSGlobalObject, callfra } var arena = MimallocArena.init(); + defer arena.deinit(); const prev_allocator = this.transpiler.allocator; const allocator = arena.allocator(); var ast_memory_allocator = bun.handleOom(allocator.create(JSAst.ASTMemoryAllocator)); diff --git a/src/bun.js/api/glob.zig b/src/bun.js/api/glob.zig index 352740edd3..927c6cbe6a 100644 --- a/src/bun.js/api/glob.zig +++ b/src/bun.js/api/glob.zig @@ -272,7 +272,7 @@ pub fn constructor(globalThis: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) b const pat_str: []u8 = @constCast((pat_arg.toSliceClone(globalThis) orelse return error.JSError).slice()); - const glob = bun.handleOom(alloc.create(Glob)); + const glob = bun.handleOom(bun.default_allocator.create(Glob)); glob.* = .{ .pattern = pat_str }; return glob; diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 98c7835b32..0ea9ff488b 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -3365,6 +3365,7 @@ const js_printer = bun.js_printer; const logger = bun.logger; const strings = bun.strings; const uws = bun.uws; +const Arena = bun.allocators.MimallocArena; const BoringSSL = bun.BoringSSL.c; const SocketAddress = bun.api.socket.SocketAddress; diff --git a/src/bun.js/bindings/Uint8Array.cpp b/src/bun.js/bindings/Uint8Array.cpp index 258c99b2fd..5fe2dcf223 100644 --- a/src/bun.js/bindings/Uint8Array.cpp +++ b/src/bun.js/bindings/Uint8Array.cpp @@ -9,12 +9,10 @@ namespace Bun { extern "C" JSC::EncodedJSValue JSUint8Array__fromDefaultAllocator(JSC::JSGlobalObject* lexicalGlobalObject, uint8_t* ptr, size_t length) { JSC::JSUint8Array* uint8Array; - if (length > 0) [[likely]] { auto buffer = ArrayBuffer::createFromBytes({ ptr, length }, createSharedTask([](void* p) { bun_free(p); })); - uint8Array = JSC::JSUint8Array::create(lexicalGlobalObject, lexicalGlobalObject->typedArrayStructureWithTypedArrayType(), WTFMove(buffer), 0, length); } else { uint8Array = JSC::JSUint8Array::create(lexicalGlobalObject, lexicalGlobalObject->typedArrayStructureWithTypedArrayType(), 0); @@ -27,7 +25,6 @@ extern "C" JSC::EncodedJSValue JSArrayBuffer__fromDefaultAllocator(JSC::JSGlobal { RefPtr buffer; - if (length > 0) [[likely]] { ASSERT(mi_is_in_heap_region(ptr) == (ENABLE_MIMALLOC == 1)); buffer = ArrayBuffer::createFromBytes({ ptr, length }, createSharedTask([](void* p) { diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 3a545590c4..ebf345dbdc 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3183,7 +3183,6 @@ JSC::EncodedJSValue ZigString__toExternalU16(const uint16_t* arg0, size_t len, J ASSERT(!mi_is_in_heap_region(str.ptr)); ASSERT(!mi_is_in_heap_region(Zig::untag(str.ptr))); #endif - 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)); return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTFMove(ref))); diff --git a/src/bundler/ThreadPool.zig b/src/bundler/ThreadPool.zig index 4f2dee427f..fb4a8c1db7 100644 --- a/src/bundler/ThreadPool.zig +++ b/src/bundler/ThreadPool.zig @@ -357,7 +357,7 @@ const default_allocator = bun.default_allocator; const js_ast = bun.ast; const allocators = bun.allocators; -const MimallocArena = bun.allocators.MimallocArena; +const ThreadLocalArena = bun.allocators.MimallocArena; const BundleV2 = bun.bundle_v2.BundleV2; const LinkerContext = bun.bundle_v2.LinkerContext; diff --git a/src/bundler/linker_context/postProcessCSSChunk.zig b/src/bundler/linker_context/postProcessCSSChunk.zig index 275232374a..c969b53c0e 100644 --- a/src/bundler/linker_context/postProcessCSSChunk.zig +++ b/src/bundler/linker_context/postProcessCSSChunk.zig @@ -60,7 +60,7 @@ pub fn postProcessCSSChunk(ctx: GenerateChunkCtx, worker: *ThreadPool.Worker, ch } // Save the offset to the start of the stored JavaScript - j.push(compile_result.code(), compile_result.allocator()); + j.push(compile_result.code(), bun.default_allocator); if (compile_result.sourceMapChunk()) |source_map_chunk| { if (c.options.source_maps != .none) { diff --git a/src/bundler/linker_context/postProcessHTMLChunk.zig b/src/bundler/linker_context/postProcessHTMLChunk.zig index 71826f7a3d..65ff00a67c 100644 --- a/src/bundler/linker_context/postProcessHTMLChunk.zig +++ b/src/bundler/linker_context/postProcessHTMLChunk.zig @@ -11,7 +11,7 @@ pub fn postProcessHTMLChunk(ctx: GenerateChunkCtx, worker: *ThreadPool.Worker, c const compile_results = chunk.compile_results_for_chunk; for (compile_results) |compile_result| { - j.push(compile_result.code(), compile_result.allocator()); + j.push(compile_result.code(), bun.default_allocator); } j.ensureNewlineAtEnd(); diff --git a/src/bundler/linker_context/postProcessJSChunk.zig b/src/bundler/linker_context/postProcessJSChunk.zig index 6cc34507e6..716f4f60eb 100644 --- a/src/bundler/linker_context/postProcessJSChunk.zig +++ b/src/bundler/linker_context/postProcessJSChunk.zig @@ -199,7 +199,7 @@ pub fn postProcessJSChunk(ctx: GenerateChunkCtx, worker: *ThreadPool.Worker, chu const source_index = compile_result.sourceIndex(); if (source_index != Index.runtime.value) break; line_offset.advance(compile_result.code()); - j.push(compile_result.code(), compile_result.allocator()); + j.push(compile_result.code(), bun.default_allocator); } } @@ -312,10 +312,10 @@ pub fn postProcessJSChunk(ctx: GenerateChunkCtx, worker: *ThreadPool.Worker, chu if (is_runtime) { if (c.options.output_format != .internal_bake_dev) { line_offset.advance(compile_result.code()); - j.push(compile_result.code(), compile_result.allocator()); + j.push(compile_result.code(), bun.default_allocator); } } else { - j.push(compile_result.code(), compile_result.allocator()); + j.push(compile_result.code(), bun.default_allocator); if (compile_result.sourceMapChunk()) |source_map_chunk| { if (c.options.source_maps != .none) {