changeset 22719:f035cf1d2e5a

Merge.
author Doug Simon <doug.simon@oracle.com>
date Tue, 29 Sep 2015 14:56:58 +0200
parents b415eaae0aa9 (diff) f7693dc4e341 (current diff)
children bba4e91a2d63
files mx.graal/suite.py
diffstat 18 files changed, 100 insertions(+), 243 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java	Tue Sep 29 14:56:58 2015 +0200
@@ -76,7 +76,7 @@
             compResult.setTargetCode(targetCode, targetCode.length);
             compResult.setTotalFrameSize(0);
 
-            InstalledCode code = codeCache.addMethod(method, compResult, null, null);
+            InstalledCode code = codeCache.addCode(method, compResult, null, null);
 
             for (DisassemblerProvider dis : Services.load(DisassemblerProvider.class)) {
                 String disasm1 = dis.disassembleCompiledCode(codeCache, compResult);
--- a/graal/com.oracle.graal.code/src/com/oracle/graal/code/DisassemblerProvider.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.code/src/com/oracle/graal/code/DisassemblerProvider.java	Tue Sep 29 14:56:58 2015 +0200
@@ -34,8 +34,7 @@
     /**
      * Gets a textual disassembly of a given compilation result.
      *
-     * @param codeCache the object used for code {@link CodeCacheProvider#addMethod code
-     *            installation}
+     * @param codeCache the object used for code {@link CodeCacheProvider#addCode code installation}
      * @param compResult a compilation result
      * @return a non-zero length string containing a disassembly of {@code compResult} or null it
      *         could not be disassembled
@@ -47,8 +46,7 @@
     /**
      * Gets a textual disassembly of a given installed code.
      *
-     * @param codeCache the object used for code {@link CodeCacheProvider#addMethod code
-     *            installation}
+     * @param codeCache the object used for code {@link CodeCacheProvider#addCode code installation}
      * @param compResult a compiled code that was installed to produce {@code installedCode}. This
      *            will be null if not available.
      * @param installedCode
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerAssumptionsTest.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerAssumptionsTest.java	Tue Sep 29 14:56:58 2015 +0200
@@ -65,7 +65,7 @@
         checkGraph(expectedAssumption, graph);
 
         CompilationResult compilationResult = compile(javaMethod, graph);
-        final InstalledCode installedCode = getProviders().getCodeCache().setDefaultMethod(javaMethod, compilationResult);
+        final InstalledCode installedCode = getProviders().getCodeCache().setDefaultCode(javaMethod, compilationResult);
         assertTrue(installedCode.isValid());
         if (classToLoad != null) {
             String fullName = getClass().getName() + "$" + classToLoad;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Sep 29 14:56:58 2015 +0200
@@ -779,7 +779,7 @@
     }
 
     protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult compResult) {
-        return getCodeCache().addMethod(method, compResult, null, null);
+        return getCodeCache().addCode(method, compResult, null, null);
     }
 
     private final Map<ResolvedJavaMethod, Method> methodMap = new HashMap<>();
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java	Tue Sep 29 14:56:58 2015 +0200
@@ -147,7 +147,7 @@
         removeLoopSafepoint(graph);
 
         CompilationResult compilationResult = compile(javaMethod, graph);
-        final InstalledCode installedCode = getProviders().getCodeCache().setDefaultMethod(javaMethod, compilationResult);
+        final InstalledCode installedCode = getProviders().getCodeCache().setDefaultCode(javaMethod, compilationResult);
 
         final Monitor monitor = new Monitor();
 
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java	Tue Sep 29 14:56:58 2015 +0200
@@ -138,7 +138,7 @@
              * Install the compilation result into the VM, i.e., copy the byte[] array that contains
              * the machine code into an actual executable memory location.
              */
-            InstalledCode installedCode = codeCache.addMethod(method, compilationResult, null, null);
+            InstalledCode installedCode = codeCache.addCode(method, compilationResult, null, null);
 
             return installedCode;
         } catch (Throwable ex) {
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Tue Sep 29 14:56:58 2015 +0200
@@ -23,7 +23,6 @@
 package com.oracle.graal.hotspot.test;
 
 import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION;
-import static jdk.internal.jvmci.hotspot.CompilerToVM.compilerToVM;
 import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config;
 
 import java.io.ByteArrayOutputStream;
@@ -40,10 +39,6 @@
 
 import jdk.internal.jvmci.code.CompilationResult;
 import jdk.internal.jvmci.code.InstalledCode;
-import jdk.internal.jvmci.hotspot.HotSpotCompiledNmethod;
-import jdk.internal.jvmci.hotspot.HotSpotNmethod;
-import jdk.internal.jvmci.hotspot.HotSpotResolvedJavaMethod;
-import jdk.internal.jvmci.hotspot.HotSpotVMConfig;
 import jdk.internal.jvmci.meta.ResolvedJavaMethod;
 
 import org.junit.Assert;
@@ -65,17 +60,7 @@
 
     @Override
     protected InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) {
-        HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method;
-        HotSpotNmethod installedCode = new HotSpotNmethod(hsMethod, compResult.getName(), true);
-        HotSpotCompiledNmethod compiledNmethod = new HotSpotCompiledNmethod(hsMethod, compResult);
-        int result = compilerToVM().installCode(getTarget(), compiledNmethod, installedCode, null);
-        HotSpotVMConfig config = config();
-        Assert.assertEquals("Error installing method " + method + ": " + config.getCodeInstallResultDescription(result), result, config.codeInstallResultOk);
-
-        // HotSpotRuntime hsRuntime = (HotSpotRuntime) getCodeCache();
-        // TTY.println(hsMethod.toString());
-        // TTY.println(hsRuntime.disassemble(installedCode));
-        return installedCode;
+        return getCodeCache().setDefaultCode(method, compResult);
     }
 
     SecretKey aesKey;
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java	Tue Sep 29 14:56:58 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;
@@ -135,12 +137,13 @@
         // invalidate any existing compiled code
         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);
+            CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), request, false);
             task.runCompilation();
         }
     }
@@ -153,12 +156,11 @@
             // invalidate any existing compiled code
             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);
+                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	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Tue Sep 29 14:56:58 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,13 +189,10 @@
                 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();
-
                 result = compiler.compile(method, entryBCI, mustRecordMethodInlining(config));
-
-                result.setId(getId());
             } catch (Throwable e) {
                 throw Debug.handle(e);
             } finally {
@@ -222,13 +210,15 @@
                     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));
                     }
                 }
             }
 
-            try (DebugCloseable b = CodeInstallationTime.start()) {
-                installedCode = (HotSpotInstalledCode) installMethod(result);
+            if (result != null) {
+                try (DebugCloseable b = CodeInstallationTime.start()) {
+                    installedCode = (HotSpotInstalledCode) installMethod(result);
+                }
             }
             stats.finish(method, installedCode);
         } catch (BailoutException bailout) {
@@ -280,6 +270,7 @@
                 compilationEvent.commit();
             }
 
+            long jvmciEnv = request.getJvmciEnv();
             if (jvmciEnv != 0) {
                 long ctask = UNSAFE.getAddress(jvmciEnv + config.jvmciEnvTaskOffset);
                 assert ctask != 0L;
@@ -289,7 +280,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 +292,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 +300,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.installCode(request, compResult, null, request.getMethod().getSpeculationLog(), installAsDefault);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
@@ -326,6 +319,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	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Tue Sep 29 14:56:58 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), 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);
+            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/HotSpotCompiledRuntimeStub.java	Tue Sep 29 09:55:35 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2011, 2014, 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 com.oracle.graal.hotspot;
-
-import static com.oracle.graal.hotspot.HotSpotHostBackend.UNCOMMON_TRAP_HANDLER;
-import jdk.internal.jvmci.code.CompilationResult;
-import jdk.internal.jvmci.code.CompilationResult.Call;
-import jdk.internal.jvmci.code.CompilationResult.ConstantReference;
-import jdk.internal.jvmci.code.CompilationResult.DataPatch;
-import jdk.internal.jvmci.code.CompilationResult.Infopoint;
-import jdk.internal.jvmci.hotspot.HotSpotCompiledCode;
-import jdk.internal.jvmci.hotspot.HotSpotMetaspaceConstant;
-
-/**
- * {@link HotSpotCompiledCode} destined for installation as a RuntimeStub.
- */
-public final class HotSpotCompiledRuntimeStub extends HotSpotCompiledCode {
-
-    public HotSpotCompiledRuntimeStub(CompilationResult compResult) {
-        super(compResult);
-        assert checkStubInvariants(compResult);
-    }
-
-    /**
-     * Checks the conditions a compilation must satisfy to be installed as a RuntimeStub.
-     */
-    private boolean checkStubInvariants(CompilationResult compResult) {
-        assert compResult.getExceptionHandlers().isEmpty() : this;
-
-        // Stubs cannot be recompiled so they cannot be compiled with
-        // assumptions and there is no point in recording evol_method dependencies
-        assert compResult.getAssumptions() == null : "stubs should not use assumptions: " + this;
-        assert compResult.getMethods() == null : "stubs should not record evol_method dependencies: " + this;
-
-        for (DataPatch data : compResult.getDataPatches()) {
-            if (data.reference instanceof ConstantReference) {
-                ConstantReference ref = (ConstantReference) data.reference;
-                if (ref.getConstant() instanceof HotSpotMetaspaceConstant) {
-                    HotSpotMetaspaceConstant c = (HotSpotMetaspaceConstant) ref.getConstant();
-                    if (c.asResolvedJavaType() != null && c.asResolvedJavaType().getName().equals("[I")) {
-                        // special handling for NewArrayStub
-                        // embedding the type '[I' is safe, since it is never unloaded
-                        continue;
-                    }
-                }
-            }
-
-            assert !(data.reference instanceof ConstantReference) : this + " cannot have embedded object or metadata constant: " + data.reference;
-        }
-        for (Infopoint infopoint : compResult.getInfopoints()) {
-            assert infopoint instanceof Call : this + " cannot have non-call infopoint: " + infopoint;
-            Call call = (Call) infopoint;
-            assert call.target instanceof HotSpotForeignCallLinkage : this + " cannot have non runtime call: " + call.target;
-            HotSpotForeignCallLinkage linkage = (HotSpotForeignCallLinkage) call.target;
-            assert !linkage.isCompiledStub() || linkage.getDescriptor().equals(UNCOMMON_TRAP_HANDLER) : this + " cannot call compiled stub " + linkage;
-        }
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return name;
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Tue Sep 29 14:56:58 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/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntimeStub.java	Tue Sep 29 09:55:35 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta;
-
-import jdk.internal.jvmci.code.InstalledCode;
-import jdk.internal.jvmci.code.InvalidInstalledCodeException;
-import jdk.internal.jvmci.hotspot.HotSpotInstalledCode;
-import jdk.internal.jvmci.meta.ResolvedJavaMethod;
-
-import com.oracle.graal.hotspot.stubs.Stub;
-
-/**
- * Implementation of {@link InstalledCode} for code installed as a RuntimeStub.
- */
-public class HotSpotRuntimeStub extends HotSpotInstalledCode {
-
-    private final Stub stub;
-
-    public HotSpotRuntimeStub(Stub stub) {
-        super(stub.toString());
-        this.stub = stub;
-    }
-
-    public ResolvedJavaMethod getMethod() {
-        return null;
-    }
-
-    @Override
-    public boolean isValid() {
-        return true;
-    }
-
-    @Override
-    public void invalidate() {
-    }
-
-    @Override
-    public String toString() {
-        return String.format("InstalledRuntimeStub[stub=%s, codeBlob=0x%x]", stub, getAddress());
-    }
-
-    @Override
-    public Object executeVarargs(Object... args) throws InvalidInstalledCodeException {
-        throw new InternalError("Cannot call stub " + stub);
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Tue Sep 29 14:56:58 2015 +0200
@@ -25,8 +25,7 @@
 import static com.oracle.graal.compiler.GraalCompiler.emitBackEnd;
 import static com.oracle.graal.compiler.GraalCompiler.emitFrontEnd;
 import static com.oracle.graal.compiler.GraalCompiler.getProfilingInfo;
-import static jdk.internal.jvmci.hotspot.CompilerToVM.compilerToVM;
-import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config;
+import static com.oracle.graal.hotspot.HotSpotHostBackend.UNCOMMON_TRAP_HANDLER;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -38,23 +37,22 @@
 import jdk.internal.jvmci.code.CallingConvention;
 import jdk.internal.jvmci.code.CodeCacheProvider;
 import jdk.internal.jvmci.code.CompilationResult;
+import jdk.internal.jvmci.code.CompilationResult.Call;
+import jdk.internal.jvmci.code.CompilationResult.ConstantReference;
+import jdk.internal.jvmci.code.CompilationResult.DataPatch;
+import jdk.internal.jvmci.code.CompilationResult.Infopoint;
 import jdk.internal.jvmci.code.InstalledCode;
 import jdk.internal.jvmci.code.Register;
 import jdk.internal.jvmci.code.RegisterConfig;
-import jdk.internal.jvmci.common.JVMCIError;
-import jdk.internal.jvmci.hotspot.HotSpotCodeCacheProvider;
-import jdk.internal.jvmci.hotspot.HotSpotCompiledCode;
-import jdk.internal.jvmci.hotspot.HotSpotVMConfig;
+import jdk.internal.jvmci.hotspot.HotSpotMetaspaceConstant;
 import jdk.internal.jvmci.meta.ResolvedJavaMethod;
 
 import com.oracle.graal.compiler.target.Backend;
 import com.oracle.graal.debug.Debug;
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.debug.internal.DebugScope;
-import com.oracle.graal.hotspot.HotSpotCompiledRuntimeStub;
 import com.oracle.graal.hotspot.HotSpotForeignCallLinkage;
 import com.oracle.graal.hotspot.meta.HotSpotProviders;
-import com.oracle.graal.hotspot.meta.HotSpotRuntimeStub;
 import com.oracle.graal.hotspot.nodes.StubStartNode;
 import com.oracle.graal.lir.asm.CompilationResultBuilderFactory;
 import com.oracle.graal.lir.phases.LIRPhase;
@@ -203,23 +201,14 @@
                     SchedulePhase schedule = emitFrontEnd(providers, backend, graph, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), suites);
                     LIRSuites lirSuites = createLIRSuites();
                     emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, compResult, CompilationResultBuilderFactory.Default, schedule, getRegisterConfig(), lirSuites);
+                    assert checkStubInvariants();
                 } catch (Throwable e) {
                     throw Debug.handle(e);
                 }
 
                 assert destroyedRegisters != null;
                 try (Scope s = Debug.scope("CodeInstall")) {
-                    Stub stub = Stub.this;
-                    HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub);
-                    HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(compResult);
-
-                    int result = compilerToVM().installCode(backend.getTarget(), hsCompResult, installedCode, null);
-                    HotSpotVMConfig config = config();
-                    if (result != config.codeInstallResultOk) {
-                        throw new JVMCIError("Error installing stub %s: %s", Stub.this, config.getCodeInstallResultDescription(result));
-                    }
-                    ((HotSpotCodeCacheProvider) codeCache).logOrDump(installedCode, compResult);
-                    code = installedCode;
+                    code = codeCache.installCode(null, compResult, null, null, false);
                 } catch (Throwable e) {
                     throw Debug.handle(e);
                 }
@@ -232,6 +221,42 @@
         return code;
     }
 
+    /**
+     * Checks the conditions a compilation must satisfy to be installed as a RuntimeStub.
+     */
+    private boolean checkStubInvariants() {
+        assert compResult.getExceptionHandlers().isEmpty() : this;
+
+        // Stubs cannot be recompiled so they cannot be compiled with
+        // assumptions and there is no point in recording evol_method dependencies
+        assert compResult.getAssumptions() == null : "stubs should not use assumptions: " + this;
+        assert compResult.getMethods() == null : "stubs should not record evol_method dependencies: " + this;
+
+        for (DataPatch data : compResult.getDataPatches()) {
+            if (data.reference instanceof ConstantReference) {
+                ConstantReference ref = (ConstantReference) data.reference;
+                if (ref.getConstant() instanceof HotSpotMetaspaceConstant) {
+                    HotSpotMetaspaceConstant c = (HotSpotMetaspaceConstant) ref.getConstant();
+                    if (c.asResolvedJavaType() != null && c.asResolvedJavaType().getName().equals("[I")) {
+                        // special handling for NewArrayStub
+                        // embedding the type '[I' is safe, since it is never unloaded
+                        continue;
+                    }
+                }
+            }
+
+            assert !(data.reference instanceof ConstantReference) : this + " cannot have embedded object or metadata constant: " + data.reference;
+        }
+        for (Infopoint infopoint : compResult.getInfopoints()) {
+            assert infopoint instanceof Call : this + " cannot have non-call infopoint: " + infopoint;
+            Call call = (Call) infopoint;
+            assert call.target instanceof HotSpotForeignCallLinkage : this + " cannot have non runtime call: " + call.target;
+            HotSpotForeignCallLinkage callLinkage = (HotSpotForeignCallLinkage) call.target;
+            assert !callLinkage.isCompiledStub() || callLinkage.getDescriptor().equals(UNCOMMON_TRAP_HANDLER) : this + " cannot call compiled stub " + callLinkage;
+        }
+        return true;
+    }
+
     private LIRSuites createLIRSuites() {
         LIRSuites lirSuites = new LIRSuites(providers.getSuites().getDefaultLIRSuites());
         ListIterator<LIRPhase<PostAllocationOptimizationContext>> moveProfiling = lirSuites.getPostAllocationOptimizationStage().findPhase(MoveProfiling.class);
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Tue Sep 29 14:56:58 2015 +0200
@@ -212,7 +212,7 @@
                 CompilationResult compResult = compileMethod(method);
                 CodeCacheProvider codeCache = providers.getCodeCache();
                 try (Scope s = Debug.scope("CodeInstall", codeCache, method)) {
-                    codeCache.setDefaultMethod(method, compResult);
+                    codeCache.setDefaultCode(method, compResult);
                 } catch (Throwable e) {
                     throw Debug.handle(e);
                 }
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java	Tue Sep 29 14:56:58 2015 +0200
@@ -182,7 +182,7 @@
                         lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default);
         InstalledCode installedCode;
         try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache(), g.method())) {
-            installedCode = providers.getCodeCache().addMethod(g.method(), compResult, null, null);
+            installedCode = providers.getCodeCache().addCode(g.method(), compResult, null, null);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java	Tue Sep 29 09:55:35 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java	Tue Sep 29 14:56:58 2015 +0200
@@ -215,7 +215,7 @@
 
         InstalledCode installedCode;
         try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache()); DebugCloseable a = CodeInstallationTime.start(); DebugCloseable c = CodeInstallationMemUse.start()) {
-            installedCode = providers.getCodeCache().addMethod(graph.method(), result, graph.getSpeculationLog(), predefinedInstalledCode);
+            installedCode = providers.getCodeCache().addCode(graph.method(), result, graph.getSpeculationLog(), predefinedInstalledCode);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
--- a/mx.graal/suite.py	Tue Sep 29 09:55:35 2015 +0200
+++ b/mx.graal/suite.py	Tue Sep 29 14:56:58 2015 +0200
@@ -6,7 +6,7 @@
     "suites": [
             {
                "name" : "jvmci",
-               "version" : "111882d99400aae882d0a8caebb53733646ded8b",
+               "version" : "545590b1ab83c00b653ec3143ff876a0c42306c4",
                "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"},