changeset 4428:0bb7ab1add7e

enable dumping graphs upon exception, new constructor for NodeInputList, initialize debug system for non-compiler threads
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 01 Feb 2012 11:59:32 +0100
parents 2302b1514e7e
children 730fab2457b8
files graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeInputList.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeList.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java
diffstat 5 files changed, 42 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java	Tue Jan 31 10:47:55 2012 +0100
+++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java	Wed Feb 01 11:59:32 2012 +0100
@@ -103,6 +103,7 @@
 
     public static void dump(Object object, String msg, Object... args) {
         if (ENABLED && DebugScope.getInstance().isDumpEnabled()) {
+            System.out.println("dumping");
             DebugScope.getInstance().dump(object, msg, args);
         }
     }
@@ -144,7 +145,7 @@
         }
     }
 
-    public static DebugConfig fixedConfig(final boolean isLogEnabled, final boolean isDumpEnabled, final boolean isMeterEnabled, final boolean isTimerEnabled) {
+    public static DebugConfig fixedConfig(final boolean isLogEnabled, final boolean isDumpEnabled, final boolean isMeterEnabled, final boolean isTimerEnabled, final List<DebugDumpHandler> dumpHandlers) {
         return new DebugConfig() {
 
             @Override
@@ -174,7 +175,7 @@
 
             @Override
             public Collection< ? extends DebugDumpHandler> dumpHandlers() {
-                return Collections.emptyList();
+                return dumpHandlers;
             }
         };
     }
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeInputList.java	Tue Jan 31 10:47:55 2012 +0100
+++ b/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeInputList.java	Wed Feb 01 11:59:32 2012 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.max.graal.graph;
 
+import java.util.*;
+
 
 public final class NodeInputList<T extends Node> extends NodeList<T> {
 
@@ -42,6 +44,12 @@
         this.self = self;
     }
 
+    public NodeInputList(Node self, List<T> elements) {
+        super(elements);
+        assert self.usages() == null;
+        this.self = self;
+    }
+
     @Override
     protected void update(T oldNode, T newNode) {
         self.updateUsages(oldNode, newNode);
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeList.java	Tue Jan 31 10:47:55 2012 +0100
+++ b/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeList.java	Wed Feb 01 11:59:32 2012 +0100
@@ -64,6 +64,21 @@
         }
     }
 
+    protected NodeList(List<T> elements) {
+        if (elements == null || elements.isEmpty()) {
+            this.size = 0;
+            this.nodes = EMPTY_NODE_ARRAY;
+            this.initialSize = 0;
+        } else {
+            this.size = elements.size();
+            this.initialSize = elements.size();
+            this.nodes = new Node[elements.size()];
+            for (int i = 0; i < elements.size(); i++) {
+                this.nodes[i] = elements.get(i);
+            }
+        }
+    }
+
     protected abstract void update(T oldNode, T newNode);
 
     @Override
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java	Tue Jan 31 10:47:55 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java	Wed Feb 01 11:59:32 2012 +0100
@@ -90,7 +90,7 @@
             for (Object o : Debug.context()) {
                 if (o instanceof RiMethod) {
                     RiMethod riMethod = (RiMethod) o;
-                    if (riMethod.toString().contains(methodFilter)) {
+                    if (CiUtil.format("%H.%n", riMethod).contains(methodFilter)) {
                         return true;
                     }
                 }
@@ -125,7 +125,7 @@
         if (e instanceof CiBailout) {
             return e;
         }
-        Debug.setConfig(Debug.fixedConfig(true, true, false, false));
+        Debug.setConfig(Debug.fixedConfig(true, true, false, false, dumpHandlers));
         // sync "Exception occured in scope: " with mx/sanitycheck.py::Test.__init__
         Debug.log(String.format("Exception occured in scope: %s", Debug.currentScope()));
         for (Object o : Debug.context()) {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Jan 31 10:47:55 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Wed Feb 01 11:59:32 2012 +0100
@@ -227,12 +227,20 @@
     @Override
     public void compileMethod(final HotSpotMethodResolved method, final int entryBCI, boolean blocking) throws Throwable {
         try {
-            if (Thread.currentThread() instanceof CompilerThread && method.holder().name().contains("java/util/concurrent")) {
-                // This is required to avoid deadlocking a compiler thread. The issue is that a
-                // java.util.concurrent.BlockingQueue is used to implement the compilation worker
-                // queues. If a compiler thread triggers a compilation, then it may be blocked trying
-                // to add something to its own queue.
-                return;
+            if (Thread.currentThread() instanceof CompilerThread) {
+                if (method.holder().name().contains("java/util/concurrent")) {
+                    // This is required to avoid deadlocking a compiler thread. The issue is that a
+                    // java.util.concurrent.BlockingQueue is used to implement the compilation worker
+                    // queues. If a compiler thread triggers a compilation, then it may be blocked trying
+                    // to add something to its own queue.
+                    return;
+                }
+            } else {
+                if (GraalOptions.Debug) {
+                    Debug.enable();
+                    HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter);
+                    Debug.setConfig(hotspotDebugConfig);
+                }
             }
 
             Runnable runnable = new Runnable() {