changeset 17211:1ac6b4879443

Enforce catch-blocks for Debug.Scopes with context objects.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 25 Sep 2014 13:28:12 +0200
parents ef64e2682bb6
children 26d07b31c4a8
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java
diffstat 6 files changed, 36 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Thu Sep 25 10:27:17 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Thu Sep 25 13:28:12 2014 +0200
@@ -707,6 +707,8 @@
             StructuredGraph graph = new StructuredGraph(javaMethod);
             graphBuilderSuite.apply(graph, new HighTierContext(providers, null, null, graphBuilderSuite, OptimisticOptimizations.ALL));
             return graph;
+        } catch (Throwable e) {
+            throw Debug.handle(e);
         }
     }
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Thu Sep 25 10:27:17 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Thu Sep 25 13:28:12 2014 +0200
@@ -970,6 +970,8 @@
                     }
                 }
             }
+        } catch (Throwable e) {
+            throw Debug.handle(e);
         }
     }
 
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Thu Sep 25 10:27:17 2014 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Thu Sep 25 13:28:12 2014 +0200
@@ -217,9 +217,26 @@
      * </pre>
      *
      * @param name the name of the new scope
+     * @param contextObjects an array of object to be appended to the {@linkplain #context()
+     *            current} debug context
+     * @throws Throwable used to enforce a catch block.
      * @return the scope entered by this method which will be exited when its {@link Scope#close()}
      *         method is called
      */
+    public static Scope scope(Object name, Object[] contextObjects) throws Throwable {
+        if (ENABLED) {
+            return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, contextObjects);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Similar to {@link #scope(Object, Object[])} but without context objects. Therefore the catch
+     * block can be omitted.
+     *
+     * @see #scope(Object, Object[])
+     */
     public static Scope scope(Object name) {
         if (ENABLED) {
             return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null);
@@ -229,23 +246,10 @@
     }
 
     /**
-     * @see #scope(Object)
-     * @param contextObjects an array of object to be appended to the {@linkplain #context()
-     *            current} debug context
-     */
-    public static Scope scope(Object name, Object[] contextObjects) {
-        if (ENABLED) {
-            return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, contextObjects);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * @see #scope(Object)
+     * @see #scope(Object, Object[])
      * @param context an object to be appended to the {@linkplain #context() current} debug context
      */
-    public static Scope scope(Object name, Object context) {
+    public static Scope scope(Object name, Object context) throws Throwable {
         if (ENABLED) {
             return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context);
         } else {
@@ -254,13 +258,13 @@
     }
 
     /**
-     * @see #scope(Object)
+     * @see #scope(Object, Object[])
      * @param context1 first object to be appended to the {@linkplain #context() current} debug
      *            context
      * @param context2 second object to be appended to the {@linkplain #context() current} debug
      *            context
      */
-    public static Scope scope(Object name, Object context1, Object context2) {
+    public static Scope scope(Object name, Object context1, Object context2) throws Throwable {
         if (ENABLED) {
             return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context1, context2);
         } else {
@@ -269,7 +273,7 @@
     }
 
     /**
-     * @see #scope(Object)
+     * @see #scope(Object, Object[])
      * @param context1 first object to be appended to the {@linkplain #context() current} debug
      *            context
      * @param context2 second object to be appended to the {@linkplain #context() current} debug
@@ -277,7 +281,7 @@
      * @param context3 third object to be appended to the {@linkplain #context() current} debug
      *            context
      */
-    public static Scope scope(Object name, Object context1, Object context2, Object context3) {
+    public static Scope scope(Object name, Object context1, Object context2, Object context3) throws Throwable {
         if (ENABLED) {
             return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context1, context2, context3);
         } else {
@@ -305,7 +309,7 @@
      * @return the scope entered by this method which will be exited when its {@link Scope#close()}
      *         method is called
      */
-    public static Scope sandbox(CharSequence name, DebugConfig config, Object... context) {
+    public static Scope sandbox(CharSequence name, DebugConfig config, Object... context) throws Throwable {
         if (ENABLED) {
             DebugConfig sandboxConfig = config == null ? silentConfig() : config;
             return DebugScope.getInstance().scope(name, sandboxConfig, context);
@@ -314,7 +318,7 @@
         }
     }
 
-    public static Scope forceLog() {
+    public static Scope forceLog() throws Throwable {
         ArrayList<Object> context = new ArrayList<>();
         for (Object obj : context()) {
             context.add(obj);
@@ -346,7 +350,7 @@
      * pattern recommended by {@link #scope(Object)} and
      * {@link #sandbox(CharSequence, DebugConfig, Object...)} is used
      *
-     * @see #scope(Object)
+     * @see #scope(Object, Object[])
      * @see #sandbox(CharSequence, DebugConfig, Object...)
      */
     public static RuntimeException handle(Throwable exception) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java	Thu Sep 25 10:27:17 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java	Thu Sep 25 13:28:12 2014 +0200
@@ -167,6 +167,8 @@
         InstalledCode installedCode;
         try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache(), g.method())) {
             installedCode = providers.getCodeCache().addMethod(g.method(), compResult, null, null);
+        } catch (Throwable e) {
+            throw Debug.handle(e);
         }
         return installedCode;
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java	Thu Sep 25 10:27:17 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java	Thu Sep 25 13:28:12 2014 +0200
@@ -399,6 +399,8 @@
             throw new GraalInternalError(e).addContext(calleeInfo.toString());
         } catch (GraalInternalError e) {
             throw e.addContext(calleeInfo.toString());
+        } catch (Throwable e) {
+            throw Debug.handle(e);
         }
     }
 
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Thu Sep 25 10:27:17 2014 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Thu Sep 25 13:28:12 2014 +0200
@@ -130,6 +130,8 @@
                 CodeCacheProvider codeCache = providers.getCodeCache();
                 try (Scope s = Debug.scope("CodeInstall", codeCache, method)) {
                     codeCache.setDefaultMethod(method, compResult);
+                } catch (Throwable e) {
+                    throw Debug.handle(e);
                 }
             }
         }