8156587: [JVMCI] remove Unsafe.getJavaMirror and Unsafe.getKlassPointer
authordnsimon
Mon, 06 Jun 2016 16:31:03 -0700
changeset 39260 10fcac2a233a
parent 39259 14a1c9c7f909
child 39262 ec2d5ec5571c
8156587: [JVMCI] remove Unsafe.getJavaMirror and Unsafe.getKlassPointer Reviewed-by: kvn
hotspot/src/share/vm/prims/unsafe.cpp
hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java
hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java
hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java
--- a/hotspot/src/share/vm/prims/unsafe.cpp	Mon Jun 06 12:56:40 2016 -0700
+++ b/hotspot/src/share/vm/prims/unsafe.cpp	Mon Jun 06 16:31:03 2016 -0700
@@ -356,19 +356,6 @@
   return JNIHandles::make_local(env, v);
 } UNSAFE_END
 
-UNSAFE_ENTRY(jclass, Unsafe_GetJavaMirror(JNIEnv *env, jobject unsafe, jlong metaspace_klass)) {
-  Klass* klass = (Klass*) (address) metaspace_klass;
-
-  return (jclass) JNIHandles::make_local(klass->java_mirror());
-} UNSAFE_END
-
-UNSAFE_ENTRY(jlong, Unsafe_GetKlassPointer(JNIEnv *env, jobject unsafe, jobject obj)) {
-  oop o = JNIHandles::resolve(obj);
-  jlong klass = (jlong) (address) o->klass();
-
-  return klass;
-} UNSAFE_END
-
 #ifndef SUPPORTS_NATIVE_CX8
 
 // VM_Version::supports_cx8() is a surrogate for 'supports atomic long memory ops'.
@@ -1152,8 +1139,6 @@
     {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_PutObjectVolatile)},
 
     {CC "getUncompressedObject", CC "(" ADR ")" OBJ,  FN_PTR(Unsafe_GetUncompressedObject)},
-    {CC "getJavaMirror",         CC "(" ADR ")" CLS,  FN_PTR(Unsafe_GetJavaMirror)},
-    {CC "getKlassPointer",       CC "(" OBJ ")" ADR,  FN_PTR(Unsafe_GetKlassPointer)},
 
     DECLARE_GETPUTOOP(Boolean, Z),
     DECLARE_GETPUTOOP(Byte, B),
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java	Mon Jun 06 12:56:40 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java	Mon Jun 06 16:31:03 2016 -0700
@@ -138,17 +138,6 @@
                 return CompilerToVMHelper.getConstantPool(cpInst, ptr);
             }
         },
-        OBJECT_TYPE_BASE {
-            @Override
-            ConstantPool getConstantPool() {
-                HotSpotResolvedObjectType type
-                        = HotSpotResolvedObjectType.fromObjectClass(
-                                OBJECT_TYPE_BASE.getClass());
-                long ptrToClass = UNSAFE.getKlassPointer(OBJECT_TYPE_BASE);
-                return CompilerToVMHelper.getConstantPool(type,
-                        getPtrToCpAddress() - ptrToClass);
-            }
-        },
         ;
         abstract ConstantPool getConstantPool();
     }
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java	Mon Jun 06 12:56:40 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java	Mon Jun 06 16:31:03 2016 -0700
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 8136421
+ * @ignore 8158860
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
  * @library ../common/patches
@@ -149,25 +150,12 @@
                         ptr, COMPRESSED);
             }
         },
-        OBJECT_TYPE_BASE {
-            @Override
-            HotSpotResolvedObjectType getResolvedJavaType() {
-                HotSpotResolvedObjectType type
-                        = HotSpotResolvedObjectType.fromObjectClass(
-                        OBJECT_TYPE_BASE.getClass());
-                long ptrToClass = UNSAFE.getKlassPointer(OBJECT_TYPE_BASE);
-                return CompilerToVMHelper.getResolvedJavaType(type,
-                        getPtrToKlass() - ptrToClass, COMPRESSED);
-            }
-        },
         ;
         abstract HotSpotResolvedObjectType getResolvedJavaType();
     }
 
     private static final Unsafe UNSAFE = Utils.getUnsafe();
     private static final WhiteBox WB = WhiteBox.getWhiteBox();
-    private static final long PTR = UNSAFE.getKlassPointer(
-            new GetResolvedJavaTypeTest());
     private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class;
     /* a compressed parameter for tested method is set to false because
        unsafe.getKlassPointer always returns uncompressed pointer */
--- a/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java	Mon Jun 06 12:56:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 8022853
- * @library /testlibrary
- * @modules java.base/jdk.internal.misc
- * @build jdk.test.lib.*
- * @run main GetKlassPointerGetJavaMirror
- */
-
-import static jdk.test.lib.Asserts.*;
-
-import jdk.test.lib.*;
-import jdk.internal.misc.Unsafe;
-
-public class GetKlassPointerGetJavaMirror {
-
-    public static void main(String args[]) throws Exception {
-        Unsafe unsafe = Utils.getUnsafe();
-        Object o = new GetKlassPointerGetJavaMirror();
-        final long metaspaceKlass = unsafe.getKlassPointer(o);
-        Class<?> c = unsafe.getJavaMirror(metaspaceKlass);
-        assertEquals(o.getClass(), c);
-    }
-
-}