Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Nov 25, 2024
1 parent 707e8d9 commit b4cb9f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/bun.js/bindings/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6772,7 +6772,7 @@ pub fn toJSHostFunction(comptime Function: JSHostZigFunction) JSC.JSHostFunction
globalThis: *JSC.JSGlobalObject,
callframe: *JSC.CallFrame,
) callconv(JSC.conv) JSC.JSValue {
if (bun.Environment.allow_assert) {
if (bun.Environment.allow_assert and bun.Environment.is_canary) {
const value = Function(globalThis, callframe) catch |err| switch (err) {
error.JSError => .zero,
error.OutOfMemory => globalThis.throwOutOfMemoryValue(),
Expand All @@ -6788,9 +6788,8 @@ pub fn toJSHostFunction(comptime Function: JSHostZigFunction) JSC.JSHostFunction
}.function;
}

// XXX: temporary
pub fn toJSHostValue(globalThis: *JSGlobalObject, value: error{ OutOfMemory, JSError }!JSValue) JSValue {
if (bun.Environment.allow_assert) {
if (bun.Environment.allow_assert and bun.Environment.is_canary) {
const normal = value catch |err| switch (err) {
error.JSError => .zero,
error.OutOfMemory => globalThis.throwOutOfMemoryValue(),
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/generate-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${classSymbolName(typeName, "call")}(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) zig("${typeName}<d>({})<r>", .{callFrame});
return JSC.toJSHostFunction(${typeName}.call)(globalObject, callFrame);
return @call(.always_inline, JSC.toJSHostFunction(${typeName}.call), .{globalObject, callFrame});
}
`;
}
Expand Down Expand Up @@ -1807,7 +1807,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${names.fn}(thisValue: *${typeName}, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame${proto[name].passThis ? ", js_this_value: JSC.JSValue" : ""}) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) zig("<d>${typeName}.<r>${name}<d>({})<r>", .{callFrame});
return JSC.toJSHostValue(globalObject, ${typeName}.${fn}(thisValue, globalObject, callFrame${proto[name].passThis ? ", js_this_value" : ""}));
return @call(.always_inline, JSC.toJSHostValue, .{globalObject, @call(.always_inline, ${typeName}.${fn}, .{thisValue, globalObject, callFrame${proto[name].passThis ? ", js_this_value" : ""}})});
}
`;
}
Expand Down Expand Up @@ -1854,7 +1854,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${names.fn}(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
return JSC.toJSHostFunction(${typeName}.${fn})(globalObject, callFrame);
return @call(.always_inline, JSC.toJSHostFunction(${typeName}.${fn}), .{globalObject, callFrame});
}
`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/generate-js2native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function getJS2NativeZig(gs2NativeZigPath: string) {
})}(global: *JSC.JSGlobalObject, call_frame: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {`,
`
const function = @import(${JSON.stringify(path.relative(path.dirname(gs2NativeZigPath), x.filename))});
return JSC.toJSHostFunction(function.${x.symbol_target})(global, call_frame);`,
return @call(.always_inline, function.${x.symbol_target}, .{global, call_frame});`,
"}",
]),
].join("\n");
Expand Down

0 comments on commit b4cb9f7

Please sign in to comment.