safety: a lot more exception checker progress (#20956)

This commit is contained in:
Meghan Denny
2025-07-15 23:11:19 -08:00
committed by GitHub
parent d8b37bf408
commit 875604a42b
102 changed files with 774 additions and 1383 deletions

View File

@@ -449,13 +449,13 @@ pub const AsyncModule = struct {
var spec = bun.String.init(ZigString.init(this.specifier).withEncoding());
var ref = bun.String.init(ZigString.init(this.referrer).withEncoding());
Bun__onFulfillAsyncModule(
bun.jsc.fromJSHostCallGeneric(this.globalThis, @src(), Bun__onFulfillAsyncModule, .{
this.globalThis,
this.promise.get().?,
&errorable,
&spec,
&ref,
);
}) catch {};
this.deinit();
jsc_vm.allocator.destroy(this);
}
@@ -468,7 +468,7 @@ pub const AsyncModule = struct {
specifier_: bun.String,
referrer_: bun.String,
log: *logger.Log,
) bun.JSExecutionTerminated!void {
) bun.JSError!void {
JSC.markBinding(@src());
var specifier = specifier_;
var referrer = referrer_;
@@ -508,14 +508,13 @@ pub const AsyncModule = struct {
debug("fulfill: {any}", .{specifier});
Bun__onFulfillAsyncModule(
try bun.jsc.fromJSHostCallGeneric(globalThis, @src(), Bun__onFulfillAsyncModule, .{
globalThis,
promise,
&errorable,
&specifier,
&referrer,
);
try scope.assertNoExceptionExceptTermination();
});
}
pub fn resolveError(this: *AsyncModule, vm: *VirtualMachine, import_record_id: u32, result: PackageResolveError) !void {
@@ -2143,24 +2142,23 @@ pub const RuntimeTranspilerStore = struct {
};
}
// This is run at the top of the event loop on the JS thread.
pub fn drain(this: *RuntimeTranspilerStore) bun.JSExecutionTerminated!void {
pub fn runFromJSThread(this: *RuntimeTranspilerStore) void {
var batch = this.queue.popBatch();
var iter = batch.iterator();
if (iter.next()) |job| {
// we run just one job first to see if there are more
try job.runFromJSThread();
} else {
return;
}
var vm: *VirtualMachine = @fieldParentPtr("transpiler_store", this);
const event_loop = vm.eventLoop();
const global = vm.global;
const jsc_vm = vm.jsc;
var iter = batch.iterator();
if (iter.next()) |job| {
// we run just one job first to see if there are more
job.runFromJSThread() catch |err| global.reportUncaughtExceptionFromError(err);
} else {
return;
}
while (iter.next()) |job| {
// if there are more, we need to drain the microtasks from the previous run
try event_loop.drainMicrotasksWithGlobal(global, jsc_vm);
try job.runFromJSThread();
event_loop.drainMicrotasksWithGlobal(global, jsc_vm) catch return;
job.runFromJSThread() catch |err| global.reportUncaughtExceptionFromError(err);
}
// immediately after this is called, the microtasks will be drained again.
@@ -2267,7 +2265,7 @@ pub const RuntimeTranspilerStore = struct {
this.vm.eventLoop().enqueueTaskConcurrent(JSC.ConcurrentTask.createFrom(&this.vm.transpiler_store));
}
pub fn runFromJSThread(this: *TranspilerJob) bun.JSExecutionTerminated!void {
pub fn runFromJSThread(this: *TranspilerJob) bun.JSError!void {
var vm = this.vm;
const promise = this.promise.swap();
const globalThis = this.globalThis;