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.

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

MicroVM.scala 1.47 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package uvm.refimpl

import uvm._
import uvm.refimpl.itpr._
import uvm.refimpl.mem._
import uvm.refimpl.mem.TypeSizes.Word
import scala.collection.mutable.HashSet
import uvm.ir.textinput.UIRTextReader
import uvm.ir.textinput.IDFactory

object MicroVM {
  val DEFAULT_HEAP_SIZE: Word = 4L * 1024L * 1024L; // 4MiB
  val DEFAULT_GLOBAL_SIZE: Word = 1L * 1024L * 1024L; // 1MiB
  val DEFAULT_STACK_SIZE: Word = 63L * 1024L; // 60KiB per stack
}

class MicroVM(heapSize: Word = MicroVM.DEFAULT_HEAP_SIZE,
  globalSize: Word = MicroVM.DEFAULT_GLOBAL_SIZE,
  stackSize: Word = MicroVM.DEFAULT_STACK_SIZE) {

  val globalBundle = new Bundle()
  val constantPool = new ConstantPool(this)
  val memoryManager = new MemoryManager(heapSize, globalSize, stackSize, this)
  //val threadStackManager = new ThreadStackManager(this)
  //val trapManager = new TrapManager(this)
  val clientAgents = new HashSet[ClientAgent]()
  
  val irReader = new UIRTextReader(new IDFactory())

  /**
   * Add things from a bundle to the Micro VM.
   */
  def addBundle(bundle: Bundle) {
    globalBundle.merge(bundle);

    for (gc <- bundle.globalCellNs.all) {
      memoryManager.globalMemory.addGlobalCell(gc)
    }
    for (g <- bundle.globalVarNs.all) {
      constantPool.addGlobalVar(g)
    }
  }
  
  def newClientAgent(): ClientAgent = new ClientAgent(this)

  def addClientAgent(ca: ClientAgent): Unit = {
    clientAgents.add(ca)
  }
  
  def removeClientAgent(ca: ClientAgent): Unit = {
    clientAgents.remove(ca)
  }
}