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
1d8bf3c1
Commit
1d8bf3c1
authored
Sep 21, 2015
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cookie.
parent
059a77ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
+16
-1
src/main/scala/uvm/refimpl/itpr/stacks.scala
src/main/scala/uvm/refimpl/itpr/stacks.scala
+17
-6
No files found.
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
View file @
1d8bf3c1
...
...
@@ -1127,6 +1127,21 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
continueNormally
()
}
case
"@uvm.native.expose"
=>
{
???
}
case
"@uvm.native.unexpose"
=>
{
???
}
case
"@uvm.native.get_cookie"
=>
{
val
cookie
=
topMu
.
cookie
boxOf
(
i
).
asInstanceOf
[
BoxInt
].
value
=
OpHelper
.
trunc
(
cookie
,
64
)
continueNormally
()
}
// Insert more CommInsts here.
case
ciName
=>
{
...
...
@@ -1280,7 +1295,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
val
funcVer
=
getFuncDefOrTriggerCallback
(
func
)
curInstHalfExecuted
=
true
curStack
.
pushMuFrame
(
funcVer
,
args
)
curStack
.
pushMuFrame
ForCallBack
(
funcVer
,
cookie
,
args
)
}
case
NativeCallResult
.
Return
()
=>
{
continueNormally
()
...
...
src/main/scala/uvm/refimpl/itpr/stacks.scala
View file @
1d8bf3c1
...
...
@@ -28,7 +28,7 @@ class InterpreterStack(val id: Int, val stackMemory: StackMemory, stackBottomFun
def
state
=
_state
private
def
state_=
(
s
:
StackState
)
=
_state
=
s
private
var
_top
:
InterpreterFrame
=
InterpreterFrame
.
forMuFunc
(
stackBottomFunc
,
args
,
None
)
private
var
_top
:
InterpreterFrame
=
InterpreterFrame
.
forMuFunc
(
stackBottomFunc
,
0L
,
args
,
None
)
def
top
=
_top
private
def
top_=
(
f
:
InterpreterFrame
)
=
_top
=
f
...
...
@@ -54,13 +54,19 @@ class InterpreterStack(val id: Int, val stackMemory: StackMemory, stackBottomFun
def
muFrames
:
Iterator
[
MuFrame
]
=
frames
.
filter
(
_
.
isInstanceOf
[
MuFrame
]).
map
(
_
.
asInstanceOf
[
MuFrame
])
def
pushMuFrame
(
funcVer
:
FuncVer
,
args
:
Seq
[
ValueBox
])
:
Unit
=
{
val
newFrame
=
InterpreterFrame
.
forMuFunc
(
funcVer
,
args
,
Some
(
top
))
val
newFrame
=
InterpreterFrame
.
forMuFunc
(
funcVer
,
0L
,
args
,
Some
(
top
))
top
=
newFrame
top
.
savedStackPointer
=
stackMemory
.
top
}
def
pushMuFrameForCallBack
(
funcVer
:
FuncVer
,
cookie
:
Long
,
args
:
Seq
[
ValueBox
])
:
Unit
=
{
val
newFrame
=
InterpreterFrame
.
forMuFunc
(
funcVer
,
cookie
,
args
,
Some
(
top
))
top
=
newFrame
top
.
savedStackPointer
=
stackMemory
.
top
}
def
replaceTopMuFrame
(
funcVer
:
FuncVer
,
args
:
Seq
[
ValueBox
])
:
Unit
=
{
val
newFrame
=
InterpreterFrame
.
forMuFunc
(
funcVer
,
args
,
top
.
prev
)
val
newFrame
=
InterpreterFrame
.
forMuFunc
(
funcVer
,
0L
,
args
,
top
.
prev
)
stackMemory
.
rewind
(
top
.
savedStackPointer
)
top
=
newFrame
top
.
savedStackPointer
=
stackMemory
.
top
...
...
@@ -137,8 +143,8 @@ abstract class InterpreterFrame(val prev: Option[InterpreterFrame]) {
}
object
InterpreterFrame
{
def
forMuFunc
(
funcVer
:
FuncVer
,
args
:
Seq
[
ValueBox
],
prev
:
Option
[
InterpreterFrame
])
:
MuFrame
=
{
val
frm
=
new
MuFrame
(
funcVer
,
prev
)
// Bottom frame
def
forMuFunc
(
funcVer
:
FuncVer
,
cookie
:
Long
,
args
:
Seq
[
ValueBox
],
prev
:
Option
[
InterpreterFrame
])
:
MuFrame
=
{
val
frm
=
new
MuFrame
(
funcVer
,
cookie
,
prev
)
// Bottom frame
for
((
p
,
a
)
<-
(
funcVer
.
params
zip
args
))
{
frm
.
boxes
(
p
).
copyFrom
(
a
)
...
...
@@ -153,7 +159,12 @@ object InterpreterFrame {
}
}
class
MuFrame
(
val
funcVer
:
FuncVer
,
prev
:
Option
[
InterpreterFrame
])
extends
InterpreterFrame
(
prev
)
{
/**
* A Mu frame
*
* @param cookie: The cookie in the native interface. When called by another Mu function, cookie can be any value.
*/
class
MuFrame
(
val
funcVer
:
FuncVer
,
val
cookie
:
Long
,
prev
:
Option
[
InterpreterFrame
])
extends
InterpreterFrame
(
prev
)
{
val
boxes
=
new
HashMap
[
LocalVariable
,
ValueBox
]()
/** Edge-assigned instructions take values determined at look backedges */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment