1 /* 2 * Copyright (c) 2020, 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 * @summary Test for Runtime.addressOf with 32-bit compressed oops 27 * @library /test/lib 28 * 29 * @run main/othervm -Xmx128m 30 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 31 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 32 * -Xint 33 * AddressOfStability 34 * 35 * @run main/othervm -Xmx128m 36 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 37 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 38 * -XX:TieredStopAtLevel=1 39 * AddressOfStability 40 * 41 * @run main/othervm -Xmx128m 42 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 43 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 44 * -XX:-TieredCompilation 45 * AddressOfStability 46 */ 47 48 /* 49 * @test 50 * @summary Test for Runtime.addressOf with zero-based compressed oops 51 * @library /test/lib 52 * @requires vm.bits == 64 53 * 54 * @run main/othervm -Xmx4g 55 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 56 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 57 * -Xint 58 * AddressOfStability 59 * 60 * @run main/othervm -Xmx4g 61 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 62 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 63 * -XX:TieredStopAtLevel=1 64 * AddressOfStability 65 * 66 * @run main/othervm -Xmx4g 67 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 68 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 69 * -XX:-TieredCompilation 70 * AddressOfStability 71 */ 72 73 /* 74 * @test 75 * @summary Test for Runtime.addressOf without compressed oops 76 * @library /test/lib 77 * @requires vm.bits == 64 78 * 79 * @run main/othervm -Xmx128m -XX:-UseCompressedOops 80 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 81 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 82 * -Xint 83 * AddressOfStability 84 * 85 * @run main/othervm -Xmx128m -XX:-UseCompressedOops 86 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 87 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 88 * -XX:TieredStopAtLevel=1 89 * AddressOfStability 90 * 91 * @run main/othervm -Xmx128m -XX:-UseCompressedOops 92 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 93 * -XX:CompileCommand=exclude,AddressOfStability::testInterpreted 94 * -XX:-TieredCompilation 95 * AddressOfStability 96 */ 97 98 import java.lang.reflect.Field; 99 100 public class AddressOfStability { 101 102 public static void main(String ... args) throws Exception { 103 Object o = new Object(); 104 for (int c = 0; c < RuntimeOfUtil.ITERS; c++) { 105 long addrInt1 = testInterpreted(o); 106 long addrComp = testCompiled(o); 107 long addrInt2 = testInterpreted(o); 108 109 if (addrInt1 == addrInt2) { 110 // No moves were detected, compare with compiled. 111 RuntimeOfUtil.assertEquals(addrInt1, addrComp); 112 } 113 } 114 } 115 116 private static long testCompiled(Object o) { 117 return Runtime.addressOf(o); 118 } 119 120 private static long testInterpreted(Object o) { 121 return Runtime.addressOf(o); 122 } 123 124 }