Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-ref2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
mu-impl-ref2
Commits
694684b2
Commit
694684b2
authored
Nov 03, 2015
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use AnyVal for all implicit classes.
parent
5c2d1c03
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
216 additions
and
181 deletions
+216
-181
src/main/scala/uvm/Bundle.scala
src/main/scala/uvm/Bundle.scala
+12
-12
src/main/scala/uvm/Identified.scala
src/main/scala/uvm/Identified.scala
+1
-1
src/main/scala/uvm/ir/textinput/later.scala
src/main/scala/uvm/ir/textinput/later.scala
+1
-1
src/main/scala/uvm/refimpl/clientInterface.scala
src/main/scala/uvm/refimpl/clientInterface.scala
+14
-12
src/main/scala/uvm/refimpl/internals.scala
src/main/scala/uvm/refimpl/internals.scala
+76
-85
src/main/scala/uvm/refimpl/itpr/CommInstExecutor.scala
src/main/scala/uvm/refimpl/itpr/CommInstExecutor.scala
+20
-3
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
+27
-12
src/main/scala/uvm/refimpl/itpr/operationHelpers.scala
src/main/scala/uvm/refimpl/itpr/operationHelpers.scala
+5
-0
src/test/scala/uvm/ir/textinput/ExtraMatchers.scala
src/test/scala/uvm/ir/textinput/ExtraMatchers.scala
+16
-14
src/test/scala/uvm/ir/textinput/TestingBundlesValidators.scala
...est/scala/uvm/ir/textinput/TestingBundlesValidators.scala
+9
-6
src/test/scala/uvm/refimpl/UvmBundleTesterBase.scala
src/test/scala/uvm/refimpl/UvmBundleTesterBase.scala
+26
-23
src/test/scala/uvm/refimpl/itpr/UvmInterpreterNativeTestsExtra.scala
...ala/uvm/refimpl/itpr/UvmInterpreterNativeTestsExtra.scala
+2
-2
tests/uvm-refimpl-test/futex-tests.uir
tests/uvm-refimpl-test/futex-tests.uir
+0
-3
tests/uvm-refimpl-test/native-tests.uir
tests/uvm-refimpl-test/native-tests.uir
+7
-7
No files found.
src/main/scala/uvm/Bundle.scala
View file @
694684b2
...
...
@@ -68,18 +68,18 @@ class GlobalBundle extends Bundle {
for
(
cand
<-
newNs
.
all
)
{
try
{
oldNs
.
add
(
cand
)
def
assertPresent
[
T
<:
Identified
](
ns
:
NestedNamespace
[
T
],
obj
:
T
)
:
Unit
=
{
assert
(
ns
.
get
(
obj
.
id
)
==
Some
(
obj
))
if
(
obj
.
id
==
65731
)
{
printf
(
"Obj[65731] found in ns "
+
ns
)
}
ns
.
maybeParent
match
{
case
None
=>
case
Some
(
ns2
)
=>
assertPresent
(
ns2
,
obj
)
}
}
assertPresent
(
oldNs
.
asInstanceOf
[
NestedNamespace
[
T
]],
cand
)
//
def assertPresent[T <: Identified](ns: NestedNamespace[T], obj: T): Unit = {
//
assert(ns.get(obj.id) == Some(obj))
//
if (obj.id == 65731) {
//
printf("Obj[65731] found in ns " + ns)
//
}
//
ns.maybeParent match {
//
case None =>
//
case Some(ns2) =>
//
assertPresent(ns2, obj)
//
}
//
}
//
assertPresent(oldNs.asInstanceOf[NestedNamespace[T]], cand)
}
catch
{
case
e
:
NameConflictException
=>
throw
new
IllegalRedefinitionException
(
...
...
src/main/scala/uvm/Identified.scala
View file @
694684b2
...
...
@@ -21,7 +21,7 @@ trait IdentifiedSettable extends Identified {
}
object
RichIdentifiedSettable
{
implicit
class
RichIdentifiedSettable
[
T
<:
IdentifiedSettable
](
val
is
:
T
)
{
implicit
class
RichIdentifiedSettable
[
T
<:
IdentifiedSettable
](
val
is
:
T
)
extends
AnyVal
{
def
:=
(
p
:
Int
)
:
T
=
{
is
.
id
=
p
is
...
...
src/main/scala/uvm/ir/textinput/later.scala
View file @
694684b2
...
...
@@ -24,7 +24,7 @@ class Later {
}
object
Later
{
implicit
class
Laterable
[
T
](
val
anything
:
T
)
{
implicit
class
Laterable
[
T
](
val
anything
:
T
)
extends
AnyVal
{
def
later
(
lat
:
Later
)(
job
:
T
=>
Unit
)
:
T
=
{
lat
(()
=>
job
(
anything
))
anything
...
...
src/main/scala/uvm/refimpl/clientInterface.scala
View file @
694684b2
...
...
@@ -716,8 +716,21 @@ class MuCtx(_mutator: Mutator)(
}
object
RichMuCtx
{
/** Allow you to use the `val h = x << ctx.makeSomeHandle()` or `val h = x(ctx.makeSomeHandle())`
* syntax to dispose it later*/
class
DelayedDisposer
(
garbageList
:
Buffer
[
MuValue
])
{
def
apply
[
T
<:
MuValue
](
v
:
T
)
:
T
=
{
garbageList
+=
v
v
}
def
<<
[
T
<:
MuValue
](
v
:
T
)
:
T
=
{
garbageList
+=
v
v
}
}
/** Extensions to the MuCtx interface. Not officially part of the client API. */
implicit
class
RichMuCtx
(
ctx
:
MuCtx
)
{
implicit
class
RichMuCtx
(
val
ctx
:
MuCtx
)
extends
AnyVal
{
def
handleFromBoolean
(
b
:
Boolean
)
=
ctx
.
handleFromInt
(
if
(
b
)
1
else
0
,
1
)
def
handleFromInt1
(
num
:
BigInt
)
=
ctx
.
handleFromInt
(
num
,
1
)
def
handleFromInt6
(
num
:
BigInt
)
=
ctx
.
handleFromInt
(
num
,
6
)
...
...
@@ -728,17 +741,6 @@ object RichMuCtx {
def
handleFromInt64
(
num
:
BigInt
)
=
ctx
.
handleFromInt
(
num
,
64
)
def
deleteValue
(
vs
:
MuValue*
)
=
vs
.
foreach
(
ctx
.
deleteValue
)
class
DelayedDisposer
(
garbageList
:
Buffer
[
MuValue
])
{
def
apply
[
T
<:
MuValue
](
v
:
T
)
:
T
=
{
garbageList
+=
v
v
}
def
<<
[
T
<:
MuValue
](
v
:
T
)
:
T
=
{
garbageList
+=
v
v
}
}
def
autoDispose
[
T
](
f
:
DelayedDisposer
=>
T
)
=
{
val
garbages
=
ArrayBuffer
[
MuValue
]()
val
dd
=
new
DelayedDisposer
(
garbages
)
...
...
src/main/scala/uvm/refimpl/internals.scala
View file @
694684b2
...
...
@@ -12,23 +12,14 @@ import uvm.IdentifiedSettable
object
InternalIDFactory
extends
IDFactory
(
32768
)
// IDs from 32768-65535 are for implementation internal use.
object
InternalTypes
{
private
implicit
class
IdentifiedSettableAssignable
[
T
<:
IdentifiedSettable
](
i
:
T
)
{
def
:=
(
name
:
String
)
:
T
=
{
i
.
id
=
InternalIDFactory
.
getID
()
i
.
name
=
Some
(
name
)
i
}
import
uvm.RichIdentifiedSettable._
def
:=
(
idName
:
(
Int
,
String
))
:
T
=
{
val
(
id
,
name
)
=
idName
i
.
id
=
id
i
.
name
=
Some
(
name
)
i
}
def
internal
(
name
:
String
)
:
(
Int
,
String
)
=
{
val
id
=
InternalIDFactory
.
getID
()
val
n
=
"@uvm.internal.types."
+
name
(
id
,
n
)
}
def
internal
(
name
:
String
)
=
"@uvm.internal.types."
+
name
val
I1
=
TypeInt
(
1
)
:=
internal
(
"i1"
)
val
I6
=
TypeInt
(
6
)
:=
internal
(
"i6"
)
val
I8
=
TypeInt
(
6
)
:=
internal
(
"i8"
)
...
...
@@ -65,7 +56,7 @@ object InternalTypePool {
val
vecOf
=
LazyPool
[(
Type
,
Long
)
,
TypeVector
]
{
case
(
t
,
l
)
=>
TypeVector
(
t
,
l
)
}
def
unmarkedOf
(
t
:
Type
)
:
Type
=
t
match
{
case
TypeWeakRef
(
r
)
=>
refOf
(
r
)
case
_
=>
t
case
_
=>
t
}
}
...
...
@@ -78,11 +69,11 @@ object TypeInferer {
}
def
inferType
(
v
:
SSAVariable
)
:
Type
=
v
match
{
case
c
:
Constant
=>
c
.
constTy
case
c
:
Constant
=>
c
.
constTy
case
g
:
GlobalCell
=>
irefOf
(
g
.
cellTy
)
case
f
:
Function
=>
funcOf
(
f
.
sig
)
case
p
:
NorParam
=>
p
.
ty
case
p
:
ExcParam
=>
REF_VOID
case
f
:
Function
=>
funcOf
(
f
.
sig
)
case
p
:
NorParam
=>
p
.
ty
case
p
:
ExcParam
=>
REF_VOID
case
r
:
InstResult
=>
{
val
resTys
=
inferInstResultTypes
(
r
.
inst
)
try
{
...
...
@@ -98,90 +89,90 @@ object TypeInferer {
case
i
:
InstBinOp
=>
Seq
(
i
.
opndTy
)
case
i
:
InstCmp
=>
i
.
opndTy
match
{
case
TypeVector
(
_
,
l
)
=>
Seq
(
vecOf
(
I1
,
l
))
case
_
=>
Seq
(
I1
)
case
_
=>
Seq
(
I1
)
}
case
i
:
InstConv
=>
Seq
(
i
.
toTy
)
case
i
:
InstSelect
=>
Seq
(
i
.
opndTy
)
case
i
:
InstBranch
=>
Seq
()
case
i
:
InstBranch2
=>
Seq
()
case
i
:
InstSwitch
=>
Seq
()
case
i
:
InstCall
=>
i
.
sig
.
retTys
case
i
:
InstTailCall
=>
Seq
()
case
i
:
InstRet
=>
Seq
()
case
i
:
InstThrow
=>
Seq
()
case
i
:
InstExtractValue
=>
Seq
(
i
.
strTy
.
fieldTys
(
i
.
index
))
case
i
:
InstInsertValue
=>
Seq
(
i
.
strTy
)
case
i
:
InstConv
=>
Seq
(
i
.
toTy
)
case
i
:
InstSelect
=>
Seq
(
i
.
opndTy
)
case
i
:
InstBranch
=>
Seq
()
case
i
:
InstBranch2
=>
Seq
()
case
i
:
InstSwitch
=>
Seq
()
case
i
:
InstCall
=>
i
.
sig
.
retTys
case
i
:
InstTailCall
=>
Seq
()
case
i
:
InstRet
=>
Seq
()
case
i
:
InstThrow
=>
Seq
()
case
i
:
InstExtractValue
=>
Seq
(
i
.
strTy
.
fieldTys
(
i
.
index
))
case
i
:
InstInsertValue
=>
Seq
(
i
.
strTy
)
case
i
:
InstExtractElement
=>
Seq
(
i
.
seqTy
.
elemTy
)
case
i
:
InstInsertElement
=>
Seq
(
i
.
seqTy
)
case
i
:
InstShuffleVector
=>
Seq
(
vecOf
((
i
.
vecTy
.
elemTy
,
i
.
maskTy
.
len
)))
case
i
:
InstNew
=>
Seq
(
refOf
(
i
.
allocTy
))
case
i
:
InstNewHybrid
=>
Seq
(
refOf
(
i
.
allocTy
))
case
i
:
InstAlloca
=>
Seq
(
irefOf
(
i
.
allocTy
))
case
i
:
InstAllocaHybrid
=>
Seq
(
irefOf
(
i
.
allocTy
))
case
i
:
InstGetIRef
=>
Seq
(
irefOf
(
i
.
referentTy
))
case
i
:
InstGetFieldIRef
=>
Seq
(
ptrOrIRefOf
(
i
.
ptr
,
i
.
referentTy
.
fieldTys
(
i
.
index
)))
case
i
:
InstGetElemIRef
=>
Seq
(
ptrOrIRefOf
(
i
.
ptr
,
i
.
referentTy
.
elemTy
))
case
i
:
InstShiftIRef
=>
Seq
(
ptrOrIRefOf
(
i
.
ptr
,
i
.
referentTy
))
case
i
:
InstInsertElement
=>
Seq
(
i
.
seqTy
)
case
i
:
InstShuffleVector
=>
Seq
(
vecOf
((
i
.
vecTy
.
elemTy
,
i
.
maskTy
.
len
)))
case
i
:
InstNew
=>
Seq
(
refOf
(
i
.
allocTy
))
case
i
:
InstNewHybrid
=>
Seq
(
refOf
(
i
.
allocTy
))
case
i
:
InstAlloca
=>
Seq
(
irefOf
(
i
.
allocTy
))
case
i
:
InstAllocaHybrid
=>
Seq
(
irefOf
(
i
.
allocTy
))
case
i
:
InstGetIRef
=>
Seq
(
irefOf
(
i
.
referentTy
))
case
i
:
InstGetFieldIRef
=>
Seq
(
ptrOrIRefOf
(
i
.
ptr
,
i
.
referentTy
.
fieldTys
(
i
.
index
)))
case
i
:
InstGetElemIRef
=>
Seq
(
ptrOrIRefOf
(
i
.
ptr
,
i
.
referentTy
.
elemTy
))
case
i
:
InstShiftIRef
=>
Seq
(
ptrOrIRefOf
(
i
.
ptr
,
i
.
referentTy
))
case
i
:
InstGetVarPartIRef
=>
Seq
(
ptrOrIRefOf
(
i
.
ptr
,
i
.
referentTy
.
varTy
))
case
i
:
InstLoad
=>
Seq
(
unmarkedOf
(
i
.
referentTy
))
case
i
:
InstStore
=>
Seq
()
case
i
:
InstCmpXchg
=>
Seq
(
unmarkedOf
(
i
.
referentTy
),
I1
)
case
i
:
InstAtomicRMW
=>
Seq
(
unmarkedOf
(
i
.
referentTy
))
case
i
:
InstFence
=>
Seq
()
case
i
:
InstTrap
=>
i
.
retTys
case
i
:
InstWatchPoint
=>
i
.
retTys
case
i
:
InstCCall
=>
i
.
sig
.
retTys
case
i
:
InstNewThread
=>
Seq
(
THREAD
)
case
i
:
InstLoad
=>
Seq
(
unmarkedOf
(
i
.
referentTy
))
case
i
:
InstStore
=>
Seq
()
case
i
:
InstCmpXchg
=>
Seq
(
unmarkedOf
(
i
.
referentTy
),
I1
)
case
i
:
InstAtomicRMW
=>
Seq
(
unmarkedOf
(
i
.
referentTy
))
case
i
:
InstFence
=>
Seq
()
case
i
:
InstTrap
=>
i
.
retTys
case
i
:
InstWatchPoint
=>
i
.
retTys
case
i
:
InstCCall
=>
i
.
sig
.
retTys
case
i
:
InstNewThread
=>
Seq
(
THREAD
)
case
i
:
InstSwapStack
=>
i
.
curStackAction
match
{
case
RetWith
(
t
)
=>
t
case
_:
KillOld
=>
Seq
()
}
case
i
:
InstCommInst
=>
i
.
inst
.
name
.
get
match
{
case
"@uvm.new_stack"
=>
Seq
(
STACK
)
case
"@uvm.kill_stack"
=>
Seq
()
case
"@uvm.thread_exit"
=>
Seq
()
case
"@uvm.current_stack"
=>
Seq
(
STACK
)
case
"@uvm.tr64.is_fp"
=>
Seq
(
I1
)
case
"@uvm.tr64.is_int"
=>
Seq
(
I1
)
case
"@uvm.tr64.is_ref"
=>
Seq
(
I1
)
case
"@uvm.tr64.from_fp"
=>
Seq
(
TAGREF64
)
case
"@uvm.tr64.from_int"
=>
Seq
(
TAGREF64
)
case
"@uvm.tr64.from_ref"
=>
Seq
(
TAGREF64
)
case
"@uvm.tr64.to_fp"
=>
Seq
(
DOUBLE
)
case
"@uvm.tr64.to_int"
=>
Seq
(
I52
)
case
"@uvm.tr64.to_ref"
=>
Seq
(
REF_VOID
)
case
"@uvm.tr64.to_tag"
=>
Seq
(
I6
)
case
"@uvm.futex.wait"
=>
Seq
(
I32
)
case
"@uvm.new_stack"
=>
Seq
(
STACK
)
case
"@uvm.kill_stack"
=>
Seq
()
case
"@uvm.thread_exit"
=>
Seq
()
case
"@uvm.current_stack"
=>
Seq
(
STACK
)
case
"@uvm.tr64.is_fp"
=>
Seq
(
I1
)
case
"@uvm.tr64.is_int"
=>
Seq
(
I1
)
case
"@uvm.tr64.is_ref"
=>
Seq
(
I1
)
case
"@uvm.tr64.from_fp"
=>
Seq
(
TAGREF64
)
case
"@uvm.tr64.from_int"
=>
Seq
(
TAGREF64
)
case
"@uvm.tr64.from_ref"
=>
Seq
(
TAGREF64
)
case
"@uvm.tr64.to_fp"
=>
Seq
(
DOUBLE
)
case
"@uvm.tr64.to_int"
=>
Seq
(
I52
)
case
"@uvm.tr64.to_ref"
=>
Seq
(
REF_VOID
)
case
"@uvm.tr64.to_tag"
=>
Seq
(
I6
)
case
"@uvm.futex.wait"
=>
Seq
(
I32
)
case
"@uvm.futex.wait_timeout"
=>
Seq
(
I32
)
case
"@uvm.futex.wake"
=>
Seq
(
I32
)
case
"@uvm.futex.cmp_requeue"
=>
Seq
(
I32
)
case
"@uvm.kill_dependency"
=>
Seq
(
i
.
typeList
(
0
))
case
"@uvm.futex.wake"
=>
Seq
(
I32
)
case
"@uvm.futex.cmp_requeue"
=>
Seq
(
I32
)
case
"@uvm.kill_dependency"
=>
Seq
(
i
.
typeList
(
0
))
case
"@uvm.native.pin"
=>
i
.
typeList
(
0
)
match
{
case
TypeRef
(
t
)
=>
Seq
(
ptrOf
(
t
))
case
TypeRef
(
t
)
=>
Seq
(
ptrOf
(
t
))
case
TypeIRef
(
t
)
=>
Seq
(
ptrOf
(
t
))
}
case
"@uvm.native.unpin"
=>
Seq
()
case
"@uvm.native.expose"
=>
Seq
(
funcPtrOf
(
i
.
funcSigList
(
0
)))
case
"@uvm.native.unexpose"
=>
Seq
()
case
"@uvm.native.get_cookie"
=>
Seq
(
I64
)
case
"@uvm.native.unpin"
=>
Seq
()
case
"@uvm.native.expose"
=>
Seq
(
funcPtrOf
(
i
.
funcSigList
(
0
)))
case
"@uvm.native.unexpose"
=>
Seq
()
case
"@uvm.native.get_cookie"
=>
Seq
(
I64
)
case
"@uvm.meta.id_of"
=>
Seq
(
I32
)
case
"@uvm.meta.name_of"
=>
Seq
(
BYTES_R
)
case
"@uvm.meta.load_bundle"
=>
Seq
(
BYTES_R
)
case
"@uvm.meta.load_hail"
=>
Seq
(
BYTES_R
)
case
"@uvm.meta.id_of"
=>
Seq
(
I32
)
case
"@uvm.meta.name_of"
=>
Seq
(
BYTES_R
)
case
"@uvm.meta.load_bundle"
=>
Seq
(
BYTES_R
)
case
"@uvm.meta.load_hail"
=>
Seq
(
BYTES_R
)
case
"@uvm.meta.cur_func"
=>
Seq
(
I32
)
case
"@uvm.meta.cur_func_ver"
=>
Seq
(
I32
)
case
"@uvm.meta.cur_inst"
=>
Seq
(
I32
)
case
"@uvm.meta.dump_keepalives"
=>
Seq
(
REFS_R
)
case
"@uvm.meta.cur_func"
=>
Seq
(
I32
)
case
"@uvm.meta.cur_func_ver"
=>
Seq
(
I32
)
case
"@uvm.meta.cur_inst"
=>
Seq
(
I32
)
case
"@uvm.meta.dump_keepalives"
=>
Seq
(
REFS_R
)
case
"@uvm.meta.pop_frame"
=>
Seq
()
case
"@uvm.meta.push_frame"
=>
Seq
()
case
"@uvm.meta.pop_frame"
=>
Seq
()
case
"@uvm.meta.push_frame"
=>
Seq
()
case
"@uvm.meta.enable_watchpoint"
=>
Seq
()
case
"@uvm.meta.enable_watchpoint"
=>
Seq
()
case
"@uvm.meta.disable_watchpoint"
=>
Seq
()
case
"@uvm.meta.set_trap_handler"
=>
Seq
()
case
"@uvm.meta.set_trap_handler"
=>
Seq
()
}
}
}
\ No newline at end of file
src/main/scala/uvm/refimpl/itpr/CommInstExecutor.scala
View file @
694684b2
...
...
@@ -255,7 +255,7 @@ trait CommInstExecutor extends InterpreterActions with ObjectPinner {
val
Seq
(
r
)
=
argList
val
(
addr
,
offset
)
=
ty
match
{
case
TypeRef
(
_
)
=>
(
boxOf
(
r
).
asInstanceOf
[
BoxRef
].
objRef
,
0L
)
case
TypeRef
(
_
)
=>
(
boxOf
(
r
).
asInstanceOf
[
BoxRef
].
objRef
,
0L
)
case
TypeIRef
(
_
)
=>
boxOf
(
r
).
asInstanceOf
[
BoxIRef
].
oo
}
...
...
@@ -270,7 +270,7 @@ trait CommInstExecutor extends InterpreterActions with ObjectPinner {
val
Seq
(
r
)
=
argList
val
addr
=
ty
match
{
case
TypeRef
(
_
)
=>
boxOf
(
r
).
asInstanceOf
[
BoxRef
].
objRef
case
TypeRef
(
_
)
=>
boxOf
(
r
).
asInstanceOf
[
BoxRef
].
objRef
case
TypeIRef
(
_
)
=>
boxOf
(
r
).
asInstanceOf
[
BoxIRef
].
objRef
}
...
...
@@ -343,7 +343,7 @@ trait CommInstExecutor extends InterpreterActions with ObjectPinner {
continueNormally
()
}
case
"@uvm.meta.load_hail"
=>
{
val
Seq
(
hailScript
)
=
argList
val
hailStr
=
MemoryOperations
.
bytesToStr
(
boxOf
(
hailScript
).
asInstanceOf
[
BoxRef
].
objRef
)
...
...
@@ -353,6 +353,23 @@ trait CommInstExecutor extends InterpreterActions with ObjectPinner {
continueNormally
()
}
case
"@uvm.meta.cur_func"
=>
{
val
Seq
(
stack
)
=
argList
???
}
case
"@uvm.meta.cur_func_ver"
=>
???
case
"@uvm.meta.cur_inst"
=>
???
case
"@uvm.meta.dump_keepalives"
=>
???
case
"@uvm.meta.pop_frame"
=>
???
case
"@uvm.meta.push_frame"
=>
???
case
"@uvm.meta.enable_watchpoint"
=>
???
case
"@uvm.meta.disable_watchpoint"
=>
???
case
"@uvm.meta.set_trap_handler"
=>
???
// Insert more CommInsts here.
case
ciName
=>
{
...
...
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
View file @
694684b2
...
...
@@ -40,7 +40,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
htr
match
{
case
HowToResume
.
PassValues
(
values
)
=>
rebindPassValues
(
initialStack
,
values
)
case
HowToResume
.
ThrowExc
(
exc
)
=>
catchException
(
exc
)
case
HowToResume
.
ThrowExc
(
exc
)
=>
catchException
(
exc
)
}
}
...
...
@@ -87,7 +87,7 @@ trait InterpreterThreadState {
protected
def
ctx
=
stack
match
{
case
None
=>
"(Thred not bound to stack): "
case
Some
(
s
)
=>
s
.
top
match
{
case
f
:
NativeFrame
=>
"TID %d, Native frame for function 0x%x: "
.
format
(
id
,
f
.
func
)
case
f
:
NativeFrame
=>
"TID %d, Native frame for function 0x%x: "
.
format
(
id
,
f
.
func
)
case
f
:
UndefinedMuFrame
=>
"TID %d, Function %s (not defined): "
.
format
(
id
,
f
.
func
.
repr
)
case
f
:
DefinedMuFrame
=>
{
val
ix
=
f
.
curInstIndex
...
...
@@ -96,7 +96,7 @@ trait InterpreterThreadState {
}
else
{
"TID %d, FuncVer %s, BB %s, Inst(%d): %s (%s): "
.
format
(
id
,
f
.
funcVer
.
repr
,
curBB
.
repr
,
ix
,
curInst
.
repr
,
curInst
match
{
case
ci
:
InstCommInst
=>
ci
.
inst
.
name
.
get
case
_
=>
curInst
.
getClass
.
getSimpleName
()
case
_
=>
curInst
.
getClass
.
getSimpleName
()
})
}
}
...
...
@@ -106,7 +106,7 @@ trait InterpreterThreadState {
/** Get the value box of an SSA variable in the current stack. */
protected
def
boxOf
(
v
:
SSAVariable
)
:
ValueBox
=
v
match
{
case
g
:
GlobalVariable
=>
microVM
.
constantPool
.
getGlobalVarBox
(
g
)
case
l
:
LocalVariable
=>
topDefMu
.
boxes
(
l
)
case
l
:
LocalVariable
=>
topDefMu
.
boxes
(
l
)
}
/** Get the edge-assigned value box of an edge-assigned instruction in the current stack. */
...
...
@@ -165,7 +165,7 @@ trait InterpreterActions extends InterpreterThreadState {
topMu
.
justCreated
=
false
topMu
match
{
case
f
:
DefinedMuFrame
=>
interpretCurrentInstruction
()
case
f
:
DefinedMuFrame
=>
interpretCurrentInstruction
()
case
f
:
UndefinedMuFrame
=>
executeUndefinedMuFrame
()
}
}
...
...
@@ -176,11 +176,11 @@ trait InterpreterActions extends InterpreterThreadState {
assert
(
f
.
virtInst
!=
UndefinedMuFrame
.
VIRT_INST_NOT_STARTED
)
f
.
virtInst
match
{
case
UndefinedMuFrame
.
VIRT_INST_TRAP
=>
{
logger
.
debug
(
ctx
+
"Executing virtual trap"
)
logger
.
debug
(
ctx
+
"Executing virtual trap"
)
doTrap
(
Seq
(),
0
)
}
case
UndefinedMuFrame
.
VIRT_INST_TAILCALL
=>
{
logger
.
debug
(
ctx
+
"Executing virtual tail-call"
)
logger
.
debug
(
ctx
+
"Executing virtual tail-call"
)
val
calleeFunc
=
f
.
func
val
argBoxes
=
f
.
boxes
...
...
@@ -281,7 +281,7 @@ trait InterpreterActions extends InterpreterThreadState {
maybeDestClause
match
{
case
Some
(
dc
)
=>
(
f
,
dc
)
case
None
=>
f
.
prev
match
{
case
None
=>
throw
new
UvmRuntimeException
(
ctx
+
"Exception is thrown out of the bottom frame."
)
case
None
=>
throw
new
UvmRuntimeException
(
ctx
+
"Exception is thrown out of the bottom frame."
)
case
Some
(
prev
)
=>
unwindUntilCatchable
(
prev
)
}
...
...
@@ -312,10 +312,10 @@ trait InterpreterActions extends InterpreterThreadState {
*/
protected
def
maybeFindExceptionHandler
(
inst
:
Instruction
)
:
Option
[
DestClause
]
=
{
inst
match
{
case
i
:
InstCall
=>
i
.
excClause
.
map
(
_
.
exc
)
case
i
:
InstTrap
=>
i
.
excClause
.
map
(
_
.
exc
)
case
i
:
InstCall
=>
i
.
excClause
.
map
(
_
.
exc
)
case
i
:
InstTrap
=>
i
.
excClause
.
map
(
_
.
exc
)
case
i
:
InstWatchPoint
=>
i
.
exc
case
i
:
InstSwapStack
=>
i
.
excClause
.
map
(
_
.
exc
)
case
i
:
InstSwapStack
=>
i
.
excClause
.
map
(
_
.
exc
)
case
_
=>
{
throw
new
UvmRefImplException
(
ctx
+
"Non-OSR point instruction %s (%s) is in a stack frame when an exception is thrown."
.
format
(
inst
.
repr
,
inst
.
getClass
.
getName
))
}
...
...
@@ -447,7 +447,7 @@ trait InterpreterActions extends InterpreterThreadState {
*/
protected
def
branchToExcDestOr
(
excClause
:
Option
[
ExcClause
])(
f
:
=>
Unit
)
:
Unit
=
{
excClause
match
{
case
None
=>
f
case
None
=>
f
case
Some
(
ExcClause
(
_
,
excBB
))
=>
branchTo
(
excBB
)
}
}
...
...
@@ -486,5 +486,20 @@ trait InterpreterActions extends InterpreterThreadState {
throw
new
UvmRuntimeException
(
ctx
+
"Accessing null reference."
)
}
}
import
MagicalBox.MagicalBox
implicit
protected
def
ssaVariableToMagicalBox
(
v
:
SSAVariable
)
=
new
MagicalBox
(
boxOf
(
v
))
implicit
protected
def
boxToMagicalBox
(
b
:
ValueBox
)
=
new
MagicalBox
(
b
)
}
object
MagicalBox
{
implicit
class
MagicalBox
(
val
box
:
ValueBox
)
extends
AnyVal
{
def
getIntRaw
()
:
BigInt
=
box
.
asInstanceOf
[
BoxInt
].
value
def
setIntRaw
(
v
:
BigInt
)
:
Unit
=
box
.
asInstanceOf
[
BoxInt
].
value
=
v
def
getSInt
(
len
:
Int
)
:
BigInt
=
OpHelper
.
prepareSigned
(
box
.
getIntRaw
(),
len
)
def
getUInt
(
len
:
Int
)
:
BigInt
=
OpHelper
.
prepareUnsigned
(
box
.
getIntRaw
(),
len
)
def
setInt
(
v
:
BigInt
,
len
:
Int
)
:
Unit
=
box
.
setIntRaw
(
OpHelper
.
unprepare
(
v
,
len
))
}
}
\ No newline at end of file
src/main/scala/uvm/refimpl/itpr/operationHelpers.scala
View file @
694684b2
...
...
@@ -32,6 +32,11 @@ object OpHelper {
}
}
// The BigInt in a BoxInt is always truncated to len bits.
//
// "prepare" means sign- or zero-extend the content to get the real math value.
// "unprepare" means truncating a math value to len bits to be stored in a BoxInt.
def
prepareUnsigned
(
n
:
BigInt
,
len
:
Int
)
:
BigInt
=
truncFromBigInt
(
n
,
len
)
def
prepareSigned
(
n
:
BigInt
,
len
:
Int
)
:
BigInt
=
{
...
...
src/test/scala/uvm/ir/textinput/ExtraMatchers.scala
View file @
694684b2
...
...
@@ -9,7 +9,22 @@ import uvm.ssavariables._
import
uvm.comminsts._
trait
ExtraMatchers
extends
Assertions
with
Matchers
{
implicit
class
AnythingExtraMatchers
(
val
thing
:
Any
)
{
import
ExtraMatchers._
implicit
def
anythingToAnythingExtraMatcher
[
U
](
thing
:
U
)
=
new
AnythingExtraMatchers
(
thing
)
val
thatsIt
=
{
f
:
Any
=>
}
case
object
nan
case
class
ExactFloat
(
num
:
Float
)
case
class
ExactDouble
(
num
:
Double
)
def
exactly
(
num
:
Float
)
=
ExactFloat
(
num
)
def
exactly
(
num
:
Double
)
=
ExactDouble
(
num
)
def
bitsf
(
num
:
Int
)
=
java
.
lang
.
Float
.
intBitsToFloat
(
num
)
def
bitsd
(
num
:
Long
)
=
java
.
lang
.
Double
.
longBitsToDouble
(
num
)
}
object
ExtraMatchers
extends
ExtraMatchers
{
implicit
class
AnythingExtraMatchers
[
U
](
val
thing
:
U
)
extends
AnyVal
{
def
shouldBeA
[
T:
ClassTag
](
f
:
T
=>
Unit
)
:
Unit
=
{
val
ct
=
classTag
[
T
]
if
(!
ct
.
runtimeClass
.
isAssignableFrom
(
thing
.
getClass
))
{
...
...
@@ -54,17 +69,4 @@ trait ExtraMatchers extends Assertions with Matchers {
}
}
val
thatsIt
=
{
f
:
Any
=>
}
case
object
nan
case
class
ExactFloat
(
num
:
Float
)
case
class
ExactDouble
(
num
:
Double
)
def
exactly
(
num
:
Float
)
=
ExactFloat
(
num
)
def
exactly
(
num
:
Double
)
=
ExactDouble
(
num
)
def
bitsf
(
num
:
Int
)
=
java
.
lang
.
Float
.
intBitsToFloat
(
num
)
def
bitsd
(
num
:
Long
)
=
java
.
lang
.
Double
.
longBitsToDouble
(
num
)
}
object
ExtraMatchers
{
}
\ No newline at end of file
src/test/scala/uvm/ir/textinput/TestingBundlesValidators.scala
View file @
694684b2
...
...
@@ -7,13 +7,12 @@ import uvm.comminsts._
import
uvm.ssavariables._
import
uvm.types._
trait
TestingBundlesValidators
extends
Matchers
with
ExtraMatchers
{
implicit
class
RichStringContext
(
sc
:
StringContext
)
{
object
TestingBundlesValidators
{
implicit
class
RichStringContext
(
val
sc
:
StringContext
)
extends
AnyVal
{
def
qw
()
:
Seq
[
String
]
=
sc
.
parts
(
0
).
split
(
"\\s+"
)
}
implicit
class
MagicalOur
(
b
:
Bundle
)
{
implicit
class
MagicalOur
(
val
b
:
Bundle
)
extends
AnyVal
{
def
anything
(
s
:
String
)
=
b
.
allNs
(
s
)
def
ty
(
s
:
String
)
=
b
.
typeNs
(
s
)
def
const
(
s
:
String
)
=
b
.
constantNs
(
s
)
...
...
@@ -27,18 +26,22 @@ trait TestingBundlesValidators extends Matchers with ExtraMatchers {
def
inst
(
s
:
String
)
=
b
.
instNs
(
s
)
}
implicit
class
MagicalThe
(
c
:
FuncVer
)
{
implicit
class
MagicalThe
(
val
c
:
FuncVer
)
extends
AnyVal
{
def
globalName
(
s
:
String
)
=
UIRTextReader
.
globalize
(
s
,
c
.
name
.
get
)
def
bb
(
s
:
String
)
=
c
.
bbNs
(
UIRTextReader
.
globalize
(
s
,
c
.
name
.
get
))
}
implicit
class
MagicalMy
(
d
:
BasicBlock
)
{
implicit
class
MagicalMy
(
val
d
:
BasicBlock
)
extends
AnyVal
{
def
globalName
(
s
:
String
)
=
UIRTextReader
.
globalize
(
s
,
d
.
name
.
get
)
def
value
(
s
:
String
)
=
d
.
localVarNs
(
UIRTextReader
.
globalize
(
s
,
d
.
name
.
get
))
def
param
(
s
:
String
)
=
d
.
localVarNs
(
UIRTextReader
.
globalize
(
s
,
d
.
name
.
get
))
def
ires
(
s
:
String
)
=
d
.
localVarNs
(
UIRTextReader
.
globalize
(
s
,
d
.
name
.
get
))
def
inst
(
s
:
String
)
=
d
.
localInstNs
(
UIRTextReader
.
globalize
(
s
,
d
.
name
.
get
))
}
}
trait
TestingBundlesValidators
extends
Matchers
with
ExtraMatchers
{
import
TestingBundlesValidators._
def
validateTypes
(
bundle
:
GlobalBundle
)
{
val
our
=
bundle
...
...
src/test/scala/uvm/refimpl/UvmBundleTesterBase.scala
View file @
694684b2
...
...
@@ -19,6 +19,26 @@ import uvm.refimpl.HowToResume.PassValues
object
UvmBundleTesterBase
{
val
logger
=
Logger
(
LoggerFactory
.
getLogger
(
getClass
.
getName
))
implicit
class
MagicalBox
(
val
vb
:
ValueBox
)
extends
AnyVal
{
def
asInt
:
BigInt
=
vb
.
asInstanceOf
[
BoxInt
].
value
def
asSInt
(
l
:
Int
)
:
BigInt
=
OpHelper
.
prepareSigned
(
vb
.
asInstanceOf
[
BoxInt
].
value
,
l
)
def
asUInt
(
l
:
Int
)
:
BigInt
=
OpHelper
.
prepareUnsigned
(
vb
.
asInstanceOf
[
BoxInt
].
value
,
l
)
def
asFloat
:
Float
=
vb
.
asInstanceOf
[
BoxFloat
].
value
def
asDouble
:
Double
=
vb
.
asInstanceOf
[
BoxDouble
].
value
def
asRef
:
Word
=
vb
.
asInstanceOf
[
BoxRef
].
objRef
def
asIRef
:
(
Word
,
Word
)
=
{
val
b
=
vb
.
asInstanceOf
[
BoxIRef
];
(
b
.
objRef
,
b
.
offset
)
}
def
asIRefAddr
:
Word
=
{
val
b
=
vb
.
asInstanceOf
[
BoxIRef
];
b
.
objRef
+
b
.
offset
}
def
asStruct
:
Seq
[
ValueBox
]
=
vb
.
asInstanceOf
[
BoxSeq
].
values
def
asFunc
:
Option
[
Function
]
=
vb
.
asInstanceOf
[
BoxFunc
].
func
def
asThread
:
Option
[
InterpreterThread
]
=
vb
.
asInstanceOf
[
BoxThread
].
thread
def
asStack
:
Option
[
InterpreterStack
]
=
vb
.
asInstanceOf
[
BoxStack
].
stack
def
asTR64Box
:
BoxTagRef64
=
vb
.
asInstanceOf
[
BoxTagRef64
]
def
asTR64Raw
:
Long
=
vb
.
asInstanceOf
[
BoxTagRef64
].
raw
def
asSeq
:
Seq
[
ValueBox
]
=
vb
.
asInstanceOf
[
BoxSeq
].
values
def
asVec
:
Seq
[
ValueBox
]
=
vb
.
asInstanceOf
[
BoxSeq
].
values
def
asPointer
:
Word
=
vb
.
asInstanceOf
[
BoxPointer
].
addr
}
}
abstract
class
UvmBundleTesterBase
extends
FlatSpec
with
Matchers
{
...
...
@@ -72,30 +92,13 @@ abstract class UvmBundleTesterBase extends FlatSpec with Matchers {
val
hThread
=
ctx
.
newThread
(
hStack
,
HowToResume
.
PassValues
(
args
))
microVM
.
execute
()
}
import
UvmBundleTesterBase._
implicit
def
magicalMuValue
(
mv
:
MuValue
)
:
MagicalBox
=
MagicalBox
(
mv
.
vb
)
implicit
def
magicalValueBox
(
vb
:
ValueBox
)
:
MagicalBox
=
MagicalBox
(
vb
)
implicit
class
MagicalBox
(
vb
:
ValueBox
)
{
def
asInt
:
BigInt
=
vb
.
asInstanceOf
[
BoxInt
].
value
def
asSInt
(
l
:
Int
)
:
BigInt
=
OpHelper
.
prepareSigned
(
vb
.
asInstanceOf
[
BoxInt
].
value
,
l
)
def
asUInt
(
l
:
Int
)
:
BigInt
=
OpHelper
.
prepareUnsigned
(
vb
.
asInstanceOf
[
BoxInt
].
value
,
l
)
def
asFloat
:
Float
=
vb
.
asInstanceOf
[
BoxFloat
].
value
def
asDouble
:
Double
=
vb
.
asInstanceOf
[
BoxDouble
].
value
def
asRef
:
Word
=
vb
.
asInstanceOf
[
BoxRef
].
objRef
def
asIRef
:
(
Word
,
Word
)
=
{
val
b
=
vb
.
asInstanceOf
[
BoxIRef
];
(
b
.
objRef
,
b
.
offset
)
}
def
asIRefAddr
:
Word
=
{
val
b
=
vb
.
asInstanceOf
[
BoxIRef
];
b
.
objRef
+
b
.
offset
}
def
asStruct
:
Seq
[
ValueBox
]
=
vb
.
asInstanceOf
[
BoxSeq
].
values
def
asFunc
:
Option
[
Function
]
=
vb
.
asInstanceOf
[
BoxFunc
].
func
def
asThread
:
Option
[
InterpreterThread
]
=
vb
.
asInstanceOf
[
BoxThread
].
thread
def
asStack
:
Option
[
InterpreterStack
]
=
vb
.
asInstanceOf
[
BoxStack
].
stack
def
asTR64Box
:
BoxTagRef64
=
vb
.
asInstanceOf
[
BoxTagRef64
]
def
asTR64Raw
:
Long
=
vb
.
asInstanceOf
[
BoxTagRef64
].
raw
def
asSeq
:
Seq
[
ValueBox
]
=
vb
.
asInstanceOf
[
BoxSeq
].
values
def
asVec
:
Seq
[
ValueBox
]
=
vb
.
asInstanceOf
[
BoxSeq
].
values
def
asPointer
:
Word
=
vb
.
asInstanceOf
[
BoxPointer
].
addr
}
implicit
def
richMuCtx
(
ctx
:
MuCtx
)
=
RichMuCtx
.
RichMuCtx
(
ctx
)
def
returnFromTrap
(
st
:
MuStackRefValue
)
=
Rebind
(
st
,
PassValues
(
Seq
()))
}
\ No newline at end of file
}
src/test/scala/uvm/refimpl/itpr/UvmInterpreterNativeTestsExtra.scala
View file @
694684b2
...
...
@@ -41,7 +41,7 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
val
a0
=
ctx
.
handleFromInt64
(
funcAddr
)
testFunc
(
ctx
,
func
,
Seq
(
a0
))
{
(
ctx
,
th
,
st
,
wp
)
=>
val
Seq
(
fp
,
rv
,
a
,
b
,
c
,
d
)
=
ctx
.
dumpKeepalives
(
st
,
0
)
val
Seq
(
fp
,
a
,
b
,
c
,
d
)
=
ctx
.
dumpKeepalives
(
st
,
0
)
fp
.
vb
.
asPointer
shouldEqual
funcAddr
...
...
@@ -69,7 +69,7 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
val
a0
=
ctx
.
handleFromInt64
(
funcAddr
)
testFunc
(
ctx
,
func
,
Seq
(
a0
))
{
(
ctx
,
th
,
st
,
wp
)
=>
val
Seq
(
fp
,
rv
,
a
,
b
)
=
ctx
.
dumpKeepalives
(
st
,
0
)
val
Seq
(
fp
,
a
,
b
)
=
ctx
.
dumpKeepalives
(
st
,
0
)
fp
.
vb
.
asPointer
shouldEqual
funcAddr
...
...
tests/uvm-refimpl-test/futex-tests.uir
View file @
694684b2
...
...
@@ -90,9 +90,6 @@
COMMINST @uvm.thread_exit
}
.typedef @refi32 = ref<@i32>
.typedef @irefi32 = iref<@i32>
.funcsig @futex_gc_waiter_sig = (@refi32) -> ()
.funcdef @futex_gc_waiter VERSION @futex_gc_waiter_v1 <@futex_gc_waiter_sig> {
%entry(<@refi32> %ref):
...
...
tests/uvm-refimpl-test/native-tests.uir
View file @
694684b2
...
...
@@ -25,7 +25,7 @@
.const @I8_o <@i8> = 0x6f
.const @I8_NL <@i8> = 0x0a
.funcsig @writetest_sig = (@write_fp) -> (
@void
)
.funcsig @writetest_sig = (@write_fp) -> ()
.funcdef @writetest VERSION @writetest_v1 <@writetest_sig> {