Index: src/compiler/x64/code-generator-x64.cc |
diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc |
index f93ad21a219a09c0ca51f556dbf9d457a8a58ad1..f1438996260fbc68991eeccd9a3c29f585b2d430 100644 |
--- a/src/compiler/x64/code-generator-x64.cc |
+++ b/src/compiler/x64/code-generator-x64.cc |
@@ -205,6 +205,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
switch (ArchOpcodeField::decode(instr->opcode())) { |
case kArchCallCodeObject: { |
+ EnsureSpaceForLazyDeopt(); |
if (HasImmediateInput(instr, 0)) { |
Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
__ Call(code, RelocInfo::CODE_TARGET); |
@@ -226,6 +227,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
} |
break; |
case kArchCallJSFunction: { |
+ EnsureSpaceForLazyDeopt(); |
Register func = i.InputRegister(0); |
if (FLAG_debug_code) { |
// Check the function's context matches the context argument. |
@@ -1001,6 +1003,21 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source, |
void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |
+ |
+void CodeGenerator::EnsureSpaceForLazyDeopt() { |
+ int space_needed = Deoptimizer::patch_size(); |
+ if (!linkage()->info()->IsStub()) { |
+ // Ensure that we have enough space after the previous lazy-bailout |
+ // instruction for patching the code here. |
+ int current_pc = masm()->pc_offset(); |
+ if (current_pc < last_lazy_deopt_pc_ + space_needed) { |
+ int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
+ __ Nop(padding_size); |
+ } |
+ } |
+ MarkLazyDeoptSite(); |
+} |
+ |
#undef __ |
} // namespace internal |