Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
thelongmarch-azx committed Nov 25, 2024
1 parent b903e24 commit fa1e130
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
15 changes: 8 additions & 7 deletions src/engine/compiler/SinglePassCompiler.v3
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class SinglePassCompiler(xenv: SpcExecEnv, masm: MacroAssembler, regAlloc: RegAl
masm.emit_debugger_breakpoint();
return;
}
x: WhammProbe => if (SpcTuning.intrinsifyWhammProbe){
x: WhammProbe => if (SpcTuning.intrinsifyWhammProbe && WasmFunction.?(x.func)){
emitWhammProbe(x);
return;
}
Expand Down Expand Up @@ -395,19 +395,20 @@ class SinglePassCompiler(xenv: SpcExecEnv, masm: MacroAssembler, regAlloc: RegAl
var inline_config = InlineConfig(false, false, false);
var new_local_base_sp = 0;
var orig_sp = state.sp;
var callee_func = WasmFunction.!(probe.func);

if (SpcTuning.inlineSmallFunc) {
// TODO: can reuse when implementing inlining for SPC
inline_config = InlineConfig(probe.spc_swap_membase, probe.spc_swap_instance, probe.spc_inline_func);
if (!probe.inline_heuristic_checked) {
inline_config = funcCanInline(probe.func.decl);
inline_config = funcCanInline(callee_func.decl);
probe.inline_heuristic_checked = true;
probe.spc_swap_instance = inline_config.swap_instance;
probe.spc_swap_membase = inline_config.swap_membase;
}

if (inline_config.swap_instance) { // push whamm instance onto abstract stack directly
var whamm_instance_addr = Pointer.atObject(probe.func.instance) - Pointer.NULL;
var whamm_instance_addr = Pointer.atObject(callee_func.instance) - Pointer.NULL;
var slot_addr = masm.slotAddr(state.sp);
inlined_instance_slot = int.view(state.sp);
state.push(KIND_REF | IS_STORED, NO_REG, 0);
Expand All @@ -416,7 +417,7 @@ class SinglePassCompiler(xenv: SpcExecEnv, masm: MacroAssembler, regAlloc: RegAl

// overwrite mem0_base with whamm instance's memory base, restore from frame slot later
if (inline_config.swap_membase) {
var memobj_addr = Pointer.atObject(probe.func.instance.memories[0]) - Pointer.NULL;
var memobj_addr = Pointer.atObject(callee_func.instance.memories[0]) - Pointer.NULL;
masm.emit_mov_r_l(regs.mem0_base, i64.view(memobj_addr));
masm.emit_read_v3_mem_base(regs.mem0_base, regs.mem0_base);
}
Expand Down Expand Up @@ -534,10 +535,10 @@ class SinglePassCompiler(xenv: SpcExecEnv, masm: MacroAssembler, regAlloc: RegAl
}
}
}
var whamm_instance = probe.func.instance;
var func_id = probe.func.decl.func_index;
var whamm_instance = callee_func.instance;
var func_id = callee_func.decl.func_index;
var whamm_module = whamm_instance.module;
var whamm_func_decl = probe.func.decl;
var whamm_func_decl = callee_func.decl;
if (inline_config.can_inline) {
var orig_decl = it.func;
var orig_pc = it.pc;
Expand Down
20 changes: 0 additions & 20 deletions src/monitors/WhammMonitor.v3
Original file line number Diff line number Diff line change
Expand Up @@ -356,26 +356,6 @@ class WhammMonitor(whamm: Module) extends Monitor {
}
}

// A probe that adapts a Wasm function to be called by the engine-internal probing mechanism.
class WhammProbe(func: Function, sig: Array<WhammArg>) extends Probe {
private def args = if(sig.length == 0, Values.NONE, Array<Value>.new(sig.length));

def fire(loc: DynamicLoc) -> Resumption {
for (i < sig.length) {
var v: Value;
match (sig[i]) {
FrameAccessor => v = Value.Ref(loc.frame.getFrameAccessor().getMetaRef());
Val(val) => v = val;
Operand(t, i) => v = loc.frame.getFrameAccessor().getOperand(i);
Local(t, i) => v = loc.frame.getFrameAccessor().getLocal(i);
}
args[i] = v;
}
Execute.call(func, args); // XXX: runs on a new stack
return Resumption.Continue;
}
}

def lookup<K, V>(v: Vector<(K, V)>, key: K, eq: (K, K) -> bool, default: V) -> V {
for (i < v.length) {
if (eq(key, v[i].0)) return v[i].1;
Expand Down
2 changes: 1 addition & 1 deletion src/util/Whamm.v3
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ component Whamm {
}

// A probe that adapts a Wasm function to be called by the engine-internal probing mechanism.
class WhammProbe(func: WasmFunction, sig: Array<WhammArg>) extends Probe {
class WhammProbe(func: Function, sig: Array<WhammArg>) extends Probe {
// properties set by the spc to make inlining optimization decisions.
var inline_heuristic_checked = false;
var spc_inline_func = false;
Expand Down

0 comments on commit fa1e130

Please sign in to comment.