Mercurial > hg > truffle
changeset 11612:54dff87002e0
check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 12 Sep 2013 17:32:45 +0200 |
parents | a27678c47948 |
children | 57674ff0f7e2 |
files | graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java |
diffstat | 3 files changed, 24 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Sep 12 16:23:28 2013 +0200 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Sep 12 17:32:45 2013 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.graal.debug; -import static com.oracle.graal.debug.Debug.Initializer.*; +import static com.oracle.graal.debug.Debug.Initialization.*; import java.io.*; import java.util.*; @@ -32,27 +32,38 @@ /** * Scope based debugging facility. This facility is {@link #isEnabled()} if assertions are enabled - * for the {@link Debug} class or the {@value Initializer#INITIALIZER_PROPERTY_NAME} system property - * is {@code "true"} when {@link Debug} is initialized. + * for the {@link Debug} class or the {@value Initialization#INITIALIZER_PROPERTY_NAME} system + * property is {@code "true"} when {@link Debug} is initialized. */ public class Debug { /** - * Class declaring the name of the system property to be used enabling the debugging facilities. + * Class to assist with initialization of {@link Debug}. */ - public static class Initializer { + public static class Initialization { public static final String INITIALIZER_PROPERTY_NAME = "graal.debug.enable"; + + private static boolean initialized; + + /** + * Determines if {@link Debug} has been initialized. + */ + public static boolean isDebugInitialized() { + return initialized; + } + } @SuppressWarnings("all") - private static boolean assertionsEnabled() { - boolean enabled = false; - assert enabled = true; - return enabled; + private static boolean initialize() { + boolean assertionsEnabled = false; + assert assertionsEnabled = true; + Initialization.initialized = true; + return assertionsEnabled || Boolean.getBoolean(INITIALIZER_PROPERTY_NAME); } - private static final boolean ENABLED = assertionsEnabled() || Boolean.getBoolean(INITIALIZER_PROPERTY_NAME); + private static final boolean ENABLED = initialize(); public static boolean isEnabled() { return ENABLED;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Sep 12 16:23:28 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Sep 12 17:32:45 2013 +0200 @@ -183,7 +183,8 @@ */ public static void finalizeOptions(boolean ciTime) { if (areDebugScopePatternsEnabled() || ciTime) { - System.setProperty(Debug.Initializer.INITIALIZER_PROPERTY_NAME, "true"); + assert !Debug.Initialization.isDebugInitialized(); + System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true"); } }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Thu Sep 12 16:23:28 2013 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Thu Sep 12 17:32:45 2013 +0200 @@ -35,7 +35,7 @@ public static void initialize(PrintStream log) { if (!Debug.isEnabled()) { - log.println("WARNING: Scope debugging needs to be enabled with -esa or -D" + Debug.Initializer.INITIALIZER_PROPERTY_NAME + "=true"); + log.println("WARNING: Scope debugging needs to be enabled with -esa or -D" + Debug.Initialization.INITIALIZER_PROPERTY_NAME + "=true"); return; } List<DebugDumpHandler> dumpHandlers = new ArrayList<>();