# HG changeset patch # User Andreas Woess # Date 1426603773 -3600 # Node ID 4b6a65cb8ecdaa5d6cbf1c71fa0171b2b748a397 # Parent 08233b1ae932f38fe3d97eec395082f9defc114a Truffle: repair TraceTruffleTransferToInterpreter option diff -r 08233b1ae932 -r 4b6a65cb8ecd graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue Mar 17 15:39:46 2015 +0100 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue Mar 17 15:49:33 2015 +0100 @@ -37,6 +37,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; @@ -44,7 +45,6 @@ import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.java.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.phases.*; @@ -58,7 +58,6 @@ import com.oracle.graal.printer.*; import com.oracle.graal.runtime.*; import com.oracle.graal.truffle.*; -import com.oracle.graal.word.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.nodes.*; @@ -80,6 +79,7 @@ private final ThreadPoolExecutor compileQueue; private final Map callTargets = Collections.synchronizedMap(new WeakHashMap()); + private static final long THREAD_EETOP_OFFSET = eetopOffset(); private HotSpotTruffleRuntime() { installOptimizedCallTargetCallMethod(); @@ -321,10 +321,11 @@ public void notifyTransferToInterpreter() { CompilerAsserts.neverPartOfCompilation(); if (TraceTruffleTransferToInterpreter.getValue()) { - Word thread = CurrentJavaThreadNode.get(); - boolean deoptimized = thread.readByte(HotSpotGraalRuntime.runtime().getConfig().pendingTransferToInterpreterOffset) != 0; + 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) { - thread.writeByte(HotSpotGraalRuntime.runtime().getConfig().pendingTransferToInterpreterOffset, (byte) 0); + UnsafeAccess.unsafe.putByte(pendingTransferToInterpreterAddress, (byte) 0); logTransferToInterpreter(); } @@ -338,4 +339,12 @@ 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 GraalInternalError(e); + } + } }