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