Commit 63a689c6 authored by Kunshan Wang's avatar Kunshan Wang

TRAP and WATCHPOINT.

parent 217ca466
......@@ -832,10 +832,6 @@ class InterpreterThread(val id: Int, microVM: MicroVM, initialStack: Interpreter
val f = s.top
val (newFrame, newBB) = unwindUntilCatchable(f)
s.top = newFrame
if (exc != 0L) {
logger.debug("Catching exception %d".format(exc))
}
branchAndMovePC(newBB, exc)
}
......
......@@ -18,7 +18,7 @@ class UvmInterpreterSpec extends UvmBundleTesterBase {
setLogLevels(
ROOT_LOGGER_NAME -> INFO,
"uvm.refimpl.mem" -> DEBUG,
//"uvm.refimpl.mem" -> DEBUG,
"uvm.refimpl.itpr" -> DEBUG)
preloadBundles("tests/uvm-refimpl-test/basic-tests.uir")
......@@ -981,7 +981,7 @@ class UvmInterpreterSpec extends UvmBundleTesterBase {
ca.close()
}
"WATCHPOINT" should "work with all supported destinations when enabled" ignore {
"WATCHPOINT" should "work with all supported destinations when enabled" in {
val ca = microVM.newClientAgent()
ca.enableWatchPoint(1)
......@@ -1021,5 +1021,40 @@ class UvmInterpreterSpec extends UvmBundleTesterBase {
ca.close()
}
"TRAP and WATCHPOINT" should "throw exceptions out of function when no exceptional dest" in {
val ca = microVM.newClientAgent()
ca.enableWatchPoint(2)
val exc1 = ca.newFixed("@void")
val exc2 = ca.newFixed("@void")
val func = ca.putFunction("@trapExc")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@trapThrow_v1.t" => {
TrapRebindThrowExc(st, exc1)
}
case "@wpThrow_v1.w" => {
wp shouldBe 2
TrapRebindThrowExc(st, exc2)
}
case "@trapExc_v1.trap_exit" => {
val Seq(lp1, lp2) = ca.dumpKeepalives(st, 0)
lp1.vb.asRef shouldBe exc1.vb.asRef
lp2.vb.asRef shouldBe exc2.vb.asRef
TrapRebindPassVoid(st)
}
case n => fail("Unexpected trap " + n)
}
}
ca.close()
}
}
\ No newline at end of file
......@@ -709,6 +709,44 @@
COMMINST @uvm.thread_exit
}
.funcdef @trapThrow VERSION @trapThrow_v1 <@noparamsnoret> () {
%entry:
%t = TRAP <@void>
%trap_unreachable = TRAP <@void>
COMMINST @uvm.thread_exit
}
.funcdef @wpThrow VERSION @wpThrow_v1 <@noparamsnoret> () {
%entry:
%w = WATCHPOINT 2 <@void> %dis %ena
%dis:
%trap_unreachable = TRAP <@void>
COMMINST @uvm.thread_exit
%ena:
%trap_unreachable2 = TRAP <@void>
COMMINST @uvm.thread_exit
}
.funcdef @trapExc VERSION @trapExc_v1 <@noparamsnoret> () {
%entry:
CALL <@noparamsnoret> @trapThrow () EXC(%unreachable %bb2)
%bb2:
%lp1 = LANDINGPAD
CALL <@noparamsnoret> @wpThrow () EXC(%unreachable %exit)
%exit:
%lp2 = LANDINGPAD
%trap_exit = TRAP <@void> KEEPALIVE (%lp1 %lp2)
COMMINST @uvm.thread_exit
%unreachable:
%trap_unreachable = TRAP <@void>
COMMINST @uvm.thread_exit
}
//
// .funcsig @watchpointtest_sig = @noparamsnoret
// .funcdef @watchpointtest VERSION @watchpointtest_v1 <@watchpointtest_sig> () {
......
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