diff graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java @ 13197:8569b9e047cd

change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
author Doug Simon <doug.simon@oracle.com>
date Sat, 30 Nov 2013 01:16:55 +0100
parents c13633a4d472
children 3603fab248a6
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Fri Nov 29 20:46:54 2013 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Sat Nov 30 01:16:55 2013 +0100
@@ -37,6 +37,7 @@
 import com.oracle.graal.compiler.alloc.Interval.SpillState;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
@@ -1818,66 +1819,61 @@
 
     public void allocate() {
 
-        Debug.scope("LifetimeAnalysis", new Runnable() {
-
-            public void run() {
-                numberInstructions();
-                printLir("Before register allocation", true);
-                computeLocalLiveSets();
-                computeGlobalLiveSets();
-                buildIntervals();
-                sortIntervalsBeforeAllocation();
-            }
-        });
-
-        Debug.scope("RegisterAllocation", new Runnable() {
+        try (Scope s = Debug.scope("LifetimeAnalysis")) {
+            numberInstructions();
+            printLir("Before register allocation", true);
+            computeLocalLiveSets();
+            computeGlobalLiveSets();
+            buildIntervals();
+            sortIntervalsBeforeAllocation();
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
 
-            public void run() {
-                printIntervals("Before register allocation");
-                allocateRegisters();
-            }
-        });
+        try (Scope s = Debug.scope("RegisterAllocation")) {
+            printIntervals("Before register allocation");
+            allocateRegisters();
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
 
-        Debug.scope("ResolveDataFlow", new Runnable() {
+        try (Scope s = Debug.scope("ResolveDataFlow")) {
+            resolveDataFlow();
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
 
-            public void run() {
-                resolveDataFlow();
-            }
-        });
-
-        Debug.scope("DebugInfo", new Runnable() {
+        try (Scope s = Debug.scope("DebugInfo")) {
+            frameMap.finish();
 
-            public void run() {
-                frameMap.finish();
+            printIntervals("After register allocation");
+            printLir("After register allocation", true);
 
-                printIntervals("After register allocation");
-                printLir("After register allocation", true);
+            sortIntervalsAfterAllocation();
 
-                sortIntervalsAfterAllocation();
+            if (DetailedAsserts.getValue()) {
+                verify();
+            }
 
-                if (DetailedAsserts.getValue()) {
-                    verify();
-                }
-
-                eliminateSpillMoves();
-                assignLocations();
+            eliminateSpillMoves();
+            assignLocations();
 
-                if (DetailedAsserts.getValue()) {
-                    verifyIntervals();
-                }
+            if (DetailedAsserts.getValue()) {
+                verifyIntervals();
             }
-        });
-
-        Debug.scope("ControlFlowOptimizations", new Runnable() {
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
 
-            public void run() {
-                printLir("After register number assignment", true);
-                EdgeMoveOptimizer.optimize(ir);
-                ControlFlowOptimizer.optimize(ir);
-                NullCheckOptimizer.optimize(ir, target.implicitNullCheckLimit);
-                printLir("After control flow optimization", false);
-            }
-        });
+        try (Scope s = Debug.scope("ControlFlowOptimizations")) {
+            printLir("After register number assignment", true);
+            EdgeMoveOptimizer.optimize(ir);
+            ControlFlowOptimizer.optimize(ir);
+            NullCheckOptimizer.optimize(ir, target.implicitNullCheckLimit);
+            printLir("After control flow optimization", false);
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
     }
 
     void printIntervals(String label) {