Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/engine/x86-64/V3Offsets.v3
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class V3Offsets {
private def wf = WasmFunction.new(i, decl);
private def mem = NativeWasmMemory.new(null);
private def vs = X86_64Stack.new(2u * 4096u);
private def acc = X86_64FrameAccessor.new(vs, Pointer.NULL, decl);
private def acc = X86_64FrameAccessor.new(vs, X86_64FrameHandler.Interpreter(Pointer.NULL), decl);
private def ha = HeapArray.new(null, []);
private def cnt = CountProbe.new();
private def metric = Metric.new("", "", "");
Expand Down
5 changes: 3 additions & 2 deletions src/engine/x86-64/X86_64Interpreter.v3
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ class X86_64InterpreterCode extends RiUserCode {
if (Debug.stack) X86_64Stacks.traceIpAndSp(ip, sp, out);
var msg = "\tin [fast-int] ";
out(msg);
var instance = (sp + X86_64InterpreterFrame.instance.offset).load<Instance>();
var func = (sp + X86_64InterpreterFrame.func_decl.offset).load<FuncDecl>();
var h = X86_64FrameHandler.Interpreter(sp);
var instance = h.instance();
var func = h.func_decl();
// TODO: lazy parse of names section may allocate; must avoid this in OOM situation
var buf = X86_64Runtime.globalFrameDescriptionBuf;
if (func == null) buf.puts("(func=null)");
Expand Down
35 changes: 19 additions & 16 deletions src/engine/x86-64/X86_64SinglePassCompiler.v3
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,9 @@ class X86_64SpcCode extends RiUserCode {
out(msg);
msg = "] ";
out(msg);
var instance = (sp + X86_64InterpreterFrame.instance.offset).load<Instance>();
var wf = (sp + X86_64InterpreterFrame.wasm_func.offset).load<WasmFunction>();
var h = X86_64FrameHandler.Spc(sp);
var instance = h.instance();
var wf = h.wasm_func();
// TODO: lazy parse of names section may allocate; must avoid this in OOM situation
var buf = X86_64Runtime.globalFrameDescriptionBuf;
wf.decl.render(instance.module.names, buf);
Expand All @@ -1176,11 +1177,11 @@ class X86_64SpcCode extends RiUserCode {
// V3-runtime callback: when the garbage collector needs to scan a JIT stack frame.
def scanFrame(ip: Pointer, sp: Pointer) {
// Handle other roots in the frame
RiGc.rescanRoot(sp + X86_64InterpreterFrame.wasm_func.offset);
RiGc.rescanRoot(sp + X86_64InterpreterFrame.instance.offset);
RiGc.rescanRoot(sp + X86_64InterpreterFrame.accessor.offset);
RiGc.rescanRoot(sp + X86_64SpcFrame.wasm_func.offset);
RiGc.rescanRoot(sp + X86_64SpcFrame.instance.offset);
RiGc.rescanRoot(sp + X86_64SpcFrame.accessor.offset);
if (SpcTuning.inlineWhammProbes && SpcTuning.intrinsifyWhammProbe) {
RiGc.rescanRoot(sp + X86_64InterpreterFrame.stp.offset); // TODO: define X86_64SpcFrame and use dedicated slot
RiGc.rescanRoot(sp + X86_64SpcFrame.inlined_instance.offset);
}
}
}
Expand Down Expand Up @@ -1241,10 +1242,11 @@ class X86_64SpcModuleCode extends X86_64SpcCode {
// Update the current PC in the JIT frame, if it is accessible.
var ip = p_rip.load<Pointer>();
var inline_ctx = lookupPc(ip, false);
var h = X86_64FrameHandler.Spc(p_rsp);
if (inline_ctx == null) {
(p_rsp + X86_64InterpreterFrame.curpc.offset).store<int>(-1);
h.set_curpc(-1);
} else if (inline_ctx.tail == null) {
(p_rsp + X86_64InterpreterFrame.curpc.offset).store<int>(inline_ctx.head.pc);
h.set_curpc(inline_ctx.head.pc);
} else {
p_rsp = reconstructInlinedFramesForTrap(p_rsp, inline_ctx);
(ucontext + ucontext_rsp_offset).store<Pointer>(p_rsp);
Expand All @@ -1262,11 +1264,10 @@ class X86_64SpcModuleCode extends X86_64SpcCode {
def inlined = frames[0 ... (frames.length - 1)];
def count = inlined.length;

// set outermost pc in the real frame
(r_rsp + X86_64InterpreterFrame.curpc.offset).store<int>(outer.pc);

// Read instance from the real outer frame (shared across all inlined frames)
var instance = (r_rsp + X86_64InterpreterFrame.instance.offset).load<Instance>();
// set outermost pc in the real frame; read instance (shared across all inlined frames)
var outer_h = X86_64FrameHandler.Spc(r_rsp);
outer_h.set_curpc(outer.pc);
var instance = outer_h.instance();

// Push inlined frames
for (i = count - 1; i >= 0; i--) {
Expand All @@ -1277,11 +1278,13 @@ class X86_64SpcModuleCode extends X86_64SpcCode {
r_rsp.store<Pointer>(INLINED_FRAME_STUB.start);

r_rsp += -X86_64InterpreterFrame.size; // move rsp?
var h = X86_64FrameHandler.Spc(r_rsp);

// write func, pc, frame accessor
var wasm_func = WasmFunction.!(instance.functions[fid]);
(r_rsp + X86_64InterpreterFrame.wasm_func.offset).store<WasmFunction>(wasm_func);
(r_rsp + X86_64InterpreterFrame.curpc.offset).store<int>(pc);
(r_rsp + X86_64InterpreterFrame.accessor.offset).store<X86_64FrameAccessor>(null);
h.set_wasm_func(wasm_func);
h.set_curpc(pc);
h.set_accessor(null);
}
return r_rsp;
}
Expand Down
Loading
Loading