changeset 23394:964f28c04d7b default tip

Don't fill the code cache with nmethods from CTW
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Fri, 05 Feb 2016 22:48:36 -0800
parents df1da4e38b16
children
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java
diffstat 2 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Fri Feb 05 17:48:48 2016 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Fri Feb 05 22:48:36 2016 -0800
@@ -32,7 +32,6 @@
 import jdk.vm.ci.code.BailoutException;
 import jdk.vm.ci.code.CodeCacheProvider;
 import jdk.vm.ci.code.CompilationRequestResult;
-import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
 import jdk.vm.ci.hotspot.HotSpotCompiledCode;
 import jdk.vm.ci.hotspot.HotSpotInstalledCode;
@@ -79,6 +78,8 @@
     private final HotSpotGraalCompiler compiler;
     private final HotSpotCompilationRequest request;
 
+    private HotSpotInstalledCode installedCode;
+
     /**
      * Specifies whether the compilation result is installed as the
      * {@linkplain HotSpotNmethod#isDefault() default} nmethod for the compiled method.
@@ -120,6 +121,10 @@
         return request.getEntryBCI();
     }
 
+    public HotSpotInstalledCode getInstalledCode() {
+        return installedCode;
+    }
+
     /**
      * Time spent in compilation.
      */
@@ -136,7 +141,6 @@
     public CompilationRequestResult runCompilation() {
         HotSpotVMConfig config = jvmciRuntime.getConfig();
         final long threadId = Thread.currentThread().getId();
-        HotSpotInstalledCode installedCode = null;
         int entryBCI = getEntryBCI();
         final boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
         HotSpotResolvedJavaMethod method = getMethod();
@@ -199,7 +203,7 @@
 
             if (result != null) {
                 try (DebugCloseable b = CodeInstallationTime.start()) {
-                    installedCode = (HotSpotInstalledCode) installMethod(result);
+                    installMethod(result);
                 }
             }
             stats.finish(method, installedCode);
@@ -287,16 +291,15 @@
     }
 
     @SuppressWarnings("try")
-    private InstalledCode installMethod(final CompilationResult compResult) {
+    private void installMethod(final CompilationResult compResult) {
         final CodeCacheProvider codeCache = jvmciRuntime.getHostJVMCIBackend().getCodeCache();
-        InstalledCode installedCode = null;
+        installedCode = null;
         try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(getId()), true), codeCache, getMethod())) {
             HotSpotCompiledCode compiledCode = HotSpotCompiledCodeBuilder.createCompiledCode(request.getMethod(), request, compResult);
-            installedCode = codeCache.installCode(request.getMethod(), compiledCode, null, request.getMethod().getSpeculationLog(), installAsDefault);
+            installedCode = (HotSpotInstalledCode) codeCache.installCode(request.getMethod(), compiledCode, null, request.getMethod().getSpeculationLog(), installAsDefault);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
-        return installedCode;
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Fri Feb 05 17:48:48 2016 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Fri Feb 05 22:48:36 2016 -0800
@@ -65,6 +65,7 @@
 import java.util.stream.Collectors;
 
 import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
+import jdk.vm.ci.hotspot.HotSpotInstalledCode;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
@@ -688,6 +689,12 @@
             CompilationTask task = new CompilationTask(jvmciRuntime, compiler, request, useProfilingInfo, installAsDefault);
             task.runCompilation();
 
+            // Invalidate the generated code so the code cache doesn't fill up
+            HotSpotInstalledCode installedCode = task.getInstalledCode();
+            if (installedCode != null) {
+                installedCode.invalidate();
+            }
+
             memoryUsed.getAndAdd(MemUseTrackerImpl.getCurrentThreadAllocatedBytes() - allocatedAtStart);
             compileTime.getAndAdd(System.currentTimeMillis() - start);
             compiledMethodsCounter.incrementAndGet();