81
82 public class TestOopMapSizeMinimal {
83
84 public static int OOP_SIZE_IN_BYTES = -1;
85 public static int HEADER_SIZE_IN_BYTES = -1;
86
87 static {
88 WhiteBox WB = WhiteBox.getWhiteBox();
89 boolean is_64_bit = System.getProperty("sun.arch.data.model").equals("64");
90 if (is_64_bit) {
91 if (System.getProperty("java.vm.compressedOopsMode") == null) {
92 OOP_SIZE_IN_BYTES = 8;
93 } else {
94 OOP_SIZE_IN_BYTES = 4;
95 }
96 } else {
97 OOP_SIZE_IN_BYTES = 4;
98 }
99 if (is_64_bit) {
100 if (WB.getBooleanVMFlag("UseCompactObjectHeaders")) {
101 HEADER_SIZE_IN_BYTES = 8;
102 } else if (WB.getBooleanVMFlag("UseCompressedClassPointers")) {
103 HEADER_SIZE_IN_BYTES = 12;
104 } else {
105 HEADER_SIZE_IN_BYTES = 16;
106 }
107 } else {
108 HEADER_SIZE_IN_BYTES = 8;
109 }
110 }
111
112 public static long alignUp(long value, long alignment) {
113 return (value + alignment - 1) & ~(alignment - 1);
114 }
115
116 public static long alignForOop(long position) {
117 return alignUp(position, OOP_SIZE_IN_BYTES);
118 }
119
120 private static final Unsafe U = Unsafe.getUnsafe();
121
177
178 // We expect the layouter to reverse order of oop- and non-oop fields
179 // when it is useful to minimize the number of oop map entries.
180 //
181 // If we have no gaps, this should be the layout:
182 // BASE i1
183 // o1 oopmap entry 1
184 // DERIVED1 o2 oopmap entry 1 (reversed order)
185 // i2
186 // DERIVED3 i3
187 // o3 oopmap entry 2
188 // DERIVED4 o4 oopmap entry 2 (reversed order)
189 // i4
190
191 // There are two combinations that have gaps:
192 // -UseCompressedOops + +COH, and -UseCompressedOops + -UseCompressedClassPointers.
193 // In both cases there is a gap following i1, and i2 will therefore nestle into that gap.
194 // Otherwise the same logic applies.
195
196 if (OOP_SIZE_IN_BYTES == 4 || // oop size == int size
197 (OOP_SIZE_IN_BYTES == 8 && HEADER_SIZE_IN_BYTES == 12)
198 ) {
199 // No gaps
200
201 // Expected layout for BASE: int, object
202 i1_loc_expected = HEADER_SIZE_IN_BYTES;
203 o1_loc_expected = i1_loc_expected + 4;
204
205 // Expected layout for DERIVED1: object, int (to make o2 border o1)
206 o2_loc_expected = o1_loc_expected + OOP_SIZE_IN_BYTES;
207 i2_loc_expected = o2_loc_expected + OOP_SIZE_IN_BYTES;
208
209 // Expected layout for DERIVED2: int, object (to trail with oops, for derived classes to nestle against)
210 i3_loc_expected = i2_loc_expected + 4;
211 o3_loc_expected = i3_loc_expected + 4;
212
213 // Expected layout for DERIVED3: object, int (to make o4 border o3)
214 o4_loc_expected = o3_loc_expected + OOP_SIZE_IN_BYTES;
215 i4_loc_expected = o4_loc_expected + OOP_SIZE_IN_BYTES;
216
217 } else if (OOP_SIZE_IN_BYTES == 8) {
|
81
82 public class TestOopMapSizeMinimal {
83
84 public static int OOP_SIZE_IN_BYTES = -1;
85 public static int HEADER_SIZE_IN_BYTES = -1;
86
87 static {
88 WhiteBox WB = WhiteBox.getWhiteBox();
89 boolean is_64_bit = System.getProperty("sun.arch.data.model").equals("64");
90 if (is_64_bit) {
91 if (System.getProperty("java.vm.compressedOopsMode") == null) {
92 OOP_SIZE_IN_BYTES = 8;
93 } else {
94 OOP_SIZE_IN_BYTES = 4;
95 }
96 } else {
97 OOP_SIZE_IN_BYTES = 4;
98 }
99 if (is_64_bit) {
100 if (WB.getBooleanVMFlag("UseCompactObjectHeaders")) {
101 HEADER_SIZE_IN_BYTES = 4;
102 } else if (WB.getBooleanVMFlag("UseCompressedClassPointers")) {
103 HEADER_SIZE_IN_BYTES = 12;
104 } else {
105 HEADER_SIZE_IN_BYTES = 16;
106 }
107 } else {
108 HEADER_SIZE_IN_BYTES = 8;
109 }
110 }
111
112 public static long alignUp(long value, long alignment) {
113 return (value + alignment - 1) & ~(alignment - 1);
114 }
115
116 public static long alignForOop(long position) {
117 return alignUp(position, OOP_SIZE_IN_BYTES);
118 }
119
120 private static final Unsafe U = Unsafe.getUnsafe();
121
177
178 // We expect the layouter to reverse order of oop- and non-oop fields
179 // when it is useful to minimize the number of oop map entries.
180 //
181 // If we have no gaps, this should be the layout:
182 // BASE i1
183 // o1 oopmap entry 1
184 // DERIVED1 o2 oopmap entry 1 (reversed order)
185 // i2
186 // DERIVED3 i3
187 // o3 oopmap entry 2
188 // DERIVED4 o4 oopmap entry 2 (reversed order)
189 // i4
190
191 // There are two combinations that have gaps:
192 // -UseCompressedOops + +COH, and -UseCompressedOops + -UseCompressedClassPointers.
193 // In both cases there is a gap following i1, and i2 will therefore nestle into that gap.
194 // Otherwise the same logic applies.
195
196 if (OOP_SIZE_IN_BYTES == 4 || // oop size == int size
197 (OOP_SIZE_IN_BYTES == 8 && (HEADER_SIZE_IN_BYTES == 12 || HEADER_SIZE_IN_BYTES == 4))
198 ) {
199 // No gaps
200
201 // Expected layout for BASE: int, object
202 i1_loc_expected = HEADER_SIZE_IN_BYTES;
203 o1_loc_expected = i1_loc_expected + 4;
204
205 // Expected layout for DERIVED1: object, int (to make o2 border o1)
206 o2_loc_expected = o1_loc_expected + OOP_SIZE_IN_BYTES;
207 i2_loc_expected = o2_loc_expected + OOP_SIZE_IN_BYTES;
208
209 // Expected layout for DERIVED2: int, object (to trail with oops, for derived classes to nestle against)
210 i3_loc_expected = i2_loc_expected + 4;
211 o3_loc_expected = i3_loc_expected + 4;
212
213 // Expected layout for DERIVED3: object, int (to make o4 border o3)
214 o4_loc_expected = o3_loc_expected + OOP_SIZE_IN_BYTES;
215 i4_loc_expected = o4_loc_expected + OOP_SIZE_IN_BYTES;
216
217 } else if (OOP_SIZE_IN_BYTES == 8) {
|