MIPS: Simplify the deopt entry method.
authordanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 7 Mar 2012 09:05:41 +0000 (09:05 +0000)
committerdanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 7 Mar 2012 09:05:41 +0000 (09:05 +0000)
The t9 register will always hold the address of the current entry when deoptimizing,
so it can be used as the basis of calculation.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9546017
Patch from Daniel Kalmar <kalmard@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10950 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/mips/deoptimizer-mips.cc

index 7e0a53a08d1dc802a238e58f83a715a82f8318f6..611fbaaf96511f9c2666f7f287ea4ed718d221e5 100644 (file)
@@ -941,7 +941,7 @@ void Deoptimizer::EntryGenerator::Generate() {
 
 
 // Maximum size of a table entry generated below.
-const int Deoptimizer::table_entry_size_ = 12 * Assembler::kInstrSize;
+const int Deoptimizer::table_entry_size_ = 9 * Assembler::kInstrSize;
 
 void Deoptimizer::TableEntryGenerator::GeneratePrologue() {
   Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm());
@@ -955,29 +955,20 @@ void Deoptimizer::TableEntryGenerator::GeneratePrologue() {
     __ bind(&start);
     if (type() != EAGER) {
       // Emulate ia32 like call by pushing return address to stack.
-      __ addiu(sp, sp, -3 * kPointerSize);
-      __ sw(ra, MemOperand(sp, 2 * kPointerSize));
-    } else {
       __ addiu(sp, sp, -2 * kPointerSize);
+      __ sw(ra, MemOperand(sp, 1 * kPointerSize));
+    } else {
+      __ addiu(sp, sp, -1 * kPointerSize);
     }
-    // Using ori makes sure only one instruction is generated. This will work
-    // as long as the number of deopt entries is below 2^16.
-    __ ori(at, zero_reg, i);
-    __ sw(at, MemOperand(sp, kPointerSize));
-    __ sw(ra, MemOperand(sp, 0));
-    // This branch instruction only jumps over one instruction, and that is
-    // executed in the delay slot. The result is that execution is linear but
-    // the ra register is updated.
-    __ bal(1);
     // Jump over the remaining deopt entries (including this one).
-    // Only include the remaining part of the current entry in the calculation.
+    // This code is always reached by calling Jump, which puts the target (label
+    // start) into t9.
     const int remaining_entries = (count() - i) * table_entry_size_;
-    const int cur_size = masm()->SizeOfCodeGeneratedSince(&start);
-    // ra points to the instruction after the delay slot. Adjust by 4.
-    __ Addu(at, ra, remaining_entries - cur_size - Assembler::kInstrSize);
-    __ lw(ra, MemOperand(sp, 0));
-    __ jr(at);  // Expose delay slot.
-    __ addiu(sp, sp, kPointerSize);  // In delay slot.
+    __ Addu(t9, t9, remaining_entries);
+    // 'at' was clobbered so we can only load the current entry value here.
+    __ li(at, i);
+    __ jr(t9);  // Expose delay slot.
+    __ sw(at, MemOperand(sp, 0 * kPointerSize));  // In the delay slot.
 
     // Pad the rest of the code.
     while (table_entry_size_ > (masm()->SizeOfCodeGeneratedSince(&start))) {