Index: src/a64/macro-assembler-a64.cc |
diff --git a/src/a64/macro-assembler-a64.cc b/src/a64/macro-assembler-a64.cc |
index 5b979c2b31ed496463018ce49d4c69ac73ceabb2..f637b2bd6a1a374745ff94c36ee2eeb910de736f 100644 |
--- a/src/a64/macro-assembler-a64.cc |
+++ b/src/a64/macro-assembler-a64.cc |
@@ -558,92 +558,6 @@ void MacroAssembler::Store(const Register& rt, |
} |
-bool MacroAssembler::ShouldEmitVeneer(int max_reachable_pc, int margin) { |
- // Account for the branch around the veneers and the guard. |
- int protection_offset = 2 * kInstructionSize; |
- return pc_offset() > max_reachable_pc - margin - protection_offset - |
- static_cast<int>(unresolved_branches_.size() * kMaxVeneerCodeSize); |
-} |
- |
- |
-void MacroAssembler::EmitVeneers(bool need_protection) { |
- RecordComment("[ Veneers"); |
- |
- Label end; |
- if (need_protection) { |
- B(&end); |
- } |
- |
- EmitVeneersGuard(); |
- |
- { |
- InstructionAccurateScope scope(this); |
- Label size_check; |
- |
- std::multimap<int, FarBranchInfo>::iterator it, it_to_delete; |
- |
- it = unresolved_branches_.begin(); |
- while (it != unresolved_branches_.end()) { |
- if (ShouldEmitVeneer(it->first)) { |
- Instruction* branch = InstructionAt(it->second.pc_offset_); |
- Label* label = it->second.label_; |
- |
-#ifdef DEBUG |
- __ bind(&size_check); |
-#endif |
- // Patch the branch to point to the current position, and emit a branch |
- // to the label. |
- Instruction* veneer = reinterpret_cast<Instruction*>(pc_); |
- RemoveBranchFromLabelLinkChain(branch, label, veneer); |
- branch->SetImmPCOffsetTarget(veneer); |
- b(label); |
-#ifdef DEBUG |
- ASSERT(SizeOfCodeGeneratedSince(&size_check) <= |
- static_cast<uint64_t>(kMaxVeneerCodeSize)); |
- size_check.Unuse(); |
-#endif |
- |
- it_to_delete = it++; |
- unresolved_branches_.erase(it_to_delete); |
- } else { |
- ++it; |
- } |
- } |
- } |
- |
- Bind(&end); |
- |
- RecordComment("]"); |
-} |
- |
- |
-void MacroAssembler::EmitVeneersGuard() { |
- if (emit_debug_code()) { |
- Unreachable(); |
- } |
-} |
- |
- |
-void MacroAssembler::CheckVeneers(bool need_protection) { |
- if (unresolved_branches_.empty()) { |
- return; |
- } |
- |
- CHECK(pc_offset() < unresolved_branches_first_limit()); |
- int margin = kVeneerDistanceMargin; |
- if (!need_protection) { |
- // Prefer emitting veneers protected by an existing instruction. |
- // The 4 divisor is a finger in the air guess. With a default margin of 2KB, |
- // that leaves 512B = 128 instructions of extra margin to avoid requiring a |
- // protective branch. |
- margin += margin / 4; |
- } |
- if (ShouldEmitVeneer(unresolved_branches_first_limit(), margin)) { |
- EmitVeneers(need_protection); |
- } |
-} |
- |
- |
bool MacroAssembler::NeedExtraInstructionsOrRegisterBranch( |
Label *label, ImmBranchType b_type) { |
bool need_longer_range = false; |
@@ -661,6 +575,10 @@ bool MacroAssembler::NeedExtraInstructionsOrRegisterBranch( |
unresolved_branches_.insert( |
std::pair<int, FarBranchInfo>(max_reachable_pc, |
FarBranchInfo(pc_offset(), label))); |
+ // Also maintain the next pool check. |
+ next_veneer_pool_check_ = |
+ Min(next_veneer_pool_check_, |
+ max_reachable_pc - kVeneerDistanceCheckMargin); |
} |
return need_longer_range; |
} |
@@ -696,11 +614,10 @@ void MacroAssembler::B(Label* label, Condition cond) { |
if (need_extra_instructions) { |
b(&done, InvertCondition(cond)); |
- b(label); |
+ B(label); |
} else { |
b(label, cond); |
} |
- CheckVeneers(!need_extra_instructions); |
bind(&done); |
} |
@@ -714,11 +631,10 @@ void MacroAssembler::Tbnz(const Register& rt, unsigned bit_pos, Label* label) { |
if (need_extra_instructions) { |
tbz(rt, bit_pos, &done); |
- b(label); |
+ B(label); |
} else { |
tbnz(rt, bit_pos, label); |
} |
- CheckVeneers(!need_extra_instructions); |
bind(&done); |
} |
@@ -732,11 +648,10 @@ void MacroAssembler::Tbz(const Register& rt, unsigned bit_pos, Label* label) { |
if (need_extra_instructions) { |
tbnz(rt, bit_pos, &done); |
- b(label); |
+ B(label); |
} else { |
tbz(rt, bit_pos, label); |
} |
- CheckVeneers(!need_extra_instructions); |
bind(&done); |
} |
@@ -750,11 +665,10 @@ void MacroAssembler::Cbnz(const Register& rt, Label* label) { |
if (need_extra_instructions) { |
cbz(rt, &done); |
- b(label); |
+ B(label); |
} else { |
cbnz(rt, label); |
} |
- CheckVeneers(!need_extra_instructions); |
bind(&done); |
} |
@@ -768,11 +682,10 @@ void MacroAssembler::Cbz(const Register& rt, Label* label) { |
if (need_extra_instructions) { |
cbnz(rt, &done); |
- b(label); |
+ B(label); |
} else { |
cbz(rt, label); |
} |
- CheckVeneers(!need_extra_instructions); |
bind(&done); |
} |
@@ -2009,7 +1922,7 @@ void MacroAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode) { |
void MacroAssembler::Call(Register target) { |
- BlockConstPoolScope scope(this); |
+ BlockPoolsScope scope(this); |
#ifdef DEBUG |
Label start_call; |
Bind(&start_call); |
@@ -2024,7 +1937,7 @@ void MacroAssembler::Call(Register target) { |
void MacroAssembler::Call(Label* target) { |
- BlockConstPoolScope scope(this); |
+ BlockPoolsScope scope(this); |
#ifdef DEBUG |
Label start_call; |
Bind(&start_call); |
@@ -2041,7 +1954,7 @@ void MacroAssembler::Call(Label* target) { |
// MacroAssembler::CallSize is sensitive to changes in this function, as it |
// requires to know how many instructions are used to branch to the target. |
void MacroAssembler::Call(Address target, RelocInfo::Mode rmode) { |
- BlockConstPoolScope scope(this); |
+ BlockPoolsScope scope(this); |
#ifdef DEBUG |
Label start_call; |
Bind(&start_call); |
@@ -4679,7 +4592,7 @@ void MacroAssembler::Abort(BailoutReason reason) { |
// Emit the message string directly in the instruction stream. |
{ |
- BlockConstPoolScope scope(this); |
+ BlockPoolsScope scope(this); |
Bind(&msg_address); |
EmitStringData(GetBailoutReason(reason)); |
} |
@@ -4871,7 +4784,7 @@ void MacroAssembler::PrintfNoPreserve(const char * format, |
Adr(x0, &format_address); |
// Emit the format string directly in the instruction stream. |
- { BlockConstPoolScope scope(this); |
+ { BlockPoolsScope scope(this); |
Label after_data; |
B(&after_data); |
Bind(&format_address); |
@@ -5036,7 +4949,7 @@ bool MacroAssembler::IsCodeAgeSequence(byte* sequence) { |
void InlineSmiCheckInfo::Emit(MacroAssembler* masm, const Register& reg, |
const Label* smi_check) { |
- Assembler::BlockConstPoolScope scope(masm); |
+ Assembler::BlockPoolsScope scope(masm); |
if (reg.IsValid()) { |
ASSERT(smi_check->is_bound()); |
ASSERT(reg.Is64Bits()); |