To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

HeaderUtils.scala 1.24 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
package uvm.refimpl.mem

import uvm.types.Type
import uvm.refimpl.MicroVM
import uvm.refimpl.mem.TypeSizes.Word
import com.typesafe.scalalogging._
import org.slf4j.LoggerFactory

object HeaderUtils extends StrictLogging {

Kunshan Wang's avatar
Kunshan Wang committed
11
  def postAllocScalar(addr: Word, tag: Word) {
12
13
14
    setTag(addr, tag)
  }

Kunshan Wang's avatar
Kunshan Wang committed
15
  def postAllocHybrid(addr: Word, tag: Word, len: Word) {
16
17
18
19
    postAllocScalar(addr, tag)
    setVarLength(addr, len)
  }

Kunshan Wang's avatar
Kunshan Wang committed
20
  def getTag(objRef: Word): Word = {
21
22
23
    MemorySupport.loadLong(objRef + TypeSizes.GC_HEADER_OFFSET_TAG)
  }

Kunshan Wang's avatar
Kunshan Wang committed
24
  def getVarLength(objRef: Word): Word = {
25
26
27
    MemorySupport.loadLong(objRef + TypeSizes.GC_HEADER_OFFSET_HYBRID_LENGTH)
  }

Kunshan Wang's avatar
Kunshan Wang committed
28
  def setTag(objRef: Word, tag: Word) {
29
30
31
32
    logger.debug(s"Storing tag ${tag} at addr ${TypeSizes.GC_HEADER_OFFSET_TAG}")
    MemorySupport.storeLong(objRef + TypeSizes.GC_HEADER_OFFSET_TAG, tag)
  }

Kunshan Wang's avatar
Kunshan Wang committed
33
  def setVarLength(objRef: Word, len: Word) {
34
35
36
    MemorySupport.storeLong(objRef + TypeSizes.GC_HEADER_OFFSET_HYBRID_LENGTH, len)
  }

Kunshan Wang's avatar
Kunshan Wang committed
37
  def getTypeID(tag: Word): Int = (tag & 0x00000000ffffffffL).toInt
38

Kunshan Wang's avatar
Kunshan Wang committed
39
  def getType(microVM: MicroVM, tag: Word): Type = {
40
41
42
43
    val typeID = getTypeID(tag)
    microVM.globalBundle.typeNs(typeID)
  }

Kunshan Wang's avatar
Kunshan Wang committed
44
  def getForwardedDest(oldHeader: Word): Word = oldHeader & 0x0000ffffffffffffL
45
}