8156587: [JVMCI] remove Unsafe.getJavaMirror and Unsafe.getKlassPointer

Reviewed-by: kvn
This commit is contained in:
Doug Simon 2016-06-06 16:31:03 -07:00
parent 47b35cab0e
commit 39e5b15fdd
4 changed files with 1 additions and 86 deletions

View file

@ -356,19 +356,6 @@ UNSAFE_ENTRY(jobject, Unsafe_GetUncompressedObject(JNIEnv *env, jobject unsafe,
return JNIHandles::make_local(env, v); return JNIHandles::make_local(env, v);
} UNSAFE_END } 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 #ifndef SUPPORTS_NATIVE_CX8
// VM_Version::supports_cx8() is a surrogate for 'supports atomic long memory ops'. // VM_Version::supports_cx8() is a surrogate for 'supports atomic long memory ops'.
@ -1152,8 +1139,6 @@ static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = {
{CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutObjectVolatile)}, {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutObjectVolatile)},
{CC "getUncompressedObject", CC "(" ADR ")" OBJ, FN_PTR(Unsafe_GetUncompressedObject)}, {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(Boolean, Z),
DECLARE_GETPUTOOP(Byte, B), DECLARE_GETPUTOOP(Byte, B),

View file

@ -138,17 +138,6 @@ public class GetConstantPoolTest {
return CompilerToVMHelper.getConstantPool(cpInst, ptr); 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(); abstract ConstantPool getConstantPool();
} }

View file

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 8136421 * @bug 8136421
* @ignore 8158860
* @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
* @library / /testlibrary /test/lib * @library / /testlibrary /test/lib
* @library ../common/patches * @library ../common/patches
@ -149,25 +150,12 @@ public class GetResolvedJavaTypeTest {
ptr, COMPRESSED); 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(); abstract HotSpotResolvedObjectType getResolvedJavaType();
} }
private static final Unsafe UNSAFE = Utils.getUnsafe(); private static final Unsafe UNSAFE = Utils.getUnsafe();
private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final long PTR = UNSAFE.getKlassPointer(
new GetResolvedJavaTypeTest());
private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class; private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class;
/* a compressed parameter for tested method is set to false because /* a compressed parameter for tested method is set to false because
unsafe.getKlassPointer always returns uncompressed pointer */ unsafe.getKlassPointer always returns uncompressed pointer */

View file

@ -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);
}
}