Index: src/mips64/assembler-mips64-inl.h |
diff --git a/src/mips64/assembler-mips64-inl.h b/src/mips64/assembler-mips64-inl.h |
index a6e0298763819cd077949f75833bce9d08d5cf33..09436ed1d41386a5b74bb7f95ab7dfe96b7cda3a 100644 |
--- a/src/mips64/assembler-mips64-inl.h |
+++ b/src/mips64/assembler-mips64-inl.h |
@@ -438,11 +438,23 @@ void Assembler::CheckTrampolinePoolQuick(int extra_instructions) { |
} |
-void Assembler::emit(Instr x, CompactBranchType is_compact_branch) { |
+void Assembler::CheckForEmitInForbiddenSlot() { |
if (!is_buffer_growth_blocked()) { |
CheckBuffer(); |
} |
if (IsPrevInstrCompactBranch()) { |
+ // Nop instruction to preceed a CTI in forbidden slot: |
+ Instr nop = SPECIAL | SLL; |
+ *reinterpret_cast<Instr*>(pc_) = nop; |
+ pc_ += kInstrSize; |
+ |
+ ClearCompactBranchState(); |
+ } |
+} |
+ |
+ |
+void Assembler::EmitHelper(Instr x, CompactBranchType is_compact_branch) { |
+ if (IsPrevInstrCompactBranch()) { |
if (Instruction::IsForbiddenAfterBranchInstr(x)) { |
// Nop instruction to preceed a CTI in forbidden slot: |
Instr nop = SPECIAL | SLL; |
@@ -460,21 +472,25 @@ void Assembler::emit(Instr x, CompactBranchType is_compact_branch) { |
} |
-void Assembler::emit(uint64_t x) { |
+template <typename T> |
+void Assembler::EmitHelper(T x) { |
+ *reinterpret_cast<T*>(pc_) = x; |
+ pc_ += sizeof(x); |
+ CheckTrampolinePoolQuick(); |
+} |
+ |
+ |
+void Assembler::emit(Instr x, CompactBranchType is_compact_branch) { |
if (!is_buffer_growth_blocked()) { |
CheckBuffer(); |
} |
- if (IsPrevInstrCompactBranch()) { |
- // Nop instruction to preceed a CTI in forbidden slot: |
- Instr nop = SPECIAL | SLL; |
- *reinterpret_cast<Instr*>(pc_) = nop; |
- pc_ += kInstrSize; |
+ EmitHelper(x, is_compact_branch); |
+} |
- ClearCompactBranchState(); |
- } |
- *reinterpret_cast<uint64_t*>(pc_) = x; |
- pc_ += kInstrSize * 2; |
- CheckTrampolinePoolQuick(); |
+ |
+void Assembler::emit(uint64_t data) { |
+ CheckForEmitInForbiddenSlot(); |
+ EmitHelper(data); |
} |