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
87632589
Commit
87632589
authored
Sep 07, 2016
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
run-time statistics
parent
7cdb32c6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
1 deletion
+60
-1
src/main/scala/uvm/refimpl/MicroVM.scala
src/main/scala/uvm/refimpl/MicroVM.scala
+9
-0
src/main/scala/uvm/refimpl/itpr/CommInstExecutor.scala
src/main/scala/uvm/refimpl/itpr/CommInstExecutor.scala
+3
-1
src/main/scala/uvm/refimpl/itpr/InstructionExecutor.scala
src/main/scala/uvm/refimpl/itpr/InstructionExecutor.scala
+8
-0
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
+2
-0
src/main/scala/uvm/refimpl/stat.scala
src/main/scala/uvm/refimpl/stat.scala
+38
-0
No files found.
src/main/scala/uvm/refimpl/MicroVM.scala
View file @
87632589
...
...
@@ -23,8 +23,12 @@ import uvm.staticanalysis.StaticAnalyzer
import
uvm.utils.IDFactory
import
uvm.utils.WithUtils.tryWithResource
import
uvm.refimpl.bootimg.PrimordialInfo
import
com.typesafe.scalalogging.Logger
import
org.slf4j.LoggerFactory
object
MicroVM
{
val
logger
=
Logger
(
LoggerFactory
.
getLogger
(
getClass
.
getName
))
val
DEFAULT_SOS_SIZE
:
Word
=
2L
*
1024L
*
1024L
;
// 2MiB
val
DEFAULT_LOS_SIZE
:
Word
=
2L
*
1024L
*
1024L
;
// 2MiB
val
DEFAULT_GLOBAL_SIZE
:
Word
=
1L
*
1024L
*
1024L
;
// 1MiB
...
...
@@ -57,6 +61,8 @@ object MicroVM {
class
MicroVM
private
(
val
vmConf
:
VMConf
,
val
appArgs
:
Option
[
Seq
[
String
]])
extends
IRBuilderListener
{
// implicitly injected resources
private
implicit
val
microVM
=
this
val
stats
=
new
VMStats
()
val
globalBundle
=
new
GlobalBundle
()
val
constantPool
=
new
ConstantPool
()
...
...
@@ -225,6 +231,9 @@ class MicroVM private (val vmConf: VMConf, val appArgs: Option[Seq[String]]) ext
*/
def
execute
()
:
Unit
=
{
threadStackManager
.
execute
()
MicroVM
.
logger
.
info
(
"Execution statistics:"
)
MicroVM
.
logger
.
info
(
stats
.
getStatesString
())
}
// Automatically load the boot image if provided
...
...
src/main/scala/uvm/refimpl/itpr/CommInstExecutor.scala
View file @
87632589
...
...
@@ -19,7 +19,9 @@ trait CommInstExecutor extends InterpreterActions with ObjectPinner with IRBuild
override
def
interpretCurrentCommonInstruction
()
:
Unit
=
{
assert
(
curInst
.
isInstanceOf
[
InstCommInst
])
val
InstCommInst
(
ci
,
flagList
,
typeList
,
sigList
,
argList
,
excClause
,
keepalives
)
=
curInst
microVM
.
stats
.
onInstExec
(
"InstCommInst/"
+
ci
.
name
.
get
)
if
(
ci
.
name
.
get
.
startsWith
(
"@uvm.irbuilder"
))
{
return
interpretCurrentIRBuilderCommonInstruction
()
}
...
...
src/main/scala/uvm/refimpl/itpr/InstructionExecutor.scala
View file @
87632589
...
...
@@ -20,6 +20,8 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
/** Interpret the current instruction. */
protected
def
interpretCurrentInstruction
()
:
Unit
=
try
{
logger
.
debug
(
ctx
+
"Executing instruction..."
)
microVM
.
stats
.
onInstExec
(
curInst
.
getClass
.
getSimpleName
)
curInst
match
{
case
i
@
InstBinOp
(
op
,
opndTy
,
op1
,
op2
,
excClause
)
=>
{
...
...
@@ -240,6 +242,10 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
}
val
argBoxes
=
argList
.
map
(
boxOf
)
if
(
i
.
excClause
.
isDefined
)
{
microVM
.
stats
.
peiCalled
+=
1
}
val
shouldIncrementPC
=
curStack
.
callMu
(
calleeFunc
,
argBoxes
)
if
(
shouldIncrementPC
)
{
...
...
@@ -361,6 +367,7 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
}
case
i
@
InstAlloca
(
allocTy
,
excClause
)
=>
{
microVM
.
stats
.
allocaExecuted
+=
1
handleOutOfMemory
(
excClause
)
{
val
addr
=
mutator
.
allocaScalar
(
curStack
.
stackMemory
,
allocTy
)
results
(
0
).
asIRef
=
(
0L
,
addr
)
...
...
@@ -369,6 +376,7 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
}
case
i
@
InstAllocaHybrid
(
allocTy
,
lenTy
,
length
,
excClause
)
=>
{
microVM
.
stats
.
allocaExecuted
+=
1
handleOutOfMemory
(
excClause
)
{
val
len
=
length
.
getUInt
(
lenTy
.
length
).
longValue
val
addr
=
mutator
.
allocaHybrid
(
curStack
.
stackMemory
,
allocTy
,
len
)
...
...
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
View file @
87632589
...
...
@@ -313,6 +313,8 @@ trait InterpreterActions extends InterpreterThreadState {
val
f
=
s
.
top
val
(
newFrame
,
dc
)
=
unwindUntilCatchable
(
f
)
s
.
unwindTo
(
newFrame
)
microVM
.
stats
.
exceptionsThrown
+=
1
branchTo
(
dc
,
Some
(
exc
))
}
...
...
src/main/scala/uvm/refimpl/stat.scala
0 → 100644
View file @
87632589
package
uvm.refimpl
import
scala.collection.mutable.HashMap
import
uvm.ssavariables.Instruction
class
VMStats
{
var
exceptionsThrown
:
Long
=
0L
var
peiCalled
:
Long
=
0L
var
allocaExecuted
:
Long
=
0L
val
instExecCount
:
HashMap
[
String
,
Long
]
=
new
HashMap
()
def
onInstExec
(
i
:
String
)
:
Unit
=
{
val
oldCount
=
instExecCount
.
getOrElse
(
i
,
0L
)
val
newCount
=
oldCount
+
1
instExecCount
.
update
(
i
,
newCount
)
}
def
getStatesString
()
:
String
=
{
val
sb
=
new
StringBuilder
()
sb
++=
"Exceptions thrown: %d\n"
.
format
(
exceptionsThrown
)
sb
++=
"PEI called: %d\n"
.
format
(
peiCalled
)
sb
++=
"ALLOCA and ALLOCAHYBRID executed: %d\n"
.
format
(
peiCalled
)
sb
++=
"Instructions executed:\n"
for
((
i
,
c
)
<-
instExecCount
.
toSeq
.
sortBy
(
_
.
_2
).
reverse
)
{
sb
++=
" %s: %d\n"
.
format
(
i
,
c
)
}
sb
.
toString
()
}
def
printState
()
:
Unit
=
{
print
(
getStatesString
())
}
}
\ No newline at end of file
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