Commit efd507b2 authored by Kunshan Wang's avatar Kunshan Wang

Fixed MuCtx.pushFrame parameter type

It now takes a frame cursor ref instead of a stack ref.
parent a970880a
......@@ -408,7 +408,7 @@ struct MuCtx {
// On-stack replacement
void (*pop_frames_to)(MuCtx *ctx, MuFCRefValue cursor);
void (*push_frame )(MuCtx *ctx, MuStackRefValue stack, MuFuncRefValue func);
void (*push_frame )(MuCtx *ctx, MuFCRefValue cursor, MuFuncRefValue func);
// 64-bit tagged reference operations
MuBool (*tr64_is_fp )(MuCtx *ctx, MuTagRef64Value value);
......
......@@ -387,7 +387,7 @@ def main():
"comminsts.scala": {
"IRBUILDER_COMMINSTS": comminsts_defs,
},
"internals.scala": {
"TypeInferer.scala": {
"IRBUILDER_RETVALS": comminsts_retvals,
},
"InstructionResultInferer.scala": {
......
......@@ -19,7 +19,7 @@ injectable_files = injecttools.make_injectable_file_set(_refimpl2_root, [
"wrp_MuIRBuilder"]),
("comminsts.scala", "src/main/scala/uvm/comminsts/comminsts.scala",
["IRBUILDER_COMMINSTS"]),
("internals.scala", "src/main/scala/uvm/refimpl/internals.scala",
("TypeInferer.scala", "src/main/scala/uvm/staticanalysis/TypeInferer.scala",
["IRBUILDER_RETVALS"]),
("InstructionResultInferer.scala", "src/main/scala/uvm/staticanalysis/InstructionResultInferer.scala",
["IRBUILDER_RETVAL_NUMS"]),
......
......@@ -1600,7 +1600,7 @@ _initialize_methods(MuCtx, [
('cur_inst', CMuID, [MuFCRefValue]),
('dump_keepalives_', None, [MuFCRefValue, ctypes.c_void_p]),
('pop_frames_to', None, [MuFCRefValue]),
('push_frame', None, [MuStackRefValue, MuFuncRefValue]),
('push_frame', None, [MuFCRefValue, MuFuncRefValue]),
('tr64_is_fp', bool, [MuTagRef64Value]),
('tr64_is_int', bool, [MuTagRef64Value]),
('tr64_is_ref', bool, [MuTagRef64Value]),
......
......@@ -575,13 +575,14 @@ class MuCtx(val ctxID: MuInternalID, _mutator: Mutator)(
}
/** Create a new frame for a Mu function and push it to the top of a stack. */
def pushFrame(stack: MuStackRefValue, func: MuFuncRefValue): Unit = {
val st = getStackNotNull(stack)
def pushFrame(cursor: MuFCRefValue, func: MuFuncRefValue): Unit = {
val c = getCursorNotNull(cursor)
val funcVal = func.vb.obj.getOrElse {
throw new UvmRuntimeException("Stack-bottom function must not be NULL")
}
val st = c.stack
st.pushFrame(funcVal)
}
......
......@@ -733,12 +733,12 @@ val _RV = ctx.popFramesTo(cursor)
}
val MUCTX__PUSH_FRAME = exposedMethod("MuCtx.push_frame", JType.VOID, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
val _raw_stack = _jffiBuffer.getAddress(1)
val _raw_cursor = _jffiBuffer.getAddress(1)
val _raw_func = _jffiBuffer.getAddress(2)
val ctx = getMuCtx(_raw_ctx)
val stack = getMuValueNotNull(_raw_stack).asInstanceOf[MuStackRefValue]
val cursor = getMuValueNotNull(_raw_cursor).asInstanceOf[MuFCRefValue]
val func = getMuValueNotNull(_raw_func).asInstanceOf[MuFuncRefValue]
val _RV = ctx.pushFrame(stack, func)
val _RV = ctx.pushFrame(cursor, func)
}
val MUCTX__TR64_IS_FP = exposedMethod("MuCtx.tr64_is_fp", JType.SINT, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......
......@@ -242,4 +242,4 @@ class TypeInferer(
/// GEN:END:IRBUILDER_RETVALS
}
}
}
\ No newline at end of file
}
......@@ -117,10 +117,11 @@ class UvmOSRTests extends UvmBundleTesterBase {
// OSR
ctx.nextFrame(fc)
ctx.popFramesTo(fc)
ctx.closeCursor(fc)
val oneShotFunc = ctx.handleFromFunc("@sum_osr_oneshot")
ctx.pushFrame(st, oneShotFunc)
ctx.pushFrame(fc, oneShotFunc)
ctx.closeCursor(fc)
// Continue
Rebind(st, PassValues(Seq(s, i, n)))
......@@ -162,9 +163,11 @@ class UvmOSRTests extends UvmBundleTesterBase {
def testFuncMulti(ctx: MuCtx, funcs: Seq[MuFuncRefValue], args: Seq[MuValue])(handler: TrapHandlerFunction): Unit = {
microVM.setTrapHandler(new MockTrapHandler(handler))
val hStack = ctx.newStack(funcs(0))
val fc = ctx.newCursor(hStack)
for (f <- funcs.tail) {
ctx.pushFrame(hStack, f)
ctx.pushFrame(fc, f)
}
ctx.closeCursor(fc)
val hThread = ctx.newThread(hStack, None, uvm.refimpl.HowToResume.PassValues(args))
microVM.execute()
}
......
......@@ -632,12 +632,15 @@ void osr_bundle_trap_handler(
ctx->next_frame(ctx, cursor);
ctx->pop_frames_to(ctx, cursor);
ctx->close_cursor(ctx, cursor);
muprintf("Pushing...\n");
MuFuncRefValue one_shot_func = ctx->handle_from_func(ctx, ID("@sum_osr_oneshot"));
ctx->push_frame(ctx, stack, one_shot_func);
ctx->push_frame(ctx, cursor, one_shot_func);
muprintf("Closing cursor...\n");
ctx->close_cursor(ctx, cursor);
MuValue *rebind_values = (MuValue*)malloc(sizeof(MuValue)*3);
rebind_values[0] = kas[2];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment