Compare commits

...

3 Commits

Author SHA1 Message Date
autofix-ci[bot]
1272661557 [autofix.ci] apply automated fixes 2025-08-08 08:40:39 +00:00
Jarred Sumner
6139f5f83e Update ban-limits.json 2025-08-08 01:37:25 -07:00
Jarred Sumner
5e3b51aaee Reduce alignment 2025-08-07 17:19:32 -07:00
5 changed files with 28 additions and 10 deletions

View File

@@ -2132,16 +2132,21 @@ pub const RuntimeTranspilerStore = struct {
generation_number: std.atomic.Value(u32) = std.atomic.Value(u32).init(0),
store: TranspilerJob.Store,
enabled: bool = true,
queue: Queue = Queue{},
queue: *Queue,
pub const Queue = bun.UnboundedQueue(TranspilerJob, .next);
pub fn init() RuntimeTranspilerStore {
return RuntimeTranspilerStore{
.store = TranspilerJob.Store.init(bun.typedAllocator(TranspilerJob)),
.queue = Queue.new(.{}),
};
}
pub fn deinit(this: *RuntimeTranspilerStore) void {
this.queue.deinit();
}
pub fn runFromJSThread(this: *RuntimeTranspilerStore, event_loop: *jsc.EventLoop, global: *jsc.JSGlobalObject, vm: *jsc.VirtualMachine) void {
var batch = this.queue.popBatch();
const jsc_vm = vm.jsc_vm;

View File

@@ -903,8 +903,9 @@ pub fn enableMacroMode(this: *VirtualMachine) void {
this.macro_event_loop.tasks = EventLoop.Queue.init(default_allocator);
this.macro_event_loop.tasks.ensureTotalCapacity(16) catch unreachable;
this.macro_event_loop.global = this.global;
this.macro_event_loop.concurrent_tasks = jsc.EventLoop.ConcurrentTask.Queue.new(.{});
this.macro_event_loop.virtual_machine = this;
this.macro_event_loop.concurrent_tasks = .{};
ensureSourceCodePrinter(this);
}
@@ -994,7 +995,7 @@ pub fn initWithModuleGraph(
);
vm.regular_event_loop.virtual_machine = vm;
vm.regular_event_loop.tasks.ensureUnusedCapacity(64) catch unreachable;
vm.regular_event_loop.concurrent_tasks = .{};
vm.regular_event_loop.concurrent_tasks = jsc.EventLoop.ConcurrentTask.Queue.new(.{});
vm.event_loop = &vm.regular_event_loop;
vm.transpiler.macro_context = null;
@@ -1117,7 +1118,7 @@ pub fn init(opts: Options) !*VirtualMachine {
vm.regular_event_loop.virtual_machine = vm;
vm.regular_event_loop.tasks.ensureUnusedCapacity(64) catch unreachable;
vm.regular_event_loop.concurrent_tasks = .{};
vm.regular_event_loop.concurrent_tasks = jsc.EventLoop.ConcurrentTask.Queue.new(.{});
vm.event_loop = &vm.regular_event_loop;
vm.transpiler.macro_context = null;
@@ -1277,7 +1278,7 @@ pub fn initWorker(
vm.regular_event_loop.virtual_machine = vm;
vm.regular_event_loop.tasks.ensureUnusedCapacity(64) catch unreachable;
vm.regular_event_loop.concurrent_tasks = .{};
vm.regular_event_loop.concurrent_tasks = jsc.EventLoop.ConcurrentTask.Queue.new(.{});
vm.event_loop = &vm.regular_event_loop;
vm.hot_reload = worker.parent.hot_reload;
vm.transpiler.macro_context = null;
@@ -1369,7 +1370,7 @@ pub fn initBake(opts: Options) anyerror!*VirtualMachine {
vm.regular_event_loop.virtual_machine = vm;
vm.regular_event_loop.tasks.ensureUnusedCapacity(64) catch unreachable;
vm.regular_event_loop.concurrent_tasks = .{};
vm.regular_event_loop.concurrent_tasks = jsc.EventLoop.ConcurrentTask.Queue.new(.{});
vm.event_loop = &vm.regular_event_loop;
if (comptime bun.Environment.isWindows) {
vm.eventLoop().ensureWaker();
@@ -1903,10 +1904,8 @@ pub fn processFetchLog(globalThis: *JSGlobalObject, specifier: bun.String, refer
}
}
// TODO:
pub fn deinit(this: *VirtualMachine) void {
this.auto_killer.deinit();
if (source_code_printer) |print| {
print.getMutableBuffer().deinit();
print.ctx.written = &.{};
@@ -1916,6 +1915,8 @@ pub fn deinit(this: *VirtualMachine) void {
rare_data.deinit();
}
this.overridden_main.deinit();
this.transpiler_store.deinit();
this.event_loop.deinit();
this.has_terminated = true;
}

View File

@@ -14,7 +14,9 @@ tasks: Queue = undefined,
immediate_tasks: std.ArrayListUnmanaged(*Timer.ImmediateObject) = .{},
next_immediate_tasks: std.ArrayListUnmanaged(*Timer.ImmediateObject) = .{},
concurrent_tasks: ConcurrentTask.Queue = ConcurrentTask.Queue{},
// Heap-allocate to prevent over-alignment.
concurrent_tasks: *ConcurrentTask.Queue = undefined,
global: *jsc.JSGlobalObject = undefined,
virtual_machine: *VirtualMachine = undefined,
waker: ?Waker = null,
@@ -617,6 +619,13 @@ pub fn unrefConcurrently(this: *EventLoop) void {
this.wakeup();
}
pub fn deinit(this: *EventLoop) void {
this.concurrent_tasks.deinit();
this.immediate_tasks.clearAndFree(bun.default_allocator);
this.next_immediate_tasks.clearAndFree(bun.default_allocator);
this.tasks.deinit();
}
pub const AnyEventLoop = @import("./event_loop/AnyEventLoop.zig").AnyEventLoop;
pub const ConcurrentPromiseTask = @import("./event_loop/ConcurrentPromiseTask.zig").ConcurrentPromiseTask;
pub const WorkTask = @import("./event_loop/WorkTask.zig").WorkTask;

View File

@@ -38,6 +38,9 @@ pub fn UnboundedQueue(comptime T: type, comptime next_field: meta.FieldEnum(T))
back: std.atomic.Value(?*T) align(queue_padding_length) = .init(null),
front: std.atomic.Value(?*T) align(queue_padding_length) = .init(null),
pub const new = bun.TrivialNew(@This());
pub const deinit = bun.TrivialDeinit(@This());
pub fn push(self: *Self, item: *T) void {
self.pushBatch(item, item);
}

View File

@@ -7,7 +7,7 @@
".stdDir()": 40,
".stdFile()": 18,
"// autofix": 168,
": [a-zA-Z0-9_\\.\\*\\?\\[\\]\\(\\)]+ = undefined,": 229,
": [a-zA-Z0-9_\\.\\*\\?\\[\\]\\(\\)]+ = undefined,": 230,
"== alloc.ptr": 0,
"== allocator.ptr": 0,
"@import(\"bun\").": 0,