diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java @ 14107:800057208a2c

enable C1 + Graal tiered
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 06 Mar 2014 17:11:39 -0800
parents f62c770c22be
children fd7fcd2d2072
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Thu Mar 06 22:45:25 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Thu Mar 06 17:11:39 2014 -0800
@@ -38,6 +38,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.debug.*;
+import com.oracle.graal.nodes.*;
 
 /**
  * Implementation of {@link JavaMethod} for resolved HotSpot methods.
@@ -346,8 +347,36 @@
         return runtime().getCompilerToVM().getCompiledCodeSize(metaspaceMethod);
     }
 
+    /**
+     * Gets the value of {@code Method::_code}.
+     * 
+     * @return the value of {@code Method::_code}
+     */
+    private long getCompiledCode() {
+        HotSpotVMConfig config = runtime().getConfig();
+        return unsafe.getAddress(metaspaceMethod + config.methodCodeOffset);
+    }
+
+    /**
+     * Returns whether this method has compiled code.
+     * 
+     * @return true if this method has compiled code, false otherwise
+     */
     public boolean hasCompiledCode() {
-        return getCompiledCodeSize() > 0;
+        return getCompiledCode() != 0L;
+    }
+
+    /**
+     * Gets the compilation level of the currently installed code for this method.
+     * 
+     * @return compilation level
+     */
+    public boolean hasCompiledCodeAtLevel(int level) {
+        long compiledCode = getCompiledCode();
+        if (compiledCode != 0) {
+            return unsafe.getInt(compiledCode + runtime().getConfig().nmethodCompLevelOffset) == level;
+        }
+        return false;
     }
 
     private static final String TraceMethodDataFilter = System.getProperty("graal.traceMethodDataFilter");
@@ -681,4 +710,11 @@
     private long getAccessFlagsAddress() {
         return metaspaceMethod + runtime().getConfig().methodAccessFlagsOffset;
     }
+
+    public boolean hasCodeAtLevel(int entryBCI, int level) {
+        if (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI) {
+            return hasCompiledCodeAtLevel(level);
+        }
+        return runtime().getCompilerToVM().hasCompiledCodeForOSR(metaspaceMethod, entryBCI, level);
+    }
 }