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 8136421
27 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
28 * @library / /testlibrary /test/lib
29 * @library ../common/patches
30 * @modules java.base/jdk.internal.misc
31 * @modules jdk.vm.ci/jdk.vm.ci.hotspot
32 * jdk.vm.ci/jdk.vm.ci.meta
33 * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
34 * jdk.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject
35 * @build compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest
36 * @build sun.hotspot.WhiteBox
37 * @run main ClassFileInstaller
38 * sun.hotspot.WhiteBox
39 * sun.hotspot.WhiteBox$WhiteBoxPermission
40 * @run main/othervm -Xbootclasspath/a:.
41 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
42 * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
43 * -XX:+UseCompressedOops
44 * compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest
45 * @run main/othervm -Xbootclasspath/a:.
46 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
47 * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
48 * -XX:-UseCompressedOops
49 * compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest
50 */
51
52 package compiler.jvmci.compilerToVM;
132 },
133 CONSTANT_POOL_BASE_ZERO {
134 @Override
135 HotSpotResolvedObjectType getResolvedJavaType() {
136 long ptr = getPtrToKlass();
137 ConstantPool cpInst = HotSpotResolvedObjectType
138 .fromObjectClass(TEST_CLASS)
139 .getConstantPool();
140 try {
141 Field field = cpInst.getClass()
142 .getDeclaredField("metaspaceConstantPool");
143 field.setAccessible(true);
144 field.set(cpInst, 0L);
145 } catch (ReflectiveOperationException e) {
146 throw new Error("TESTBUG : " + e, e);
147 }
148 return CompilerToVMHelper.getResolvedJavaType(cpInst,
149 ptr, COMPRESSED);
150 }
151 },
152 OBJECT_TYPE_BASE {
153 @Override
154 HotSpotResolvedObjectType getResolvedJavaType() {
155 HotSpotResolvedObjectType type
156 = HotSpotResolvedObjectType.fromObjectClass(
157 OBJECT_TYPE_BASE.getClass());
158 long ptrToClass = UNSAFE.getKlassPointer(OBJECT_TYPE_BASE);
159 return CompilerToVMHelper.getResolvedJavaType(type,
160 getPtrToKlass() - ptrToClass, COMPRESSED);
161 }
162 },
163 ;
164 abstract HotSpotResolvedObjectType getResolvedJavaType();
165 }
166
167 private static final Unsafe UNSAFE = Utils.getUnsafe();
168 private static final WhiteBox WB = WhiteBox.getWhiteBox();
169 private static final long PTR = UNSAFE.getKlassPointer(
170 new GetResolvedJavaTypeTest());
171 private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class;
172 /* a compressed parameter for tested method is set to false because
173 unsafe.getKlassPointer always returns uncompressed pointer */
174 private static final boolean COMPRESSED = false;
175 // = WB.getBooleanVMFlag("UseCompressedClassPointers");
176
177 private static long getPtrToKlass() {
178 Field field;
179 try {
180 field = TEST_CLASS.getDeclaredField("PTR");
181 } catch (NoSuchFieldException e) {
182 throw new Error("TEST BUG : " + e, e);
183 }
184 Object base = UNSAFE.staticFieldBase(field);
185 return WB.getObjectAddress(base) + UNSAFE.staticFieldOffset(field);
186 }
187
188 public void test(TestCase testCase) {
189 System.out.println(testCase.name());
190 HotSpotResolvedObjectType type = testCase.getResolvedJavaType();
|
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 8136421
27 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
28 * @library / /testlibrary /test/lib
29 * @library ../common/patches
30 * @modules java.base/jdk.internal.misc
31 * @modules jdk.vm.ci/jdk.vm.ci.hotspot
32 * jdk.vm.ci/jdk.vm.ci.meta
33 * @ignore 8158860
34 * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
35 * jdk.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject
36 * @build compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest
37 * @build sun.hotspot.WhiteBox
38 * @run main ClassFileInstaller
39 * sun.hotspot.WhiteBox
40 * sun.hotspot.WhiteBox$WhiteBoxPermission
41 * @run main/othervm -Xbootclasspath/a:.
42 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
43 * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
44 * -XX:+UseCompressedOops
45 * compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest
46 * @run main/othervm -Xbootclasspath/a:.
47 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
48 * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
49 * -XX:-UseCompressedOops
50 * compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest
51 */
52
53 package compiler.jvmci.compilerToVM;
133 },
134 CONSTANT_POOL_BASE_ZERO {
135 @Override
136 HotSpotResolvedObjectType getResolvedJavaType() {
137 long ptr = getPtrToKlass();
138 ConstantPool cpInst = HotSpotResolvedObjectType
139 .fromObjectClass(TEST_CLASS)
140 .getConstantPool();
141 try {
142 Field field = cpInst.getClass()
143 .getDeclaredField("metaspaceConstantPool");
144 field.setAccessible(true);
145 field.set(cpInst, 0L);
146 } catch (ReflectiveOperationException e) {
147 throw new Error("TESTBUG : " + e, e);
148 }
149 return CompilerToVMHelper.getResolvedJavaType(cpInst,
150 ptr, COMPRESSED);
151 }
152 },
153 ;
154 abstract HotSpotResolvedObjectType getResolvedJavaType();
155 }
156
157 private static final Unsafe UNSAFE = Utils.getUnsafe();
158 private static final WhiteBox WB = WhiteBox.getWhiteBox();
159 private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class;
160 /* a compressed parameter for tested method is set to false because
161 unsafe.getKlassPointer always returns uncompressed pointer */
162 private static final boolean COMPRESSED = false;
163 // = WB.getBooleanVMFlag("UseCompressedClassPointers");
164
165 private static long getPtrToKlass() {
166 Field field;
167 try {
168 field = TEST_CLASS.getDeclaredField("PTR");
169 } catch (NoSuchFieldException e) {
170 throw new Error("TEST BUG : " + e, e);
171 }
172 Object base = UNSAFE.staticFieldBase(field);
173 return WB.getObjectAddress(base) + UNSAFE.staticFieldOffset(field);
174 }
175
176 public void test(TestCase testCase) {
177 System.out.println(testCase.name());
178 HotSpotResolvedObjectType type = testCase.getResolvedJavaType();
|