changeset 7029:d918b5ba3e89

Merge.
author Doug Simon <doug.simon@oracle.com>
date Mon, 26 Nov 2012 18:21:22 +0100
parents 0353b031235a (current diff) 635349143c4f (diff)
children d78c83e8b70b
files
diffstat 7 files changed, 49 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/BoxedVirtualObjectNode.java	Mon Nov 26 18:20:34 2012 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/BoxedVirtualObjectNode.java	Mon Nov 26 18:21:22 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@
     }
 
     @Override
-    public Object fieldName(int index) {
+    public String fieldName(int index) {
         assert index == 0;
         return "value";
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Mon Nov 26 18:20:34 2012 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Mon Nov 26 18:21:22 2012 +0100
@@ -67,7 +67,7 @@
     }
 
     @Override
-    public Object fieldName(int index) {
+    public String fieldName(int index) {
         return "[" + index + "]";
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java	Mon Nov 26 18:20:34 2012 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java	Mon Nov 26 18:21:22 2012 +0100
@@ -67,7 +67,7 @@
     }
 
     @Override
-    public Object fieldName(int index) {
+    public String fieldName(int index) {
         return fields[index].getName();
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectNode.java	Mon Nov 26 18:20:34 2012 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectNode.java	Mon Nov 26 18:21:22 2012 +0100
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -51,5 +52,9 @@
         // nothing to do...
     }
 
-    public abstract Object fieldName(int i);
+    public abstract String fieldName(int i);
+
+    public void materializeAt(@SuppressWarnings("unused") FixedNode fixed) {
+        // nothing to do in here - this method allows subclasses to respond to materialization
+    }
 }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InsertStateAfterPlaceholderPhase.java	Mon Nov 26 18:20:34 2012 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InsertStateAfterPlaceholderPhase.java	Mon Nov 26 18:21:22 2012 +0100
@@ -50,16 +50,29 @@
             if (stateAfter() == null) {
                 return null;
             }
+            FixedNode next = next();
+            if (next instanceof PlaceholderNode && ((PlaceholderNode) next).stateAfter() != null) {
+                return null;
+            }
             return this;
         }
     }
 
     @Override
     protected void run(StructuredGraph graph) {
-        for (ReturnNode ret : graph.getNodes(ReturnNode.class)) {
-            PlaceholderNode p = graph.add(new PlaceholderNode());
-            p.setStateAfter(graph.add(new FrameState(FrameState.AFTER_BCI)));
-            graph.addBeforeFixed(ret, p);
+        boolean needsPlaceHolder = false;
+        for (Node node : graph.getNodes().filterInterface(StateSplit.class)) {
+            StateSplit stateSplit = (StateSplit) node;
+            if (stateSplit.hasSideEffect() && stateSplit.stateAfter() != null) {
+                needsPlaceHolder = true;
+            }
+        }
+        if (needsPlaceHolder) {
+            for (ReturnNode ret : graph.getNodes(ReturnNode.class)) {
+                PlaceholderNode p = graph.add(new PlaceholderNode());
+                p.setStateAfter(graph.add(new FrameState(FrameState.AFTER_BCI)));
+                graph.addBeforeFixed(ret, p);
+            }
         }
     }
 
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/BlockState.java	Mon Nov 26 18:20:34 2012 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/BlockState.java	Mon Nov 26 18:21:22 2012 +0100
@@ -119,6 +119,7 @@
             materializeEffects.addFixedNodeBefore(newObject, fixed);
         } else {
             // some entries are not default constants - do the materialization
+            virtual.materializeAt(fixed);
             MaterializeObjectNode materialize = new MaterializeObjectNode(virtual, obj.getLockCount());
             ValueNode[] values = new ValueNode[obj.getEntries().length];
             materialize.setProbability(fixed.probability());
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java	Mon Nov 26 18:20:34 2012 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java	Mon Nov 26 18:21:22 2012 +0100
@@ -23,12 +23,14 @@
 package com.oracle.graal.virtual.phases.ea;
 
 import java.util.*;
+import java.util.concurrent.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
 import com.oracle.graal.phases.graph.*;
@@ -65,17 +67,30 @@
             return;
         }
 
-        for (int iteration = 0; iteration < GraalOptions.EscapeAnalysisIterations; iteration++) {
-            Debug.scope("iteration " + iteration, new Runnable() {
+        boolean analyzableNodes = false;
+        for (Node node : graph.getNodes()) {
+            if (node instanceof EscapeAnalyzable) {
+                analyzableNodes = true;
+                break;
+            }
+        }
+        if (!analyzableNodes) {
+            return;
+        }
+
+        Boolean continueIteration = true;
+        for (int iteration = 0; iteration < GraalOptions.EscapeAnalysisIterations && continueIteration; iteration++) {
+            continueIteration = Debug.scope("iteration " + iteration, new Callable<Boolean>() {
+
                 @Override
-                public void run() {
+                public Boolean call() {
                     SchedulePhase schedule = new SchedulePhase();
                     schedule.apply(graph, false);
                     PartialEscapeClosure closure = new PartialEscapeClosure(graph.createNodeBitMap(), schedule, runtime);
                     ReentrantBlockIterator.apply(closure, schedule.getCFG().getStartBlock(), new BlockState(), null);
 
                     if (closure.getVirtualIdCount() == 0) {
-                        return;
+                        return false;
                     }
 
                     // apply the effects collected during the escape analysis iteration
@@ -90,11 +105,12 @@
 
                     new DeadCodeEliminationPhase().apply(graph);
                     if (!iterative) {
-                        return;
+                        return false;
                     }
                     if (GraalOptions.OptCanonicalizer) {
                         new CanonicalizerPhase(target, runtime, assumptions).apply(graph);
                     }
+                    return true;
                 }
             });
         }