Index: src/ic/mips64/ic-mips64.cc |
diff --git a/src/ic/mips64/ic-mips64.cc b/src/ic/mips64/ic-mips64.cc |
index 6e78196f6d5f87609a8dc6be76f9bfbadf5595d5..c5da5fbb4249ae6f5455ae9a6df3449e6cca6301 100644 |
--- a/src/ic/mips64/ic-mips64.cc |
+++ b/src/ic/mips64/ic-mips64.cc |
@@ -863,8 +863,6 @@ void PatchInlinedSmiCode(Isolate* isolate, Address address, |
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 |
@@ -884,13 +882,44 @@ void PatchInlinedSmiCode(Isolate* isolate, Address address, |
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 |