diff options
| author | 2023-09-05 16:52:57 -0800 | |
|---|---|---|
| committer | 2023-09-05 17:52:57 -0700 | |
| commit | 1bd5b245b8a55353e60a2decad507ef8014be044 (patch) | |
| tree | 1a5cd5bcc7d7758bbfd154cf49470c1b0f3dc1bb /src/bun.js/event_loop.zig | |
| parent | acfd028e8f859a0e8139b7adab5d319e326c2373 (diff) | |
| download | bun-1bd5b245b8a55353e60a2decad507ef8014be044.tar.gz bun-1bd5b245b8a55353e60a2decad507ef8014be044.tar.zst bun-1bd5b245b8a55353e60a2decad507ef8014be044.zip | |
Align `process.nextTick` execution order with Node (#4409)
* Align `process.nextTick` execution order with Node
* some tests
* formatting
* fixups
* fix the test failures
* simplify the logic here
* push it up
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
Diffstat (limited to 'src/bun.js/event_loop.zig')
| -rw-r--r-- | src/bun.js/event_loop.zig | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 640a9276c..f1367c239 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -529,14 +529,14 @@ pub const EventLoop = struct { this.virtual_machine.event_loop_handle.?.tick(); } } - - pub fn drainMicrotasksWithVM(this: *EventLoop, vm: *JSC.VM) void { - vm.drainMicrotasks(); + extern fn JSC__JSGlobalObject__drainMicrotasks(*JSC.JSGlobalObject) void; + fn drainMicrotasksWithGlobal(this: *EventLoop, globalObject: *JSC.JSGlobalObject) void { + JSC__JSGlobalObject__drainMicrotasks(globalObject); this.drainDeferredTasks(); } pub fn drainMicrotasks(this: *EventLoop) void { - this.drainMicrotasksWithVM(this.global.vm()); + this.drainMicrotasksWithGlobal(this.global); } pub fn ensureAliveForOneTick(this: *EventLoop) void { @@ -666,7 +666,7 @@ pub const EventLoop = struct { } global_vm.releaseWeakRefs(); - this.drainMicrotasksWithVM(global_vm); + this.drainMicrotasksWithGlobal(global); } this.tasks.head = if (this.tasks.count == 0) 0 else this.tasks.head; @@ -824,13 +824,14 @@ pub const EventLoop = struct { this.processGCTimer(); - var global_vm = ctx.global.vm(); + var global = ctx.global; + var global_vm = global.vm(); while (true) { while (this.tickWithCount() > 0) : (this.global.handleRejectedPromises()) { this.tickConcurrent(); } else { global_vm.releaseWeakRefs(); - this.drainMicrotasksWithVM(global_vm); + this.drainMicrotasksWithGlobal(global); this.tickConcurrent(); if (this.tasks.count > 0) continue; } |
