# HG changeset patch # User Josef Eisl # Date 1411644492 -7200 # Node ID 1ac6b4879443974692e25246218f874d9228a9e0 # Parent ef64e2682bb6da92526297c80e2d3aba98a0e88f Enforce catch-blocks for Debug.Scopes with context objects. diff -r ef64e2682bb6 -r 1ac6b4879443 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- 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); } } diff -r ef64e2682bb6 -r 1ac6b4879443 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- 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); } } diff -r ef64e2682bb6 -r 1ac6b4879443 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- 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 @@ * * * @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 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) { diff -r ef64e2682bb6 -r 1ac6b4879443 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java --- 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; } diff -r ef64e2682bb6 -r 1ac6b4879443 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java --- 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); } } diff -r ef64e2682bb6 -r 1ac6b4879443 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- 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); } } }