# HG changeset patch # User Doug Simon # Date 1377529845 -7200 # Node ID 7c4c1a7c875afb1dda8d2097735cae33a2a40c70 # Parent 2fac92eb455931dc6a7f1dd9e3f1230868b34aa6 made HotSpotGraalRuntime.instance final diff -r 2fac92eb4559 -r 7c4c1a7c875a graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java Thu Aug 22 14:45:40 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java Mon Aug 26 17:10:45 2013 +0200 @@ -44,15 +44,17 @@ * Called from C++ code to retrieve the singleton instance, creating it first if necessary. */ public static HotSpotGraalRuntime makeInstance() { - if (graalRuntime() == null) { + HotSpotGraalRuntime graalRuntime = graalRuntime(); + if (graalRuntime == null) { HotSpotGraalRuntimeFactory factory = findFactory("AMD64"); if (factory != null) { - setInstance(factory.createRuntime()); + graalRuntime = factory.createRuntime(); } else { - setInstance(new AMD64HotSpotGraalRuntime()); + graalRuntime = new AMD64HotSpotGraalRuntime(); } + graalRuntime.completeInitialization(); } - return graalRuntime(); + return graalRuntime; } protected Architecture createArchitecture() { diff -r 2fac92eb4559 -r 7c4c1a7c875a graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java Thu Aug 22 14:45:40 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java Mon Aug 26 17:10:45 2013 +0200 @@ -41,10 +41,12 @@ * Called from C++ code to retrieve the singleton instance, creating it first if necessary. */ public static HotSpotGraalRuntime makeInstance() { - if (graalRuntime() == null) { - setInstance(new SPARCHotSpotGraalRuntime()); + HotSpotGraalRuntime graalRuntime = graalRuntime(); + if (graalRuntime == null) { + graalRuntime = new SPARCHotSpotGraalRuntime(); + graalRuntime.completeInitialization(); } - return graalRuntime(); + return graalRuntime; } protected static Architecture createArchitecture() { diff -r 2fac92eb4559 -r 7c4c1a7c875a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Aug 22 14:45:40 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Aug 26 17:10:45 2013 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot; import static com.oracle.graal.graph.UnsafeAccess.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.Options.*; import java.lang.reflect.*; import java.util.*; @@ -49,7 +50,7 @@ */ public abstract class HotSpotGraalRuntime implements GraalRuntime { - private static HotSpotGraalRuntime instance; + private static final HotSpotGraalRuntime instance = (HotSpotGraalRuntime) Graal.getRuntime(); /** * Gets the singleton {@link HotSpotGraalRuntime} object. @@ -59,22 +60,18 @@ } /** - * Called by the platform specific class exactly once to register the singleton instance. + * Do deferred initialization. */ - protected static void setInstance(HotSpotGraalRuntime runtime) { - assert instance == null : "runtime already registered"; - instance = runtime; - - // Do deferred initialization + public void completeInitialization() { // Proxies for the VM/Compiler interfaces cannot be initialized // in the constructor as proxy creation causes static // initializers to be executed for all the types involved in the // proxied methods. Some of these static initializers (e.g. in - // HotSpotMethodData) rely on the above instance field being set - // to retrieve config details. - VMToCompiler toCompiler = runtime.vmToCompiler; - CompilerToVM toVM = runtime.compilerToVm; + // HotSpotMethodData) rely on the static 'instance' field being set + // to retrieve configuration details. + VMToCompiler toCompiler = this.vmToCompiler; + CompilerToVM toVM = this.compilerToVm; if (CountingProxy.ENABLED) { toCompiler = CountingProxy.getProxy(VMToCompiler.class, toCompiler); @@ -85,14 +82,18 @@ toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); } - runtime.vmToCompiler = toCompiler; - runtime.compilerToVm = toVM; + this.vmToCompiler = toCompiler; + this.compilerToVm = toVM; } - // @formatter:off - @Option(help = "The runtime configuration to use") - private static final OptionValue GraalRuntime = new OptionValue<>(""); - // @formatter:on + // Options must not be directly declared in HotSpotGraalRuntime - see VerifyHotSpotOptionsPhase + static class Options { + + // @formatter:off + @Option(help = "The runtime configuration to use") + static final OptionValue GraalRuntime = new OptionValue<>(""); + // @formatter:on + } protected static HotSpotGraalRuntimeFactory findFactory(String architecture) { HotSpotGraalRuntimeFactory basic = null;