# HG changeset patch # User Doug Simon # Date 1407776018 -7200 # Node ID db2ac421649a00f0f8e1022d9daa682a0e9dd114 # Parent b359f0468128cb0559b1718adc0a075c7ceaea4f# Parent 8341b061e4966386cd9e0d7fddcec2ba3524d5e8 Merge. diff -r 8341b061e496 -r db2ac421649a graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/AllocSpy.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/AllocSpy.java Mon Aug 11 18:07:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/AllocSpy.java Mon Aug 11 18:53:38 2014 +0200 @@ -51,7 +51,7 @@ * @see #BarSize * @see #NumberSize */ -final class AllocSpy implements AutoCloseable { +public final class AllocSpy implements AutoCloseable { static ThreadLocal current = new ThreadLocal<>(); @@ -70,6 +70,10 @@ } } + public static boolean isEnabled() { + return ENABLED; + } + static String prop(String sfx) { return AllocSpy.class.getSimpleName() + "." + sfx; } diff -r 8341b061e496 -r db2ac421649a graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Mon Aug 11 18:07:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Mon Aug 11 18:53:38 2014 +0200 @@ -127,7 +127,7 @@ new MemoryUsageBenchmark().run(); } - private void doCompilation(String methodName) { + private void doCompilation(String methodName, String label) { HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getMetaAccess().lookupJavaMethod(getMethod(methodName)); HotSpotBackend backend = runtime().getHostBackend(); @@ -136,8 +136,28 @@ int id = method.allocateCompileId(INVOCATION_ENTRY_BCI); long ctask = 0L; - CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id); - task.runCompilation(); + + try (MemoryUsageCloseable c = label == null ? null : new MemoryUsageCloseable(label)) { + CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id); + task.runCompilation(); + } + } + + private void allocSpyCompilation(String methodName) { + if (AllocSpy.isEnabled()) { + HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getMetaAccess().lookupJavaMethod(getMethod(methodName)); + HotSpotBackend backend = runtime().getHostBackend(); + + // invalidate any existing compiled code + method.reprofile(); + + int id = method.allocateCompileId(INVOCATION_ENTRY_BCI); + long ctask = 0L; + try (AllocSpy as = AllocSpy.open(methodName)) { + CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id); + task.runCompilation(); + } + } } private static final boolean verbose = Boolean.getBoolean("verbose"); @@ -149,14 +169,10 @@ // Warm up and initialize compiler phases used by this compilation for (int i = 0; i < 10; i++) { - try (MemoryUsageCloseable c = verbose ? new MemoryUsageCloseable(methodName + "[warmup-" + i + "]") : null) { - doCompilation(methodName); - } + doCompilation(methodName, verbose ? methodName + "[warmup-" + i + "]" : null); } - try (MemoryUsageCloseable c = new MemoryUsageCloseable(methodName)) { - doCompilation(methodName); - } + doCompilation(methodName, methodName); } public void run() { @@ -171,5 +187,7 @@ e.printStackTrace(); } } + allocSpyCompilation("simple"); + allocSpyCompilation("complex"); } } diff -r 8341b061e496 -r db2ac421649a 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 Mon Aug 11 18:07:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Mon Aug 11 18:53:38 2014 +0200 @@ -36,6 +36,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; +import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; @@ -428,6 +429,20 @@ } /** + * Calls in snippets to methods matching one of these filters are elided. Only void methods are + * considered for elision. + */ + private static final MethodFilter[] MethodsElidedInSnippets = getMethodsElidedInSnippets(); + + private static MethodFilter[] getMethodsElidedInSnippets() { + String commaSeparatedPatterns = System.getProperty("graal.MethodsElidedInSnippets"); + if (commaSeparatedPatterns != null) { + return MethodFilter.parse(commaSeparatedPatterns); + } + return null; + } + + /** * Creates and preprocesses a graph for a replacement. */ protected class GraphMaker { @@ -554,7 +569,12 @@ final StructuredGraph graph = new StructuredGraph(methodToParse); try (Scope s = Debug.scope("buildInitialGraph", graph)) { MetaAccessProvider metaAccess = providers.getMetaAccess(); - createGraphBuilder(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph); + + if (MethodsElidedInSnippets != null && methodToParse.getSignature().getReturnKind() == Kind.Void && MethodFilter.matches(MethodsElidedInSnippets, methodToParse)) { + graph.addAfterFixed(graph.start(), graph.add(new ReturnNode(null))); + } else { + createGraphBuilder(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph); + } new WordTypeVerificationPhase(metaAccess, snippetReflection, target.wordKind).apply(graph); new WordTypeRewriterPhase(metaAccess, snippetReflection, target.wordKind).apply(graph);