changeset 22717:f8a090c89bf4

added CompilationRequest to package up a compilation request and be able to add VM specific context
author Doug Simon <doug.simon@oracle.com>
date Mon, 28 Sep 2015 21:23:34 +0200
parents 3ffc0d85d79a
children b415eaae0aa9
files graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java mx.graal/suite.py
diffstat 5 files changed, 41 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java	Mon Sep 28 15:08:41 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java	Mon Sep 28 21:23:34 2015 +0200
@@ -23,6 +23,8 @@
 package com.oracle.graal.hotspot.test;
 
 import static com.oracle.graal.debug.internal.MemUseTrackerImpl.getCurrentThreadAllocatedBytes;
+import jdk.internal.jvmci.compiler.Compiler;
+import jdk.internal.jvmci.hotspot.HotSpotCompilationRequest;
 import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime;
 import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider;
 import jdk.internal.jvmci.hotspot.HotSpotResolvedJavaMethod;
@@ -136,11 +138,13 @@
         method.reprofile();
 
         int id = method.allocateCompileId(jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI);
-        long graalEnv = 0L;
+        long jvmciEnv = 0L;
 
         try (MemoryUsageCloseable c = label == null ? null : new MemoryUsageCloseable(label)) {
             HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
-            CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), method, jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI, graalEnv, id, false);
+            int entryBCI = Compiler.INVOCATION_ENTRY_BCI;
+            HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id);
+            CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), request, false);
             task.runCompilation();
         }
     }
@@ -154,11 +158,11 @@
             method.reprofile();
 
             int id = method.allocateCompileId(jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI);
-            long graalEnv = 0L;
+            long jvmciEnv = 0L;
             try (AllocSpy as = AllocSpy.open(methodName)) {
                 HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
-                CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), method, jdk.internal.jvmci.compiler.Compiler.INVOCATION_ENTRY_BCI, graalEnv, id,
-                                false);
+                HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, Compiler.INVOCATION_ENTRY_BCI, jvmciEnv, id);
+                CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), request, false);
                 task.runCompilation();
             }
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Sep 28 15:08:41 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Sep 28 21:23:34 2015 +0200
@@ -39,6 +39,7 @@
 import jdk.internal.jvmci.compiler.Compiler;
 import jdk.internal.jvmci.hotspot.CompilerToVM;
 import jdk.internal.jvmci.hotspot.HotSpotCodeCacheProvider;
+import jdk.internal.jvmci.hotspot.HotSpotCompilationRequest;
 import jdk.internal.jvmci.hotspot.HotSpotInstalledCode;
 import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider;
 import jdk.internal.jvmci.hotspot.HotSpotNmethod;
@@ -48,7 +49,6 @@
 import jdk.internal.jvmci.hotspot.events.EventProvider;
 import jdk.internal.jvmci.hotspot.events.EventProvider.CompilationEvent;
 import jdk.internal.jvmci.hotspot.events.EventProvider.CompilerFailureEvent;
-import jdk.internal.jvmci.meta.ResolvedJavaMethod;
 import jdk.internal.jvmci.service.Services;
 import sun.misc.Unsafe;
 
@@ -97,10 +97,7 @@
     private final HotSpotJVMCIRuntimeProvider jvmciRuntime;
 
     private final HotSpotGraalCompiler compiler;
-
-    private final HotSpotResolvedJavaMethod method;
-    private final int entryBCI;
-    private final int id;
+    private final HotSpotCompilationRequest request;
 
     /**
      * Specifies whether the compilation result is installed as the
@@ -116,23 +113,15 @@
         static final com.sun.management.ThreadMXBean threadMXBean = (com.sun.management.ThreadMXBean) Management.getThreadMXBean();
     }
 
-    /**
-     * The address of the JVMCIEnv associated with this compilation or 0L if no such object exists.
-     */
-    private final long jvmciEnv;
-
-    public CompilationTask(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler, HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id, boolean installAsDefault) {
+    public CompilationTask(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler, HotSpotCompilationRequest request, boolean installAsDefault) {
         this.jvmciRuntime = jvmciRuntime;
         this.compiler = compiler;
-        this.method = method;
-        this.entryBCI = entryBCI;
-        this.id = id;
-        this.jvmciEnv = jvmciEnv;
+        this.request = request;
         this.installAsDefault = installAsDefault;
     }
 
-    public ResolvedJavaMethod getMethod() {
-        return method;
+    public HotSpotResolvedJavaMethod getMethod() {
+        return request.getMethod();
     }
 
     /**
@@ -141,11 +130,11 @@
      * @return compile id
      */
     public int getId() {
-        return id;
+        return request.getId();
     }
 
     public int getEntryBCI() {
-        return entryBCI;
+        return request.getEntryBCI();
     }
 
     /**
@@ -166,7 +155,9 @@
         final long threadId = Thread.currentThread().getId();
         long startCompilationTime = System.nanoTime();
         HotSpotInstalledCode installedCode = null;
+        int entryBCI = getEntryBCI();
         final boolean isOSR = entryBCI != Compiler.INVOCATION_ENTRY_BCI;
+        HotSpotResolvedJavaMethod method = getMethod();
 
         // Log a compilation event.
         CompilationEvent compilationEvent = eventProvider.newCompilationEvent();
@@ -198,7 +189,7 @@
                 allocatedBytesBefore = 0L;
             }
 
-            try (Scope s = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) {
+            try (Scope s = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(getId()), true))) {
                 // Begin the compilation event.
                 compilationEvent.begin();
 
@@ -222,7 +213,7 @@
                     if (printAfterCompilation) {
                         TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dkB", stop - start, targetCodeSize, allocatedBytes));
                     } else if (printCompilation) {
-                        TTY.println(String.format("%-6d JVMCI %-70s %-45s %-50s | %4dms %5dB %5dkB", id, "", "", "", stop - start, targetCodeSize, allocatedBytes));
+                        TTY.println(String.format("%-6d JVMCI %-70s %-45s %-50s | %4dms %5dB %5dkB", getId(), "", "", "", stop - start, targetCodeSize, allocatedBytes));
                     }
                 }
             }
@@ -280,6 +271,7 @@
                 compilationEvent.commit();
             }
 
+            long jvmciEnv = request.getJvmciEnv();
             if (jvmciEnv != 0) {
                 long ctask = UNSAFE.getAddress(jvmciEnv + config.jvmciEnvTaskOffset);
                 assert ctask != 0L;
@@ -289,7 +281,7 @@
             if ((config.ciTime || config.ciTimeEach) && installedCode != null) {
                 long timeUnitsPerSecond = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
                 CompilerToVM c2vm = jvmciRuntime.getCompilerToVM();
-                c2vm.notifyCompilationStatistics(id, method, entryBCI != Compiler.INVOCATION_ENTRY_BCI, compiledBytecodes, compilationTime, timeUnitsPerSecond, installedCode);
+                c2vm.notifyCompilationStatistics(getId(), method, entryBCI != Compiler.INVOCATION_ENTRY_BCI, compiledBytecodes, compilationTime, timeUnitsPerSecond, installedCode);
             }
         }
     }
@@ -301,6 +293,7 @@
         if (config.ciTime || config.ciTimeEach || CompiledBytecodes.isEnabled()) {
             return true;
         }
+        long jvmciEnv = request.getJvmciEnv();
         if (jvmciEnv == 0 || UNSAFE.getByte(jvmciEnv + config.jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0) {
             return true;
         }
@@ -308,16 +301,17 @@
     }
 
     private String getMethodDescription() {
-        return String.format("%-6d JVMCI %-70s %-45s %-50s %s", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(),
-                        entryBCI == Compiler.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") ");
+        HotSpotResolvedJavaMethod method = getMethod();
+        return String.format("%-6d JVMCI %-70s %-45s %-50s %s", getId(), method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(),
+                        getEntryBCI() == Compiler.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + getEntryBCI() + ") ");
     }
 
     @SuppressWarnings("try")
     private InstalledCode installMethod(final CompilationResult compResult) {
         final HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmciRuntime.getHostJVMCIBackend().getCodeCache();
         InstalledCode installedCode = null;
-        try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) {
-            installedCode = codeCache.installMethod(method, compResult, jvmciEnv, installAsDefault);
+        try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(getId()), true), codeCache, getMethod())) {
+            installedCode = codeCache.installMethod(getMethod(), compResult, request.getJvmciEnv(), installAsDefault);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
@@ -326,6 +320,6 @@
 
     @Override
     public String toString() {
-        return "Compilation[id=" + id + ", " + method.format("%H.%n(%p)") + (entryBCI == Compiler.INVOCATION_ENTRY_BCI ? "" : "@" + entryBCI) + "]";
+        return "Compilation[id=" + getId() + ", " + getMethod().format("%H.%n(%p)") + (getEntryBCI() == Compiler.INVOCATION_ENTRY_BCI ? "" : "@" + getEntryBCI()) + "]";
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Mon Sep 28 15:08:41 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Mon Sep 28 21:23:34 2015 +0200
@@ -56,6 +56,7 @@
 import java.util.stream.Collectors;
 
 import jdk.internal.jvmci.compiler.Compiler;
+import jdk.internal.jvmci.hotspot.HotSpotCompilationRequest;
 import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime;
 import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider;
 import jdk.internal.jvmci.hotspot.HotSpotResolvedJavaMethod;
@@ -293,7 +294,8 @@
             // compile dummy method to get compiler initilized outside of the config debug override.
             HotSpotResolvedJavaMethod dummyMethod = (HotSpotResolvedJavaMethod) JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess().lookupJavaMethod(
                             CompileTheWorld.class.getDeclaredMethod("dummy"));
-            CompilationTask task = new CompilationTask(jvmciRuntime, compiler, dummyMethod, Compiler.INVOCATION_ENTRY_BCI, 0L, dummyMethod.allocateCompileId(Compiler.INVOCATION_ENTRY_BCI), false);
+            int entryBCI = Compiler.INVOCATION_ENTRY_BCI;
+            CompilationTask task = new CompilationTask(jvmciRuntime, compiler, new HotSpotCompilationRequest(dummyMethod, entryBCI, 0L, dummyMethod.allocateCompileId(entryBCI)), false);
             task.runCompilation();
         } catch (NoSuchMethodException | SecurityException e1) {
             e1.printStackTrace();
@@ -483,8 +485,9 @@
         try {
             long start = System.currentTimeMillis();
             long allocatedAtStart = MemUseTrackerImpl.getCurrentThreadAllocatedBytes();
-
-            CompilationTask task = new CompilationTask(jvmciRuntime, compiler, method, Compiler.INVOCATION_ENTRY_BCI, 0L, method.allocateCompileId(Compiler.INVOCATION_ENTRY_BCI), false);
+            int entryBCI = Compiler.INVOCATION_ENTRY_BCI;
+            HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, 0L, method.allocateCompileId(entryBCI));
+            CompilationTask task = new CompilationTask(jvmciRuntime, compiler, request, false);
             task.runCompilation();
 
             memoryUsed.getAndAdd(MemUseTrackerImpl.getCurrentThreadAllocatedBytes() - allocatedAtStart);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Mon Sep 28 15:08:41 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Mon Sep 28 21:23:34 2015 +0200
@@ -28,11 +28,12 @@
 import static jdk.internal.jvmci.code.CodeUtil.getCallingConvention;
 import jdk.internal.jvmci.code.CallingConvention;
 import jdk.internal.jvmci.code.CallingConvention.Type;
+import jdk.internal.jvmci.code.CompilationRequest;
 import jdk.internal.jvmci.code.CompilationResult;
 import jdk.internal.jvmci.compiler.Compiler;
 import jdk.internal.jvmci.hotspot.CompilerToVM;
+import jdk.internal.jvmci.hotspot.HotSpotCompilationRequest;
 import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider;
-import jdk.internal.jvmci.hotspot.HotSpotResolvedJavaMethod;
 import jdk.internal.jvmci.meta.JavaType;
 import jdk.internal.jvmci.meta.ProfilingInfo;
 import jdk.internal.jvmci.meta.ResolvedJavaMethod;
@@ -79,13 +80,13 @@
 
     @Override
     @SuppressWarnings("try")
-    public void compileMethod(ResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) {
+    public void compileMethod(CompilationRequest request) {
         // Ensure a debug configuration for this thread is initialized
         if (Debug.isEnabled() && DebugScope.getConfig() == null) {
             DebugEnvironment.initialize(TTY.out);
         }
 
-        CompilationTask task = new CompilationTask(jvmciRuntime, this, (HotSpotResolvedJavaMethod) method, entryBCI, jvmciEnv, id, true);
+        CompilationTask task = new CompilationTask(jvmciRuntime, this, (HotSpotCompilationRequest) request, true);
         try (DebugConfigScope dcs = Debug.setConfig(new TopLevelDebugConfig())) {
             task.runCompilation();
         }
--- a/mx.graal/suite.py	Mon Sep 28 15:08:41 2015 +0200
+++ b/mx.graal/suite.py	Mon Sep 28 21:23:34 2015 +0200
@@ -6,7 +6,7 @@
     "suites": [
             {
                "name" : "jvmci",
-               "version" : "0f13373f18d01dec38726de941bf625b1b0273bf",
+               "version" : "bec9cd4e731ae36000b5eb0110b849b9775e28d6",
                "urls" : [
                     {"url" : "http://lafo.ssw.uni-linz.ac.at/hg/graal-jvmci-8", "kind" : "hg"},
                     {"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},