Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/ic/mips/ic-mips.cc

Issue 1396133002: MIPS: r6 compact branch optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/mips/assembler-mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MIPS 5 #if V8_TARGET_ARCH_MIPS
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 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 873 }
874 874
875 if (FLAG_trace_ic) { 875 if (FLAG_trace_ic) {
876 PrintF("[ patching ic at %p, andi=%p, delta=%d\n", address, 876 PrintF("[ patching ic at %p, andi=%p, delta=%d\n", address,
877 andi_instruction_address, delta); 877 andi_instruction_address, delta);
878 } 878 }
879 879
880 Address patch_address = 880 Address patch_address =
881 andi_instruction_address - delta * Instruction::kInstrSize; 881 andi_instruction_address - delta * Instruction::kInstrSize;
882 Instr instr_at_patch = Assembler::instr_at(patch_address); 882 Instr instr_at_patch = Assembler::instr_at(patch_address);
883 Instr branch_instr =
884 Assembler::instr_at(patch_address + Instruction::kInstrSize);
885 // This is patching a conditional "jump if not smi/jump if smi" site. 883 // This is patching a conditional "jump if not smi/jump if smi" site.
886 // Enabling by changing from 884 // Enabling by changing from
887 // andi at, rx, 0 885 // andi at, rx, 0
888 // Branch <target>, eq, at, Operand(zero_reg) 886 // Branch <target>, eq, at, Operand(zero_reg)
889 // to: 887 // to:
890 // andi at, rx, #kSmiTagMask 888 // andi at, rx, #kSmiTagMask
891 // Branch <target>, ne, at, Operand(zero_reg) 889 // Branch <target>, ne, at, Operand(zero_reg)
892 // and vice-versa to be disabled again. 890 // and vice-versa to be disabled again.
893 CodePatcher patcher(patch_address, 2); 891 CodePatcher patcher(patch_address, 2);
894 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); 892 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch));
895 if (check == ENABLE_INLINED_SMI_CHECK) { 893 if (check == ENABLE_INLINED_SMI_CHECK) {
896 DCHECK(Assembler::IsAndImmediate(instr_at_patch)); 894 DCHECK(Assembler::IsAndImmediate(instr_at_patch));
897 DCHECK_EQ(0u, Assembler::GetImmediate16(instr_at_patch)); 895 DCHECK_EQ(0u, Assembler::GetImmediate16(instr_at_patch));
898 patcher.masm()->andi(at, reg, kSmiTagMask); 896 patcher.masm()->andi(at, reg, kSmiTagMask);
899 } else { 897 } else {
900 DCHECK_EQ(check, DISABLE_INLINED_SMI_CHECK); 898 DCHECK_EQ(check, DISABLE_INLINED_SMI_CHECK);
901 DCHECK(Assembler::IsAndImmediate(instr_at_patch)); 899 DCHECK(Assembler::IsAndImmediate(instr_at_patch));
902 patcher.masm()->andi(at, reg, 0); 900 patcher.masm()->andi(at, reg, 0);
903 } 901 }
902 Instr branch_instr =
903 Assembler::instr_at(patch_address + Instruction::kInstrSize);
904 DCHECK(Assembler::IsBranch(branch_instr)); 904 DCHECK(Assembler::IsBranch(branch_instr));
905 if (Assembler::IsBeq(branch_instr)) { 905
906 patcher.ChangeBranchCondition(ne); 906 uint32_t opcode = Assembler::GetOpcodeField(branch_instr);
907 } else { 907 // Currently only the 'eq' and 'ne' cond values are supported and the simple
908 DCHECK(Assembler::IsBne(branch_instr)); 908 // branch instructions and their r6 variants (with opcode being the branch
909 patcher.ChangeBranchCondition(eq); 909 // type). There are some special cases (see Assembler::IsBranch()) so
910 // extending this would be tricky.
911 DCHECK(opcode == BEQ || // BEQ
912 opcode == BNE || // BNE
913 opcode == POP10 || // BEQC
914 opcode == POP30 || // BNEC
915 opcode == POP66 || // BEQZC
916 opcode == POP76); // BNEZC
917 switch (opcode) {
918 case BEQ:
919 opcode = BNE; // change BEQ to BNE.
920 break;
921 case POP10:
922 opcode = POP30; // change BEQC to BNEC.
923 break;
924 case POP66:
925 opcode = POP76; // change BEQZC to BNEZC.
926 break;
927 case BNE:
928 opcode = BEQ; // change BNE to BEQ.
929 break;
930 case POP30:
931 opcode = POP10; // change BNEC to BEQC.
932 break;
933 case POP76:
934 opcode = POP66; // change BNEZC to BEQZC.
935 break;
936 default:
937 UNIMPLEMENTED();
910 } 938 }
939 patcher.ChangeBranchCondition(branch_instr, opcode);
911 } 940 }
912 } // namespace internal 941 } // namespace internal
913 } // namespace v8 942 } // namespace v8
914 943
915 #endif // V8_TARGET_ARCH_MIPS 944 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | src/mips/assembler-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698