# HG changeset patch # User Doug Simon # Date 1355255651 -3600 # Node ID e86ac899c5be941965e9f09381046910516b9e04 # Parent ff6df8b7ce81c1bc2ae1d379f75f89a3b4c367d0 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 diff -r ff6df8b7ce81 -r e86ac899c5be 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 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();