8156768: [JVMCI] remove support for patching Symbol pointers

Reviewed-by: iveresov
This commit is contained in:
Roland Schatz 2016-05-12 12:59:35 +02:00
parent 5e2fa37504
commit 9f43471b55
13 changed files with 2 additions and 141 deletions

View File

@ -479,11 +479,6 @@ final class CompilerToVM {
*/
native String getSymbol(long metaspaceSymbol);
/**
* Lookup a VMSymbol from a String.
*/
native long lookupSymbol(String symbol);
/**
* Looks for the next Java stack frame matching an entry in {@code methods}.
*

View File

@ -39,6 +39,4 @@ public interface HotSpotMemoryAccessProvider extends MemoryAccessProvider {
Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding);
Constant readMethodPointerConstant(Constant base, long displacement);
Constant readSymbolConstant(Constant base, long displacement);
}

View File

@ -232,16 +232,4 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Ho
HotSpotResolvedJavaMethodImpl method = runtime.getCompilerToVM().getResolvedJavaMethod(baseObject, displacement);
return HotSpotMetaspaceConstantImpl.forMetaspaceObject(method, false);
}
@Override
public Constant readSymbolConstant(Constant base, long displacement) {
int bits = runtime.getConfig().symbolPointerSize * Byte.SIZE;
long pointer = readRawValue(base, displacement, bits);
if (pointer == 0) {
return JavaConstant.NULL_POINTER;
} else {
String symbol = runtime.getCompilerToVM().getSymbol(pointer);
return new HotSpotSymbol(symbol, pointer).asConstant();
}
}
}

View File

@ -78,15 +78,6 @@ public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotPro
return new HotSpotSignature(runtime, signature);
}
public HotSpotSymbol lookupSymbol(String symbol) {
long pointer = runtime.getCompilerToVM().lookupSymbol(symbol);
if (pointer == 0) {
return null;
} else {
return new HotSpotSymbol(symbol, pointer);
}
}
/**
* {@link Field} object of {@link Method#slot}.
*/

View File

@ -29,6 +29,4 @@ public interface HotSpotMetaspaceConstant extends HotSpotConstant, VMConstant {
HotSpotResolvedObjectType asResolvedJavaType();
HotSpotResolvedJavaMethod asResolvedJavaMethod();
HotSpotSymbol asSymbol();
}

View File

@ -108,11 +108,4 @@ final class HotSpotMetaspaceConstantImpl implements HotSpotMetaspaceConstant, VM
}
return null;
}
public HotSpotSymbol asSymbol() {
if (metaspaceObject instanceof HotSpotSymbol) {
return (HotSpotSymbol) metaspaceObject;
}
return null;
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright (c) 2016, 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.
*/
package jdk.vm.ci.hotspot;
import jdk.vm.ci.meta.Constant;
/**
* Class to access the C++ {@code vmSymbols} table.
*/
public final class HotSpotSymbol implements MetaspaceWrapperObject {
private final String symbol;
private final long pointer;
HotSpotSymbol(String symbol, long pointer) {
this.symbol = symbol;
this.pointer = pointer;
}
public String getSymbol() {
return symbol;
}
public Constant asConstant() {
return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false);
}
@Override
public long getMetaspacePointer() {
return pointer;
}
@Override
public String toString() {
return "Symbol<" + symbol + ">";
}
}

View File

@ -181,8 +181,8 @@ void* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) {
/*
* This method needs to return a raw (untyped) pointer, since the value of a pointer to the base
* class is in general not equal to the pointer of the subclass. When patching metaspace pointers,
* the compiler expects a direct pointer to the subclass (Klass*, Method* or Symbol*), not a
* pointer to the base class (Metadata* or MetaspaceObj*).
* the compiler expects a direct pointer to the subclass (Klass* or Method*), not a pointer to the
* base class (Metadata* or MetaspaceObj*).
*/
oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant);
if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) {
@ -197,11 +197,6 @@ void* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) {
int index = _oop_recorder->find_index(method);
TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string());
return method;
} else if (obj->is_a(HotSpotSymbol::klass())) {
Symbol* symbol = (Symbol*) (address) HotSpotSymbol::pointer(obj);
assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed symbol pointer %s @ " INTPTR_FORMAT, symbol->as_C_string(), p2i(symbol));
TRACE_jvmci_3("symbol = %s", symbol->as_C_string());
return symbol;
} else {
JVMCI_ERROR_NULL("unexpected metadata reference for constant of type %s", obj->klass()->signature_name());
}

View File

@ -1048,11 +1048,6 @@ C2V_VMENTRY(jobject, getSymbol, (JNIEnv*, jobject, jlong symbol))
return JNIHandles::make_local(THREAD, sym());
C2V_END
C2V_VMENTRY(jlong, lookupSymbol, (JNIEnv*, jobject, jobject string))
Symbol* symbol = java_lang_String::as_symbol_or_null(JNIHandles::resolve(string));
return (jlong) symbol;
C2V_END
bool matches(jobjectArray methods, Method* method) {
objArrayOop methods_oop = (objArrayOop) JNIHandles::resolve(methods);
@ -1480,7 +1475,6 @@ JNINativeMethod CompilerToVM::methods[] = {
{CC "isMature", CC "(" METASPACE_METHOD_DATA ")Z", FN_PTR(isMature)},
{CC "hasCompiledCodeForOSR", CC "(" HS_RESOLVED_METHOD "II)Z", FN_PTR(hasCompiledCodeForOSR)},
{CC "getSymbol", CC "(J)" STRING, FN_PTR(getSymbol)},
{CC "lookupSymbol", CC "(" STRING ")J", FN_PTR(lookupSymbol)},
{CC "getNextStackFrame", CC "(" HS_STACK_FRAME_REF "[" RESOLVED_METHOD "I)" HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)},
{CC "materializeVirtualObjects", CC "(" HS_STACK_FRAME_REF "Z)V", FN_PTR(materializeVirtualObjects)},
{CC "shouldDebugNonSafepoints", CC "()Z", FN_PTR(shouldDebugNonSafepoints)},

View File

@ -64,9 +64,6 @@ class JVMCIJavaClasses : AllStatic {
start_class(HotSpotResolvedJavaMethodImpl) \
long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \
end_class \
start_class(HotSpotSymbol) \
long_field(HotSpotSymbol, pointer) \
end_class \
start_class(InstalledCode) \
long_field(InstalledCode, address) \
long_field(InstalledCode, entryPoint) \

View File

@ -49,7 +49,6 @@
do_klass(HotSpotJVMCIMetaAccessContext_klass, jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext, Jvmci) \
do_klass(HotSpotJVMCIRuntime_klass, jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, Jvmci) \
do_klass(HotSpotSpeculationLog_klass, jdk_vm_ci_hotspot_HotSpotSpeculationLog, Jvmci) \
do_klass(HotSpotSymbol_klass, jdk_vm_ci_hotspot_HotSpotSymbol, Jvmci) \
do_klass(Assumptions_ConcreteMethod_klass, jdk_vm_ci_meta_Assumptions_ConcreteMethod, Jvmci) \
do_klass(Assumptions_NoFinalizableSubclass_klass, jdk_vm_ci_meta_Assumptions_NoFinalizableSubclass, Jvmci) \
do_klass(Assumptions_ConcreteSubtype_klass, jdk_vm_ci_meta_Assumptions_ConcreteSubtype, Jvmci) \

View File

@ -50,7 +50,6 @@
template(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext, "jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext") \
template(jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, "jdk/vm/ci/hotspot/HotSpotJVMCIRuntime") \
template(jdk_vm_ci_hotspot_HotSpotSpeculationLog, "jdk/vm/ci/hotspot/HotSpotSpeculationLog") \
template(jdk_vm_ci_hotspot_HotSpotSymbol, "jdk/vm/ci/hotspot/HotSpotSymbol") \
template(jdk_vm_ci_meta_JavaConstant, "jdk/vm/ci/meta/JavaConstant") \
template(jdk_vm_ci_meta_PrimitiveConstant, "jdk/vm/ci/meta/PrimitiveConstant") \
template(jdk_vm_ci_meta_RawConstant, "jdk/vm/ci/meta/RawConstant") \

View File

@ -42,7 +42,6 @@ import jdk.vm.ci.code.Register;
import jdk.vm.ci.code.site.DataSectionReference;
import jdk.vm.ci.hotspot.HotSpotConstant;
import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider;
import jdk.vm.ci.hotspot.HotSpotSymbol;
import jdk.vm.ci.hotspot.HotSpotVMConfig;
import jdk.vm.ci.meta.ResolvedJavaType;
@ -158,32 +157,4 @@ public class DataPatchTest extends CodeInstallationTest {
asm.emitPointerRet(ret);
});
}
public static long getConstSymbol(HotSpotMetaAccessProvider meta) {
HotSpotSymbol symbol = meta.lookupSymbol("java/lang/Object");
return symbol.getMetaspacePointer();
}
private void testSymbol(TestCompiler compiler) {
test(compiler, getMethod("getConstSymbol", HotSpotMetaAccessProvider.class), (HotSpotMetaAccessProvider) metaAccess);
}
@Test
public void testInlineSymbol() {
testSymbol(asm -> {
HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
Register ret = asm.emitLoadPointer((HotSpotConstant) symbol.asConstant());
asm.emitPointerRet(ret);
});
}
@Test
public void testSymbolInDataSection() {
testSymbol(asm -> {
HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
DataSectionReference ref = asm.emitDataItem((HotSpotConstant) symbol.asConstant());
Register ret = asm.emitLoadPointer(ref);
asm.emitPointerRet(ret);
});
}
}