1 /*
  2  * Copyright (c) 2020, 2024, Red Hat, Inc. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8253525
 27  * @summary Test for fInst.getObjectSize with 32-bit compressed oops
 28  * @library /test/lib
 29  *
 30  * @build jdk.test.whitebox.WhiteBox
 31  * @run build GetObjectSizeIntrinsicsTest
 32  * @run shell MakeJAR.sh basicAgent
 33  *
 34  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
 35  *
 36  * @run main/othervm -Xmx128m
 37  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 38  *                   -Xint
 39  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
 40  *
 41  * @run main/othervm -Xmx128m
 42  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 43  *                   -Xbatch -XX:TieredStopAtLevel=1
 44  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
 45  *
 46  * @run main/othervm -Xmx128m
 47  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 48  *                   -Xbatch -XX:-TieredCompilation
 49  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
 50  */
 51 
 52 /*
 53  * @test
 54  * @summary Test for fInst.getObjectSize with zero-based compressed oops
 55  * @library /test/lib
 56  * @requires vm.bits == 64
 57  *
 58  * @build jdk.test.whitebox.WhiteBox
 59  * @run build GetObjectSizeIntrinsicsTest
 60  * @run shell MakeJAR.sh basicAgent
 61  *
 62  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
 63  *
 64  * @run main/othervm -Xmx4g
 65  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 66  *                   -Xint
 67  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
 68  *
 69  * @run main/othervm -Xmx4g
 70  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 71  *                   -Xbatch -XX:TieredStopAtLevel=1
 72  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
 73  *
 74  * @run main/othervm -Xmx4g
 75  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 76  *                   -Xbatch -XX:-TieredCompilation
 77  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
 78  */
 79 
 80 /*
 81  * @test
 82  * @summary Test for fInst.getObjectSize without compressed oops
 83  * @library /test/lib
 84  * @requires vm.bits == 64
 85  *
 86  * @build jdk.test.whitebox.WhiteBox
 87  * @run build GetObjectSizeIntrinsicsTest
 88  * @run shell MakeJAR.sh basicAgent
 89  *
 90  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
 91  *
 92  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 93  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 94  *                   -Xint
 95  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
 96  *
 97  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 98  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 99  *                   -Xbatch -XX:TieredStopAtLevel=1
100  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
101  *
102  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
103  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
104  *                   -Xbatch -XX:-TieredCompilation
105  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
106  */
107 
108 /*
109  * @test
110  * @summary Test for fInst.getObjectSize with 32-bit compressed oops
111  * @library /test/lib
112  * @requires vm.debug
113  *
114  * @build jdk.test.whitebox.WhiteBox
115  * @run build GetObjectSizeIntrinsicsTest
116  * @run shell MakeJAR.sh basicAgent
117  *
118  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
119  *
120  * @run main/othervm -Xmx128m
121  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
122  *                   -XX:FastAllocateSizeLimit=0
123  *                   -Xint
124  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
125  *
126  * @run main/othervm -Xmx128m
127  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
128  *                   -XX:FastAllocateSizeLimit=0
129  *                   -Xbatch -XX:TieredStopAtLevel=1
130  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
131  *
132  * @run main/othervm -Xmx128m
133  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
134  *                   -XX:FastAllocateSizeLimit=0
135  *                   -Xbatch -XX:-TieredCompilation
136  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
137  */
138 
139 /*
140  * @test
141  * @summary Test for fInst.getObjectSize with zero-based compressed oops
142  * @library /test/lib
143  * @requires vm.bits == 64
144  * @requires vm.debug
145  *
146  * @build jdk.test.whitebox.WhiteBox
147  * @run build GetObjectSizeIntrinsicsTest
148  * @run shell MakeJAR.sh basicAgent
149  *
150  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
151  *
152  * @run main/othervm -Xmx4g
153  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
154  *                   -XX:FastAllocateSizeLimit=0
155  *                   -Xint
156  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
157  *
158  * @run main/othervm -Xmx4g
159  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
160  *                   -XX:FastAllocateSizeLimit=0
161  *                   -Xbatch -XX:TieredStopAtLevel=1
162  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
163  *
164  * @run main/othervm -Xmx4g
165  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
166  *                   -XX:FastAllocateSizeLimit=0
167  *                   -Xbatch -XX:-TieredCompilation
168  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
169  */
170 
171 /*
172  * @test
173  * @summary Test for fInst.getObjectSize without compressed oops
174  * @library /test/lib
175  * @requires vm.bits == 64
176  * @requires vm.debug
177  *
178  * @build jdk.test.whitebox.WhiteBox
179  * @run build GetObjectSizeIntrinsicsTest
180  * @run shell MakeJAR.sh basicAgent
181  *
182  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
183  *
184  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
185  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
186  *                   -XX:FastAllocateSizeLimit=0
187  *                   -Xint
188  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
189  *
190  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
191  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
192  *                   -XX:FastAllocateSizeLimit=0
193  *                   -Xbatch -XX:TieredStopAtLevel=1
194  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
195  *
196  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
197  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
198  *                   -XX:FastAllocateSizeLimit=0
199  *                   -Xbatch -XX:-TieredCompilation
200  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
201  */
202 
203 /*
204  * @test
205  * @summary Test for fInst.getObjectSize with 32-bit compressed oops
206  * @library /test/lib
207  * @requires vm.bits == 64
208  * @requires vm.debug
209  *
210  * @build jdk.test.whitebox.WhiteBox
211  * @run build GetObjectSizeIntrinsicsTest
212  * @run shell MakeJAR.sh basicAgent
213  *
214  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
215  *
216  * @run main/othervm -Xmx128m
217  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
218  *                   -XX:ObjectAlignmentInBytes=32
219  *                   -Xint
220  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
221  *
222  * @run main/othervm -Xmx128m
223  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
224  *                   -XX:ObjectAlignmentInBytes=32
225  *                   -Xbatch -XX:TieredStopAtLevel=1
226  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
227  *
228  * @run main/othervm -Xmx128m
229  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
230  *                   -XX:ObjectAlignmentInBytes=32
231  *                   -Xbatch -XX:-TieredCompilation
232  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
233  */
234 
235 /*
236  * @test
237  * @summary Test for fInst.getObjectSize with zero-based compressed oops
238  * @library /test/lib
239  * @requires vm.bits == 64
240  * @requires vm.debug
241  *
242  * @build jdk.test.whitebox.WhiteBox
243  * @run build GetObjectSizeIntrinsicsTest
244  * @run shell MakeJAR.sh basicAgent
245  *
246  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
247  *
248  * @run main/othervm -Xmx4g
249  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
250  *                   -XX:ObjectAlignmentInBytes=32
251  *                   -Xint
252  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
253  *
254  * @run main/othervm -Xmx4g
255  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
256  *                   -XX:ObjectAlignmentInBytes=32
257  *                   -Xbatch -XX:TieredStopAtLevel=1
258  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
259  *
260  * @run main/othervm -Xmx4g
261  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
262  *                   -XX:ObjectAlignmentInBytes=32
263  *                   -Xbatch -XX:-TieredCompilation
264  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest
265  */
266 
267 /*
268  * @test
269  * @summary Test for fInst.getObjectSize with large arrays
270  * @library /test/lib
271  * @requires vm.bits == 64
272  * @requires vm.debug
273  * @requires os.maxMemory >= 10G
274  *
275  * @build jdk.test.whitebox.WhiteBox
276  * @run build GetObjectSizeIntrinsicsTest
277  * @run shell MakeJAR.sh basicAgent
278  *
279  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
280  *
281  * @run main/othervm/timeout=300 -Xmx8g
282  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
283  *                   -Xint
284  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large
285  *
286  * @run main/othervm/timeout=240 -Xmx8g
287  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
288  *                   -Xbatch -XX:TieredStopAtLevel=1
289  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large
290  *
291  * @run main/othervm/timeout=180 -Xmx8g
292  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:.
293  *                   -Xbatch -XX:-TieredCompilation
294  *                   -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large
295  */
296 
297 import java.util.*;
298 
299 import jdk.test.lib.Platform;
300 import jdk.test.whitebox.WhiteBox;
301 
302 public class GetObjectSizeIntrinsicsTest extends ASimpleInstrumentationTestCase {
303 
304     private static final boolean COMPACT_HEADERS = Platform.is64bit() && WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders");
305     static final Boolean COMPRESSED_OOPS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedOops");
306     static final long REF_SIZE = (COMPRESSED_OOPS == null || COMPRESSED_OOPS == true) ? 4 : 8;
307 
308     static final Long align = WhiteBox.getWhiteBox().getIntVMFlag("ObjectAlignmentInBytes");
309     static final int OBJ_ALIGN = (align == null ? 8 : align.intValue());
310 
311     static final int SMALL_ARRAY_SIZE = 1024;
312 
313     // These should overflow 4G size boundary
314     static final int LARGE_INT_ARRAY_SIZE = 1024*1024*1024 + 1024;
315     static final int LARGE_OBJ_ARRAY_SIZE = (4096/(int)REF_SIZE)*1024*1024 + 1024;
316 
317     static final boolean CCP = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers");
318     static final int ARRAY_HEADER_SIZE = CCP ? 16 : (Platform.is64bit() ? 20 : 16);
319 
320     final String mode;
321 
322     public GetObjectSizeIntrinsicsTest(String name, String mode) {
323         super(name);
324         this.mode = mode;
325     }
326 
327     public static void main(String[] args)throws Throwable {
328         new GetObjectSizeIntrinsicsTest(args[0], (args.length >= 2 ? args[1] : "")).runTest();
329     }
330 
331     public static final int ITERS = 200_000;
332 
333     public static void assertEquals(long expected, long actual) {
334         if (expected != actual) {
335             throw new IllegalStateException(
336                "Error: expected: " + expected + " (" + Long.toHexString(expected) +
337                 "), actual: " + actual + " (" + Long.toHexString(actual) + ")");
338         }
339     }
340 
341     public static void assertNotEquals(long notExpected, long actual) {
342         if (notExpected == actual) {
343             throw new IllegalStateException(
344                "Error: not expected: " + notExpected + " (" + Long.toHexString(notExpected) +
345                 "), actual: " + actual + " (" + Long.toHexString(actual) + ")");
346         }
347     }
348 
349     public static void assertFail() {
350         throw new IllegalStateException("Should not be here");
351     }
352 
353     protected final void doRunTest() throws Throwable {
354         testSize_newObject();
355         testSize_localObject();
356         testSize_fieldObject();
357 
358         testSize_newSmallIntArray();
359         testSize_localSmallIntArray();
360         testSize_fieldSmallIntArray();
361 
362         testSize_newSmallObjArray();
363         testSize_localSmallObjArray();
364         testSize_fieldSmallObjArray();
365 
366         if (mode.equals("large")) {
367             testSize_localLargeIntArray();
368             testSize_localLargeObjArray();
369         }
370 
371         testNulls();
372     }
373 
374     private static long roundUp(long v, long a) {
375         return (v + a - 1) / a * a;
376     }
377 
378     private static long expectedSmallObjSize() {
379         long size;
380         if (!Platform.is64bit() || COMPACT_HEADERS) {
381             size = 8;
382         } else {
383             size = 16;
384         }
385         return roundUp(size, OBJ_ALIGN);
386     }
387 
388     private void testSize_newObject() {
389         long expected = expectedSmallObjSize();
390         for (int c = 0; c < ITERS; c++) {
391             assertEquals(expected, fInst.getObjectSize(new Object()));
392         }
393     }
394 
395     private void testSize_localObject() {
396         long expected = expectedSmallObjSize();
397         Object o = new Object();
398         for (int c = 0; c < ITERS; c++) {
399             assertEquals(expected, fInst.getObjectSize(o));
400         }
401     }
402 
403     static Object staticO = new Object();
404 
405     private void testSize_fieldObject() {
406         long expected = expectedSmallObjSize();
407         for (int c = 0; c < ITERS; c++) {
408             assertEquals(expected, fInst.getObjectSize(staticO));
409         }
410     }
411 
412     private void testSize_newSmallIntArray() {
413         long expected = roundUp(4L*SMALL_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
414         for (int c = 0; c < ITERS; c++) {
415             assertEquals(expected, fInst.getObjectSize(new int[SMALL_ARRAY_SIZE]));
416         }
417     }
418 
419     private void testSize_localSmallIntArray() {
420         int[] arr = new int[SMALL_ARRAY_SIZE];
421         long expected = roundUp(4L*SMALL_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
422         for (int c = 0; c < ITERS; c++) {
423             assertEquals(expected, fInst.getObjectSize(arr));
424         }
425     }
426 
427     static int[] smallArr = new int[SMALL_ARRAY_SIZE];
428 
429     private void testSize_fieldSmallIntArray() {
430         long expected = roundUp(4L*SMALL_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
431         for (int c = 0; c < ITERS; c++) {
432             assertEquals(expected, fInst.getObjectSize(smallArr));
433         }
434     }
435 
436     private void testSize_newSmallObjArray() {
437         long expected = roundUp(REF_SIZE*SMALL_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
438         for (int c = 0; c < ITERS; c++) {
439             assertEquals(expected, fInst.getObjectSize(new Object[SMALL_ARRAY_SIZE]));
440         }
441     }
442 
443     private void testSize_localSmallObjArray() {
444         Object[] arr = new Object[SMALL_ARRAY_SIZE];
445         long expected = roundUp(REF_SIZE*SMALL_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
446         for (int c = 0; c < ITERS; c++) {
447             assertEquals(expected, fInst.getObjectSize(arr));
448         }
449     }
450 
451     static Object[] smallObjArr = new Object[SMALL_ARRAY_SIZE];
452 
453     private void testSize_fieldSmallObjArray() {
454         long expected = roundUp(REF_SIZE*SMALL_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
455         for (int c = 0; c < ITERS; c++) {
456             assertEquals(expected, fInst.getObjectSize(smallObjArr));
457         }
458     }
459 
460     private void testSize_localLargeIntArray() {
461         int[] arr = new int[LARGE_INT_ARRAY_SIZE];
462         long expected = roundUp(4L*LARGE_INT_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
463         for (int c = 0; c < ITERS; c++) {
464             assertEquals(expected, fInst.getObjectSize(arr));
465         }
466     }
467 
468     private void testSize_localLargeObjArray() {
469         Object[] arr = new Object[LARGE_OBJ_ARRAY_SIZE];
470         long expected = roundUp(REF_SIZE*LARGE_OBJ_ARRAY_SIZE + ARRAY_HEADER_SIZE, OBJ_ALIGN);
471         for (int c = 0; c < ITERS; c++) {
472             assertEquals(expected, fInst.getObjectSize(arr));
473         }
474     }
475 
476     private void testNulls() {
477         for (int c = 0; c < ITERS; c++) {
478             try {
479                 fInst.getObjectSize(null);
480                 assertFail();
481             } catch (NullPointerException e) {
482                 // expected
483             }
484         }
485     }
486 
487 }