Compare commits

...

1 Commits

Author SHA1 Message Date
Meghan Denny
44ee31ebcb codegen: uninline more callframes in debug mode with bun.callmod_inline 2024-07-31 11:55:43 -07:00
5 changed files with 23 additions and 22 deletions

View File

@@ -89,7 +89,7 @@ pub const BunObject = struct {
fn toJSGetter(comptime getter: anytype) LazyPropertyCallback {
return struct {
pub fn callback(this: *JSC.JSGlobalObject, object: *JSC.JSObject) callconv(JSC.conv) JSC.JSValue {
return @call(.always_inline, getter, .{ this, object });
return @call(bun.callmod_inline, getter, .{ this, object });
}
}.callback;
}

View File

@@ -1153,7 +1153,7 @@ pub fn wrapInstanceMethod(
}
}
return @call(.always_inline, @field(Container, name), args);
return @call(bun.callmod_inline, @field(Container, name), args);
}
}.method;
}
@@ -1306,7 +1306,7 @@ pub fn wrapStaticMethod(
defer iter.deinit();
return @call(.always_inline, @field(Container, name), args);
return @call(bun.callmod_inline, @field(Container, name), args);
}
}.method;
}

View File

@@ -6137,7 +6137,7 @@ pub fn toJSHostFunction(comptime Function: anytype) JSC.JSHostFunctionType {
}
}
return @call(.always_inline, Function, .{ globalThis, callframe });
return @call(bun.callmod_inline, Function, .{ globalThis, callframe });
}
}.function;
}

View File

@@ -1625,7 +1625,7 @@ const JavaScriptCoreBindings = struct {
exports.set("estimatedSize", symbolName(typeName, "estimatedSize"));
output += `
pub fn ${symbolName(typeName, "estimatedSize")}(thisValue: *${typeName}) callconv(JSC.conv) usize {
return @call(.always_inline, ${typeName}.estimatedSize, .{thisValue});
return @call(bun.callmod_inline, ${typeName}.estimatedSize, .{thisValue});
}
`;
}
@@ -1634,7 +1634,7 @@ const JavaScriptCoreBindings = struct {
exports.set("hasPendingActivity", symbolName(typeName, "hasPendingActivity"));
output += `
pub fn ${symbolName(typeName, "hasPendingActivity")}(thisValue: *${typeName}) callconv(JSC.conv) bool {
return @call(.always_inline, ${typeName}.hasPendingActivity, .{thisValue});
return @call(bun.callmod_inline, ${typeName}.hasPendingActivity, .{thisValue});
}
`;
}
@@ -1644,7 +1644,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${classSymbolName(typeName, "finalize")}(thisValue: *${typeName}) callconv(JSC.conv) void {
if (comptime Environment.enable_logs) zig("<d>~${typeName} 0x{x:8}<r>", .{@intFromPtr(thisValue)});
@call(.always_inline, ${typeName}.finalize, .{thisValue});
@call(bun.callmod_inline, ${typeName}.finalize, .{thisValue});
}
`;
}
@@ -1654,7 +1654,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${classSymbolName(typeName, "construct")}(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(JSC.conv) ?*${typeName} {
if (comptime Environment.enable_logs) zig("<r><blue>new<r> ${typeName}<d>({})<r>", .{callFrame});
return @call(.always_inline, ${typeName}.constructor, .{globalObject, callFrame});
return @call(bun.callmod_inline, ${typeName}.constructor, .{globalObject, callFrame});
}
`;
}
@@ -1664,7 +1664,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 @call(.always_inline, ${typeName}.call, .{globalObject, callFrame});
return @call(bun.callmod_inline, ${typeName}.call, .{globalObject, callFrame});
}
`;
}
@@ -1674,7 +1674,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${classSymbolName(typeName, "getInternalProperties")}(thisValue: *${typeName}, globalObject: *JSC.JSGlobalObject, thisValue: JSC.JSValue) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
return @call(.always_inline, ${typeName}.getInternalProperties, .{thisValue, globalObject, thisValue});
return @call(bun.callmod_inline, ${typeName}.getInternalProperties, .{thisValue, globalObject, thisValue});
}
`;
}
@@ -1688,7 +1688,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${names.getter}(this: *${typeName}, ${thisValue ? "thisValue: JSC.JSValue," : ""} globalObject: *JSC.JSGlobalObject) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) zig("<r><blue>get<r> ${typeName}<d>.<r>${name}", .{});
return @call(.always_inline, ${typeName}.${getter}, .{this, ${thisValue ? "thisValue," : ""} globalObject});
return @call(bun.callmod_inline, ${typeName}.${getter}, .{this, ${thisValue ? "thisValue," : ""} globalObject});
}
`;
}
@@ -1697,7 +1697,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${names.setter}(this: *${typeName}, ${thisValue ? "thisValue: JSC.JSValue," : ""} globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) callconv(JSC.conv) bool {
if (comptime Environment.enable_logs) zig("<r><blue>set<r> ${typeName}<d>.<r>${name} = {}", .{value});
return @call(.always_inline, ${typeName}.${setter}, .{this, ${thisValue ? "thisValue," : ""} globalObject, value});
return @call(bun.callmod_inline, ${typeName}.${setter}, .{this, ${thisValue ? "thisValue," : ""} globalObject, value});
}
`;
}
@@ -1709,7 +1709,7 @@ const JavaScriptCoreBindings = struct {
pub fn ${names.DOMJIT}(thisValue: *${typeName}, globalObject: *JSC.JSGlobalObject, ${args
.map(ZigDOMJITArgTypeDefinition)
.join(", ")}) callconv(JSC.conv) JSC.JSValue {
return @call(.always_inline, ${typeName}.${DOMJITName(fn)}, .{thisValue, globalObject, ${args.map((_, i) => `arg${i}`).join(", ")}});
return @call(bun.callmod_inline, ${typeName}.${DOMJITName(fn)}, .{thisValue, globalObject, ${args.map((_, i) => `arg${i}`).join(", ")}});
}
`;
}
@@ -1717,7 +1717,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${names.fn}(thisValue: *${typeName}, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) zig("<d>${typeName}.<r>${name}<d>({})<r>", .{callFrame});
return @call(.always_inline, ${typeName}.${fn}, .{thisValue, globalObject, callFrame});
return @call(bun.callmod_inline, ${typeName}.${fn}, .{thisValue, globalObject, callFrame});
}
`;
}
@@ -1733,7 +1733,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${names.getter}(globalObject: *JSC.JSGlobalObject, ${thisValue ? "thisValue: JSC.JSValue," : ""} propertyName: JSC.JSValue) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
return @call(.always_inline, ${typeName}.${getter}, .{globalObject, ${thisValue ? "thisValue," : ""} propertyName});
return @call(bun.callmod_inline, ${typeName}.${getter}, .{globalObject, ${thisValue ? "thisValue," : ""} propertyName});
}
`;
}
@@ -1742,7 +1742,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${names.setter}(globalObject: *JSC.JSGlobalObject, thisValue: JSC.JSValue, target: JSC.JSValue) callconv(JSC.conv) bool {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
return @call(.always_inline, ${typeName}.${setter || accessor.setter}, .{thisValue, globalObject, target});
return @call(bun.callmod_inline, ${typeName}.${setter || accessor.setter}, .{thisValue, globalObject, target});
}
`;
}
@@ -1756,7 +1756,7 @@ const JavaScriptCoreBindings = struct {
.map(ZigDOMJITArgTypeDefinition)
.join(", ")}) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
return @call(.always_inline, ${typeName}.${DOMJITName(fn)}, .{thisValue, globalObject, ${args.map((_, i) => `arg${i}`).join(", ")}});
return @call(bun.callmod_inline, ${typeName}.${DOMJITName(fn)}, .{thisValue, globalObject, ${args.map((_, i) => `arg${i}`).join(", ")}});
}
`;
}
@@ -1764,7 +1764,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 @call(.always_inline, ${typeName}.${fn}, .{globalObject, callFrame});
return @call(bun.callmod_inline, ${typeName}.${fn}, .{globalObject, callFrame});
}
`;
}
@@ -1776,7 +1776,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${symbolName(typeName, "onStructuredCloneSerialize")}(thisValue: *${typeName}, globalObject: *JSC.JSGlobalObject, ctx: *anyopaque, writeBytes: WriteBytesFn) callconv(JSC.conv) void {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
@call(.always_inline, ${typeName}.onStructuredCloneSerialize, .{thisValue, globalObject, ctx, writeBytes});
@call(bun.callmod_inline, ${typeName}.onStructuredCloneSerialize, .{thisValue, globalObject, ctx, writeBytes});
}
`;
@@ -1785,7 +1785,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${exports.get("structuredClone_transferable")}(thisValue: *${typeName}, globalObject: *JSC.JSGlobalObject, ctx: *anyopaque, write: WriteBytesFn) callconv(JSC.conv) void {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
@call(.always_inline, ${typeName}.onStructuredCloneTransfer, .{thisValue, globalObject, ctx, write});
@call(bun.callmod_inline, ${typeName}.onStructuredCloneTransfer, .{thisValue, globalObject, ctx, write});
}
`;
}
@@ -1795,7 +1795,7 @@ const JavaScriptCoreBindings = struct {
output += `
pub fn ${symbolName(typeName, "onStructuredCloneDeserialize")}(globalObject: *JSC.JSGlobalObject, ptr: [*]u8, end: [*]u8) callconv(JSC.conv) JSC.JSValue {
if (comptime Environment.enable_logs) JSC.markBinding(@src());
return @call(.always_inline, ${typeName}.onStructuredCloneDeserialize, .{globalObject, ptr, end});
return @call(bun.callmod_inline, ${typeName}.onStructuredCloneDeserialize, .{globalObject, ptr, end});
}
`;
} else {

View File

@@ -186,6 +186,7 @@ export function getJS2NativeCPP() {
export function getJS2NativeZig(gs2NativeZigPath: string) {
return [
"//! This file is generated by src/codegen/generate-js2native.ts based on seen calls to the $zig() JS macro",
`const bun = @import("root").bun;`,
`const JSC = @import("root").bun.JSC;`,
...nativeCalls
.filter(x => x.type === "zig")
@@ -205,7 +206,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 @call(.always_inline, function.${x.symbol_taget}, .{global, call_frame});`,
return @call(bun.callmod_inline, function.${x.symbol_taget}, .{global, call_frame});`,
"}",
]),
"comptime {",