changeset 8467:eb0282efad36

rewrote Thread.isInterrupted() substitution to use @Alias mechanism
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 Mar 2013 22:37:18 +0100
parents c7a2a937233f
children 95e21e035363
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java	Mon Mar 25 22:35:42 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java	Mon Mar 25 22:37:18 2013 +0100
@@ -23,6 +23,7 @@
 package com.oracle.graal.hotspot.replacements;
 
 import static com.oracle.graal.hotspot.replacements.HotSpotSnippetUtils.*;
+import static com.oracle.graal.nodes.extended.UnsafeCastNode.*;
 
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.hotspot.nodes.*;
@@ -39,13 +40,17 @@
         return CurrentThread.get();
     }
 
+    @Alias(declaringClass = Thread.class) private long eetop;
+
     @MethodSubstitution(isStatic = false)
-    private static boolean isInterrupted(final Thread thisObject, boolean clearInterrupted) {
-        Word rawThread = HotSpotCurrentRawThreadNode.get();
-        Thread thread = (Thread) rawThread.readObject(threadObjectOffset(), FINAL_LOCATION);
+    public static boolean isInterrupted(final Thread thisObject, boolean clearInterrupted) {
+        Thread thread = CurrentThread.get();
         if (thisObject == thread) {
+            ThreadSubstitutions threadAlias = unsafeCast(thread, ThreadSubstitutions.class, false, true);
+            Word rawThread = Word.unsigned(threadAlias.eetop);
             Word osThread = rawThread.readWord(osThreadOffset(), FINAL_LOCATION);
-            boolean interrupted = osThread.readInt(osThreadInterruptedOffset(), UNKNOWN_LOCATION) != 0;
+            int int0 = osThread.readInt(osThreadInterruptedOffset(), UNKNOWN_LOCATION);
+            boolean interrupted = int0 != 0;
             if (!interrupted || !clearInterrupted) {
                 return interrupted;
             }