Mercurial > hg > graal-compiler
changeset 22577:824520386e8e
Truffle: extract TraceTruffleTransferToInterpreter code into helper class
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Thu, 03 Sep 2015 19:24:03 +0200 |
parents | fec3ef6b46ed |
children | 8b3b7d701f78 |
files | graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java |
diffstat | 1 files changed, 32 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Thu Sep 03 17:45:03 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Thu Sep 03 19:24:03 2015 +0200 @@ -77,7 +77,6 @@ private final ExecutorService compileQueue; private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>()); - private static final long THREAD_EETOP_OFFSET = eetopOffset(); private HotSpotTruffleRuntime() { installOptimizedCallTargetCallMethod(); @@ -315,30 +314,7 @@ public void notifyTransferToInterpreter() { CompilerAsserts.neverPartOfCompilation(); if (TraceTruffleTransferToInterpreter.getValue()) { - long thread = UnsafeAccess.unsafe.getLong(Thread.currentThread(), THREAD_EETOP_OFFSET); - long pendingTransferToInterpreterAddress = thread + HotSpotGraalRuntime.runtime().getConfig().pendingTransferToInterpreterOffset; - boolean deoptimized = UnsafeAccess.unsafe.getByte(pendingTransferToInterpreterAddress) != 0; - if (deoptimized) { - UnsafeAccess.unsafe.putByte(pendingTransferToInterpreterAddress, (byte) 0); - - logTransferToInterpreter(); - } - } - } - - private static void logTransferToInterpreter() { - final int skip = 2; - final int limit = TraceTruffleStackTraceLimit.getValue(); - StackTraceElement[] stackTrace = new Throwable().getStackTrace(); - String suffix = stackTrace.length > skip + limit ? "\n ..." : ""; - TTY.out().out().println(Arrays.stream(stackTrace).skip(skip).limit(limit).map(StackTraceElement::toString).collect(Collectors.joining("\n ", "", suffix))); - } - - private static long eetopOffset() { - try { - return UnsafeAccess.unsafe.objectFieldOffset(Thread.class.getDeclaredField("eetop")); - } catch (Exception e) { - throw new JVMCIError(e); + TraceTraceTransferToInterpreterHelper.traceTransferToInterpreter(); } } @@ -361,4 +337,35 @@ } return new HotSpotNativeFunctionInterface(HotSpotGraalRuntime.runtime().getHostProviders(), factory, backend, config.dllLoad, config.dllLookup, config.rtldDefault); } + + private static class TraceTraceTransferToInterpreterHelper { + private static final long THREAD_EETOP_OFFSET; + + static { + try { + THREAD_EETOP_OFFSET = UnsafeAccess.unsafe.objectFieldOffset(Thread.class.getDeclaredField("eetop")); + } catch (Exception e) { + throw new JVMCIError(e); + } + } + + static void traceTransferToInterpreter() { + long thread = UnsafeAccess.unsafe.getLong(Thread.currentThread(), THREAD_EETOP_OFFSET); + long pendingTransferToInterpreterAddress = thread + HotSpotGraalRuntime.runtime().getConfig().pendingTransferToInterpreterOffset; + boolean deoptimized = UnsafeAccess.unsafe.getByte(pendingTransferToInterpreterAddress) != 0; + if (deoptimized) { + UnsafeAccess.unsafe.putByte(pendingTransferToInterpreterAddress, (byte) 0); + + logTransferToInterpreter(); + } + } + + private static void logTransferToInterpreter() { + final int skip = 3; + final int limit = TraceTruffleStackTraceLimit.getValue(); + StackTraceElement[] stackTrace = new Throwable().getStackTrace(); + String suffix = stackTrace.length > skip + limit ? "\n ..." : ""; + TTY.out().out().println(Arrays.stream(stackTrace).skip(skip).limit(limit).map(StackTraceElement::toString).collect(Collectors.joining("\n ", "", suffix))); + } + } }