Index: src/ic/mips/ic-mips.cc |
diff --git a/src/ic/mips/ic-mips.cc b/src/ic/mips/ic-mips.cc |
index beff9a90a67b61684c4a0c42ec7b055a9abb2625..cf9afdc124e64aac608efc53cefcd7a47263de97 100644 |
--- a/src/ic/mips/ic-mips.cc |
+++ b/src/ic/mips/ic-mips.cc |
@@ -880,8 +880,6 @@ void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { |
Address patch_address = |
andi_instruction_address - delta * Instruction::kInstrSize; |
Instr instr_at_patch = Assembler::instr_at(patch_address); |
- Instr branch_instr = |
- Assembler::instr_at(patch_address + Instruction::kInstrSize); |
// This is patching a conditional "jump if not smi/jump if smi" site. |
// Enabling by changing from |
// andi at, rx, 0 |
@@ -901,13 +899,44 @@ void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { |
DCHECK(Assembler::IsAndImmediate(instr_at_patch)); |
patcher.masm()->andi(at, reg, 0); |
} |
+ Instr branch_instr = |
+ Assembler::instr_at(patch_address + Instruction::kInstrSize); |
DCHECK(Assembler::IsBranch(branch_instr)); |
- if (Assembler::IsBeq(branch_instr)) { |
- patcher.ChangeBranchCondition(ne); |
- } else { |
- DCHECK(Assembler::IsBne(branch_instr)); |
- patcher.ChangeBranchCondition(eq); |
+ |
+ uint32_t opcode = Assembler::GetOpcodeField(branch_instr); |
+ // Currently only the 'eq' and 'ne' cond values are supported and the simple |
+ // branch instructions and their r6 variants (with opcode being the branch |
+ // type). There are some special cases (see Assembler::IsBranch()) so |
+ // extending this would be tricky. |
+ DCHECK(opcode == BEQ || // BEQ |
+ opcode == BNE || // BNE |
+ opcode == POP10 || // BEQC |
+ opcode == POP30 || // BNEC |
+ opcode == POP66 || // BEQZC |
+ opcode == POP76); // BNEZC |
+ switch (opcode) { |
+ case BEQ: |
+ opcode = BNE; // change BEQ to BNE. |
+ break; |
+ case POP10: |
+ opcode = POP30; // change BEQC to BNEC. |
+ break; |
+ case POP66: |
+ opcode = POP76; // change BEQZC to BNEZC. |
+ break; |
+ case BNE: |
+ opcode = BEQ; // change BNE to BEQ. |
+ break; |
+ case POP30: |
+ opcode = POP10; // change BNEC to BEQC. |
+ break; |
+ case POP76: |
+ opcode = POP66; // change BNEZC to BEQZC. |
+ break; |
+ default: |
+ UNIMPLEMENTED(); |
} |
+ patcher.ChangeBranchCondition(branch_instr, opcode); |
} |
} // namespace internal |
} // namespace v8 |