changeset 9420:393d62a868da

replaced thread_is_interrupted assembler stub with a compiled stub (GRAAL-81)
author Doug Simon <doug.simon@oracle.com>
date Tue, 30 Apr 2013 00:33:27 +0200
parents 640d86a6bf4a
children 20dc10bb82d1
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ThreadIsInterruptedStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ThreadIsInterruptedStub.java src/cpu/x86/vm/graalRuntime_x86.cpp src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/graal/graalRuntime.hpp
diffstat 9 files changed, 83 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Mon Apr 29 22:49:49 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Tue Apr 30 00:33:27 2013 +0200
@@ -30,7 +30,6 @@
 import static com.oracle.graal.hotspot.nodes.IdentityHashCodeStubCall.*;
 import static com.oracle.graal.hotspot.nodes.MonitorEnterStubCall.*;
 import static com.oracle.graal.hotspot.nodes.MonitorExitStubCall.*;
-import static com.oracle.graal.hotspot.nodes.ThreadIsInterruptedStubCall.*;
 import static com.oracle.graal.hotspot.nodes.VMErrorNode.*;
 import static com.oracle.graal.hotspot.nodes.VerifyOopStubCall.*;
 import static com.oracle.graal.hotspot.nodes.WriteBarrierPostStubCall.*;
@@ -118,12 +117,6 @@
                 /*          ret */ rax.asValue(Kind.Int),
                 /* arg0:    obj */ javaCallingConvention(Kind.Object));
 
-        addRuntimeCall(THREAD_IS_INTERRUPTED, config.threadIsInterruptedStub,
-                /*        temps */ null,
-                /*          ret */ rax.asValue(Kind.Boolean),
-                /* arg0: thread */ javaCallingConvention(Kind.Object,
-      /* arg1: clearInterrupted */                       Kind.Boolean));
-
         addRuntimeCall(ENCRYPT_BLOCK, config.aescryptEncryptBlockStub,
                 /*        temps */ null,
                 /*          ret */ ret(Kind.Void),
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon Apr 29 22:49:49 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Apr 30 00:33:27 2013 +0200
@@ -370,7 +370,6 @@
     public long logPrintfStub;
     public long stubPrintfStub;
     public int deoptReasonNone;
-    public long threadIsInterruptedStub;
     public long identityHashCodeStub;
     public long aescryptEncryptBlockStub;
     public long aescryptDecryptBlockStub;
@@ -381,6 +380,7 @@
     public long newArrayAddress;
     public long newMultiArrayAddress;
     public long registerFinalizerAddress;
+    public long threadIsInterruptedAddress;
 
     public int deoptReasonNullCheck;
     public int deoptReasonRangeCheck;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon Apr 29 22:49:49 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Tue Apr 30 00:33:27 2013 +0200
@@ -33,11 +33,13 @@
 import static com.oracle.graal.hotspot.nodes.NewArrayStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewMultiArrayStubCall.*;
+import static com.oracle.graal.hotspot.nodes.ThreadIsInterruptedStubCall.*;
 import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*;
 import static com.oracle.graal.hotspot.stubs.NewArrayStub.*;
 import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*;
 import static com.oracle.graal.hotspot.stubs.NewMultiArrayStub.*;
 import static com.oracle.graal.hotspot.stubs.RegisterFinalizerStub.*;
+import static com.oracle.graal.hotspot.stubs.ThreadIsInterruptedStub.*;
 import static com.oracle.graal.java.GraphBuilderPhase.RuntimeCalls.*;
 import static com.oracle.graal.nodes.java.RegisterFinalizerNode.*;
 import static com.oracle.graal.replacements.Log.*;
@@ -221,7 +223,6 @@
                         /* arg0:    object */ javaCallingConvention(Kind.Object));
 
         addCRuntimeCall(REGISTER_FINALIZER_C, config.registerFinalizerAddress,
-                        /*           temps */ null,
                         /*             ret */ ret(Kind.Void),
                         /* arg0:    thread */ nativeCallingConvention(word,
                         /* arg1:    object */                         Kind.Object));
@@ -232,7 +233,6 @@
                         /* arg1:    length */ Kind.Int));
 
         addCRuntimeCall(NEW_ARRAY_C, config.newArrayAddress,
-                        /*           temps */ null,
                         /*             ret */ ret(Kind.Void),
                         /* arg0:    thread */ nativeCallingConvention(word,
                         /* arg1:       hub */                         word,
@@ -243,7 +243,6 @@
                         /* arg0:       hub */ javaCallingConvention(word));
 
         addCRuntimeCall(NEW_INSTANCE_C, config.newInstanceAddress,
-                        /*           temps */ null,
                         /*             ret */ ret(Kind.Void),
                         /* arg0:    thread */ nativeCallingConvention(word,
                         /* arg1:       hub */                         word));
@@ -255,7 +254,6 @@
                         /* arg2:      dims */                       word));
 
         addCRuntimeCall(NEW_MULTI_ARRAY_C, config.newMultiArrayAddress,
-                        /*           temps */ null,
                         /*             ret */ ret(Kind.Void),
                         /* arg0:    thread */ nativeCallingConvention(word,
                         /* arg1:       hub */                         word,
@@ -322,6 +320,18 @@
                         /*             ret */ ret(Kind.Void),
                         /* arg0:    object */ javaCallingConvention(Kind.Object,
                         /* arg1:     flags */                       Kind.Int));
+
+        addStubCall(THREAD_IS_INTERRUPTED,
+                        /*             ret */ ret(Kind.Boolean),
+                        /* arg0:    thread */ javaCallingConvention(Kind.Object,
+                 /* arg1: clearInterrupted */                       Kind.Boolean));
+
+        addCRuntimeCall(THREAD_IS_INTERRUPTED_C, config.threadIsInterruptedAddress,
+                        /*             ret */ ret(Kind.Boolean),
+                        /* arg0:    thread */ nativeCallingConvention(word,
+                   /* arg1: receiverThread */                         Kind.Object,
+              /* arg1: clearInterrupted */                            Kind.Boolean));
+
         // @formatter:on
     }
 
@@ -336,8 +346,8 @@
         return addRuntimeCall(descriptor, 0L, null, ret, args);
     }
 
-    protected RuntimeCallTarget addCRuntimeCall(Descriptor descriptor, long address, Register[] tempRegs, AllocatableValue ret, AllocatableValue... args) {
-        return addRuntimeCall(descriptor, address, true, tempRegs, ret, args);
+    protected RuntimeCallTarget addCRuntimeCall(Descriptor descriptor, long address, AllocatableValue ret, AllocatableValue... args) {
+        return addRuntimeCall(descriptor, address, true, null, ret, args);
     }
 
     protected RuntimeCallTarget addRuntimeCall(Descriptor descriptor, long address, Register[] tempRegs, AllocatableValue ret, AllocatableValue... args) {
@@ -415,6 +425,7 @@
         registerStub(new NewArrayStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(NEW_ARRAY)));
         registerStub(new NewMultiArrayStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(NEW_MULTI_ARRAY)));
         registerStub(new RegisterFinalizerStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(REGISTER_FINALIZER)));
+        registerStub(new ThreadIsInterruptedStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(THREAD_IS_INTERRUPTED)));
     }
 
     private void registerStub(Stub stub) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ThreadIsInterruptedStubCall.java	Mon Apr 29 22:49:49 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ThreadIsInterruptedStubCall.java	Tue Apr 30 00:33:27 2013 +0200
@@ -30,12 +30,13 @@
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 
 /**
- * Node implementing a call to HotSpot's ThreadIsInterrupted stub.
+ * Node implementing a call to {@link ThreadIsInterruptedStub}.
  */
 public class ThreadIsInterruptedStubCall extends DeoptimizingStubCall implements LIRGenLowerable {
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon Apr 29 22:49:49 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Tue Apr 30 00:33:27 2013 +0200
@@ -193,6 +193,8 @@
                             if (Debug.isDumpEnabled()) {
                                 Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
                             }
+                            // TTY.println(getMethod().toString());
+                            // TTY.println(runtime().disassemble(installedCode));
                             return installedCode;
                         }
                     });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ThreadIsInterruptedStub.java	Tue Apr 30 00:33:27 2013 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.stubs;
+
+import static com.oracle.graal.hotspot.replacements.HotSpotSnippetUtils.*;
+
+import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor;
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.replacements.*;
+import com.oracle.graal.word.*;
+
+/**
+ * Stub called from {@link ThreadIsInterruptedStubCall}.
+ */
+public class ThreadIsInterruptedStub extends CRuntimeStub {
+
+    public ThreadIsInterruptedStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) {
+        super(runtime, replacements, target, linkage);
+    }
+
+    @Snippet
+    private static boolean threadIsInterrupted(Thread receiverThread, boolean clearIsInterrupted) {
+        boolean result = threadIsInterruptedC(THREAD_IS_INTERRUPTED_C, thread(), receiverThread, clearIsInterrupted);
+        handlePendingException(false);
+        return result;
+    }
+
+    public static final Descriptor THREAD_IS_INTERRUPTED_C = descriptorFor(ThreadIsInterruptedStub.class, "threadIsInterruptedC", false);
+
+    @NodeIntrinsic(CRuntimeCall.class)
+    public static native boolean threadIsInterruptedC(@ConstantNodeParameter Descriptor newArrayC, Word thread, Thread receiverThread, boolean clearIsInterrupted);
+}
--- a/src/cpu/x86/vm/graalRuntime_x86.cpp	Mon Apr 29 22:49:49 2013 +0200
+++ b/src/cpu/x86/vm/graalRuntime_x86.cpp	Tue Apr 30 00:33:27 2013 +0200
@@ -1048,8 +1048,7 @@
       }
       __ ret(0);
       break;
-   }
-
+    }
 
     case identity_hash_code_id: {
       Register obj = j_rarg0; // Incoming
@@ -1064,21 +1063,6 @@
       __ ret(0);
       break;
     }
-    case thread_is_interrupted_id: {
-      Register thread = j_rarg0;
-      Register clear_interrupted = j_rarg1;
-
-      __ set_info("identity_hash_code", dont_gc_arguments);
-      __ enter();
-      OopMap* map = save_live_registers(sasm, 1);
-      int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, thread_is_interrupted), thread, clear_interrupted);
-      oop_maps = new OopMapSet();
-      oop_maps->add_gc_map(call_offset, map);
-      restore_live_registers_except_rax(sasm);
-      __ leave();
-      __ ret(0);
-      break;
-    }
 
     default:
       { GraalStubFrame f(sasm, "unimplemented entry", dont_gc_arguments);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon Apr 29 22:49:49 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Apr 30 00:33:27 2013 +0200
@@ -751,7 +751,6 @@
   set_address("wbPostCallStub", GraalRuntime::entry_for(GraalRuntime::wb_post_call_id));
 
   set_address("identityHashCodeStub", GraalRuntime::entry_for(GraalRuntime::identity_hash_code_id));
-  set_address("threadIsInterruptedStub", GraalRuntime::entry_for(GraalRuntime::thread_is_interrupted_id));
   set_address("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub());
   set_address("handleExceptionStub", GraalRuntime::entry_for(GraalRuntime::handle_exception_nofpu_id));
   set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
@@ -784,6 +783,7 @@
   set_address("newArrayAddress", GraalRuntime::new_array);
   set_address("newMultiArrayAddress", GraalRuntime::new_multi_array);
   set_address("registerFinalizerAddress", SharedRuntime::register_finalizer);
+  set_address("threadIsInterruptedAddress", GraalRuntime::thread_is_interrupted);
 
   set_int("deoptReasonNone", Deoptimization::Reason_none);
   set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check);
--- a/src/share/vm/graal/graalRuntime.hpp	Mon Apr 29 22:49:49 2013 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Tue Apr 30 00:33:27 2013 +0200
@@ -97,7 +97,6 @@
   stub(stub_printf)             \
   stub(log_primitive)           \
   stub(identity_hash_code)      \
-  stub(thread_is_interrupted)   \
   stub(wb_pre_call)             \
   stub(wb_post_call)             \
  last_entry(number_of_ids)
@@ -145,7 +144,6 @@
   static void wb_post_call(JavaThread* thread, oopDesc* obj, void* card);
 
   static jint identity_hash_code(JavaThread* thread, oopDesc* objd);
-  static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupte);
 
   // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log
   enum {
@@ -159,6 +157,7 @@
   static void new_instance(JavaThread* thread, Klass* klass);
   static void new_array(JavaThread* thread, Klass* klass, jint length);
   static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims);
+  static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupte);
   // initialization
   static void initialize(BufferBlob* blob);