To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

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