Commit ccb3181c authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: Refine 'r6 compact branch optimization.'

BUG=

Review URL: https://codereview.chromium.org/1593713002

Cr-Commit-Position: refs/heads/master@{#33361}
parent faf5e681
...@@ -285,10 +285,7 @@ Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) ...@@ -285,10 +285,7 @@ Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size)
void Assembler::GetCode(CodeDesc* desc) { void Assembler::GetCode(CodeDesc* desc) {
if (IsPrevInstrCompactBranch()) { EmitForbiddenSlotInstruction();
nop();
ClearCompactBranchState();
}
DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap.
// Set up code descriptor. // Set up code descriptor.
desc->buffer = buffer_; desc->buffer = buffer_;
...@@ -302,10 +299,7 @@ void Assembler::GetCode(CodeDesc* desc) { ...@@ -302,10 +299,7 @@ void Assembler::GetCode(CodeDesc* desc) {
void Assembler::Align(int m) { void Assembler::Align(int m) {
DCHECK(m >= 4 && base::bits::IsPowerOfTwo32(m)); DCHECK(m >= 4 && base::bits::IsPowerOfTwo32(m));
if (IsPrevInstrCompactBranch()) { EmitForbiddenSlotInstruction();
nop();
ClearCompactBranchState();
}
while ((pc_offset() & (m - 1)) != 0) { while ((pc_offset() & (m - 1)) != 0) {
nop(); nop();
} }
......
...@@ -1206,6 +1206,12 @@ class Assembler : public AssemblerBase { ...@@ -1206,6 +1206,12 @@ class Assembler : public AssemblerBase {
return block_buffer_growth_; return block_buffer_growth_;
} }
void EmitForbiddenSlotInstruction() {
if (IsPrevInstrCompactBranch()) {
nop();
}
}
inline void CheckTrampolinePoolQuick(int extra_instructions = 0); inline void CheckTrampolinePoolQuick(int extra_instructions = 0);
private: private:
......
...@@ -142,7 +142,7 @@ bool Instruction::IsForbiddenAfterBranchInstr(Instr instr) { ...@@ -142,7 +142,7 @@ bool Instruction::IsForbiddenAfterBranchInstr(Instr instr) {
case BC: case BC:
case BALC: case BALC:
case POP10: // beqzalc, bovc, beqc case POP10: // beqzalc, bovc, beqc
case POP30: // bnezalc, bvnc, bnec case POP30: // bnezalc, bnvc, bnec
case POP66: // beqzc, jic case POP66: // beqzc, jic
case POP76: // bnezc, jialc case POP76: // bnezc, jialc
return true; return true;
......
...@@ -390,7 +390,7 @@ enum Opcode : uint32_t { ...@@ -390,7 +390,7 @@ enum Opcode : uint32_t {
POP10 = ADDI, // beqzalc, bovc, beqc POP10 = ADDI, // beqzalc, bovc, beqc
POP26 = BLEZL, // bgezc, blezc, bgec/blec POP26 = BLEZL, // bgezc, blezc, bgec/blec
POP27 = BGTZL, // bgtzc, bltzc, bltc/bgtc POP27 = BGTZL, // bgtzc, bltzc, bltc/bgtc
POP30 = DADDI, // bnezalc, bvnc, bnec POP30 = DADDI, // bnezalc, bnvc, bnec
}; };
enum SecondaryField : uint32_t { enum SecondaryField : uint32_t {
......
...@@ -1500,6 +1500,7 @@ void Decoder::DecodeTypeImmediate(Instruction* instr) { ...@@ -1500,6 +1500,7 @@ void Decoder::DecodeTypeImmediate(Instruction* instr) {
if (rs_reg >= rt_reg) { if (rs_reg >= rt_reg) {
Format(instr, "bovc 'rs, 'rt, 'imm16s -> 'imm16p4s2"); Format(instr, "bovc 'rs, 'rt, 'imm16s -> 'imm16p4s2");
} else { } else {
DCHECK(rt_reg > 0);
if (rs_reg == 0) { if (rs_reg == 0) {
Format(instr, "beqzalc 'rt, 'imm16s -> 'imm16p4s2"); Format(instr, "beqzalc 'rt, 'imm16s -> 'imm16p4s2");
} else { } else {
...@@ -1516,6 +1517,7 @@ void Decoder::DecodeTypeImmediate(Instruction* instr) { ...@@ -1516,6 +1517,7 @@ void Decoder::DecodeTypeImmediate(Instruction* instr) {
if (rs_reg >= rt_reg) { if (rs_reg >= rt_reg) {
Format(instr, "bnvc 'rs, 'rt, 'imm16s -> 'imm16p4s2"); Format(instr, "bnvc 'rs, 'rt, 'imm16s -> 'imm16p4s2");
} else { } else {
DCHECK(rt_reg > 0);
if (rs_reg == 0) { if (rs_reg == 0) {
Format(instr, "bnezalc 'rt, 'imm16s -> 'imm16p4s2"); Format(instr, "bnezalc 'rt, 'imm16s -> 'imm16p4s2");
} else { } else {
......
...@@ -359,13 +359,13 @@ class Simulator { ...@@ -359,13 +359,13 @@ class Simulator {
// Compact branch guard. // Compact branch guard.
void CheckForbiddenSlot(int32_t current_pc) { void CheckForbiddenSlot(int32_t current_pc) {
Instruction* instr_aftter_compact_branch = Instruction* instr_after_compact_branch =
reinterpret_cast<Instruction*>(current_pc + Instruction::kInstrSize); reinterpret_cast<Instruction*>(current_pc + Instruction::kInstrSize);
if (instr_aftter_compact_branch->IsForbiddenInBranchDelay()) { if (instr_after_compact_branch->IsForbiddenAfterBranch()) {
V8_Fatal(__FILE__, __LINE__, V8_Fatal(__FILE__, __LINE__,
"Error: Unexpected instruction 0x%08x immediately after a " "Error: Unexpected instruction 0x%08x immediately after a "
"compact branch instruction.", "compact branch instruction.",
*reinterpret_cast<uint32_t*>(instr_aftter_compact_branch)); *reinterpret_cast<uint32_t*>(instr_after_compact_branch));
} }
} }
......
...@@ -3270,10 +3270,9 @@ void Assembler::CheckTrampolinePool() { ...@@ -3270,10 +3270,9 @@ void Assembler::CheckTrampolinePool() {
bc(&after_pool); bc(&after_pool);
} else { } else {
b(&after_pool); b(&after_pool);
nop();
} }
nop();
EmitForbiddenSlotInstruction();
int pool_start = pc_offset(); int pool_start = pc_offset();
for (int i = 0; i < unbound_labels_count_; i++) { for (int i = 0; i < unbound_labels_count_; i++) {
{ BlockGrowBufferScope block_buf_growth(this); { BlockGrowBufferScope block_buf_growth(this);
......
...@@ -1272,7 +1272,6 @@ class Assembler : public AssemblerBase { ...@@ -1272,7 +1272,6 @@ class Assembler : public AssemblerBase {
void EmitForbiddenSlotInstruction() { void EmitForbiddenSlotInstruction() {
if (IsPrevInstrCompactBranch()) { if (IsPrevInstrCompactBranch()) {
nop(); nop();
ClearCompactBranchState();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment