45 public static final int callTypeDataTag = 10; |
45 public static final int callTypeDataTag = 10; |
46 public static final int virtualCallTypeDataTag = 11; |
46 public static final int virtualCallTypeDataTag = 11; |
47 public static final int parametersTypeDataTag = 12; |
47 public static final int parametersTypeDataTag = 12; |
48 public static final int speculativeTrapDataTag = 13; |
48 public static final int speculativeTrapDataTag = 13; |
49 |
49 |
50 // The _struct._flags word is formatted as [trapState:4 | flags:4]. |
50 // The trap state breaks down as [recompile:1 | reason:31]. |
51 // The trap state breaks down further as [recompile:1 | reason:3]. |
|
52 // This further breakdown is defined in deoptimization.cpp. |
51 // This further breakdown is defined in deoptimization.cpp. |
53 // See Deoptimization.trapStateReason for an assert that |
52 // See Deoptimization.trapStateReason for an assert that |
54 // trapBits is big enough to hold reasons < reasonRecordedLimit. |
53 // trapBits is big enough to hold reasons < reasonRecordedLimit. |
55 // |
54 // |
56 // The trapState is collected only if ProfileTraps is true. |
55 // The trapState is collected only if ProfileTraps is true. |
57 public static final int trapBits = 1+3; // 3: enough to distinguish [0..reasonRecordedLimit]. |
56 public static final int trapBits = 1+31; // 31: enough to distinguish [0..reasonRecordedLimit]. |
58 public static final int trapShift = 8 - trapBits; |
|
59 public static final int trapMask = Bits.rightNBits(trapBits); |
57 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; |
58 public static final int firstFlag = 0; |
64 |
59 |
65 private Address data; |
60 private Address data; |
66 |
61 |
67 private int offset; |
62 private int offset; |
95 return data.getAddressAt(offset + cellOffset(index)); |
90 return data.getAddressAt(offset + cellOffset(index)); |
96 } |
91 } |
97 |
92 |
98 // Every data layout begins with a header. This header |
93 // Every data layout begins with a header. This header |
99 // contains a tag, which is used to indicate the size/layout |
94 // 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, |
95 // of the data, 8 bits of flags, which can be used in any way, |
101 // 4 bits of trap history (none/one reason/many reasons), |
96 // 32 bits of trap history (none/one reason/many reasons), |
102 // and a bci, which is used to tie this piece of data to a |
97 // and a bci, which is used to tie this piece of data to a |
103 // specific bci in the bytecodes. |
98 // specific bci in the bytecodes. |
104 // union { |
99 // union { |
105 // intptrT _bits; |
100 // u8 _bits; |
106 // struct { |
101 // struct { |
107 // u1 _tag; |
102 // u1 _tag; |
108 // u1 _flags; |
103 // u1 _flags; |
109 // u2 _bci; |
104 // u2 _bci; |
|
105 // u4 _traps; |
110 // } _struct; |
106 // } _struct; |
111 // } _header; |
107 // } _header; |
112 |
108 |
113 // Some types of data layouts need a length field. |
109 // Some types of data layouts need a length field. |
114 static boolean needsArrayLen(int tag) { |
110 static boolean needsArrayLen(int tag) { |
117 |
113 |
118 public static final int counterIncrement = 1; |
114 public static final int counterIncrement = 1; |
119 |
115 |
120 // Size computation |
116 // Size computation |
121 static int headerSizeInBytes() { |
117 static int headerSizeInBytes() { |
122 return MethodData.cellSize; |
118 return MethodData.cellSize * headerSizeInCells(); |
123 } |
119 } |
124 static int headerSizeInCells() { |
120 static int headerSizeInCells() { |
125 return 1; |
121 return VM.getVM().isLP64() ? 1 : 2; |
126 } |
122 } |
127 |
123 |
128 static public int computeSizeInBytes(int cellCount) { |
124 static public int computeSizeInBytes(int cellCount) { |
129 return headerSizeInBytes() + cellCount * MethodData.cellSize; |
125 return headerSizeInBytes() + cellCount * MethodData.cellSize; |
130 } |
126 } |
144 // traps are common or not. If a BCI shows that a trap X has |
140 // 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 |
141 // occurred, and the MDO shows N occurrences of X, we make the |
146 // simplifying assumption that all N occurrences can be blamed |
142 // simplifying assumption that all N occurrences can be blamed |
147 // on that BCI. |
143 // on that BCI. |
148 int trapState() { |
144 int trapState() { |
149 return (flags() >> trapShift) & trapMask; |
145 return data.getJIntAt(offset+4); |
150 } |
146 } |
151 |
147 |
152 int flags() { |
148 int flags() { |
153 return getU11(1); |
149 return getU11(1); |
154 } |
150 } |