# HG changeset patch # User Christian Haeubl # Date 1370608605 -7200 # Node ID a9311ec68721c881f12d929884c6c35a057538b9 # Parent 81b298e0868bd17c5e444d0c55b44290ce7fcdc5 Avoid graph caching if immature or no profiling information was used for graph building. diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java Fri Jun 07 14:36:45 2013 +0200 @@ -87,6 +87,11 @@ } @Override + public boolean isMature() { + return false; + } + + @Override public String toString() { return "BaseProfilingInfo<" + MetaUtil.profileToString(this, null, "; ") + ">"; } diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java Fri Jun 07 14:36:45 2013 +0200 @@ -112,4 +112,12 @@ */ int getDeoptimizationCount(DeoptimizationReason reason); + /** + * Returns true if the profiling information can be assumed as sufficiently accurate. + * + * @return true if the profiling information was recorded often enough mature enough, false + * otherwise. + */ + boolean isMature(); + } diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Fri Jun 07 14:36:45 2013 +0200 @@ -384,6 +384,8 @@ public int typeProfileWidth; public int methodProfileWidth; + public int interpreterProfilingThreshold; + public long inlineCacheMissStub; public long handleDeoptStub; public long uncommonTrapStub; diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java Fri Jun 07 14:36:45 2013 +0200 @@ -127,13 +127,15 @@ } @Override - public void put(StructuredGraph graph) { + public void put(StructuredGraph graph, boolean hasMatureProfilingInfo) { assert graph.method() != null; - cachedGraphIds.put(graph.graphId(), new WeakReference<>(graph.method())); - graph.method().getCompilerStorage().put(this, graph); + if (hasMatureProfilingInfo) { + cachedGraphIds.put(graph.graphId(), new WeakReference<>(graph.method())); + graph.method().getCompilerStorage().put(this, graph); - if (PrintGraphCache.getValue()) { - putCounter++; + if (PrintGraphCache.getValue()) { + putCounter++; + } } } diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Fri Jun 07 14:36:45 2013 +0200 @@ -24,7 +24,6 @@ import static com.oracle.graal.graph.UnsafeAccess.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.phases.GraalOptions.*; import java.util.*; @@ -376,7 +375,7 @@ protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position); private static JavaTypeProfile createTypeProfile(TriState nullSeen, ResolvedJavaType[] types, long[] counts, long totalCount, int entries) { - if (entries <= 0 || totalCount < MatureExecutionsTypeProfile.getValue()) { + if (entries <= 0 || totalCount <= 0) { return null; } @@ -484,7 +483,7 @@ } private static JavaMethodProfile createMethodProfile(ResolvedJavaMethod[] methods, long[] counts, long totalCount, int entries) { - if (entries <= 0 || totalCount < MatureExecutionsTypeProfile.getValue()) { + if (entries <= 0 || totalCount <= 0) { return null; } @@ -540,11 +539,7 @@ long notTakenCount = data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET); long total = takenCount + notTakenCount; - if (total < MatureExecutionsBranch.getValue()) { - return -1; - } else { - return takenCount / (double) total; - } + return total <= 0 ? -1 : takenCount / (double) total; } @Override @@ -607,7 +602,7 @@ result[i - 1] = count; } - if (totalCount < MatureExecutionsPerSwitchCase.getValue() * length) { + if (totalCount <= 0) { return null; } else { for (int i = 0; i < length; i++) { diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java Fri Jun 07 14:36:45 2013 +0200 @@ -22,32 +22,36 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.phases.*; public final class HotSpotProfilingInfo extends CompilerObject implements ProfilingInfo { private static final long serialVersionUID = -8307682725047864875L; private static final DebugMetric metricInsufficentSpace = Debug.metric("InsufficientSpaceForProfilingData"); + private final HotSpotMethodData methodData; + private final HotSpotResolvedJavaMethod method; + private int position; private int hintPosition; private int hintBCI; private HotSpotMethodDataAccessor dataAccessor; - private HotSpotMethodData methodData; - private final int codeSize; - public HotSpotProfilingInfo(HotSpotMethodData methodData, int codeSize) { + public HotSpotProfilingInfo(HotSpotMethodData methodData, HotSpotResolvedJavaMethod method) { this.methodData = methodData; - this.codeSize = codeSize; + this.method = method; hintPosition = 0; hintBCI = -1; } @Override public int getCodeSize() { - return codeSize; + return method.getCodeSize(); } @Override @@ -158,6 +162,11 @@ } @Override + public boolean isMature() { + return method.invocationCount() >= graalRuntime().getConfig().interpreterProfilingThreshold + GraalOptions.MatureProfilingInformationThreshold.getValue(); + } + + @Override public String toString() { return "HotSpotProfilingInfo<" + MetaUtil.profileToString(this, null, "; ") + ">"; } diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Fri Jun 07 14:36:45 2013 +0200 @@ -288,7 +288,7 @@ // case of a deoptimization. info = DefaultProfilingInfo.get(TriState.FALSE); } else { - info = new HotSpotProfilingInfo(methodData, codeSize); + info = new HotSpotProfilingInfo(methodData, this); } return info; } diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java Fri Jun 07 14:36:45 2013 +0200 @@ -27,7 +27,7 @@ public interface GraphCache { - void put(StructuredGraph graph); + void put(StructuredGraph graph, boolean hasMatureProfilingInfo); StructuredGraph get(ResolvedJavaMethod method); diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Fri Jun 07 14:36:45 2013 +0200 @@ -298,6 +298,8 @@ } private StructuredGraph parseBytecodes(StructuredGraph newGraph, Assumptions assumptions) { + boolean hasMatureProfilingInfo = newGraph.method().getProfilingInfo().isMature(); + if (plan != null) { plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); } @@ -313,7 +315,7 @@ new CullFrameStatesPhase().apply(newGraph); } if (CacheGraphs.getValue() && cache != null) { - cache.put(newGraph.copy()); + cache.put(newGraph.copy(), hasMatureProfilingInfo); } return newGraph; } diff -r 81b298e0868b -r a9311ec68721 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Fri Jun 07 14:15:38 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Fri Jun 07 14:36:45 2013 +0200 @@ -87,11 +87,7 @@ @Option(help = "") public static final OptionValue DeoptsToDisableOptimisticOptimization = new OptionValue<>(40); @Option(help = "") - public static final OptionValue MatureExecutionsBranch = new OptionValue<>(1); - @Option(help = "") - public static final OptionValue MatureExecutionsPerSwitchCase = new OptionValue<>(1); - @Option(help = "") - public static final OptionValue MatureExecutionsTypeProfile = new OptionValue<>(1); + public static final OptionValue MatureProfilingInformationThreshold = new OptionValue<>(100); // comilation queue @Option(help = "") diff -r 81b298e0868b -r a9311ec68721 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Fri Jun 07 14:15:38 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Fri Jun 07 14:36:45 2013 +0200 @@ -734,6 +734,8 @@ set_int("typeProfileWidth", TypeProfileWidth); set_int("methodProfileWidth", MethodProfileWidth); + set_int("interpreterProfilingThreshold", InvocationCounter::get_ProfileLimit()); + set_int("tlabAlignmentReserve", (int32_t)ThreadLocalAllocBuffer::alignment_reserve()); set_long("tlabIntArrayMarkWord", (intptr_t)markOopDesc::prototype()->copy_set_hash(0x2)); set_long("heapTopAddress", (jlong)(address) Universe::heap()->top_addr()); diff -r 81b298e0868b -r a9311ec68721 src/share/vm/interpreter/invocationCounter.hpp --- a/src/share/vm/interpreter/invocationCounter.hpp Fri Jun 07 14:15:38 2013 +0200 +++ b/src/share/vm/interpreter/invocationCounter.hpp Fri Jun 07 14:36:45 2013 +0200 @@ -95,9 +95,9 @@ Action action() const { return _action[state()]; } int count() const { return _counter >> number_of_noncount_bits; } - int get_InvocationLimit() const { return InterpreterInvocationLimit >> number_of_noncount_bits; } - int get_BackwardBranchLimit() const { return InterpreterBackwardBranchLimit >> number_of_noncount_bits; } - int get_ProfileLimit() const { return InterpreterProfileLimit >> number_of_noncount_bits; } + static int get_InvocationLimit() { return InterpreterInvocationLimit >> number_of_noncount_bits; } + static int get_BackwardBranchLimit() { return InterpreterBackwardBranchLimit >> number_of_noncount_bits; } + static int get_ProfileLimit() { return InterpreterProfileLimit >> number_of_noncount_bits; } // Test counter using scaled limits like the asm interpreter would do rather than doing // the shifts to normalize the counter.