# HG changeset patch # User Tom Rodriguez # Date 1454741316 28800 # Node ID 964f28c04d7bbae2b7dfad8ed7003140d92b84ba # Parent df1da4e38b16320a218f160d2d9268e759f24151 Don't fill the code cache with nmethods from CTW diff -r df1da4e38b16 -r 964f28c04d7b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- 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 diff -r df1da4e38b16 -r 964f28c04d7b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java --- 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();