Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index 24e2044f27417b9c17c2297a6e80ebfc95df3ba6..a947cb8234df23de6889f7fc0f74cd1accbc9bf8 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -257,11 +257,28 @@ LInstruction* LCodeGen::GetNextInstruction() { |
bool LCodeGen::GenerateDeferredCode() { |
ASSERT(is_generating()); |
- for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
- LDeferredCode* code = deferred_[i]; |
- __ bind(code->entry()); |
- code->Generate(); |
- __ jmp(code->exit()); |
+ Label last_jump; |
+ if (deferred_.length() > 0) { |
+ for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
+ LDeferredCode* code = deferred_[i]; |
+ __ bind(code->entry()); |
+ code->Generate(); |
+#ifdef DEBUG |
+ if (i == deferred_.length() - 1) { |
+ __ bind(&last_jump); |
+ } |
+#endif |
+ __ jmp(code->exit()); |
+ } |
+ |
+ // Reserve some space to ensure that the last piece of deferred code |
+ // have room for lazy bailout. |
+ __ nop(); |
+ __ nop(); |
+ |
+ int code_generated = |
+ masm_->InstructionsGeneratedSince(&last_jump) * Assembler::kInstrSize; |
+ ASSERT(Deoptimizer::patch_size() <= code_generated); |
} |
// Force constant pool emission at the end of the deferred code to make |
@@ -4322,8 +4339,16 @@ void LCodeGen::DoIn(LIn* instr) { |
void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) { |
- PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); |
- CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr); |
+ { |
+ PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); |
+ __ CallRuntimeSaveDoubles(Runtime::kStackGuard); |
+ RegisterLazyDeoptimization( |
+ instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
+ } |
+ |
+ // The gap code includes the restoring of the safepoint registers. |
+ int pc = masm()->pc_offset(); |
+ safepoints_.SetPcAfterGap(pc); |
} |