changeset 13241:8b5852df0471

remove CompilerToVM.initializeMethodData
author twisti
date Tue, 03 Dec 2013 14:48:09 -0800
parents 3543861aeeb2
children 65c0f2ec1ad7
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/graal/graalJavaAccess.hpp
diffstat 6 files changed, 30 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Dec 03 18:44:52 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Dec 03 14:48:09 2013 -0800
@@ -959,6 +959,11 @@
     @HotSpotVMField(name = "Method::_method_data", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset;
     @HotSpotVMField(name = "Method::_from_compiled_entry", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset;
 
+    @HotSpotVMField(name = "MethodData::_size", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataSize;
+    @HotSpotVMField(name = "MethodData::_data_size", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataDataSize;
+    @HotSpotVMField(name = "MethodData::_data[0]", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset;
+    @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset;
+
     @HotSpotVMField(name = "nmethod::_verified_entry_point", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodEntryOffset;
 
     @HotSpotVMType(name = "BasicLock", get = HotSpotVMType.Type.SIZE) @Stable public int basicLockSize;
@@ -1034,9 +1039,6 @@
         return (layoutHelperArrayTagTypeValue & ~layoutHelperArrayTagObjectValue) << layoutHelperArrayTagShift;
     }
 
-    @HotSpotVMField(name = "MethodData::_data[0]", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset;
-    @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset;
-
     /**
      * The DataLayout header size is the same as the cell size.
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Dec 03 18:44:52 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Dec 03 14:48:09 2013 -0800
@@ -101,14 +101,6 @@
     void initializeMethod(long metaspaceMethod, HotSpotResolvedJavaMethod method);
 
     /**
-     * Initializes a {@link HotSpotMethodData} object from a metaspace MethodData object.
-     * 
-     * @param metaspaceMethodData the metaspace MethodData object
-     * @param methodData the object to initialize from the metaspace object
-     */
-    void initializeMethodData(long metaspaceMethodData, HotSpotMethodData methodData);
-
-    /**
      * Converts a name to a Java type.
      * 
      * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Dec 03 18:44:52 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Dec 03 14:48:09 2013 -0800
@@ -106,9 +106,6 @@
     public native void initializeMethod(long metaspaceMethod, HotSpotResolvedJavaMethod method);
 
     @Override
-    public native void initializeMethodData(long metaspaceMethodData, HotSpotMethodData methodData);
-
-    @Override
     public native ResolvedJavaType getResolvedType(Class<?> javaClass);
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Tue Dec 03 18:44:52 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Tue Dec 03 14:48:09 2013 -0800
@@ -66,28 +66,43 @@
      */
     private final long metaspaceMethodData;
 
-    private int normalDataSize;
-    private int extraDataSize;
-
     HotSpotMethodData(long metaspaceMethodData) {
         this.metaspaceMethodData = metaspaceMethodData;
-        runtime().getCompilerToVM().initializeMethodData(metaspaceMethodData, this);
+    }
+
+    /**
+     * @return value of the MethodData::_data_size field
+     */
+    private int normalDataSize() {
+        return unsafe.getInt(metaspaceMethodData + config.methodDataDataSize);
+    }
+
+    /**
+     * Returns the size of the extra data records. This method does the same calculation as
+     * MethodData::extra_data_size().
+     * 
+     * @return size of extra data records
+     */
+    private int extraDataSize() {
+        final int extraDataBase = config.methodDataOopDataOffset + normalDataSize();
+        final int extraDataLimit = unsafe.getInt(metaspaceMethodData + config.methodDataSize);
+        return extraDataLimit - extraDataBase;
     }
 
     public boolean hasNormalData() {
-        return normalDataSize > 0;
+        return normalDataSize() > 0;
     }
 
     public boolean hasExtraData() {
-        return extraDataSize > 0;
+        return extraDataSize() > 0;
     }
 
     public int getExtraDataBeginOffset() {
-        return normalDataSize;
+        return normalDataSize();
     }
 
     public boolean isWithin(int position) {
-        return position >= 0 && position < normalDataSize + extraDataSize;
+        return position >= 0 && position < normalDataSize() + extraDataSize();
     }
 
     public int getDeoptimizationCount(DeoptimizationReason reason) {
@@ -101,7 +116,7 @@
     }
 
     public HotSpotMethodDataAccessor getNormalData(int position) {
-        if (position >= normalDataSize) {
+        if (position >= normalDataSize()) {
             return null;
         }
 
@@ -111,7 +126,7 @@
     }
 
     public HotSpotMethodDataAccessor getExtraData(int position) {
-        if (position >= normalDataSize + extraDataSize) {
+        if (position >= normalDataSize() + extraDataSize()) {
             return null;
         }
         HotSpotMethodDataAccessor data = getData(position);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Dec 03 18:44:52 2013 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Dec 03 14:48:09 2013 -0800
@@ -298,12 +298,6 @@
   return !method->is_not_compilable() && !CompilerOracle::should_not_inline(method);
 C2V_END
 
-C2V_VMENTRY(void, initializeMethodData,(JNIEnv *, jobject, jlong metaspace_method_data, jobject hotspot_method_data))
-  MethodData* method_data = asMethodData(metaspace_method_data);
-  HotSpotMethodData::set_normalDataSize(hotspot_method_data, method_data->data_size());
-  HotSpotMethodData::set_extraDataSize(hotspot_method_data, method_data->extra_data_size());
-C2V_END
-  
 C2V_ENTRY(jint, getCompiledCodeSize, (JNIEnv *env, jobject, jlong metaspace_method))
   nmethod* code = (asMethod(metaspace_method))->code();
   return code == NULL ? 0 : code->insts_size();
@@ -1075,9 +1069,7 @@
 #define HS_CONFIG             "Lcom/oracle/graal/hotspot/HotSpotVMConfig;"
 #define HS_METHOD             "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;"
 #define HS_INSTALLED_CODE     "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;"
-#define METHOD_DATA           "Lcom/oracle/graal/hotspot/meta/HotSpotMethodData;"
 #define METASPACE_METHOD      "J"
-#define METASPACE_METHOD_DATA "J"
 
 JNINativeMethod CompilerToVM_methods[] = {
   {CC"initializeBytecode",            CC"("METASPACE_METHOD"[B)[B",                                     FN_PTR(initializeBytecode)},
@@ -1089,7 +1081,6 @@
   {CC"getStackTraceElement",          CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT,                     FN_PTR(getStackTraceElement)},
   {CC"initializeMethod",              CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V",                     FN_PTR(initializeMethod)},
   {CC"doNotInlineOrCompile",          CC"("METASPACE_METHOD")V",                                        FN_PTR(doNotInlineOrCompile)},
-  {CC"initializeMethodData",          CC"("METASPACE_METHOD_DATA METHOD_DATA")V",                       FN_PTR(initializeMethodData)},
   {CC"isMethodCompilable",            CC"("METASPACE_METHOD")Z",                                        FN_PTR(isMethodCompilable)},
   {CC"getCompiledCodeSize",           CC"("METASPACE_METHOD")I",                                        FN_PTR(getCompiledCodeSize)},
   {CC"lookupType",                    CC"("STRING HS_RESOLVED_TYPE"Z)"TYPE,                             FN_PTR(lookupType)},
--- a/src/share/vm/graal/graalJavaAccess.hpp	Tue Dec 03 18:44:52 2013 +0100
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Tue Dec 03 14:48:09 2013 -0800
@@ -63,11 +63,6 @@
     boolean_field(HotSpotResolvedJavaMethod, dontInline)                                                                                                       \
     boolean_field(HotSpotResolvedJavaMethod, ignoredBySecurityStackWalk)                                                                                       \
   end_class                                                                                                                                                    \
-  start_class(HotSpotMethodData)                                                                                                                               \
-    long_field(HotSpotMethodData, metaspaceMethodData)                                                                                                         \
-    int_field(HotSpotMethodData, normalDataSize)                                                                                                               \
-    int_field(HotSpotMethodData, extraDataSize)                                                                                                                \
-  end_class                                                                                                                                                    \
   start_class(HotSpotJavaType)                                                                                                                                 \
     oop_field(HotSpotJavaType, name, "Ljava/lang/String;")                                                                                                     \
   end_class                                                                                                                                                    \