changeset 9590:5f9c41cd3b1e

replaced monitorenter/monitorexit assembler stubs with compiled stubs (GRAAL-81)
author Doug Simon <doug.simon@oracle.com>
date Mon, 06 May 2013 22:37:00 +0200
parents 7df076e74e8e
children 0381c7937e7a
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/stubs/MonitorEnterStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorExitStub.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, 148 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Mon May 06 22:12:28 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Mon May 06 22:37:00 2013 +0200
@@ -24,8 +24,6 @@
 
 import static com.oracle.graal.amd64.AMD64.*;
 import static com.oracle.graal.hotspot.HotSpotBackend.*;
-import static com.oracle.graal.hotspot.nodes.MonitorEnterStubCall.*;
-import static com.oracle.graal.hotspot.nodes.MonitorExitStubCall.*;
 import static com.oracle.graal.hotspot.nodes.VMErrorNode.*;
 import static com.oracle.graal.hotspot.nodes.WriteBarrierPostStubCall.*;
 import static com.oracle.graal.hotspot.nodes.WriteBarrierPreStubCall.*;
@@ -64,12 +62,6 @@
                 /* arg0: exception */ rax.asValue(Kind.Object),
                /* arg1: exceptionPc */ rdx.asValue(word));
 
-        addRuntimeCall(MONITORENTER, config.monitorEnterStub,
-                /*        temps */ null,
-                /*          ret */ ret(Kind.Void),
-                /* arg0: object */ javaCallingConvention(Kind.Object,
-                /* arg1:   lock */                       word));
-
        addRuntimeCall(WBPRECALL, config.wbPreCallStub,
                 /*        temps */ null,
                 /*          ret */ ret(Kind.Void),
@@ -80,12 +72,6 @@
                 /*          ret */ ret(Kind.Void),
                 /* arg0: object */ javaCallingConvention(Kind.Object, word));
 
-        addRuntimeCall(MONITOREXIT, config.monitorExitStub,
-                /*        temps */ null,
-                /*          ret */ ret(Kind.Void),
-                /* arg0: object */ javaCallingConvention(Kind.Object,
-                /* arg1:   lock */                       word));
-
         addRuntimeCall(VM_ERROR, config.vmErrorStub,
                 /*        temps */ null,
                 /*          ret */ ret(Kind.Void),
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon May 06 22:12:28 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon May 06 22:37:00 2013 +0200
@@ -369,8 +369,6 @@
     // runtime stubs
     public long inlineCacheMissStub;
     public long handleDeoptStub;
-    public long monitorEnterStub;
-    public long monitorExitStub;
     public long wbPreCallStub;
     public long wbPostCallStub;
 
@@ -403,6 +401,8 @@
     public long exceptionHandlerForPcAddress;
     public long exceptionHandlerForReturnAddressAddress;
     public long osrMigrationEndAddress;
+    public long monitorenterAddress;
+    public long monitorexitAddress;
 
     public int deoptReasonNullCheck;
     public int deoptReasonRangeCheck;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon May 06 22:12:28 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon May 06 22:37:00 2013 +0200
@@ -31,6 +31,8 @@
 import static com.oracle.graal.hotspot.HotSpotBackend.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 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.NewArrayStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewMultiArrayStubCall.*;
@@ -39,6 +41,8 @@
 import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*;
 import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*;
 import static com.oracle.graal.hotspot.stubs.IdentityHashCodeStub.*;
+import static com.oracle.graal.hotspot.stubs.MonitorEnterStub.*;
+import static com.oracle.graal.hotspot.stubs.MonitorExitStub.*;
 import static com.oracle.graal.hotspot.stubs.NewArrayStub.*;
 import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*;
 import static com.oracle.graal.hotspot.stubs.NewMultiArrayStub.*;
@@ -378,6 +382,28 @@
                         /* arg0:    thread */ nativeCallingConvention(word,
                         /* arg1:    object */                         Kind.Object));
 
+        addStubCall(MONITORENTER,
+                        /*          ret */ ret(Kind.Void),
+                        /* arg0: object */ javaCallingConvention(Kind.Object,
+                        /* arg1:   lock */                       word));
+
+        addCRuntimeCall(MONITORENTER_C, config.monitorenterAddress,
+                        /*          ret */ ret(Kind.Void),
+                        /* arg0: thread */ nativeCallingConvention(word,
+                        /* arg1: object */                         Kind.Object,
+                        /* arg1:   lock */                         word));
+
+        addStubCall(MONITOREXIT,
+                        /*          ret */ ret(Kind.Void),
+                        /* arg0: object */ javaCallingConvention(Kind.Object,
+                        /* arg1:   lock */                       word));
+
+        addCRuntimeCall(MONITOREXIT_C, config.monitorexitAddress,
+                        /*          ret */ ret(Kind.Void),
+                        /* arg0: thread */ nativeCallingConvention(word,
+                        /* arg1: object */                         Kind.Object,
+                        /* arg1:   lock */                         word));
+
         // @formatter:on
     }
 
@@ -497,6 +523,8 @@
         registerStub(new UnwindExceptionToCallerStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(UNWIND_EXCEPTION_TO_CALLER)));
         registerStub(new VerifyOopStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(VERIFY_OOP)));
         registerStub(new OSRMigrationEndStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(OSR_MIGRATION_END)));
+        registerStub(new MonitorEnterStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITORENTER)));
+        registerStub(new MonitorExitStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITOREXIT)));
     }
 
     private void registerStub(Stub stub) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorEnterStub.java	Mon May 06 22:37:00 2013 +0200
@@ -0,0 +1,57 @@
+/*
+ * 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.HotSpotReplacementsUtil.*;
+
+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 MonitorEnterStubCall}.
+ */
+public class MonitorEnterStub extends CRuntimeStub {
+
+    public MonitorEnterStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) {
+        super(runtime, replacements, target, linkage);
+    }
+
+    @Snippet
+    private static void monitorenter(Object object, Word lock) {
+        monitorenterC(MONITORENTER_C, thread(), object, lock);
+        handlePendingException(false);
+    }
+
+    public static final Descriptor MONITORENTER_C = descriptorFor(MonitorEnterStub.class, "monitorenterC", false);
+
+    @NodeIntrinsic(CRuntimeCall.class)
+    public static native void monitorenterC(@ConstantNodeParameter Descriptor monitorenterC, Word thread, Object object, Word lock);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorExitStub.java	Mon May 06 22:37:00 2013 +0200
@@ -0,0 +1,56 @@
+/*
+ * 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.HotSpotReplacementsUtil.*;
+
+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 MonitorExitStubCall}.
+ */
+public class MonitorExitStub extends CRuntimeStub {
+
+    public MonitorExitStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) {
+        super(runtime, replacements, target, linkage);
+    }
+
+    @Snippet
+    private static void monitorexit(Object object, Word lock) {
+        monitorexitC(MONITOREXIT_C, thread(), object, lock);
+    }
+
+    public static final Descriptor MONITOREXIT_C = descriptorFor(MonitorExitStub.class, "monitorexitC", false);
+
+    @NodeIntrinsic(CRuntimeCall.class)
+    public static native void monitorexitC(@ConstantNodeParameter Descriptor monitorexitC, Word thread, Object object, Word lock);
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ThreadIsInterruptedStub.java	Mon May 06 22:12:28 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ThreadIsInterruptedStub.java	Mon May 06 22:37:00 2013 +0200
@@ -54,5 +54,5 @@
     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);
+    public static native boolean threadIsInterruptedC(@ConstantNodeParameter Descriptor threadIsInterruptedC, Word thread, Thread receiverThread, boolean clearIsInterrupted);
 }
--- a/src/cpu/x86/vm/graalRuntime_x86.cpp	Mon May 06 22:12:28 2013 +0200
+++ b/src/cpu/x86/vm/graalRuntime_x86.cpp	Mon May 06 22:37:00 2013 +0200
@@ -697,42 +697,6 @@
       break;
     }
 
-    case monitorenter_id: {
-      Register obj = j_rarg0;
-      Register lock = j_rarg1;
-      {
-        GraalStubFrame f(sasm, "monitorenter", dont_gc_arguments);
-        OopMap* map = save_live_registers(sasm, 2, save_fpu_registers);
-
-        // Called with store_parameter and not C abi
-        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), obj, lock);
-
-        oop_maps = new OopMapSet();
-        oop_maps->add_gc_map(call_offset, map);
-        restore_live_registers(sasm, save_fpu_registers);
-      }
-      __ ret(0);
-      break;
-    }
-    case monitorexit_id: {
-      Register obj = j_rarg0;
-      Register lock = j_rarg1;
-      {
-        GraalStubFrame f(sasm, "monitorexit", dont_gc_arguments);
-        OopMap* map = save_live_registers(sasm, 2, save_fpu_registers);
-
-        // note: really a leaf routine but must setup last java sp
-        //       => use call_RT for now (speed can be improved by
-        //       doing last java sp setup manually)
-        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), obj, lock);
-
-        oop_maps = new OopMapSet();
-        oop_maps->add_gc_map(call_offset, map);
-        restore_live_registers(sasm, save_fpu_registers);
-      }
-      __ ret(0);
-      break;
-   }
    case wb_pre_call_id: {
       Register obj = j_rarg0;
       {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon May 06 22:12:28 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Mon May 06 22:37:00 2013 +0200
@@ -762,8 +762,6 @@
 
   set_address("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub());
   set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
-  set_address("monitorEnterStub", GraalRuntime::entry_for(GraalRuntime::monitorenter_id));
-  set_address("monitorExitStub", GraalRuntime::entry_for(GraalRuntime::monitorexit_id));
   set_address("vmErrorStub", GraalRuntime::entry_for(GraalRuntime::vm_error_id));
   set_address("createNullPointerExceptionStub", GraalRuntime::entry_for(GraalRuntime::create_null_pointer_exception_id));
   set_address("createOutOfBoundsExceptionStub", GraalRuntime::entry_for(GraalRuntime::create_out_of_bounds_exception_id));
@@ -791,6 +789,8 @@
   set_address("exceptionHandlerForPcAddress", GraalRuntime::exception_handler_for_pc);
   set_address("exceptionHandlerForReturnAddressAddress", SharedRuntime::exception_handler_for_return_address);
   set_address("osrMigrationEndAddress", SharedRuntime::OSR_migration_end);
+  set_address("monitorenterAddress", GraalRuntime::monitorenter);
+  set_address("monitorexitAddress", GraalRuntime::monitorexit);
 
   set_int("deoptReasonNone", Deoptimization::Reason_none);
   set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check);
--- a/src/share/vm/graal/graalRuntime.hpp	Mon May 06 22:12:28 2013 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Mon May 06 22:37:00 2013 +0200
@@ -78,8 +78,6 @@
 // runtime routines needed by code code generated
 // by Graal.
 #define GRAAL_STUBS(stub, last_entry) \
-  stub(monitorenter)            \
-  stub(monitorexit)             \
   stub(vm_error)                \
   stub(create_null_pointer_exception) \
   stub(create_out_of_bounds_exception) \
@@ -120,8 +118,6 @@
 
   static void create_null_exception(JavaThread* thread);
   static void create_out_of_bounds_exception(JavaThread* thread, jint index);
-  static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
-  static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
   static void vm_error(JavaThread* thread, oop where, oop format, jlong value);
   static void log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3);
   static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline);
@@ -145,6 +141,8 @@
   static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3);
   static jint identity_hash_code(JavaThread* thread, oopDesc* objd);
   static address exception_handler_for_pc(JavaThread* thread);
+  static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
+  static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
 
   // initialization
   static void initialize(BufferBlob* blob);