changeset 19109:61c772f6d8eb

More restructuring in PartialEvaluator.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 04 Feb 2015 00:41:25 +0100
parents c4cb2ccd0b96
children 9e07d5219944
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java
diffstat 1 files changed, 60 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Feb 04 00:31:33 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Feb 04 00:41:25 2015 +0100
@@ -103,65 +103,35 @@
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
-        final StructuredGraph graph = createRootGraph(callTarget.toString());
+
+        final StructuredGraph graph = new StructuredGraph(callTarget.toString(), callRootMethod);
         assert graph != null : "no graph for root method";
 
         try (Scope s = Debug.scope("CreateGraph", graph); Indent indent = Debug.logAndIndent("createGraph %s", graph)) {
-            // Canonicalize / constant propagate.
-            PhaseContext baseContext = new PhaseContext(providers, assumptions);
 
-            injectConstantCallTarget(graph, callTarget, baseContext);
-
-            Debug.dump(graph, "Before expansion");
-
-            TruffleExpansionLogger expansionLogger = null;
-            if (TraceTruffleExpansion.getValue()) {
-                expansionLogger = new TruffleExpansionLogger(providers, graph);
-            }
+            createRootGraph(graph);
 
-            expandTree(graph, assumptions, expansionLogger);
+            Map<ResolvedJavaMethod, StructuredGraph> graphCache = null;
+            if (CacheGraphs.getValue()) {
+                graphCache = new HashMap<>();
+            }
+            PhaseContext baseContext = new PhaseContext(providers, assumptions);
+            HighTierContext tierContext = new HighTierContext(providers, assumptions, graphCache, new PhaseSuite<HighTierContext>(), OptimisticOptimizations.NONE);
 
-            TruffleInliningCache inliningCache = null;
-            if (TruffleFunctionInlining.getValue()) {
-                callTarget.setInlining(new TruffleInlining(callTarget, new DefaultInliningPolicy()));
-                if (TruffleFunctionInliningCache.getValue()) {
-                    inliningCache = new TruffleInliningCache();
-                }
+            if (TruffleCompilerOptions.FastPE.getValue()) {
+                fastPartialEvaluation(callTarget, assumptions, graph, baseContext, tierContext);
+            } else {
+                partialEvaluation(callTarget, assumptions, graph, baseContext, tierContext);
             }
 
-            expandDirectCalls(graph, assumptions, expansionLogger, callTarget.getInlining(), inliningCache);
-
             if (Thread.currentThread().isInterrupted()) {
                 return null;
             }
 
             new VerifyFrameDoesNotEscapePhase().apply(graph, false);
-
             if (TraceTruffleCompilationHistogram.getValue() && constantReceivers != null) {
                 createHistogram();
             }
-
-            canonicalizer.apply(graph, baseContext);
-            Map<ResolvedJavaMethod, StructuredGraph> graphCache = null;
-            if (CacheGraphs.getValue()) {
-                graphCache = new HashMap<>();
-            }
-            HighTierContext tierContext = new HighTierContext(providers, assumptions, graphCache, new PhaseSuite<HighTierContext>(), OptimisticOptimizations.NONE);
-
-            // EA frame and clean up.
-            do {
-                try (Scope pe = Debug.scope("TrufflePartialEscape", graph)) {
-                    new PartialEscapePhase(true, canonicalizer).apply(graph, tierContext);
-                    new IncrementalCanonicalizerPhase<>(canonicalizer, new ConditionalEliminationPhase()).apply(graph, tierContext);
-                } catch (Throwable t) {
-                    Debug.handle(t);
-                }
-            } while (expandTree(graph, assumptions, expansionLogger));
-
-            if (expansionLogger != null) {
-                expansionLogger.print(callTarget);
-            }
-
             postPartialEvaluation(graph);
 
         } catch (Throwable e) {
@@ -171,8 +141,53 @@
         return graph;
     }
 
-    public StructuredGraph createRootGraph(String name) {
-        StructuredGraph graph = new StructuredGraph(name, callRootMethod);
+    @SuppressWarnings("unused")
+    private void fastPartialEvaluation(OptimizedCallTarget callTarget, Assumptions assumptions, StructuredGraph graph, PhaseContext baseContext, HighTierContext tierContext) {
+    }
+
+    private void partialEvaluation(final OptimizedCallTarget callTarget, final Assumptions assumptions, final StructuredGraph graph, PhaseContext baseContext, HighTierContext tierContext) {
+        injectConstantCallTarget(graph, callTarget, baseContext);
+
+        Debug.dump(graph, "Before expansion");
+
+        TruffleExpansionLogger expansionLogger = null;
+        if (TraceTruffleExpansion.getValue()) {
+            expansionLogger = new TruffleExpansionLogger(providers, graph);
+        }
+
+        expandTree(graph, assumptions, expansionLogger);
+
+        TruffleInliningCache inliningCache = null;
+        if (TruffleFunctionInlining.getValue()) {
+            callTarget.setInlining(new TruffleInlining(callTarget, new DefaultInliningPolicy()));
+            if (TruffleFunctionInliningCache.getValue()) {
+                inliningCache = new TruffleInliningCache();
+            }
+        }
+
+        expandDirectCalls(graph, assumptions, expansionLogger, callTarget.getInlining(), inliningCache);
+
+        if (Thread.currentThread().isInterrupted()) {
+            return;
+        }
+
+        canonicalizer.apply(graph, baseContext);
+        // EA frame and clean up.
+        do {
+            try (Scope pe = Debug.scope("TrufflePartialEscape", graph)) {
+                new PartialEscapePhase(true, canonicalizer).apply(graph, tierContext);
+                new IncrementalCanonicalizerPhase<>(canonicalizer, new ConditionalEliminationPhase()).apply(graph, tierContext);
+            } catch (Throwable t) {
+                Debug.handle(t);
+            }
+        } while (expandTree(graph, assumptions, expansionLogger));
+
+        if (expansionLogger != null) {
+            expansionLogger.print(callTarget);
+        }
+    }
+
+    public StructuredGraph createRootGraph(StructuredGraph graph) {
         new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), new Assumptions(false), configForRoot, TruffleCompilerImpl.Optimizations).apply(graph);
         return graph;
     }