diff src/cpu/sparc/vm/sharedRuntime_sparc.cpp @ 16326:51f392557124

[SPARC] Improving implicit exception handling on sparc
author Stefan Anzinger <stefan.anzinger@gmail.com>
date Mon, 30 Jun 2014 08:50:26 +0200
parents 2395c0fc5a19
children 422eda5267b3
line wrap: on
line diff
--- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Fri Jun 06 01:19:20 2014 +0200
+++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Mon Jun 30 08:50:26 2014 +0200
@@ -43,6 +43,9 @@
 #include "compiler/compileBroker.hpp"
 #include "shark/sharkCompiler.hpp"
 #endif
+#ifdef GRAAL
+#include "graal/graalJavaAccess.hpp"
+#endif
 
 #define __ masm->
 
@@ -3496,6 +3499,46 @@
   __ ba(cont);
   __ delayed()->mov(Deoptimization::Unpack_deopt, L0deopt_mode);
 
+
+#ifdef GRAAL
+  masm->block_comment("BEGIN GRAAL");
+  int implicit_exception_uncommon_trap_offset = __ offset() - start;
+  //__ pushptr(Address(G2_thread, in_bytes(JavaThread::graal_implicit_exception_pc_offset())));
+  __ ld_ptr(G2_thread, in_bytes(JavaThread::graal_implicit_exception_pc_offset()), O7);
+  //__ add(G0, 0x321, O7);
+  __ add(O7, -8, O7);
+  //__ st_ptr(I7, SP, I7->sp_offset_in_saved_window()*wordSize + STACK_BIAS);
+  // Save everything in sight.
+  masm->block_comment("save_live_regs");
+  (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_words);
+  masm->block_comment("/save_live_regs");
+  //__ ld_ptr(G2_thread, in_bytes(JavaThread::graal_implicit_exception_pc_offset()), O7);
+  // fetch_unroll_info needs to call last_java_frame()
+  masm->block_comment("set_last_java_frame");
+  __ set_last_Java_frame(SP, NULL);
+  masm->block_comment("/set_last_java_frame");
+
+  //__ movl(c_rarg1, Address(r15_thread, in_bytes(ThreadShadow::pending_deoptimization_offset())));
+  __ ld(G2_thread, in_bytes(ThreadShadow::pending_deoptimization_offset()), O1);
+  //__ movl(Address(r15_thread, in_bytes(ThreadShadow::pending_deoptimization_offset())), -1);
+  __ sub(G0, 1, L1);
+  __ st_ptr(L1, G2_thread, in_bytes(ThreadShadow::pending_deoptimization_offset()));
+
+  __ mov((int32_t)Deoptimization::Unpack_reexecute, L0deopt_mode);
+  __ mov(G2_thread, O0);
+  __ call(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap));
+  __ delayed()->nop();
+  oop_maps->add_gc_map( __ offset()-start, map->deep_copy());
+  __ get_thread();
+  __ add(O7, 8, O7);
+  __ reset_last_Java_frame();
+
+  Label after_fetch_unroll_info_call;
+  __ ba(after_fetch_unroll_info_call);
+  __ delayed()->nop(); // Delay slot
+  masm->block_comment("END GRAAL");
+#endif // GRAAL
+
   int exception_offset = __ offset() - start;
 
   // restore G2, the trampoline destroyed it
@@ -3573,6 +3616,9 @@
 
   __ reset_last_Java_frame();
 
+#ifdef GRAAL
+  __ bind(after_fetch_unroll_info_call);
+#endif
   // NOTE: we know that only O0/O1 will be reloaded by restore_result_registers
   // so this move will survive
 
@@ -3581,7 +3627,6 @@
   __ mov(O0, O2UnrollBlock->after_save());
 
   RegisterSaver::restore_result_registers(masm);
-
   Label noException;
   __ cmp_and_br_short(G4deopt_mode, Deoptimization::Unpack_exception, Assembler::notEqual, Assembler::pt, noException);
 
@@ -3638,6 +3683,9 @@
   masm->flush();
   _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_words);
   _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset);
+#ifdef GRAAL
+  _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset);
+#endif
 }
 
 #ifdef COMPILER2