changeset 4481:600ec4e44b2e

Merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 07 Feb 2012 15:59:54 +0100
parents 7d6490436b57 (current diff) 95802b2cec42 (diff)
children 7903b6c28f9c
files
diffstat 10 files changed, 125 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java	Tue Feb 07 15:59:54 2012 +0100
@@ -81,7 +81,7 @@
         if (osrBCI != -1) {
             throw new CiBailout("No OSR supported");
         }
-        return Debug.scope(createScopeName(method), method, new Callable<CiTargetMethod>() {
+        return Debug.scope(createScopeName(method), new Callable<CiTargetMethod>() {
             public CiTargetMethod call() {
                 final CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null;
                 final LIR lir = Debug.scope("FrontEnd", graph, new Callable<LIR>() {
--- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java	Tue Feb 07 15:59:54 2012 +0100
@@ -26,8 +26,8 @@
 import java.util.*;
 import java.util.concurrent.*;
 
+public class Debug {
 
-public class Debug {
     private static boolean ENABLED = false;
 
     public static void enable() {
@@ -73,7 +73,7 @@
 
     public static void scope(String name, Object context, Runnable runnable) {
         if (ENABLED) {
-            DebugScope.getInstance().scope(name, runnable, null, false, new Object[]{context});
+            DebugScope.getInstance().scope(name, runnable, null, false, new Object[] {context});
         } else {
             runnable.run();
         }
@@ -89,7 +89,7 @@
 
     public static <T> T scope(String name, Object context, Callable<T> callable) {
         if (ENABLED) {
-            return DebugScope.getInstance().scope(name, null, callable, false, new Object[]{context});
+            return DebugScope.getInstance().scope(name, null, callable, false, new Object[] {context});
         } else {
             return DebugScope.call(callable);
         }
@@ -130,6 +130,18 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
+    public static <T> T contextLookup(Class<T> clazz) {
+        if (ENABLED) {
+            for (Object o : context()) {
+                if (clazz.isInstance(o)) {
+                    return ((T) o);
+                }
+            }
+        }
+        return null;
+    }
+
     public static DebugMetric metric(String name) {
         if (ENABLED) {
             return new MetricImpl(name);
@@ -168,8 +180,8 @@
             }
 
             @Override
-            public RuntimeException interceptException(RuntimeException e) {
-                return e;
+            public RuntimeException interceptException(Throwable e) {
+                return null;
             }
 
             @Override
@@ -180,8 +192,12 @@
     }
 
     private static final DebugMetric VOID_METRIC = new DebugMetric() {
-        public void increment() { }
-        public void add(int value) { }
+
+        public void increment() {
+        }
+
+        public void add(int value) {
+        }
     };
 
     public static DebugTimer timer(String name) {
@@ -193,6 +209,9 @@
     }
 
     private static final DebugTimer VOID_TIMER = new DebugTimer() {
-        public TimerCloseable start() { return TimerImpl.VOID_CLOSEABLE; }
+
+        public TimerCloseable start() {
+            return TimerImpl.VOID_CLOSEABLE;
+        }
     };
 }
--- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugConfig.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugConfig.java	Tue Feb 07 15:59:54 2012 +0100
@@ -30,6 +30,6 @@
     boolean isMeterEnabled();
     boolean isDumpEnabled();
     boolean isTimeEnabled();
-    RuntimeException interceptException(RuntimeException e);
+    RuntimeException interceptException(Throwable e);
     Collection<? extends DebugDumpHandler> dumpHandlers();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugDumpScope.java	Tue Feb 07 15:59:54 2012 +0100
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.max.graal.debug;
+
+public final class DebugDumpScope {
+
+    private final String name;
+
+    public DebugDumpScope(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+}
--- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java	Tue Feb 07 15:59:54 2012 +0100
@@ -32,7 +32,7 @@
 
     private static ThreadLocal<DebugScope> instanceTL = new ThreadLocal<>();
     private static ThreadLocal<DebugConfig> configTL = new ThreadLocal<>();
-    private static ThreadLocal<RuntimeException> lastExceptionThrownTL = new ThreadLocal<>();
+    private static ThreadLocal<Throwable> lastExceptionThrownTL = new ThreadLocal<>();
     private static DebugTimer scopeTime = Debug.timer("ScopeTime");
     private static DebugMetric scopeCount = Debug.metric("ScopeCount");
 
@@ -142,13 +142,18 @@
             if (callable != null) {
                 return call(callable);
             }
-        } catch (RuntimeException e) {
+        } catch (Throwable e) {
             if (e == lastExceptionThrownTL.get()) {
                 throw e;
             } else {
                 RuntimeException newException = interceptException(e);
-                lastExceptionThrownTL.set(newException);
-                throw newException;
+                if (newException == null) {
+                    lastExceptionThrownTL.set(e);
+                    throw e;
+                } else {
+                    lastExceptionThrownTL.set(newException);
+                    throw newException;
+                }
             }
         }
         return null;
@@ -173,7 +178,7 @@
         context = null;
     }
 
-    private RuntimeException interceptException(final RuntimeException e) {
+    private RuntimeException interceptException(final Throwable e) {
         final DebugConfig config = getConfig();
         if (config != null) {
             return scope("InterceptException", null, new Callable<RuntimeException>() {
@@ -183,12 +188,12 @@
                     try {
                         return config.interceptException(e);
                     } catch (Throwable t) {
-                        return e;
+                        return new RuntimeException("Exception while intercepting exception", e);
                     }
                 }
             }, false, new Object[] {e});
         }
-        return e;
+        return null;
     }
 
     private DebugValueMap getValueMap() {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java	Tue Feb 07 15:59:54 2012 +0100
@@ -120,9 +120,9 @@
     }
 
     @Override
-    public RuntimeException interceptException(RuntimeException e) {
+    public RuntimeException interceptException(Throwable e) {
         if (e instanceof CiBailout) {
-            return e;
+            return null;
         }
         Debug.setConfig(Debug.fixedConfig(true, true, false, false, dumpHandlers));
         // sync "Exception occured in scope: " with mx/sanitycheck.py::Test.__init__
@@ -135,7 +135,7 @@
                 Debug.dump(o, "Exception graph");
             }
         }
-        return e;
+        return null;
     }
 
     @Override
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Feb 07 15:59:54 2012 +0100
@@ -239,19 +239,13 @@
                     // 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() {
 
                 public void run() {
                     try {
-                        PhasePlan plan = getDefaultPhasePlan();
+                        final PhasePlan plan = getDefaultPhasePlan();
                         GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime());
                         plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
                         long startTime = 0;
@@ -265,7 +259,12 @@
                         CiTargetMethod result = null;
                         TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method);
                         try {
-                            result = compiler.getCompiler().compileMethod(method, -1, plan);
+                            result = Debug.scope("Compiling", method, new Callable<CiTargetMethod>() {
+                                @Override
+                                public CiTargetMethod call() throws Exception {
+                                    return compiler.getCompiler().compileMethod(method, -1, plan);
+                                }
+                            });
                         } finally {
                             filter.remove();
                             if (printCompilation) {
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/type/StampFactory.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/type/StampFactory.java	Tue Feb 07 15:59:54 2012 +0100
@@ -173,7 +173,7 @@
             RiResolvedType exactType = first.exactType();
             while (iterator.hasNext()) {
                 Stamp current = iterator.next().stamp();
-                assert current.kind() == first.kind() : values + " first=" + first + " current=" + current;
+                assert current.kind() == first.kind() : values + " first=" + first + " current=" + current + " first kind=" + first.kind() + " current kind=" + current.kind();
                 nonNull &= current.nonNull();
                 declaredType = orTypes(declaredType, current.declaredType());
                 exactType = orTypes(exactType, current.exactType());
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterDumpHandler.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterDumpHandler.java	Tue Feb 07 15:59:54 2012 +0100
@@ -25,6 +25,7 @@
 import java.io.*;
 import java.net.*;
 import java.util.*;
+
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
 import com.oracle.max.criutils.*;
@@ -40,7 +41,7 @@
     private static final String DEFAULT_FILE_NAME = "output.igv.xml";
 
     private IdealGraphPrinter printer;
-    private List<RiResolvedMethod> previousInlineContext = new ArrayList<>();
+    private List<String> previousInlineContext = new ArrayList<>();
     private String fileName;
     private String host;
     private int port;
@@ -61,8 +62,6 @@
         this.port = port;
     }
 
-
-
     private void ensureInitialized() {
         if (!initialized) {
             initialized = true;
@@ -85,7 +84,7 @@
     }
 
     private void initializeNetworkPrinter() {
-        try  {
+        try {
             Socket socket = new Socket(host, port);
             BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream(), 0x4000);
             printer = new IdealGraphPrinter(stream);
@@ -103,26 +102,29 @@
 
             if (printer.isValid()) {
                 // Get all current RiResolvedMethod instances in the context.
-                List<RiResolvedMethod> inlineContext = Debug.contextSnapshot(RiResolvedMethod.class);
+                List<String> inlineContext = getInlineContext();
+                Debug.contextSnapshot(RiResolvedMethod.class);
 
                 // Reverse list such that inner method comes after outer method.
                 Collections.reverse(inlineContext);
 
                 // Check for method scopes that must be closed since the previous dump.
                 for (int i = 0; i < previousInlineContext.size(); ++i) {
-                    if (i >= inlineContext.size() || inlineContext.get(i) != previousInlineContext.get(i)) {
+                    if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
                         for (int j = previousInlineContext.size() - 1; j >= i; --j) {
-                            closeMethodScope();
+                            closeScope();
                         }
+                        break;
                     }
                 }
 
                 // Check for method scopes that must be opened since the previous dump.
                 for (int i = 0; i < inlineContext.size(); ++i) {
-                    if (i >= previousInlineContext.size() || inlineContext.get(i) != previousInlineContext.get(i)) {
+                    if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
                         for (int j = i; j < inlineContext.size(); ++j) {
-                            openMethodScope(inlineContext.get(j));
+                            openScope(inlineContext.get(j));
                         }
+                        break;
                     }
                 }
 
@@ -145,13 +147,25 @@
         }
     }
 
-    private void openMethodScope(RiResolvedMethod method) {
-        printer.beginGroup(CiUtil.format("%H::%n", method), CiUtil.format("%h::%n", method), method, -1);
-
+    private static List<String> getInlineContext() {
+        List<String> result = new ArrayList<>();
+        for (Object o : Debug.context()) {
+            if (o instanceof RiResolvedMethod) {
+                RiResolvedMethod method = (RiResolvedMethod) o;
+                result.add(CiUtil.format("%H::%n", method));
+            } else if (o instanceof DebugDumpScope) {
+                DebugDumpScope debugDumpScope = (DebugDumpScope) o;
+                result.add(debugDumpScope.getName());
+            }
+        }
+        return result;
     }
 
-    private void closeMethodScope() {
+    private void openScope(String name) {
+        printer.beginGroup(name, name, Debug.contextLookup(RiResolvedMethod.class), -1);
+    }
+
+    private void closeScope() {
         printer.endGroup();
-
     }
 }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Tue Feb 07 15:59:29 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Tue Feb 07 15:59:54 2012 +0100
@@ -128,8 +128,8 @@
 
         @Override
         protected Group start() throws SAXException {
-            Group group = new Group(this.getParentObject());
-            
+            final Group group = new Group(this.getParentObject());
+
             String differenceProperty = this.readAttribute(DIFFERENCE_PROPERTY);
             Parser.this.differenceEncoding.put(group, (differenceProperty != null && (differenceProperty.equals("1") || differenceProperty.equals("true"))));
 
@@ -138,12 +138,6 @@
                 monitor.setState(group.getName());
             }
 
-            return group;
-        }
-
-        @Override
-        protected void end(String text) throws SAXException {
-            final Group group = getObject();
             final Folder parent = getParentObject();
             if (groupCallback == null || parent instanceof Group) {
                 SwingUtilities.invokeLater(new Runnable(){
@@ -153,6 +147,12 @@
                     }
                 });
             }
+
+            return group;
+        }
+
+        @Override
+        protected void end(String text) throws SAXException {
         }
     };
     // <method>
@@ -270,7 +270,7 @@
                 graph.addBlockEdge(left, right);
             }
             blockConnections.clear();
-            
+
             SwingUtilities.invokeLater(new Runnable(){
 
                 @Override