Index: src/safepoint-table.cc |
diff --git a/src/safepoint-table.cc b/src/safepoint-table.cc |
index 9e423045aec59c01d7fca266e83116ec09096d24..714e5c3977f7b8a5ac99ece038733e893edbbc30 100644 |
--- a/src/safepoint-table.cc |
+++ b/src/safepoint-table.cc |
@@ -59,8 +59,7 @@ bool SafepointEntry::HasRegisterAt(int reg_index) const { |
SafepointTable::SafepointTable(Code* code) { |
- ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION || |
- code->kind() == Code::COMPILED_STUB); |
+ ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
code_ = code; |
Address header = code->instruction_start() + code->safepoint_table_offset(); |
length_ = Memory::uint32_at(header + kLengthOffset); |
@@ -159,6 +158,14 @@ unsigned SafepointTableBuilder::GetCodeOffset() const { |
void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) { |
+ // For lazy deoptimization we need space to patch a call after every call. |
+ // Ensure there is always space for such patching, even if the code ends |
+ // in a call. |
+ int target_offset = assembler->pc_offset() + Deoptimizer::patch_size(); |
+ while (assembler->pc_offset() < target_offset) { |
+ assembler->nop(); |
+ } |
+ |
// Make sure the safepoint table is properly aligned. Pad with nops. |
assembler->Align(kIntSize); |
assembler->RecordComment(";;; Safepoint table."); |