# HG changeset patch # User Gilles Duboscq # Date 1335348119 -7200 # Node ID 60e658e50fceac852b681a20ce4206acb9e520a1 # Parent 31fc6b6c042584819f25a7298bc39f6f3b439825# Parent 796917d3bfc92707bda7291d7a3e9e2dd8ba6a22 Merge diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Apr 25 12:01:59 2012 +0200 @@ -75,21 +75,11 @@ } - public CiTargetMethod compileMethod(final RiResolvedMethod method, final StructuredGraph graph, int osrBCI, final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts) { + public CiTargetMethod compileMethod(final RiResolvedMethod method, final StructuredGraph graph, int osrBCI, final RiGraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts) { assert (method.accessFlags() & Modifier.NATIVE) == 0 : "compiling native methods is not supported"; if (osrBCI != -1) { throw new CiBailout("No OSR supported"); } - if (cache != null) { - long[] deoptedGraphs = runtime.getDeoptedLeafGraphIds(); - if (deoptedGraphs != null) { - if (deoptedGraphs.length == 0) { - cache.clear(); - } else { - cache.removeGraphs(deoptedGraphs); - } - } - } return Debug.scope("GraalCompiler", new Object[] {graph, method, this}, new Callable() { public CiTargetMethod call() { @@ -116,7 +106,7 @@ /** * Builds the graph, optimizes it. */ - public LIR emitHIR(StructuredGraph graph, CiAssumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { + public LIR emitHIR(StructuredGraph graph, CiAssumptions assumptions, RiGraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { if (graph.start().next() == null) { plan.runPhases(PhasePosition.AFTER_PARSING, graph); diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/graph/GraphCache.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/graph/GraphCache.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/graph/GraphCache.java Wed Apr 25 12:01:59 2012 +0200 @@ -29,10 +29,12 @@ import java.util.concurrent.atomic.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.cri.*; import com.oracle.graal.nodes.*; import com.oracle.max.cri.ri.*; -public class GraphCache { +public class GraphCache implements RiGraphCache { + private static final PrintStream out = System.out; private final boolean dump; private boolean enabled = true; @@ -89,6 +91,7 @@ enabled = true; } + @Override public StructuredGraph get(RiResolvedMethod method) { if (!enabled) { return null; @@ -114,6 +117,7 @@ return result; } + @Override public void put(StructuredGraph graph) { if (!enabled) { return; @@ -134,6 +138,7 @@ } } + @Override public void clear() { graphs.clear(); currentGraphIds.clear(); @@ -145,6 +150,7 @@ putCounter.set(0); } + @Override public void removeGraphs(long[] deoptedGraphs) { for (long graphId : deoptedGraphs) { graphs.remove(graphId); diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EscapeAnalysisPhase.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EscapeAnalysisPhase.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EscapeAnalysisPhase.java Wed Apr 25 12:01:59 2012 +0200 @@ -239,11 +239,11 @@ private final CiTarget target; private final GraalRuntime runtime; private final CiAssumptions assumptions; - private final GraphCache cache; + private final RiGraphCache cache; private final PhasePlan plan; private final OptimisticOptimizations optimisticOpts; - public EscapeAnalysisPhase(CiTarget target, GraalRuntime runtime, CiAssumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { + public EscapeAnalysisPhase(CiTarget target, GraalRuntime runtime, CiAssumptions assumptions, RiGraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { this.runtime = runtime; this.target = target; this.assumptions = assumptions; diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java Wed Apr 25 12:01:59 2012 +0200 @@ -57,7 +57,7 @@ private CiAssumptions assumptions; private final PhasePlan plan; - private final GraphCache cache; + private final RiGraphCache cache; private final WeightComputationPolicy weightComputationPolicy; private final InliningPolicy inliningPolicy; private final OptimisticOptimizations optimisticOpts; @@ -67,7 +67,7 @@ private static final DebugMetric metricInliningConsidered = Debug.metric("InliningConsidered"); private static final DebugMetric metricInliningStoppedByMaxDesiredSize = Debug.metric("InliningStoppedByMaxDesiredSize"); - public InliningPhase(CiTarget target, GraalRuntime runtime, Collection hints, CiAssumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { + public InliningPhase(CiTarget target, GraalRuntime runtime, Collection hints, CiAssumptions assumptions, RiGraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { this.target = target; this.runtime = runtime; this.hints = hints; diff -r 31fc6b6c0425 -r 60e658e50fce 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 Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Apr 25 12:01:59 2012 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.phases.*; +import com.oracle.graal.cri.*; import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.ri.*; import com.oracle.graal.nodes.*; @@ -90,7 +91,6 @@ if (GraalOptions.DynamicCompilePriority) { int threadPriority = priority < GraalOptions.SlowQueueCutoff ? Thread.NORM_PRIORITY : Thread.MIN_PRIORITY; if (Thread.currentThread().getPriority() != threadPriority) { - // out.print(threadPriority); Thread.currentThread().setPriority(threadPriority); } } @@ -118,6 +118,7 @@ @Override public CiTargetMethod call() throws Exception { + compiler.evictDeoptedGraphs(); StructuredGraph graph = new StructuredGraph(method); return compiler.getCompiler().compileMethod(method, graph, -1, compiler.getCache(), plan, optimisticOpts); } diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/Compiler.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/Compiler.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/Compiler.java Wed Apr 25 12:01:59 2012 +0200 @@ -22,13 +22,12 @@ */ package com.oracle.graal.hotspot; -import com.oracle.max.cri.ci.*; -import com.oracle.max.cri.ri.*; import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.graph.*; -import com.oracle.graal.cri.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.ri.*; +import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; public interface Compiler { @@ -37,8 +36,9 @@ GraalCompiler getCompiler(); RiType lookupType(String returnType, HotSpotTypeResolved accessingClass, boolean eagerResolve); HotSpotVMConfig getConfig(); - GraalRuntime getRuntime(); + HotSpotRuntime getRuntime(); CiTarget getTarget(); GraphCache getCache(); + void evictDeoptedGraphs(); } diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerImpl.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerImpl.java Wed Apr 25 12:01:59 2012 +0200 @@ -109,22 +109,22 @@ toVM = new CompilerToVMImpl(); } - // initialize VMExits - VMToCompiler exits = new VMToCompilerImpl(this); + // initialize VmToCompiler + VMToCompiler toCompiler = new VMToCompilerImpl(this); // logging, etc. if (CountingProxy.ENABLED) { - exits = CountingProxy.getProxy(VMToCompiler.class, exits); + toCompiler = CountingProxy.getProxy(VMToCompiler.class, toCompiler); toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); } if (Logger.ENABLED) { - exits = LoggingProxy.getProxy(VMToCompiler.class, exits); + toCompiler = LoggingProxy.getProxy(VMToCompiler.class, toCompiler); toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); } // set the final fields compilerToVm = toVM; - vmToCompiler = exits; + vmToCompiler = toCompiler; // initialize compiler config = compilerToVm.getConfiguration(); @@ -256,4 +256,17 @@ } return runtime; } + + public void evictDeoptedGraphs() { + if (cache != null) { + long[] deoptedGraphs = getCompilerToVM().getDeoptedLeafGraphIds(); + if (deoptedGraphs != null) { + if (deoptedGraphs.length == 0) { + cache.clear(); + } else { + cache.removeGraphs(deoptedGraphs); + } + } + } + } } diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Wed Apr 25 12:01:59 2012 +0200 @@ -28,6 +28,7 @@ import java.util.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.compiler.graph.*; import com.oracle.graal.compiler.phases.*; import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition; import com.oracle.graal.compiler.target.*; @@ -502,11 +503,6 @@ } @Override - public long[] getDeoptedLeafGraphIds() { - return compiler.getCompilerToVM().getDeoptedLeafGraphIds(); - } - - @Override public int encodeDeoptActionAndReason(RiDeoptAction action, RiDeoptReason reason) { final int actionShift = 0; final int reasonShift = 3; diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/GraalRuntime.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/GraalRuntime.java Wed Apr 25 12:01:52 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/GraalRuntime.java Wed Apr 25 12:01:59 2012 +0200 @@ -40,5 +40,4 @@ CiTargetMethod compile(RiResolvedMethod method, StructuredGraph graph); - long[] getDeoptedLeafGraphIds(); } diff -r 31fc6b6c0425 -r 60e658e50fce graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/RiGraphCache.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/RiGraphCache.java Wed Apr 25 12:01:59 2012 +0200 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012, 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.cri; + +import com.oracle.graal.nodes.*; +import com.oracle.max.cri.ri.*; + + +public interface RiGraphCache { + + void put(StructuredGraph graph); + + StructuredGraph get(RiResolvedMethod method); + + void removeGraphs(long[] deoptedGraphs); + + void clear(); + +}