8156768: [JVMCI] remove support for patching Symbol pointers
authorrschatz
Thu, 12 May 2016 12:59:35 +0200
changeset 38678 06d6c40ce33b
parent 38677 1c1598b02874
child 38680 d88f2ffa89fa
8156768: [JVMCI] remove support for patching Symbol pointers Reviewed-by: iveresov
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSymbol.java
hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp
hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp
hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp
hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp
hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp
hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Thu May 12 12:59:35 2016 +0200
@@ -480,11 +480,6 @@
     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}.
      *
      * @param frame the starting point of the search, where {@code null} refers to the topmost frame
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java	Thu May 12 12:59:35 2016 +0200
@@ -39,6 +39,4 @@
     Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding);
 
     Constant readMethodPointerConstant(Constant base, long displacement);
-
-    Constant readSymbolConstant(Constant base, long displacement);
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java	Thu May 12 12:59:35 2016 +0200
@@ -232,16 +232,4 @@
         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();
-        }
-    }
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java	Thu May 12 12:59:35 2016 +0200
@@ -78,15 +78,6 @@
         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}.
      */
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java	Thu May 12 12:59:35 2016 +0200
@@ -29,6 +29,4 @@
     HotSpotResolvedObjectType asResolvedJavaType();
 
     HotSpotResolvedJavaMethod asResolvedJavaMethod();
-
-    HotSpotSymbol asSymbol();
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java	Thu May 12 12:59:35 2016 +0200
@@ -108,11 +108,4 @@
         }
         return null;
     }
-
-    public HotSpotSymbol asSymbol() {
-        if (metaspaceObject instanceof HotSpotSymbol) {
-            return (HotSpotSymbol) metaspaceObject;
-        }
-        return null;
-    }
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSymbol.java	Thu May 12 12:46:07 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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 + ">";
-    }
-}
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Thu May 12 12:59:35 2016 +0200
@@ -181,8 +181,8 @@
   /*
    * 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 @@
     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());
   }
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Thu May 12 12:59:35 2016 +0200
@@ -1048,11 +1048,6 @@
   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 @@
   {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)},
--- a/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp	Thu May 12 12:59:35 2016 +0200
@@ -64,9 +64,6 @@
   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)                                                                                                                      \
--- a/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Thu May 12 12:59:35 2016 +0200
@@ -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) \
--- a/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Thu May 12 12:59:35 2016 +0200
@@ -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")                            \
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java	Thu May 12 12:46:07 2016 +0300
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java	Thu May 12 12:59:35 2016 +0200
@@ -42,7 +42,6 @@
 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 @@
             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);
-        });
-    }
 }