OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
9 #include "src/ic/ic-compiler.h" | 9 #include "src/ic/ic-compiler.h" |
10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.h" |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 } | 856 } |
857 | 857 |
858 if (FLAG_trace_ic) { | 858 if (FLAG_trace_ic) { |
859 PrintF("[ patching ic at %p, andi=%p, delta=%d\n", address, | 859 PrintF("[ patching ic at %p, andi=%p, delta=%d\n", address, |
860 andi_instruction_address, delta); | 860 andi_instruction_address, delta); |
861 } | 861 } |
862 | 862 |
863 Address patch_address = | 863 Address patch_address = |
864 andi_instruction_address - delta * Instruction::kInstrSize; | 864 andi_instruction_address - delta * Instruction::kInstrSize; |
865 Instr instr_at_patch = Assembler::instr_at(patch_address); | 865 Instr instr_at_patch = Assembler::instr_at(patch_address); |
866 Instr branch_instr = | |
867 Assembler::instr_at(patch_address + Instruction::kInstrSize); | |
868 // This is patching a conditional "jump if not smi/jump if smi" site. | 866 // This is patching a conditional "jump if not smi/jump if smi" site. |
869 // Enabling by changing from | 867 // Enabling by changing from |
870 // andi at, rx, 0 | 868 // andi at, rx, 0 |
871 // Branch <target>, eq, at, Operand(zero_reg) | 869 // Branch <target>, eq, at, Operand(zero_reg) |
872 // to: | 870 // to: |
873 // andi at, rx, #kSmiTagMask | 871 // andi at, rx, #kSmiTagMask |
874 // Branch <target>, ne, at, Operand(zero_reg) | 872 // Branch <target>, ne, at, Operand(zero_reg) |
875 // and vice-versa to be disabled again. | 873 // and vice-versa to be disabled again. |
876 CodePatcher patcher(isolate, patch_address, 2); | 874 CodePatcher patcher(isolate, patch_address, 2); |
877 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); | 875 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); |
878 if (check == ENABLE_INLINED_SMI_CHECK) { | 876 if (check == ENABLE_INLINED_SMI_CHECK) { |
879 DCHECK(Assembler::IsAndImmediate(instr_at_patch)); | 877 DCHECK(Assembler::IsAndImmediate(instr_at_patch)); |
880 DCHECK_EQ(0u, Assembler::GetImmediate16(instr_at_patch)); | 878 DCHECK_EQ(0u, Assembler::GetImmediate16(instr_at_patch)); |
881 patcher.masm()->andi(at, reg, kSmiTagMask); | 879 patcher.masm()->andi(at, reg, kSmiTagMask); |
882 } else { | 880 } else { |
883 DCHECK_EQ(check, DISABLE_INLINED_SMI_CHECK); | 881 DCHECK_EQ(check, DISABLE_INLINED_SMI_CHECK); |
884 DCHECK(Assembler::IsAndImmediate(instr_at_patch)); | 882 DCHECK(Assembler::IsAndImmediate(instr_at_patch)); |
885 patcher.masm()->andi(at, reg, 0); | 883 patcher.masm()->andi(at, reg, 0); |
886 } | 884 } |
| 885 Instr branch_instr = |
| 886 Assembler::instr_at(patch_address + Instruction::kInstrSize); |
887 DCHECK(Assembler::IsBranch(branch_instr)); | 887 DCHECK(Assembler::IsBranch(branch_instr)); |
888 if (Assembler::IsBeq(branch_instr)) { | 888 |
889 patcher.ChangeBranchCondition(ne); | 889 uint32_t opcode = Assembler::GetOpcodeField(branch_instr); |
890 } else { | 890 // Currently only the 'eq' and 'ne' cond values are supported and the simple |
891 DCHECK(Assembler::IsBne(branch_instr)); | 891 // branch instructions and their r6 variants (with opcode being the branch |
892 patcher.ChangeBranchCondition(eq); | 892 // type). There are some special cases (see Assembler::IsBranch()) so |
| 893 // extending this would be tricky. |
| 894 DCHECK(opcode == BEQ || // BEQ |
| 895 opcode == BNE || // BNE |
| 896 opcode == POP10 || // BEQC |
| 897 opcode == POP30 || // BNEC |
| 898 opcode == POP66 || // BEQZC |
| 899 opcode == POP76); // BNEZC |
| 900 switch (opcode) { |
| 901 case BEQ: |
| 902 opcode = BNE; // change BEQ to BNE. |
| 903 break; |
| 904 case POP10: |
| 905 opcode = POP30; // change BEQC to BNEC. |
| 906 break; |
| 907 case POP66: |
| 908 opcode = POP76; // change BEQZC to BNEZC. |
| 909 break; |
| 910 case BNE: |
| 911 opcode = BEQ; // change BNE to BEQ. |
| 912 break; |
| 913 case POP30: |
| 914 opcode = POP10; // change BNEC to BEQC. |
| 915 break; |
| 916 case POP76: |
| 917 opcode = POP66; // change BNEZC to BEQZC. |
| 918 break; |
| 919 default: |
| 920 UNIMPLEMENTED(); |
893 } | 921 } |
| 922 patcher.ChangeBranchCondition(branch_instr, opcode); |
894 } | 923 } |
895 } // namespace internal | 924 } // namespace internal |
896 } // namespace v8 | 925 } // namespace v8 |
897 | 926 |
898 #endif // V8_TARGET_ARCH_MIPS64 | 927 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |