Index: src/x64/lithium-codegen-x64.cc |
=================================================================== |
--- src/x64/lithium-codegen-x64.cc (revision 7102) |
+++ src/x64/lithium-codegen-x64.cc (working copy) |
@@ -39,7 +39,7 @@ |
// When invoking builtins, we need to record the safepoint in the middle of |
// the invoke instruction sequence generated by the macro assembler. |
-class SafepointGenerator : public PostCallGenerator { |
+class SafepointGenerator : public CallWrapper { |
public: |
SafepointGenerator(LCodeGen* codegen, |
LPointerMap* pointers, |
@@ -48,29 +48,29 @@ |
: codegen_(codegen), |
pointers_(pointers), |
deoptimization_index_(deoptimization_index), |
- ensure_reloc_space_(ensure_reloc_space), |
- previous_safepoint_position_(-kMinSafepointSize) { } |
+ ensure_reloc_space_(ensure_reloc_space) { } |
virtual ~SafepointGenerator() { } |
- virtual void Generate() { |
+ virtual void BeforeCall(int call_size) { |
+ ASSERT(call_size >= 0); |
// Ensure that we have enough space after the previous safepoint position |
- // for the generated code there. |
- int position = codegen_->masm()->pc_offset(); |
- ASSERT(position > previous_safepoint_position_); |
- if (position < previous_safepoint_position_ + kMinSafepointSize) { |
- int padding_size = |
- previous_safepoint_position_ + kMinSafepointSize - position; |
+ // for the jump generated there. |
+ int call_end = codegen_->masm()->pc_offset() + call_size; |
+ int prev_jump_end = codegen_->LastSafepointEnd() + kMinSafepointSize; |
+ if (call_end < prev_jump_end) { |
+ int padding_size = prev_jump_end - call_end; |
STATIC_ASSERT(kMinSafepointSize <= 9); // One multibyte nop is enough. |
codegen_->masm()->nop(padding_size); |
- position += padding_size; |
} |
+ } |
+ |
+ virtual void AfterCall() { |
// Ensure that we have enough space in the reloc info to patch |
// this with calls when doing deoptimization. |
if (ensure_reloc_space_) { |
codegen_->masm()->RecordComment(RelocInfo::kFillerCommentString, true); |
} |
codegen_->RecordSafepoint(pointers_, deoptimization_index_); |
- previous_safepoint_position_ = position; |
} |
private: |
@@ -80,7 +80,6 @@ |
LPointerMap* pointers_; |
int deoptimization_index_; |
bool ensure_reloc_space_; |
- int previous_safepoint_position_; |
}; |
@@ -259,9 +258,8 @@ |
bool LCodeGen::GenerateJumpTable() { |
for (int i = 0; i < jump_table_.length(); i++) { |
- JumpTableEntry* info = jump_table_[i]; |
- __ bind(&(info->label_)); |
- __ Jump(info->address_, RelocInfo::RUNTIME_ENTRY); |
+ __ bind(&jump_table_[i].label); |
+ __ Jump(jump_table_[i].address, RelocInfo::RUNTIME_ENTRY); |
} |
return !is_aborted(); |
} |
@@ -539,17 +537,13 @@ |
if (cc == no_condition) { |
__ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
} else { |
- JumpTableEntry* jump_info = NULL; |
// We often have several deopts to the same entry, reuse the last |
// jump entry if this is the case. |
- if (jump_table_.length() > 0 && |
- jump_table_[jump_table_.length() - 1]->address_ == entry) { |
- jump_info = jump_table_[jump_table_.length() - 1]; |
- } else { |
- jump_info = new JumpTableEntry(entry); |
- jump_table_.Add(jump_info); |
+ if (jump_table_.is_empty() || |
+ jump_table_.last().address != entry) { |
+ jump_table_.Add(entry); |
} |
- __ j(cc, &jump_info->label_); |
+ __ j(cc, &jump_table_.last().label); |
} |
} |