71
72 public class TestOopMapSizeMinimal {
73
74 public static int OOP_SIZE_IN_BYTES = -1;
75 public static int HEADER_SIZE_IN_BYTES = -1;
76
77 static {
78 WhiteBox WB = WhiteBox.getWhiteBox();
79 boolean is_64_bit = System.getProperty("sun.arch.data.model").equals("64");
80 if (is_64_bit) {
81 if (System.getProperty("java.vm.compressedOopsMode") == null) {
82 OOP_SIZE_IN_BYTES = 8;
83 } else {
84 OOP_SIZE_IN_BYTES = 4;
85 }
86 } else {
87 OOP_SIZE_IN_BYTES = 4;
88 }
89 if (is_64_bit) {
90 if (WB.getBooleanVMFlag("UseCompactObjectHeaders")) {
91 HEADER_SIZE_IN_BYTES = 8;
92 } else {
93 HEADER_SIZE_IN_BYTES = 12;
94 }
95 } else {
96 HEADER_SIZE_IN_BYTES = 8;
97 }
98 }
99
100 public static long alignUp(long value, long alignment) {
101 return (value + alignment - 1) & ~(alignment - 1);
102 }
103
104 public static long alignForOop(long position) {
105 return alignUp(position, OOP_SIZE_IN_BYTES);
106 }
107
108 private static final Unsafe U = Unsafe.getUnsafe();
109
110 public static class BASE {
111 int i1;
164 long i4_loc_expected;
165
166 // We expect the layouter to reverse order of oop- and non-oop fields
167 // when it is useful to minimize the number of oop map entries.
168 //
169 // If we have no gaps, this should be the layout:
170 // BASE i1
171 // o1 oopmap entry 1
172 // DERIVED1 o2 oopmap entry 1 (reversed order)
173 // i2
174 // DERIVED3 i3
175 // o3 oopmap entry 2
176 // DERIVED4 o4 oopmap entry 2 (reversed order)
177 // i4
178
179 // There is one combination that has gaps:
180 // -UseCompressedOops + +COH: A gap will be following i1, and i2 will therefore nestle into that gap.
181 // Otherwise, the same logic applies.
182
183 if (OOP_SIZE_IN_BYTES == 4 || // oop size == int size
184 (OOP_SIZE_IN_BYTES == 8 && HEADER_SIZE_IN_BYTES == 12)
185 ) {
186 // No gaps
187
188 // Expected layout for BASE: int, object
189 i1_loc_expected = HEADER_SIZE_IN_BYTES;
190 o1_loc_expected = i1_loc_expected + 4;
191
192 // Expected layout for DERIVED1: object, int (to make o2 border o1)
193 o2_loc_expected = o1_loc_expected + OOP_SIZE_IN_BYTES;
194 i2_loc_expected = o2_loc_expected + OOP_SIZE_IN_BYTES;
195
196 // Expected layout for DERIVED2: int, object (to trail with oops, for derived classes to nestle against)
197 i3_loc_expected = i2_loc_expected + 4;
198 o3_loc_expected = i3_loc_expected + 4;
199
200 // Expected layout for DERIVED3: object, int (to make o4 border o3)
201 o4_loc_expected = o3_loc_expected + OOP_SIZE_IN_BYTES;
202 i4_loc_expected = o4_loc_expected + OOP_SIZE_IN_BYTES;
203
204 } else if (OOP_SIZE_IN_BYTES == 8) {
|
71
72 public class TestOopMapSizeMinimal {
73
74 public static int OOP_SIZE_IN_BYTES = -1;
75 public static int HEADER_SIZE_IN_BYTES = -1;
76
77 static {
78 WhiteBox WB = WhiteBox.getWhiteBox();
79 boolean is_64_bit = System.getProperty("sun.arch.data.model").equals("64");
80 if (is_64_bit) {
81 if (System.getProperty("java.vm.compressedOopsMode") == null) {
82 OOP_SIZE_IN_BYTES = 8;
83 } else {
84 OOP_SIZE_IN_BYTES = 4;
85 }
86 } else {
87 OOP_SIZE_IN_BYTES = 4;
88 }
89 if (is_64_bit) {
90 if (WB.getBooleanVMFlag("UseCompactObjectHeaders")) {
91 HEADER_SIZE_IN_BYTES = 4;
92 } else {
93 HEADER_SIZE_IN_BYTES = 12;
94 }
95 } else {
96 HEADER_SIZE_IN_BYTES = 8;
97 }
98 }
99
100 public static long alignUp(long value, long alignment) {
101 return (value + alignment - 1) & ~(alignment - 1);
102 }
103
104 public static long alignForOop(long position) {
105 return alignUp(position, OOP_SIZE_IN_BYTES);
106 }
107
108 private static final Unsafe U = Unsafe.getUnsafe();
109
110 public static class BASE {
111 int i1;
164 long i4_loc_expected;
165
166 // We expect the layouter to reverse order of oop- and non-oop fields
167 // when it is useful to minimize the number of oop map entries.
168 //
169 // If we have no gaps, this should be the layout:
170 // BASE i1
171 // o1 oopmap entry 1
172 // DERIVED1 o2 oopmap entry 1 (reversed order)
173 // i2
174 // DERIVED3 i3
175 // o3 oopmap entry 2
176 // DERIVED4 o4 oopmap entry 2 (reversed order)
177 // i4
178
179 // There is one combination that has gaps:
180 // -UseCompressedOops + +COH: A gap will be following i1, and i2 will therefore nestle into that gap.
181 // Otherwise, the same logic applies.
182
183 if (OOP_SIZE_IN_BYTES == 4 || // oop size == int size
184 (OOP_SIZE_IN_BYTES == 8 && (HEADER_SIZE_IN_BYTES == 12 || HEADER_SIZE_IN_BYTES == 4))
185 ) {
186 // No gaps
187
188 // Expected layout for BASE: int, object
189 i1_loc_expected = HEADER_SIZE_IN_BYTES;
190 o1_loc_expected = i1_loc_expected + 4;
191
192 // Expected layout for DERIVED1: object, int (to make o2 border o1)
193 o2_loc_expected = o1_loc_expected + OOP_SIZE_IN_BYTES;
194 i2_loc_expected = o2_loc_expected + OOP_SIZE_IN_BYTES;
195
196 // Expected layout for DERIVED2: int, object (to trail with oops, for derived classes to nestle against)
197 i3_loc_expected = i2_loc_expected + 4;
198 o3_loc_expected = i3_loc_expected + 4;
199
200 // Expected layout for DERIVED3: object, int (to make o4 border o3)
201 o4_loc_expected = o3_loc_expected + OOP_SIZE_IN_BYTES;
202 i4_loc_expected = o4_loc_expected + OOP_SIZE_IN_BYTES;
203
204 } else if (OOP_SIZE_IN_BYTES == 8) {
|