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)
void Assembler::GetCode(CodeDesc* desc) {
if (IsPrevInstrCompactBranch()) {
nop();
ClearCompactBranchState();
}
EmitForbiddenSlotInstruction();
DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap.
// Set up code descriptor.
desc->buffer = buffer_;
......@@ -302,10 +299,7 @@ void Assembler::GetCode(CodeDesc* desc) {
void Assembler::Align(int m) {
DCHECK(m >= 4 && base::bits::IsPowerOfTwo32(m));
if (IsPrevInstrCompactBranch()) {
nop();
ClearCompactBranchState();
}
EmitForbiddenSlotInstruction();
while ((pc_offset() & (m - 1)) != 0) {
nop();
}
......
......@@ -1206,6 +1206,12 @@ class Assembler : public AssemblerBase {
return block_buffer_growth_;
}
void EmitForbiddenSlotInstruction() {
if (IsPrevInstrCompactBranch()) {
nop();
}
}
inline void CheckTrampolinePoolQuick(int extra_instructions = 0);
private:
......
......@@ -142,7 +142,7 @@ bool Instruction::IsForbiddenAfterBranchInstr(Instr instr) {
case BC:
case BALC:
case POP10: // beqzalc, bovc, beqc
case POP30: // bnezalc, bvnc, bnec
case POP30: // bnezalc, bnvc, bnec
case POP66: // beqzc, jic
case POP76: // bnezc, jialc
return true;
......
......@@ -390,7 +390,7 @@ enum Opcode : uint32_t {
POP10 = ADDI, // beqzalc, bovc, beqc
POP26 = BLEZL, // bgezc, blezc, bgec/blec
POP27 = BGTZL, // bgtzc, bltzc, bltc/bgtc
POP30 = DADDI, // bnezalc, bvnc, bnec
POP30 = DADDI, // bnezalc, bnvc, bnec
};
enum SecondaryField : uint32_t {
......
......@@ -1500,6 +1500,7 @@ void Decoder::DecodeTypeImmediate(Instruction* instr) {
if (rs_reg >= rt_reg) {
Format(instr, "bovc 'rs, 'rt, 'imm16s -> 'imm16p4s2");
} else {
DCHECK(rt_reg > 0);
if (rs_reg == 0) {
Format(instr, "beqzalc 'rt, 'imm16s -> 'imm16p4s2");
} else {
......@@ -1516,6 +1517,7 @@ void Decoder::DecodeTypeImmediate(Instruction* instr) {
if (rs_reg >= rt_reg) {
Format(instr, "bnvc 'rs, 'rt, 'imm16s -> 'imm16p4s2");
} else {
DCHECK(rt_reg > 0);
if (rs_reg == 0) {
Format(instr, "bnezalc 'rt, 'imm16s -> 'imm16p4s2");
} else {
......
......@@ -359,13 +359,13 @@ class Simulator {
// Compact branch guard.
void CheckForbiddenSlot(int32_t current_pc) {
Instruction* instr_aftter_compact_branch =
Instruction* instr_after_compact_branch =
reinterpret_cast<Instruction*>(current_pc + Instruction::kInstrSize);
if (instr_aftter_compact_branch->IsForbiddenInBranchDelay()) {
if (instr_after_compact_branch->IsForbiddenAfterBranch()) {
V8_Fatal(__FILE__, __LINE__,
"Error: Unexpected instruction 0x%08x immediately after a "
"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() {
bc(&after_pool);
} else {
b(&after_pool);
nop();
}
nop();
EmitForbiddenSlotInstruction();
int pool_start = pc_offset();
for (int i = 0; i < unbound_labels_count_; i++) {
{ BlockGrowBufferScope block_buf_growth(this);
......
......@@ -1272,7 +1272,6 @@ class Assembler : public AssemblerBase {
void EmitForbiddenSlotInstruction() {
if (IsPrevInstrCompactBranch()) {
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