# HG changeset patch # User Christian Humer # Date 1383854113 -3600 # Node ID 882a0aadfed66cb0927f16ab49c9b3d2e412d99d # Parent fb4658e16b5da4c6f658cf054d93332c32869dda# Parent 3b2b8a71d10df016d3e13c2d60403b9dad229efb Merge. diff -r fb4658e16b5d -r 882a0aadfed6 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Thu Nov 07 20:47:11 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Thu Nov 07 20:55:13 2013 +0100 @@ -54,6 +54,8 @@ public static final OptionValue DebugValueSummary = new OptionValue<>("Name"); @Option(help = "Omit reporting 0-value metrics") public static final OptionValue SuppressZeroDebugValues = new OptionValue<>(false); + @Option(help = "Report and reset metrics after bootstrapping") + public static final OptionValue ResetDebugValuesAfterBootstrap = new OptionValue<>(true); @Option(help = "Send Graal IR to dump handlers on error") public static final OptionValue DumpOnError = new OptionValue<>(false); @Option(help = "Enable expensive assertions") diff -r fb4658e16b5d -r 882a0aadfed6 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java Thu Nov 07 20:47:11 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java Thu Nov 07 20:55:13 2013 +0100 @@ -55,6 +55,15 @@ } } + public void reset() { + Arrays.fill(values, 0L); + if (children != null) { + for (DebugValueMap child : children) { + child.reset(); + } + } + } + private void ensureSize(int index) { if (values == null) { values = new long[index + 1]; diff -r fb4658e16b5d -r 882a0aadfed6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Nov 07 20:47:11 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Nov 07 20:55:13 2013 +0100 @@ -323,6 +323,9 @@ } } while ((System.currentTimeMillis() - startTime) <= TimedBootstrap.getValue()); + if (ResetDebugValuesAfterBootstrap.getValue()) { + printDebugValues("bootstrap", true); + } phaseTransition("bootstrap"); bootstrapRunning = false; @@ -368,6 +371,25 @@ CompilationTask.withinEnqueue.set(Boolean.FALSE); } + printDebugValues(ResetDebugValuesAfterBootstrap.getValue() ? "application" : null, false); + phaseTransition("final"); + + if (runtime.getConfig().ciTime) { + parsedBytecodesPerSecond.printAll("ParsedBytecodesPerSecond", System.out); + inlinedBytecodesPerSecond.printAll("InlinedBytecodesPerSecond", System.out); + } + + SnippetCounter.printGroups(TTY.out().out()); + BenchmarkCounters.shutdown(runtime.getCompilerToVM(), compilerStartTime); + } + + private void printDebugValues(String phase, boolean reset) throws GraalInternalError { + TTY.println(); + if (phase != null) { + TTY.println(""); + } else { + TTY.println(""); + } if (Debug.isEnabled() && areMetricsOrTimersEnabled()) { List topLevelMaps = DebugValueMap.getTopLevelMaps(); List debugValues = KeyRegistry.getDebugValues(); @@ -414,16 +436,17 @@ throw new GraalInternalError("Unknown summary type: %s", summary); } } + if (reset) { + for (DebugValueMap topLevelMap : topLevelMaps) { + topLevelMap.reset(); + } + } + if (phase != null) { + TTY.println(""); + } else { + TTY.println(""); + } } - phaseTransition("final"); - - if (runtime.getConfig().ciTime) { - parsedBytecodesPerSecond.printAll("ParsedBytecodesPerSecond", System.out); - inlinedBytecodesPerSecond.printAll("InlinedBytecodesPerSecond", System.out); - } - - SnippetCounter.printGroups(TTY.out().out()); - BenchmarkCounters.shutdown(runtime.getCompilerToVM(), compilerStartTime); } private void flattenChildren(DebugValueMap map, DebugValueMap globalMap) { diff -r fb4658e16b5d -r 882a0aadfed6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Nov 07 20:47:11 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Nov 07 20:55:13 2013 +0100 @@ -79,14 +79,21 @@ this.snippetTemplateCache = new HashMap<>(); } + private static final boolean UseSnippetGraphCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetGraphCache", "true")); + public StructuredGraph getSnippet(ResolvedJavaMethod method) { assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName(); assert !Modifier.isAbstract(method.getModifiers()) && !Modifier.isNative(method.getModifiers()) : "Snippet must not be abstract or native"; - StructuredGraph graph = graphs.get(method); + StructuredGraph graph = UseSnippetGraphCache ? graphs.get(method) : null; if (graph == null) { - graphs.putIfAbsent(method, makeGraph(method, null, inliningPolicy(method), method.getAnnotation(Snippet.class).removeAllFrameStates())); + StructuredGraph newGraph = makeGraph(method, null, inliningPolicy(method), method.getAnnotation(Snippet.class).removeAllFrameStates()); + if (UseSnippetGraphCache) { + return newGraph; + } + graphs.putIfAbsent(method, newGraph); graph = graphs.get(method); + } return graph; } diff -r fb4658e16b5d -r 882a0aadfed6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Nov 07 20:47:11 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Nov 07 20:55:13 2013 +0100 @@ -335,6 +335,10 @@ private static final DebugTimer SnippetCreationAndSpecialization = Debug.timer("SnippetCreationAndSpecialization"); private static final DebugMetric SnippetSpecializations = Debug.metric("SnippetSpecializations"); + private static final DebugMetric SnippetSpecializationsNodeCount = Debug.metric("SnippetSpecializationsNodeCount"); + private static final DebugMetric SnippetGraphsNodeCount = Debug.metric("SnippetGraphsNodeCount"); + + private static final boolean UseSnippetTemplateCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetTemplateCache", "true")); /** * Base class for snippet classes. It provides a cache for {@link SnippetTemplate}s. @@ -348,7 +352,11 @@ protected AbstractTemplates(Providers providers, TargetDescription target) { this.providers = providers; this.target = target; - this.templates = new ConcurrentHashMap<>(); + if (UseSnippetTemplateCache) { + this.templates = new ConcurrentHashMap<>(); + } else { + this.templates = null; + } } /** @@ -372,7 +380,7 @@ * Gets a template for a given key, creating it first if necessary. */ protected SnippetTemplate template(final Arguments args) { - SnippetTemplate template = templates.get(args.cacheKey); + SnippetTemplate template = UseSnippetTemplateCache ? templates.get(args.cacheKey) : null; if (template == null) { SnippetSpecializations.increment(); try (TimerCloseable a = SnippetCreationAndSpecialization.start()) { @@ -383,7 +391,9 @@ return new SnippetTemplate(providers, args); } }); - templates.put(args.cacheKey, template); + if (UseSnippetTemplateCache) { + templates.put(args.cacheKey, template); + } } } return template; @@ -410,6 +420,7 @@ */ protected SnippetTemplate(final Providers providers, Arguments args) { StructuredGraph snippetGraph = providers.getReplacements().getSnippet(args.info.method); + SnippetGraphsNodeCount.add(snippetGraph.getNodeCount()); ResolvedJavaMethod method = snippetGraph.method(); Signature signature = method.getSignature(); @@ -596,6 +607,8 @@ this.deoptNodes = curDeoptNodes; this.stampNodes = curStampNodes; this.returnNode = retNode; + + SnippetSpecializationsNodeCount.add(nodes.size()); } private static boolean checkAllVarargPlaceholdersAreDeleted(int parameterCount, VarargsPlaceholderNode[] placeholders) {