WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit 2bee1cff authored by Kunshan Wang's avatar Kunshan Wang
Browse files

better stats

parent 12b2d179
......@@ -21,10 +21,15 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
protected def interpretCurrentInstruction(): Unit = try {
logger.debug(ctx + "Executing instruction...")
microVM.stats.onInstExec(curInst.getClass.getSimpleName)
val statInstName = curInst.getClass.getSimpleName
microVM.stats.onInstExec(statInstName)
curInst match {
case i @ InstBinOp(op, opndTy, op1, op2, excClause) => {
val statOpName = op.toString()
microVM.stats.onInstExec(statInstName + "/" + statOpName)
def doScalar(scalarTy: Type, b1: ValueBox, b2: ValueBox, br: ValueBox): Unit = {
scalarTy match {
case TypeInt(l) => br.asIntRaw = PrimOpHelpers.intBinOp(op, l, b1.asIntRaw, b2.asIntRaw, ctx)
......@@ -55,6 +60,9 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
}
case i @ InstCmp(op, opndTy, op1, op2) => {
val statOpName = op.toString()
microVM.stats.onInstExec(statInstName + "/" + statOpName)
def doScalar(scalarTy: Type, b1: ValueBox, b2: ValueBox, br: ValueBox): Unit = {
br.asBoolean = scalarTy match {
case TypeInt(l) => PrimOpHelpers.intCmp(op, l, b1.asIntRaw, b2.asIntRaw, ctx)
......@@ -87,6 +95,9 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
}
case i @ InstConv(op, fromTy, toTy, opnd) => {
val statOpName = op.toString()
microVM.stats.onInstExec(statInstName + "/" + statOpName)
def doScalar(scalarFromTy: Type, scalarToTy: Type, bOpnd: ValueBox, br: ValueBox): Unit = {
def iToI(): Unit = (scalarFromTy, scalarToTy) match {
case (TypeInt(fl), TypeInt(tl)) => {
......
......@@ -12,13 +12,14 @@ import uvm.refimpl.mem._
import uvm.refimpl.mem.TypeSizes._
import uvm.refimpl.mem.los.LargeObjectSpace
import uvm.utils.RetryUtils._
import uvm.refimpl.MicroVM
object SimpleImmixMutator {
val logger = Logger(LoggerFactory.getLogger(getClass.getName))
}
class SimpleImmixMutator(val heap: SimpleImmixHeap, val space: SimpleImmixSpace, val los: LargeObjectSpace, name: String)(
implicit memorySupport: MemorySupport)
implicit microVM: MicroVM, memorySupport: MemorySupport)
extends Mutator(name) with Allocator {
import SimpleImmixMutator._
......@@ -50,6 +51,7 @@ class SimpleImmixMutator(val heap: SimpleImmixHeap, val space: SimpleImmixSpace,
}
override def alloc(size: Word, align: Word, headerSize: Word): Word = {
microVM.stats.onHeapAlloc(size)
logger.debug(s"alloc(${size}, ${align}, ${headerSize})")
val actualAlign = if (align < WORD_SIZE_BYTES) WORD_SIZE_BYTES else align
val result = tryRepeatedly { // Actually try at most twice.
......
......@@ -7,7 +7,9 @@ class VMStats {
var exceptionsThrown: Long = 0L
var peiCalled: Long = 0L
var allocaExecuted: Long = 0L
var bytesAllocatedHeap: Long = 0L
val heapAllocSizeMap: HashMap[Long, Long] = new HashMap()
val instExecCount: HashMap[String, Long] = new HashMap()
def onInstExec(i: String): Unit = {
......@@ -16,6 +18,14 @@ class VMStats {
instExecCount.update(i, newCount)
}
def onHeapAlloc(sz: Long): Unit = {
bytesAllocatedHeap += sz
val oldCount = heapAllocSizeMap.getOrElse(sz, 0L)
val newCount = oldCount + 1
heapAllocSizeMap.update(sz, newCount)
}
def getStatesString(): String = {
val sb = new StringBuilder()
sb ++= "Exceptions thrown: %d\n".format(exceptionsThrown)
......@@ -27,6 +37,12 @@ class VMStats {
sb ++= " %s: %d\n".format(i, c)
}
sb ++= "Bytes allocated on the heap (only small obj space): %d\n".format(bytesAllocatedHeap)
sb ++= "Heap object size : allocation count:\n"
for ((i, c) <- heapAllocSizeMap.toSeq.sortBy(_._1)) {
sb ++= " %d: %d\n".format(i, c)
}
sb.toString()
}
......
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