Status: New
Owner: ----

New issue 1588 by [email protected]: IC generates bad code for certain ARM variants
http://code.google.com/p/v8/issues/detail?id=1588

The code sequence str pc [sp, #x] stores pc+8 on some ARM variants and pc+12 on others. See ARM DDI 0100I

This causes very subtle bad behavior on CALL_IC stubs to C-Stubs.

The entry sequence to an IC-Stub in:

void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
                                    ExternalReference function) {
  __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()),
                     RelocInfo::CODE_TARGET));
  __ mov(r2, Operand(function));
  // Push return address (accessible to GC through exit frame pc).
  __ str(pc, MemOperand(sp, 0));
  __ Jump(r2);  // Call the api function.
}

stores a return address that is one instruction past the intended return point on some ARMs. This can causes some very subtle bugs when IC is turned on.

This can be easily fixed by adding a nop() after the Jump.

Here is a simple patch:
diff --git a/deps/v8/src/arm/code-stubs-arm.cc b/deps/v8/src/arm/code-stubs-arm.cc
index eaad9f2..fce2601 100644
--- a/deps/v8/src/arm/code-stubs-arm.cc
+++ b/deps/v8/src/arm/code-stubs-arm.cc
@@ -6291,6 +6291,7 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
   // Push return address (accessible to GC through exit frame pc).
   __ str(pc, MemOperand(sp, 0));
   __ Jump(r2);  // Call the api function.
+  __ nop();
 }


@@ -6301,6 +6302,7 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
   // Push return address (accessible to GC through exit frame pc).
   __ str(pc, MemOperand(sp, 0));
   __ Jump(target);  // Call the C++ function.
+  __ nop();
 }



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to