< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java

Print this page




  30 import sun.jvm.hotspot.runtime.*;
  31 import sun.jvm.hotspot.types.*;
  32 import sun.jvm.hotspot.utilities.*;
  33 
  34 public class DataLayout {
  35   public static final int noTag = 0;
  36   public static final int bitDataTag = 1;
  37   public static final int counterDataTag = 2;
  38   public static final int jumpDataTag= 3;
  39   public static final int receiverTypeDataTag = 4;
  40   public static final int virtualCallDataTag = 5;
  41   public static final int retDataTag = 6;
  42   public static final int branchDataTag = 7;
  43   public static final int multiBranchDataTag = 8;
  44   public static final int argInfoDataTag = 9;
  45   public static final int callTypeDataTag = 10;
  46   public static final int virtualCallTypeDataTag = 11;
  47   public static final int parametersTypeDataTag = 12;
  48   public static final int speculativeTrapDataTag = 13;
  49 
  50   // The _struct._flags word is formatted as [trapState:4 | flags:4].
  51   // The trap state breaks down further as [recompile:1 | reason:3].
  52   // This further breakdown is defined in deoptimization.cpp.
  53   // See Deoptimization.trapStateReason for an assert that
  54   // trapBits is big enough to hold reasons < reasonRecordedLimit.
  55   //
  56   // The trapState is collected only if ProfileTraps is true.
  57   public static final int trapBits = 1+3;  // 3: enough to distinguish [0..reasonRecordedLimit].
  58   public static final int trapShift = 8 - trapBits;
  59   public static final int trapMask = Bits.rightNBits(trapBits);
  60   public static final int trapMaskInPlace = (trapMask << trapShift);
  61   public static final int flagLimit = trapShift;
  62   public static final int flagMask = Bits.rightNBits(flagLimit);
  63   public static final int firstFlag = 0;
  64 
  65   private Address data;
  66 
  67   private int offset;
  68 
  69   public DataLayout(MethodData d, int o) {
  70     data = d.getAddress();
  71     offset = o;
  72   }
  73 
  74   public DataLayout(Address d, int o) {
  75     data = d;
  76     offset = o;
  77   }
  78 
  79   public int dp() { return offset; }
  80 
  81   private int getU11(int at) {
  82     return data.getJByteAt(offset + at) & 0xff;
  83   }
  84 
  85   private int getU22(int at) {
  86     return data.getJShortAt(offset + at) & 0xffff;
  87   }
  88 
  89   int cellAt(int index) {
  90     // Cells are intptr_t sized but only contain ints as raw values
  91     return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false);
  92   }
  93 
  94   public Address addressAt(int index) {
  95     return data.getAddressAt(offset + cellOffset(index));
  96   }
  97 
  98   // Every data layout begins with a header.  This header
  99   // contains a tag, which is used to indicate the size/layout
 100   // of the data, 4 bits of flags, which can be used in any way,
 101   // 4 bits of trap history (none/one reason/many reasons),
 102   // and a bci, which is used to tie this piece of data to a
 103   // specific bci in the bytecodes.
 104   // union {
 105   //   intptrT _bits;
 106   //   struct {
 107   //     u1 _tag;
 108   //     u1 _flags;
 109   //     u2 _bci;

 110   //   } _struct;
 111   // } _header;
 112 
 113   // Some types of data layouts need a length field.
 114   static boolean needsArrayLen(int tag) {
 115     return (tag == multiBranchDataTag);
 116   }
 117 
 118   public static final int counterIncrement = 1;
 119 
 120   // Size computation
 121   static int headerSizeInBytes() {
 122     return MethodData.cellSize;
 123   }
 124   static int headerSizeInCells() {
 125     return 1;
 126   }
 127 
 128   static public int computeSizeInBytes(int cellCount) {
 129     return headerSizeInBytes() + cellCount * MethodData.cellSize;
 130   }
 131 
 132   // Initialization
 133   // void initialize(int tag, int bci, int cellCount);
 134 
 135   // Accessors
 136   public int tag() {
 137     return getU11(0);
 138   }
 139 
 140   // Return a few bits of trap state.  Range is [0..trapMask].
 141   // The state tells if traps with zero, one, or many reasons have occurred.
 142   // It also tells whether zero or many recompilations have occurred.
 143   // The associated trap histogram in the MDO itself tells whether
 144   // traps are common or not.  If a BCI shows that a trap X has
 145   // occurred, and the MDO shows N occurrences of X, we make the
 146   // simplifying assumption that all N occurrences can be blamed
 147   // on that BCI.
 148   int trapState() {
 149     return (flags() >> trapShift) & trapMask;
 150   }
 151 
 152   int flags() {
 153     return getU11(1);
 154   }
 155 
 156   int bci() {
 157     return getU22(2);
 158   }
 159 
 160   boolean flagAt(int flagNumber) {
 161     // assert(flagNumber < flagLimit, "oob");
 162     return (flags() & (0x1 << flagNumber)) != 0;
 163   }
 164 
 165   // Low-level support for code generation.
 166   static int headerOffset() {
 167     return 0;
 168   }
 169   static int tagOffset() {




  30 import sun.jvm.hotspot.runtime.*;
  31 import sun.jvm.hotspot.types.*;
  32 import sun.jvm.hotspot.utilities.*;
  33 
  34 public class DataLayout {
  35   public static final int noTag = 0;
  36   public static final int bitDataTag = 1;
  37   public static final int counterDataTag = 2;
  38   public static final int jumpDataTag= 3;
  39   public static final int receiverTypeDataTag = 4;
  40   public static final int virtualCallDataTag = 5;
  41   public static final int retDataTag = 6;
  42   public static final int branchDataTag = 7;
  43   public static final int multiBranchDataTag = 8;
  44   public static final int argInfoDataTag = 9;
  45   public static final int callTypeDataTag = 10;
  46   public static final int virtualCallTypeDataTag = 11;
  47   public static final int parametersTypeDataTag = 12;
  48   public static final int speculativeTrapDataTag = 13;
  49 
  50   // The trap state breaks down as [recompile:1 | reason:31].

  51   // This further breakdown is defined in deoptimization.cpp.
  52   // See Deoptimization.trapStateReason for an assert that
  53   // trapBits is big enough to hold reasons < reasonRecordedLimit.
  54   //
  55   // The trapState is collected only if ProfileTraps is true.
  56   public static final int trapBits = 1+31;  // 31: enough to distinguish [0..reasonRecordedLimit].

  57   public static final int trapMask = Bits.rightNBits(trapBits);



  58   public static final int firstFlag = 0;
  59 
  60   private Address data;
  61 
  62   private int offset;
  63 
  64   public DataLayout(MethodData d, int o) {
  65     data = d.getAddress();
  66     offset = o;
  67   }
  68 
  69   public DataLayout(Address d, int o) {
  70     data = d;
  71     offset = o;
  72   }
  73 
  74   public int dp() { return offset; }
  75 
  76   private int getU11(int at) {
  77     return data.getJByteAt(offset + at) & 0xff;
  78   }
  79 
  80   private int getU22(int at) {
  81     return data.getJShortAt(offset + at) & 0xffff;
  82   }
  83 
  84   int cellAt(int index) {
  85     // Cells are intptr_t sized but only contain ints as raw values
  86     return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false);
  87   }
  88 
  89   public Address addressAt(int index) {
  90     return data.getAddressAt(offset + cellOffset(index));
  91   }
  92 
  93   // Every data layout begins with a header.  This header
  94   // contains a tag, which is used to indicate the size/layout
  95   // of the data, 8 bits of flags, which can be used in any way,
  96   // 32 bits of trap history (none/one reason/many reasons),
  97   // and a bci, which is used to tie this piece of data to a
  98   // specific bci in the bytecodes.
  99   // union {
 100   //   u8 _bits;
 101   //   struct {
 102   //     u1 _tag;
 103   //     u1 _flags;
 104   //     u2 _bci;
 105   //     u4 _traps;
 106   //   } _struct;
 107   // } _header;
 108 
 109   // Some types of data layouts need a length field.
 110   static boolean needsArrayLen(int tag) {
 111     return (tag == multiBranchDataTag);
 112   }
 113 
 114   public static final int counterIncrement = 1;
 115 
 116   // Size computation
 117   static int headerSizeInBytes() {
 118     return MethodData.cellSize * headerSizeInCells();
 119   }
 120   static int headerSizeInCells() {
 121       return VM.getVM().isLP64() ? 1 : 2;
 122   }
 123 
 124   static public int computeSizeInBytes(int cellCount) {
 125     return headerSizeInBytes() + cellCount * MethodData.cellSize;
 126   }
 127 
 128   // Initialization
 129   // void initialize(int tag, int bci, int cellCount);
 130 
 131   // Accessors
 132   public int tag() {
 133     return getU11(0);
 134   }
 135 
 136   // Return a few bits of trap state.  Range is [0..trapMask].
 137   // The state tells if traps with zero, one, or many reasons have occurred.
 138   // It also tells whether zero or many recompilations have occurred.
 139   // The associated trap histogram in the MDO itself tells whether
 140   // traps are common or not.  If a BCI shows that a trap X has
 141   // occurred, and the MDO shows N occurrences of X, we make the
 142   // simplifying assumption that all N occurrences can be blamed
 143   // on that BCI.
 144   int trapState() {
 145     return data.getJIntAt(offset+4);
 146   }
 147 
 148   int flags() {
 149     return getU11(1);
 150   }
 151 
 152   int bci() {
 153     return getU22(2);
 154   }
 155 
 156   boolean flagAt(int flagNumber) {
 157     // assert(flagNumber < flagLimit, "oob");
 158     return (flags() & (0x1 << flagNumber)) != 0;
 159   }
 160 
 161   // Low-level support for code generation.
 162   static int headerOffset() {
 163     return 0;
 164   }
 165   static int tagOffset() {


< prev index next >