changeset 9592:efb8c1918ea5

replaced create_out_of_bounds_exception assembler stub with compiled stub (GRAAL-81)
author Doug Simon <doug.simon@oracle.com>
date Mon, 06 May 2013 23:43:01 +0200
parents 0381c7937e7a
children a3b4bcc22313
files 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/CreateOutOfBoundsExceptionStub.java src/cpu/x86/vm/graalRuntime_x86.cpp src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/graal/graalRuntime.hpp
diffstat 6 files changed, 77 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon May 06 23:42:17 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon May 06 23:43:01 2013 +0200
@@ -375,8 +375,6 @@
     public long vmErrorStub;
     public long uncommonTrapStub;
     public long unwindExceptionStub;
-    public long createNullPointerExceptionAddress;
-    public long createOutOfBoundsExceptionStub;
     public long javaTimeMillisStub;
     public long javaTimeNanosStub;
     public long arithmeticSinStub;
@@ -403,6 +401,8 @@
     public long osrMigrationEndAddress;
     public long monitorenterAddress;
     public long monitorexitAddress;
+    public long createNullPointerExceptionAddress;
+    public long createOutOfBoundsExceptionAddress;
 
     public int deoptReasonNullCheck;
     public int deoptReasonRangeCheck;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon May 06 23:42:17 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon May 06 23:43:01 2013 +0200
@@ -40,6 +40,7 @@
 import static com.oracle.graal.hotspot.nodes.VerifyOopStubCall.*;
 import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*;
 import static com.oracle.graal.hotspot.stubs.CreateNullPointerExceptionStub.*;
+import static com.oracle.graal.hotspot.stubs.CreateOutOfBoundsExceptionStub.*;
 import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*;
 import static com.oracle.graal.hotspot.stubs.IdentityHashCodeStub.*;
 import static com.oracle.graal.hotspot.stubs.MonitorEnterStub.*;
@@ -294,11 +295,6 @@
                         /* arg2:      rank */                         Kind.Int,
                         /* arg3:      dims */                         word));
 
-        addRuntimeCall(CREATE_OUT_OF_BOUNDS_EXCEPTION, config.createOutOfBoundsExceptionStub,
-                        /*           temps */ null,
-                        /*             ret */ ret(Kind.Object),
-                        /* arg0:     index */ javaCallingConvention(Kind.Int));
-
         addRuntimeCall(JAVA_TIME_MILLIS, config.javaTimeMillisStub,
                         /*           temps */ this.regConfig.getCallerSaveRegisters(),
                         /*             ret */ ret(Kind.Long));
@@ -408,6 +404,14 @@
                         /*          ret */ ret(Kind.Void),
                         /* arg0: thread */ nativeCallingConvention(word));
 
+        addStubCall(CREATE_OUT_OF_BOUNDS_EXCEPTION,
+                        /*             ret */ ret(Kind.Object),
+                        /* arg0:     index */ javaCallingConvention(Kind.Int));
+
+        addCRuntimeCall(CREATE_OUT_OF_BOUNDS_C, config.createOutOfBoundsExceptionAddress,
+                        /*          ret */ ret(Kind.Void),
+                        /* arg0: thread */ nativeCallingConvention(word,
+                        /* arg1:  index */                         Kind.Int));
         // @formatter:on
     }
 
@@ -532,6 +536,7 @@
         registerStub(new MonitorEnterStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITORENTER)));
         registerStub(new MonitorExitStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITOREXIT)));
         registerStub(new CreateNullPointerExceptionStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(CREATE_NULL_POINTER_EXCEPTION)));
+        registerStub(new CreateOutOfBoundsExceptionStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(CREATE_OUT_OF_BOUNDS_EXCEPTION)));
     }
 
     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/CreateOutOfBoundsExceptionStub.java	Mon May 06 23:43:01 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.HotSpotReplacementsUtil.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.RuntimeCallTarget.*;
+import com.oracle.graal.graph.Node.*;
+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 to create a {@link ArrayIndexOutOfBoundsException}.
+ */
+public class CreateOutOfBoundsExceptionStub extends CRuntimeStub {
+
+    public CreateOutOfBoundsExceptionStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) {
+        super(runtime, replacements, target, linkage);
+    }
+
+    @Snippet
+    private static Object createOutOfBoundsException(int index) {
+        createOutOfBoundsExceptionC(CREATE_OUT_OF_BOUNDS_C, thread(), index);
+        handlePendingException(true);
+        return verifyObject(getAndClearObjectResult(thread()));
+    }
+
+    public static final Descriptor CREATE_OUT_OF_BOUNDS_C = descriptorFor(CreateOutOfBoundsExceptionStub.class, "createOutOfBoundsExceptionC", false);
+
+    @NodeIntrinsic(CRuntimeCall.class)
+    public static native void createOutOfBoundsExceptionC(@ConstantNodeParameter Descriptor createOutOfBoundsExceptionC, Word thread, int index);
+
+}
--- a/src/cpu/x86/vm/graalRuntime_x86.cpp	Mon May 06 23:42:17 2013 +0200
+++ b/src/cpu/x86/vm/graalRuntime_x86.cpp	Mon May 06 23:43:01 2013 +0200
@@ -575,43 +575,6 @@
   __ popa();
 }
 
-
-static void restore_live_registers_except_rax(GraalStubAssembler* sasm, bool restore_fpu_registers = true) {
-  __ block_comment("restore_live_registers_except_rax");
-
-  restore_fpu(sasm, restore_fpu_registers);
-
-#ifdef _LP64
-  __ movptr(r15, Address(rsp, 0));
-  __ movptr(r14, Address(rsp, wordSize));
-  __ movptr(r13, Address(rsp, 2 * wordSize));
-  __ movptr(r12, Address(rsp, 3 * wordSize));
-  __ movptr(r11, Address(rsp, 4 * wordSize));
-  __ movptr(r10, Address(rsp, 5 * wordSize));
-  __ movptr(r9,  Address(rsp, 6 * wordSize));
-  __ movptr(r8,  Address(rsp, 7 * wordSize));
-  __ movptr(rdi, Address(rsp, 8 * wordSize));
-  __ movptr(rsi, Address(rsp, 9 * wordSize));
-  __ movptr(rbp, Address(rsp, 10 * wordSize));
-  // skip rsp
-  __ movptr(rbx, Address(rsp, 12 * wordSize));
-  __ movptr(rdx, Address(rsp, 13 * wordSize));
-  __ movptr(rcx, Address(rsp, 14 * wordSize));
-
-  __ addptr(rsp, 16 * wordSize);
-#else
-
-  __ pop(rdi);
-  __ pop(rsi);
-  __ pop(rbp);
-  __ pop(rbx); // skip this value
-  __ pop(rbx);
-  __ pop(rdx);
-  __ pop(rcx);
-  __ addptr(rsp, BytesPerWord);
-#endif // _LP64
-}
-
 OopMapSet* GraalRuntime::generate_code_for(StubID id, GraalStubAssembler* sasm) {
 
   // for better readability
@@ -625,18 +588,6 @@
   OopMapSet* oop_maps = NULL;
   switch (id) {
 
-    case create_out_of_bounds_exception_id: {
-		__ enter();
-		oop_maps = new OopMapSet();
-		OopMap* oop_map = save_live_registers(sasm, 1);
-		int call_offset = __ call_RT(rax, noreg, (address)create_out_of_bounds_exception, j_rarg0);
-		oop_maps->add_gc_map(call_offset, oop_map);
-		restore_live_registers_except_rax(sasm);
-		__ leave();
-		__ ret(0);
-      break;
-    }
-
     case vm_error_id: {
       __ enter();
       oop_maps = new OopMapSet();
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon May 06 23:42:17 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Mon May 06 23:43:01 2013 +0200
@@ -763,7 +763,6 @@
   set_address("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub());
   set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
   set_address("vmErrorStub", GraalRuntime::entry_for(GraalRuntime::vm_error_id));
-  set_address("createOutOfBoundsExceptionStub", GraalRuntime::entry_for(GraalRuntime::create_out_of_bounds_exception_id));
   set_address("javaTimeMillisStub", CAST_FROM_FN_PTR(address, os::javaTimeMillis));
   set_address("javaTimeNanosStub", CAST_FROM_FN_PTR(address, os::javaTimeNanos));
   set_address("arithmeticSinStub", CAST_FROM_FN_PTR(address, SharedRuntime::dsin));
@@ -791,6 +790,7 @@
   set_address("monitorenterAddress", GraalRuntime::monitorenter);
   set_address("monitorexitAddress", GraalRuntime::monitorexit);
   set_address("createNullPointerExceptionAddress", GraalRuntime::create_null_exception);
+  set_address("createOutOfBoundsExceptionAddress", GraalRuntime::create_out_of_bounds_exception);
 
   set_int("deoptReasonNone", Deoptimization::Reason_none);
   set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check);
--- a/src/share/vm/graal/graalRuntime.hpp	Mon May 06 23:42:17 2013 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Mon May 06 23:43:01 2013 +0200
@@ -79,7 +79,6 @@
 // by Graal.
 #define GRAAL_STUBS(stub, last_entry) \
   stub(vm_error)                \
-  stub(create_out_of_bounds_exception) \
   stub(log_object)              \
   stub(log_printf)              \
   stub(log_primitive)           \
@@ -115,14 +114,6 @@
   // runtime entry points
   static void unimplemented_entry(JavaThread* thread, StubID id);
 
-  static void create_out_of_bounds_exception(JavaThread* thread, jint index);
-  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);
-  static void wb_pre_call(JavaThread* thread, oopDesc* obj);
-  static void wb_post_call(JavaThread* thread, oopDesc* obj, void* card);
-
-
   // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log
   enum {
     LOG_OBJECT_NEWLINE = 0x01,
@@ -142,6 +133,12 @@
   static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
   static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
   static void create_null_exception(JavaThread* thread);
+  static void create_out_of_bounds_exception(JavaThread* thread, jint index);
+  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);
+  static void wb_pre_call(JavaThread* thread, oopDesc* obj);
+  static void wb_post_call(JavaThread* thread, oopDesc* obj, void* card);
 
   // initialization
   static void initialize(BufferBlob* blob);