Mercurial > hg > graal-compiler
changeset 7152:e86ac899c5be
fixed issues triggered when using the CountingProxy (i.e., -Dgraal.countcalls=true) or LoggingProxy (i.e., -Dgraal.debug=true) to analyze traffic across the VM/compiler boundary
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 11 Dec 2012 20:54:11 +0100 |
parents | ff6df8b7ce81 |
children | c421c19b7bf8 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java |
diffstat | 1 files changed, 25 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Tue Dec 11 08:29:25 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Tue Dec 11 20:54:11 2012 +0100 @@ -60,6 +60,29 @@ protected static void setInstance(HotSpotGraalRuntime runtime) { assert instance == null : "runtime already registered"; instance = runtime; + + // Do deferred initialization + + // 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; + + if (CountingProxy.ENABLED) { + toCompiler = CountingProxy.getProxy(VMToCompiler.class, toCompiler); + toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); + } + if (Logger.ENABLED) { + toCompiler = LoggingProxy.getProxy(VMToCompiler.class, toCompiler); + toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); + } + + runtime.vmToCompiler = toCompiler; + runtime.compilerToVm = toVM; } private static Kind wordKind; @@ -82,8 +105,8 @@ return unsafe.getInt(address); } - protected final CompilerToVM compilerToVm; - protected final VMToCompiler vmToCompiler; + protected /*final*/ CompilerToVM compilerToVm; + protected /*final*/ VMToCompiler vmToCompiler; protected final HotSpotRuntime runtime; protected final GraalCompiler compiler; @@ -100,17 +123,6 @@ // initialize VmToCompiler VMToCompiler toCompiler = new VMToCompilerImpl(this); - // logging, etc. - if (CountingProxy.ENABLED) { - toCompiler = CountingProxy.getProxy(VMToCompiler.class, toCompiler); - toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); - } - if (Logger.ENABLED) { - toCompiler = LoggingProxy.getProxy(VMToCompiler.class, toCompiler); - toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); - } - - // set the final fields compilerToVm = toVM; vmToCompiler = toCompiler; config = new HotSpotVMConfig();