changeset 35:dd1d79f9798b

Fix deoptimization bugs. Fix bugs of exception_offset and reexecute_offset entries, and of saving return value into registers.
author Ao Qi <aoqi@loongson.cn>
date Wed, 01 Dec 2010 17:39:16 +0800
parents 75473a9073f5
children 18922e417eb4
files hotspot/src/cpu/mips/vm/sharedRuntime_mips.cpp
diffstat 1 files changed, 20 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/cpu/mips/vm/sharedRuntime_mips.cpp	Wed Dec 01 17:12:39 2010 +0800
+++ b/hotspot/src/cpu/mips/vm/sharedRuntime_mips.cpp	Wed Dec 01 17:39:16 2010 +0800
@@ -77,26 +77,21 @@
 
   public:
 
-  //static int Oexception_offset() { return o0_offset; };
-  //static int G3_offset() { return g3_offset; };
-  //static int G5_offset() { return g5_offset; };
-  static OopMap* save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words);
-  static void restore_live_registers(MacroAssembler* masm);
+	static OopMap* save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words);
+	static void restore_live_registers(MacroAssembler* masm);
 	//FIXME, I have no idea which register to use
-	//static int eax_offset() { return eax_off; }
-	// static int ebx_offset() { return ebx_off; }
-	static int v0_Offset(void) { return v0_off; } 
-	static int t7_Offset(void) { return t7_off; }
+	static int raOffset(void) { return return_off; } 
+	static int t7Offset(void) { return t7_off; }
 
 	static int v0Offset(void) { return v0_off; }
 	static int v1Offset(void) { return v1_off; }
-  
+
 	static int fpResultOffset(void) { return fpr0_off; }
-	
+
 	// During deoptimization only the result register need to be restored
-  // all the other values have already been extracted.
-
-  static void restore_result_registers(MacroAssembler* masm);
+	// all the other values have already been extracted.
+
+	static void restore_result_registers(MacroAssembler* masm);
 };
 
 OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words) {
@@ -3247,6 +3242,7 @@
    // return address is the pc describes what bci to do re-execute at
 
    // No need to update map as each call to save_live_registers will produce identical oopmap
+  //__ addi(RA, RA, - (NativeCall::return_address_offset));
   (void) RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words);
   __ move(reason, Deoptimization::Unpack_reexecute); 
   __ b(cont);
@@ -3272,15 +3268,11 @@
   // tos: stack at point of call to method that threw the exception (i.e. only
   // args are on the stack, no return address)
 
-  // make room on stack for the return address
-  // It will be patched later with the throwing pc. The correct value is not 
+  // Return address will be patched later with the throwing pc. The correct value is not 
   // available now because loading it from memory would destroy registers.
-   //__ pushl(0);
-   //It is no need here, because in save_live_register, we saved the return address(RA)  
-   //FIXME here, do mips need patch the return address on stack? 
-   // __ push(ZERO);
    // Save everything in sight.
   // No need to update map as each call to save_live_registers will produce identical oopmap
+  __ addi(RA, RA, - (NativeCall::return_address_offset));
   (void) RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words);
 
   // Now it is safe to overwrite any register
@@ -3290,8 +3282,7 @@
   // of the current frame. Then clear the field in JavaThread
   __ get_thread(thread);
   __ lw(V1, thread, in_bytes(JavaThread::exception_pc_offset()));
-  //we should save on the stack or register? 
-  __ move(RA, V1); 
+  __ sw(V1, SP, RegisterSaver::raOffset() * wordSize); //save ra
   __ sw(ZERO, thread, in_bytes(JavaThread::exception_pc_offset()));
 
 
@@ -3318,7 +3309,7 @@
   __ get_thread(thread);
 #endif
   __ move(A0, thread);
-  __ addiu(SP, SP, -2 * wordSize);
+  __ addiu(SP, SP, -additional_words  * wordSize);
 
   __ set_last_Java_frame(thread, NOREG, NOREG, NULL);
 
@@ -3338,7 +3329,7 @@
   __ jalr(T9);
   __ delayed()->nop();
   oop_maps->add_gc_map(__ pc() - start, map);
-  __ addiu(SP, SP, 2 * wordSize);
+  __ addiu(SP, SP, additional_words * wordSize);
   __ get_thread(thread);
   __ reset_last_Java_frame(thread, false, true);
 
@@ -3449,7 +3440,7 @@
   __ sw(FP, SP, 0 * wordSize);          // save final return address
   __ sw(AT, SP, 1 * wordSize);
   __ move(FP, SP);
-  __ addi(SP, SP, -(frame_size_in_words - additional_words) * wordSize);
+  __ addi(SP, SP, -(frame_size_in_words - 2 - additional_words) * wordSize);
 
   // Restore frame locals after moving the frame
   __ sw(V0, SP, RegisterSaver::v0Offset() * wordSize);
@@ -3463,7 +3454,7 @@
   __ move(A1, reason);	// exec_mode
   __ get_thread(thread);
   __ move(A0, thread);	// thread
-  //__ addi(SP, SP, (-2) *wordSize);
+  __ addi(SP, SP, (-additional_words) *wordSize);
 
   // set last_Java_sp, last_Java_fp
   __ set_last_Java_frame(thread, NOREG, FP, NULL);
@@ -3483,10 +3474,9 @@
   // Set an oopmap for the call site
   oop_maps->add_gc_map(__ offset(), new OopMap( frame_size_in_words , 0));
 
-  //__ addi(SP, SP, 2 * wordSize);
+  __ push(V0);
 	
   __ get_thread(thread);
-  __ lw(SP, thread, in_bytes(JavaThread::last_Java_sp_offset()));
   __ reset_last_Java_frame(thread, false, false);
 
   // Collect return values
@@ -3892,8 +3882,8 @@
 	// get the returned methodOop
 	//FIXME, do mips need this ? 
 	__ lw(T7, thread, in_bytes(JavaThread::vm_result_offset()));
-	__ sw(T7, SP, RegisterSaver::t7_Offset() * wordSize);
-	__ sw(V0, SP, RegisterSaver::v0_Offset() * wordSize);
+	__ sw(T7, SP, RegisterSaver::t7Offset() * wordSize);
+	__ sw(V0, SP, RegisterSaver::v0Offset() * wordSize);
 	RegisterSaver::restore_live_registers(masm);
 
 	// We are back the the original state on entry and ready to go the callee method.