changeset 2982:228276b7813b

Merge
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Wed, 15 Jun 2011 11:31:00 +0200
parents 42681ed31c4d ec86f14be4cf
children 11dfbb40ca69
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java graal/com.oracle.max.graal.graphviz/.checkstyle
diffstat 12 files changed, 71 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Wed Jun 15 11:31:00 2011 +0200
@@ -173,7 +173,7 @@
             }
             for (Entry<Object, Object> entry : props.entrySet()) {
                 String key = entry.getKey().toString();
-                String value = entry.getValue().toString();
+                String value = entry.getValue() == null ? "null" : entry.getValue().toString();
                 stream.printf("    <p name='%s'>%s</p>%n", escape(key), escape(value));
             }
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Deoptimize.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Deoptimize.java	Wed Jun 15 11:31:00 2011 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.max.graal.compiler.ir;
 
+import java.util.*;
+
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
@@ -75,6 +77,14 @@
     }
 
     @Override
+    public Map<Object, Object> getDebugProperties() {
+        Map<Object, Object> properties = super.getDebugProperties();
+        properties.put("message", message);
+        properties.put("action", action);
+        return properties;
+    }
+
+    @Override
     public Node copy(Graph into) {
         Deoptimize x = new Deoptimize(action, into);
         x.setMessage(message);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java	Wed Jun 15 11:31:00 2011 +0200
@@ -127,7 +127,7 @@
         @Override
         public Node lower(Node n, LoweringTool tool) {
             LoadField field = (LoadField) n;
-            return null;//field.field().createLoad(tool);
+            return null; //field.field().createLoad(tool);
         }
 
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoopBegin.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoopBegin.java	Wed Jun 15 11:31:00 2011 +0200
@@ -43,7 +43,7 @@
                 }
             }
         }
-        assert false : "Begin should always have a LoopEnd";
+        assert false : "LoopBegin should always have a LoopEnd";
         return null;
     }
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Wed Jun 15 11:31:00 2011 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.max.graal.compiler.phases;
 
+import java.util.*;
+
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.gen.*;
 import com.oracle.max.graal.compiler.ir.*;
@@ -32,38 +34,42 @@
 
     private NodeFlood flood;
     private Graph graph;
+    private ArrayList<LoopBegin> brokenLoops;
 
     @Override
     protected void run(Graph graph) {
         this.graph = graph;
         this.flood = graph.createNodeFlood();
+        this.brokenLoops = new ArrayList<LoopBegin>();
 
         // remove chained Merges
-//        for (Merge merge : graph.getNodes(Merge.class)) {
-//            if (merge.predecessors().size() == 1 && merge.usages().size() == 0) {
-//                if (merge.successors().get(0) instanceof Merge) {
-//                    Node pred = merge.predecessors().get(0);
-//                    int predIndex = merge.predecessorsIndex().get(0);
-//                    pred.successors().setAndClear(predIndex, merge, 0);
-//                    merge.delete();
-//                }
-//            }
-//        }
-//        Node startSuccessor = graph.start().successors().get(0);
-//        if (startSuccessor instanceof Merge) {
-//            Merge startMerge = (Merge) startSuccessor;
-//            if (startMerge.predecessors().size() == 1 && startMerge.usages().size() == 0) {
-//                int predIndex = startMerge.predecessorsIndex().get(0);
-//                graph.start().successors().setAndClear(predIndex, startMerge, 0);
-//                startMerge.delete();
-//            }
-//        }
+        for (Merge merge : graph.getNodes(Merge.class)) {
+            if (merge.predecessors().size() == 1 && merge.usages().size() == 0) {
+                if (merge.successors().get(0) instanceof Merge) {
+                    Node pred = merge.predecessors().get(0);
+                    int predIndex = merge.predecessorsIndex().get(0);
+                    pred.successors().setAndClear(predIndex, merge, 0);
+                    merge.delete();
+                }
+            }
+        }
+        Node startSuccessor = graph.start().successors().get(0);
+        if (startSuccessor instanceof Merge) {
+            Merge startMerge = (Merge) startSuccessor;
+            if (startMerge.predecessors().size() == 1 && startMerge.usages().size() == 0) {
+                int predIndex = startMerge.predecessorsIndex().get(0);
+                graph.start().successors().setAndClear(predIndex, startMerge, 0);
+                startMerge.delete();
+            }
+        }
 
         flood.add(graph.start());
 
         iterateSuccessors();
         disconnectCFGNodes();
 
+        deleteBrokenLoops();
+
         iterateInputs();
         disconnectNonCFGNodes();
 
@@ -72,6 +78,7 @@
 
         new PhiSimplifier(graph);
 
+
         if (GraalOptions.TraceDeadCodeElimination) {
             System.out.printf("dead code elimination finished\n");
         }
@@ -92,6 +99,9 @@
     private void disconnectCFGNodes() {
         for (Node node : graph.getNodes()) {
             if (node != Node.Null && !flood.isMarked(node) && isCFG(node)) {
+                if (node instanceof LoopEnd) {
+                    brokenLoops.add(((LoopEnd) node).loopBegin());
+                }
                 // iterate backwards so that the predecessor indexes in removePhiPredecessor are correct
                 for (int i = node.successors().size() - 1; i >= 0; i--) {
                     Node successor = node.successors().get(i);
@@ -107,6 +117,21 @@
         }
     }
 
+    private void deleteBrokenLoops() {
+        for (LoopBegin loop : brokenLoops) {
+            assert loop.predecessors().size() == 1;
+            for (Node usage : new ArrayList<Node>(loop.usages())) {
+                assert usage instanceof Phi;
+                usage.replace(((Phi) usage).valueAt(0));
+            }
+
+            Node pred = loop.predecessors().get(0);
+            int predIndex = loop.predecessorsIndex().get(0);
+            pred.successors().setAndClear(predIndex, loop, 0);
+            loop.delete();
+        }
+    }
+
     private void deleteCFGNodes() {
         for (Node node : graph.getNodes()) {
             if (node != Node.Null && !flood.isMarked(node) && isCFG(node)) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Wed Jun 15 11:31:00 2011 +0200
@@ -820,7 +820,7 @@
                 LoadField load = new LoadField(container, field, graph);
                 appendOptimizedLoadField(kind, load);
             } else {
-                append(new Deoptimize(DeoptAction.InvalidateRecompile, graph));
+                // deopt will be generated by genTypeOrDeopt, not needed here
                 frameState.push(kind.stackKind(), append(Constant.defaultForKind(kind, graph)));
             }
         }
@@ -834,7 +834,7 @@
             StoreField store = new StoreField(container, field, value, graph);
             appendOptimizedStoreField(store);
         } else {
-            append(new Deoptimize(DeoptAction.InvalidateRecompile, graph));
+            // deopt will be generated by genTypeOrDeopt, not needed here
         }
     }
 
@@ -923,7 +923,9 @@
     private void appendInvoke(int opcode, RiMethod target, Value[] args, int cpi, RiConstantPool constantPool) {
         CiKind resultType = returnKind(target);
         if (GraalOptions.DeoptALot) {
-            append(new Deoptimize(DeoptAction.None, graph));
+            Deoptimize deoptimize = new Deoptimize(DeoptAction.None, graph);
+            deoptimize.setMessage("invoke " + target.name());
+            append(deoptimize);
             frameState.pushReturn(resultType, Constant.defaultForKind(resultType, graph));
         } else {
             Invoke invoke = new Invoke(bci(), opcode, resultType.stackKind(), args, target, target.signature().returnType(method.holder()), method.typeProfile(bci()), graph);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java	Wed Jun 15 11:31:00 2011 +0200
@@ -56,10 +56,8 @@
                     if (!loopNodes.isMarked(init) && backEdge instanceof IntegerAdd && loopNodes.isMarked(backEdge)) {
                         IntegerAdd add = (IntegerAdd) backEdge;
                         int addUsageCount = 0;
-                        System.out.println("BackEdge usages :");
                         for (Node u : add.usages()) {
                             if (u != loopEnd.stateBefore()) {
-                                System.out.println(" - " + u);
                                 addUsageCount++;
                             }
                         }
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeBitMap.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeBitMap.java	Wed Jun 15 11:31:00 2011 +0200
@@ -65,7 +65,7 @@
         check(node);
         bitMap.clear(node.id());
     }
-    
+
     public void clearAll() {
         bitMap.clearAll();
     }
--- a/graal/com.oracle.max.graal.graphviz/.checkstyle	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.graphviz/.checkstyle	Wed Jun 15 11:31:00 2011 +0200
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
-  <local-check-config name="C1X Checkstyle checks" location="/GraalCompiler/.checkstyle_checks.xml" type="project" description="">
+  <local-check-config name="C1X Checkstyle checks" location="/com.oracle.max.graal.compiler/.checkstyle_checks.xml" type="project" description="">
     <additional-data name="protect-config-file" value="false"/>
   </local-check-config>
   <fileset name="all" enabled="true" check-config-name="C1X Checkstyle checks" local="true">
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java	Wed Jun 15 11:20:26 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java	Wed Jun 15 11:31:00 2011 +0200
@@ -103,11 +103,12 @@
     public abstract class Sandbox {
 
         public void start() throws Throwable {
-            PrintStream oldOut = System.out;
-            PrintStream oldErr = System.err;
+            // (ls) removed output and error stream rewiring, this influences applications and, for example, makes dacapo tests fail.
+//            PrintStream oldOut = System.out;
+//            PrintStream oldErr = System.err;
             run();
-            System.setOut(oldOut);
-            System.setErr(oldErr);
+//            System.setOut(oldOut);
+//            System.setErr(oldErr);
         }
 
         protected abstract void run() throws Throwable;
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Wed Jun 15 11:20:26 2011 +0200
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Wed Jun 15 11:31:00 2011 +0200
@@ -156,8 +156,7 @@
     if (index >= 0) {
       value = new LocationValue(Location::new_stk_loc(locationType, index * HeapWordSize));
     } else {
-      int frame_size_bytes = frame_size + 2 * HeapWordSize;
-      value = new LocationValue(Location::new_stk_loc(locationType, -(index * HeapWordSize) + frame_size_bytes));
+      value = new LocationValue(Location::new_stk_loc(locationType, -(index * HeapWordSize) + frame_size));
     }
     if (type == T_DOUBLE || type == T_LONG) {
       second = value;
--- a/src/share/vm/graal/graalVMExits.cpp	Wed Jun 15 11:20:26 2011 +0200
+++ b/src/share/vm/graal/graalVMExits.cpp	Wed Jun 15 11:31:00 2011 +0200
@@ -113,6 +113,7 @@
 }
 
 void VMExits::shutdownCompiler() {
+  HandleMark hm;
   JavaThread* THREAD = JavaThread::current();
   JavaValue result(T_VOID);
   JavaCallArguments args;