Index: src/arm/codegen-arm.cc |
=================================================================== |
--- src/arm/codegen-arm.cc (revision 2877) |
+++ src/arm/codegen-arm.cc (working copy) |
@@ -299,7 +299,10 @@ |
} |
// Generate the return sequence if necessary. |
- if (frame_ != NULL || function_return_.is_linked()) { |
+ if (has_valid_frame() || function_return_.is_linked()) { |
+ if (!function_return_.is_linked()) { |
+ CodeForReturnPosition(fun); |
+ } |
// exit |
// r0: result |
// sp: stack pointer |
@@ -315,12 +318,24 @@ |
frame_->CallRuntime(Runtime::kTraceExit, 1); |
} |
+ // Add a label for checking the size of the code used for returning. |
+ Label check_exit_codesize; |
+ masm_->bind(&check_exit_codesize); |
+ |
// Tear down the frame which will restore the caller's frame pointer and |
// the link register. |
frame_->Exit(); |
- __ add(sp, sp, Operand((scope_->num_parameters() + 1) * kPointerSize)); |
- __ Jump(lr); |
+ // Here we use masm_-> instead of the __ macro to avoid the code coverage |
+ // tool from instrumenting as we rely on the code size here. |
+ masm_->add(sp, sp, Operand((scope_->num_parameters() + 1) * kPointerSize)); |
+ masm_->Jump(lr); |
+ |
+ // Check that the size of the code used for returning matches what is |
+ // expected by the debugger. |
+ ASSERT_EQ(kJSReturnSequenceLength, |
+ masm_->InstructionsGeneratedSince(&check_exit_codesize)); |
+ |
} |
// Code generation state must be reset. |
@@ -1111,10 +1126,10 @@ |
if (FLAG_check_stack) { |
Comment cmnt(masm_, "[ check stack"); |
__ LoadRoot(ip, Heap::kStackLimitRootIndex); |
- // Put the lr setup instruction in the delay slot. The 'sizeof(Instr)' is |
- // added to the implicit 8 byte offset that always applies to operations |
- // with pc and gives a return address 12 bytes down. |
- masm_->add(lr, pc, Operand(sizeof(Instr))); |
+ // Put the lr setup instruction in the delay slot. kInstrSize is added to |
+ // the implicit 8 byte offset that always applies to operations with pc and |
+ // gives a return address 12 bytes down. |
+ masm_->add(lr, pc, Operand(Assembler::kInstrSize)); |
masm_->cmp(sp, Operand(ip)); |
StackCheckStub stub; |
// Call the stub if lower. |
@@ -1380,16 +1395,12 @@ |
VirtualFrame::SpilledScope spilled_scope; |
Comment cmnt(masm_, "[ ReturnStatement"); |
+ CodeForStatementPosition(node); |
+ LoadAndSpill(node->expression()); |
if (function_return_is_shadowed_) { |
- CodeForStatementPosition(node); |
- LoadAndSpill(node->expression()); |
frame_->EmitPop(r0); |
function_return_.Jump(); |
} else { |
- // Load the returned value. |
- CodeForStatementPosition(node); |
- LoadAndSpill(node->expression()); |
- |
// Pop the result from the frame and prepare the frame for |
// returning thus making it easier to merge. |
frame_->EmitPop(r0); |