Commit f92fbb2f authored by Kunshan Wang's avatar Kunshan Wang

Passes gc and futex test.

parent 87c9ebdc
......@@ -11,6 +11,8 @@ import scala.collection.AbstractIterator
import uvm.refimpl.nat.NativeStackKeeper
import uvm.refimpl.nat.NativeCallResult
import uvm.refimpl.nat.NativeCallHelper
import org.slf4j.LoggerFactory
import com.typesafe.scalalogging.Logger
abstract class StackState
......@@ -216,8 +218,16 @@ class MuFrame(val funcVer: FuncVer, val cookie: Long, prev: Option[InterpreterFr
}
private def putBox(lv: LocalVariable) {
import MuFrame.logger
val ty = TypeInferer.inferType(lv)
boxes.put(lv, ValueBox.makeBoxForType(ty))
try {
boxes.put(lv, ValueBox.makeBoxForType(ty))
} catch {
case e: UvmRefImplException => {
logger.error("Having problem creating box for lv: %s".format(lv))
throw e
}
}
if (lv.isInstanceOf[Parameter]) {
edgeAssignedBoxes.put(lv.asInstanceOf[Parameter], ValueBox.makeBoxForType(ty))
}
......@@ -256,6 +266,10 @@ class MuFrame(val funcVer: FuncVer, val cookie: Long, prev: Option[InterpreterFr
}
}
object MuFrame {
val logger = Logger(LoggerFactory.getLogger(getClass.getName))
}
class NativeFrame(val func: Word, prev: Option[InterpreterFrame]) extends InterpreterFrame(prev) {
/**
* When calling back from native, maybeCallback is set to the CallBack object.
......
......@@ -33,7 +33,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@futex_waiter_v1.trap_waiter" => {
case "@futex_waiter_v1.entry.trap_waiter" => {
val Seq(rv, sv) = ca.dumpKeepalives(st, 0)
ca.toInt(rv, signExt = true) shouldBe 0
......@@ -43,7 +43,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
TrapRebindPassVoid(st)
}
case "@futex_setter_v1.trap_setter" => {
case "@futex_setter_v1.wait_exit.trap_setter" => {
trapSetterReached = true
TrapRebindPassVoid(st)
......@@ -69,7 +69,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@futex_delayer_v1.trap_delayer" => {
case "@futex_delayer_v1.entry.trap_delayer" => {
val Seq(rv) = ca.dumpKeepalives(st, 0)
ca.toInt(rv, signExt = true) shouldBe -3
......@@ -98,7 +98,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@futex_no_sleep_v1.trap_no_sleep" => {
case "@futex_no_sleep_v1.entry.trap_no_sleep" => {
val Seq(rv) = ca.dumpKeepalives(st, 0)
ca.toInt(rv, signExt = true) shouldBe -1
......@@ -128,7 +128,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@futex_requeue_waiter_v1.trap_requeue_waiter" => {
case "@futex_requeue_waiter_v1.entry.trap_requeue_waiter" => {
val Seq(rv) = ca.dumpKeepalives(st, 0)
ca.toInt(rv, signExt = true) shouldBe 0
......@@ -137,7 +137,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
TrapRebindPassVoid(st)
}
case "@futex_requeue_test_v1.trap_wait" => {
case "@futex_requeue_test_v1.wait_body.trap_wait" => {
val Seq(nt, nt2) = ca.dumpKeepalives(st, 0)
val nthr = nt.vb.asThread.get
......@@ -151,7 +151,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
TrapRebindPassValue(st, zero)
}
}
case "@futex_requeue_test_v1.trap_setter" => {
case "@futex_requeue_test_v1.wait_exit.trap_setter" => {
val Seq(nwakes, nwakes2) = ca.dumpKeepalives(st, 0)
ca.toInt(nwakes, signExt = true) shouldBe 1
......@@ -198,7 +198,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@futex_gc_waiter_v1.trap_gc_waiter" => {
case "@futex_gc_waiter_v1.entry.trap_gc_waiter" => {
val Seq(rv) = ca.dumpKeepalives(st, 0)
ca.toInt(rv, signExt = true) shouldBe 0
......@@ -207,7 +207,7 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
TrapRebindPassVoid(st)
}
case "@futex_with_gc_v1.trap_wait" => {
case "@futex_with_gc_v1.wait_body.trap_wait" => {
val Seq(nt) = ca.dumpKeepalives(st, 0)
val nthr = nt.vb.asThread.get
......@@ -220,12 +220,12 @@ class UvmInterpreterFutexTests extends UvmBundleTesterBase {
TrapRebindPassValue(st, zero)
}
}
case "@futex_with_gc_v1.trap_gc" => {
case "@futex_with_gc_v1.wait_exit.trap_gc" => {
gc()
TrapRebindPassVoid(st)
}
case "@futex_with_gc_v1.trap_exit" => {
case "@futex_with_gc_v1.wait_exit.trap_exit" => {
val Seq(nwakes) = ca.dumpKeepalives(st, 0)
ca.toInt(nwakes, signExt = true) shouldBe 1
......
......@@ -45,11 +45,11 @@ class UvmInterpreterGCTests extends UvmBundleTesterBase {
val func = ca.putFunction("@keepglobal")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@keepglobal_v1.gctrap" => {
case "@keepglobal_v1.entry.gctrap" => {
gc()
TrapRebindPassVoid(st)
}
case "@keepglobal_v1.checktrap" => {
case "@keepglobal_v1.entry.checktrap" => {
val Seq(obj2, obj2val) = ca.dumpKeepalives(st, 0)
obj2.vb.asRef shouldNot be(0L)
......@@ -69,11 +69,11 @@ class UvmInterpreterGCTests extends UvmBundleTesterBase {
val func = ca.putFunction("@nokeepalloca")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@nokeepalloca_v1.gctrap" => {
case "@nokeepalloca_v1.entry.gctrap" => {
gc()
TrapRebindPassVoid(st)
}
case "@allocatest_v1.gctrap" => {
case "@allocatest_v1.entry.gctrap" => {
gc()
TrapRebindPassVoid(st)
}
......@@ -119,18 +119,18 @@ class UvmInterpreterGCTests extends UvmBundleTesterBase {
val func = ca.putFunction("@testweakref")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@testweakref_v1.gctrap" => {
case "@testweakref_v1.entry.gctrap" => {
gc()
TrapRebindPassVoid(st)
}
case "@peekweakref_v1.checknztrap" => {
case "@peekweakref_v1.entry.checknztrap" => {
val Seq(refval) = ca.dumpKeepalives(st, 0)
refval.vb.asRef shouldNot be(0L)
TrapRebindPassVoid(st)
}
case "@testweakref_v1.checkztrap" => {
case "@testweakref_v1.entry.checkztrap" => {
val Seq(refval) = ca.dumpKeepalives(st, 0)
refval.vb.asRef should be(0L)
......@@ -151,12 +151,12 @@ class UvmInterpreterGCTests extends UvmBundleTesterBase {
val func = ca.putFunction("@testtagrefgc")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@testtagrefgc_v1.gctrap" => {
case "@testtagrefgc_v1.entry.gctrap" => {
gc()
TrapRebindPassVoid(st)
}
case "@testtagrefgc_v1.checktrap" => {
case "@testtagrefgc_v1.entry.checktrap" => {
val Seq(tr, refv, tagv, iv) = ca.dumpKeepalives(st, 0)
ca.toInt(tagv) shouldBe 13
......@@ -178,12 +178,12 @@ class UvmInterpreterGCTests extends UvmBundleTesterBase {
val func = ca.putFunction("@testtagrefgcmem")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@testtagrefgcmem_v1.gctrap" => {
case "@testtagrefgcmem_v1.entry.gctrap" => {
gc()
TrapRebindPassVoid(st)
}
case "@testtagrefgcmem_v1.checktrap" => {
case "@testtagrefgcmem_v1.entry.checktrap" => {
val Seq(tr, refv, tagv, iv) = ca.dumpKeepalives(st, 0)
ca.toInt(tagv) shouldBe 13
......
......@@ -8,8 +8,8 @@
.const @I32_0 <@i32> = 0
.const @I32_1 <@i32> = 1
.funcdef @futex_waiter VERSION @futex_waiter_v1 <@noparamsnoret> () {
%entry:
.funcdef @futex_waiter VERSION @futex_waiter_v1 <@noparamsnoret> {
%entry():
%rv = COMMINST @uvm.futex.wait <@i32> (@the_futex @I32_0)
%sv = LOAD <@i64> @shared_value1
......@@ -17,8 +17,8 @@
COMMINST @uvm.thread_exit
}
.funcdef @futex_setter VERSION @futex_setter_v1 <@noparamsnoret> () {
%entry:
.funcdef @futex_setter VERSION @futex_setter_v1 <@noparamsnoret> {
%entry():
STORE <@i64> @shared_value1 @I64_0
STORE <@i64> @shared_value2 @I64_0
STORE <@i32> @the_futex @I32_0
......@@ -28,30 +28,30 @@
STORE <@i64> @shared_value1 @I64_42
BRANCH %wait_body
BRANCH %wait_body()
%wait_body:
%wait_body():
%nwakes = COMMINST @uvm.futex.wake <@i32> (@the_futex @I32_1)
%is_1 = EQ <@i32> %nwakes @I32_1
BRANCH2 %is_1 %wait_exit %wait_body
BRANCH2 %is_1 %wait_exit() %wait_body()
%wait_exit:
%wait_exit():
%trap_setter = TRAP <@void>
COMMINST @uvm.thread_exit
}
.const @I64_ONE_SECOND <@i64> = 1000000000
.funcdef @futex_delayer VERSION @futex_delayer_v1 <@noparamsnoret> () {
%entry:
.funcdef @futex_delayer VERSION @futex_delayer_v1 <@noparamsnoret> {
%entry():
STORE <@i32> @the_futex @I32_0
%rv = COMMINST @uvm.futex.wait_timeout <@i32> (@the_futex @I32_0 @I64_ONE_SECOND)
%trap_delayer = TRAP <@void> KEEPALIVE(%rv)
COMMINST @uvm.thread_exit
}
.funcdef @futex_no_sleep VERSION @futex_no_sleep_v1 <@noparamsnoret> () {
%entry:
.funcdef @futex_no_sleep VERSION @futex_no_sleep_v1 <@noparamsnoret> {
%entry():
STORE <@i32> @the_futex @I32_0
%rv = COMMINST @uvm.futex.wait <@i32> (@the_futex @I32_1)
%trap_no_sleep = TRAP <@void> KEEPALIVE(%rv)
......@@ -60,15 +60,15 @@
.global @the_other_futex <@i32>
.funcdef @futex_requeue_waiter VERSION @futex_requeue_waiter_v1 <@noparamsnoret> () {
%entry:
.funcdef @futex_requeue_waiter VERSION @futex_requeue_waiter_v1 <@noparamsnoret> {
%entry():
%rv = COMMINST @uvm.futex.wait <@i32> (@the_futex @I32_0)
%trap_requeue_waiter = TRAP <@void> KEEPALIVE(%rv)
COMMINST @uvm.thread_exit
}
.funcdef @futex_requeue_test VERSION @futex_requeue_test_v1 <@noparamsnoret> () {
%entry:
.funcdef @futex_requeue_test VERSION @futex_requeue_test_v1 <@noparamsnoret> {
%entry():
STORE <@i32> @the_futex @I32_0
STORE <@i32> @the_other_futex @I32_0
......@@ -78,14 +78,14 @@
%ns2 = NEWSTACK <@noparamsnoret> @futex_requeue_waiter ()
%nt2 = COMMINST @uvm.new_thread (%ns2)
BRANCH %wait_body
BRANCH %wait_body(%nt %nt2)
%wait_body:
%wait_body(<@thread> %nt <@thread> %nt2):
%trap_wait = TRAP <@i32> KEEPALIVE (%nt %nt2)
%is_1 = EQ <@i32> %trap_wait @I32_1
BRANCH2 %is_1 %wait_exit %wait_body
BRANCH2 %is_1 %wait_exit() %wait_body()
%wait_exit:
%wait_exit():
%nwakes = COMMINST @uvm.futex.cmp_requeue <@i32> (@the_futex @the_other_futex @I32_0 @I32_1)
%nwakes2 = COMMINST @uvm.futex.wake <@i32> (@the_other_futex @I32_1)
%trap_setter = TRAP <@void> KEEPALIVE (%nwakes %nwakes2)
......@@ -96,16 +96,16 @@
.typedef @irefi32 = iref<@i32>
.funcsig @futex_gc_waiter_sig = @void (@refi32)
.funcdef @futex_gc_waiter VERSION @futex_gc_waiter_v1 <@futex_gc_waiter_sig> (%ref) {
%entry:
.funcdef @futex_gc_waiter VERSION @futex_gc_waiter_v1 <@futex_gc_waiter_sig> {
%entry(<@refi32> %ref):
%ir = GETIREF <@i32> %ref
%rv = COMMINST @uvm.futex.wait <@i32> (%ir @I32_0)
%trap_gc_waiter = TRAP <@void> KEEPALIVE(%rv)
COMMINST @uvm.thread_exit
}
.funcdef @futex_with_gc VERSION @futex_with_gc_v1 <@noparamsnoret> () {
%entry:
.funcdef @futex_with_gc VERSION @futex_with_gc_v1 <@noparamsnoret> {
%entry():
%obj = NEW <@i64>
%ir = GETIREF <@i64> %obj
STORE <@i32> %ir @I32_0
......@@ -113,14 +113,14 @@
%ns = NEWSTACK <@noparamsnoret> @futex_gc_waiter (%obj)
%nt = COMMINST @uvm.new_thread (%ns)
BRANCH %wait_body
BRANCH %wait_body(%ir %nt)
%wait_body:
%wait_body(<@irefi64> %ir <@thread> %nt):
%trap_wait = TRAP <@i32> KEEPALIVE (%nt)
%is_1 = EQ <@i32> %trap_wait @I32_1
BRANCH2 %is_1 %wait_exit %wait_body
BRANCH2 %is_1 %wait_exit(%ir) %wait_body(%ir %nt)
%wait_exit:
%wait_exit(<@irefi64> %ir):
%trap_gc = TRAP<@void>
%nwakes = COMMINST @uvm.futex.wake <@i32> (%ir @I32_1)
......
This diff is collapsed.
......@@ -9,8 +9,8 @@
.funcsig @noparamsnoret = @void ()
.typedef @thread = thread
.typedef @stack = stack
.typedef @thread = threadref
.typedef @stack = stackref
.typedef @tagref64 = tagref64
.const @TRUE <@i64> = 1
......
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