# HG changeset patch # User Doug Simon # Date 1378995808 -7200 # Node ID a27678c479487dc6833b86c4640b153e946c382b # Parent 5f532ea846fbcadd1ddcb40ea9326ff3ff43f19d made Debug.ENABLED static (i.e. a compile-time constant) diff -r 5f532ea846fb -r a27678c47948 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 12 14:43:21 2013 +0200 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Sep 12 16:23:28 2013 +0200 @@ -22,24 +22,38 @@ */ package com.oracle.graal.debug; -import com.oracle.graal.debug.internal.*; +import static com.oracle.graal.debug.Debug.Initializer.*; import java.io.*; import java.util.*; import java.util.concurrent.*; +import com.oracle.graal.debug.internal.*; + +/** + * 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. + */ public class Debug { - private static boolean ENABLED = false; + /** + * Class declaring the name of the system property to be used enabling the debugging facilities. + */ + public static class Initializer { - public static void enable() { - ENABLED = true; + public static final String INITIALIZER_PROPERTY_NAME = "graal.debug.enable"; } - public static void disable() { - ENABLED = false; + @SuppressWarnings("all") + private static boolean assertionsEnabled() { + boolean enabled = false; + assert enabled = true; + return enabled; } + private static final boolean ENABLED = assertionsEnabled() || Boolean.getBoolean(INITIALIZER_PROPERTY_NAME); + public static boolean isEnabled() { return ENABLED; } diff -r 5f532ea846fb -r a27678c47948 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Sep 12 14:43:21 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Sep 12 16:23:28 2013 +0200 @@ -183,7 +183,7 @@ */ public static void finalizeOptions(boolean ciTime) { if (areDebugScopePatternsEnabled() || ciTime) { - Debug.enable(); + System.setProperty(Debug.Initializer.INITIALIZER_PROPERTY_NAME, "true"); } } diff -r 5f532ea846fb -r a27678c47948 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Thu Sep 12 14:43:21 2013 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Thu Sep 12 16:23:28 2013 +0200 @@ -34,7 +34,10 @@ public class DebugEnvironment { public static void initialize(PrintStream log) { - Debug.enable(); + if (!Debug.isEnabled()) { + log.println("WARNING: Scope debugging needs to be enabled with -esa or -D" + Debug.Initializer.INITIALIZER_PROPERTY_NAME + "=true"); + return; + } List dumpHandlers = new ArrayList<>(); dumpHandlers.add(new GraphPrinterDumpHandler()); if (PrintCFG.getValue() || PrintBackendCFG.getValue()) {