# HG changeset patch # User Doug Simon # Date 1382388568 -7200 # Node ID d72864a2886ecdf013f5a7eb67cb06e3062d6223 # Parent 1be3cb11f88e702efe6c00dad7074156a6313a8d moved snippet timers/metrics from SnippetTemplate to SnippetInfo and added new metric for number of snippet specializations (i.e. number of SnippetTemplate objects created) diff -r 1be3cb11f88e -r d72864a2886e 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 Mon Oct 21 22:47:54 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Oct 21 22:49:28 2013 +0200 @@ -71,6 +71,8 @@ protected final ResolvedJavaMethod method; protected final boolean[] constantParameters; protected final boolean[] varargsParameters; + private final DebugMetric instantiationCounter; + private final DebugTimer instantiationTimer; /** * The parameter names, taken from the local variables table. Only used for assertion @@ -80,7 +82,8 @@ protected SnippetInfo(ResolvedJavaMethod method) { this.method = method; - + instantiationCounter = Debug.metric("SnippetInstantiationCount[" + method.getName() + "]"); + instantiationTimer = Debug.timer("SnippetInstantiationTime[" + method.getName() + "]"); assert Modifier.isStatic(method.getModifiers()) : "snippet method must be static: " + MetaUtil.format("%H.%n", method); int count = method.getSignature().getParameterCount(false); constantParameters = new boolean[count]; @@ -316,6 +319,7 @@ } private static final DebugTimer SnippetCreationAndSpecialization = Debug.timer("SnippetCreationAndSpecialization"); + private static final DebugMetric SnippetSpecializations = Debug.metric("SnippetSpecializations"); /** * Base class for snippet classes. It provides a cache for {@link SnippetTemplate}s. @@ -355,6 +359,7 @@ protected SnippetTemplate template(final Arguments args) { SnippetTemplate template = templates.get(args.cacheKey); if (template == null) { + SnippetSpecializations.increment(); try (TimerCloseable a = SnippetCreationAndSpecialization.start()) { template = Debug.scope("SnippetSpecialization", args.info.method, new Callable() { @@ -385,9 +390,6 @@ return false; } - private final DebugMetric instantiationCounter; - private final DebugTimer instantiationTimer; - /** * Creates a snippet template. */ @@ -580,9 +582,6 @@ this.deoptNodes = curDeoptNodes; this.stampNodes = curStampNodes; this.returnNode = retNode; - - this.instantiationCounter = Debug.metric("SnippetInstantiationCount[" + method.getName() + "]"); - this.instantiationTimer = Debug.timer("SnippetInstantiationTime[" + method.getName() + "]"); } private static boolean checkAllVarargPlaceholdersAreDeleted(int parameterCount, ConstantNode[] placeholders) { @@ -865,8 +864,8 @@ */ public Map instantiate(MetaAccessProvider metaAccess, FixedNode replacee, UsageReplacer replacer, Arguments args) { assert checkSnippetKills(replacee); - try (TimerCloseable a = instantiationTimer.start()) { - instantiationCounter.increment(); + try (TimerCloseable a = args.info.instantiationTimer.start()) { + args.info.instantiationCounter.increment(); // Inline the snippet nodes, replacing parameters with the given args in the process StartNode entryPointNode = snippet.start(); FixedNode firstCFGNode = entryPointNode.next(); @@ -958,8 +957,8 @@ */ public void instantiate(MetaAccessProvider metaAccess, FloatingNode replacee, UsageReplacer replacer, LoweringTool tool, Arguments args) { assert checkSnippetKills(replacee); - try (TimerCloseable a = instantiationTimer.start()) { - instantiationCounter.increment(); + try (TimerCloseable a = args.info.instantiationTimer.start()) { + args.info.instantiationCounter.increment(); // Inline the snippet nodes, replacing parameters with the given args in the process String name = snippet.name == null ? "{copy}" : snippet.name + "{copy}";