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

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 745633002: [turbofan] Clean up and factor out branch generation logic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix IA32 fall through. Created 6 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #include "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/compiler/code-generator-impl.h" 7 #include "src/compiler/code-generator-impl.h"
8 #include "src/compiler/gap-resolver.h" 8 #include "src/compiler/gap-resolver.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (FLAG_debug_code) { 231 if (FLAG_debug_code) {
232 // Check the function's context matches the context argument. 232 // Check the function's context matches the context argument.
233 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); 233 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset));
234 __ Assert(equal, kWrongFunctionContext); 234 __ Assert(equal, kWrongFunctionContext);
235 } 235 }
236 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset)); 236 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset));
237 AddSafepointAndDeopt(instr); 237 AddSafepointAndDeopt(instr);
238 break; 238 break;
239 } 239 }
240 case kArchJmp: 240 case kArchJmp:
241 __ jmp(GetLabel(i.InputRpo(0))); 241 AssembleArchJump(i.InputRpo(0));
242 break; 242 break;
243 case kArchNop: 243 case kArchNop:
244 // don't emit code for nops. 244 // don't emit code for nops.
245 break; 245 break;
246 case kArchRet: 246 case kArchRet:
247 AssembleReturn(); 247 AssembleReturn();
248 break; 248 break;
249 case kArchStackPointer: 249 case kArchStackPointer:
250 __ movq(i.OutputRegister(), rsp); 250 __ movq(i.OutputRegister(), rsp);
251 break; 251 break;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 SaveFPRegsMode mode = 618 SaveFPRegsMode mode =
619 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; 619 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs;
620 __ RecordWrite(object, index, value, mode); 620 __ RecordWrite(object, index, value, mode);
621 break; 621 break;
622 } 622 }
623 } 623 }
624 } 624 }
625 625
626 626
627 // Assembles branches after this instruction. 627 // Assembles branches after this instruction.
628 void CodeGenerator::AssembleArchBranch(Instruction* instr, 628 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) {
629 FlagsCondition condition) {
630 X64OperandConverter i(this, instr); 629 X64OperandConverter i(this, instr);
631 Label done; 630 Label::Distance flabel_distance =
632 631 branch->fallthru ? Label::kNear : Label::kFar;
633 // Emit a branch. The true and false targets are always the last two inputs 632 Label* tlabel = branch->true_label;
634 // to the instruction. 633 Label* flabel = branch->false_label;
635 BasicBlock::RpoNumber tblock = 634 switch (branch->condition) {
636 i.InputRpo(static_cast<int>(instr->InputCount()) - 2);
637 BasicBlock::RpoNumber fblock =
638 i.InputRpo(static_cast<int>(instr->InputCount()) - 1);
639 bool fallthru = IsNextInAssemblyOrder(fblock);
640 Label* tlabel = GetLabel(tblock);
641 Label* flabel = fallthru ? &done : GetLabel(fblock);
642 Label::Distance flabel_distance = fallthru ? Label::kNear : Label::kFar;
643 switch (condition) {
644 case kUnorderedEqual: 635 case kUnorderedEqual:
645 __ j(parity_even, flabel, flabel_distance); 636 __ j(parity_even, flabel, flabel_distance);
646 // Fall through. 637 // Fall through.
647 case kEqual: 638 case kEqual:
648 __ j(equal, tlabel); 639 __ j(equal, tlabel);
649 break; 640 break;
650 case kUnorderedNotEqual: 641 case kUnorderedNotEqual:
651 __ j(parity_even, tlabel); 642 __ j(parity_even, tlabel);
652 // Fall through. 643 // Fall through.
653 case kNotEqual: 644 case kNotEqual:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 case kUnsignedGreaterThan: 680 case kUnsignedGreaterThan:
690 __ j(above, tlabel); 681 __ j(above, tlabel);
691 break; 682 break;
692 case kOverflow: 683 case kOverflow:
693 __ j(overflow, tlabel); 684 __ j(overflow, tlabel);
694 break; 685 break;
695 case kNotOverflow: 686 case kNotOverflow:
696 __ j(no_overflow, tlabel); 687 __ j(no_overflow, tlabel);
697 break; 688 break;
698 } 689 }
699 if (!fallthru) __ jmp(flabel, flabel_distance); // no fallthru to flabel. 690 if (!branch->fallthru) __ jmp(flabel, flabel_distance);
700 __ bind(&done);
701 } 691 }
702 692
703 693
694 void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) {
695 if (!IsNextInAssemblyOrder(target)) __ jmp(GetLabel(target));
696 }
697
698
704 // Assembles boolean materializations after this instruction. 699 // Assembles boolean materializations after this instruction.
705 void CodeGenerator::AssembleArchBoolean(Instruction* instr, 700 void CodeGenerator::AssembleArchBoolean(Instruction* instr,
706 FlagsCondition condition) { 701 FlagsCondition condition) {
707 X64OperandConverter i(this, instr); 702 X64OperandConverter i(this, instr);
708 Label done; 703 Label done;
709 704
710 // Materialize a full 64-bit 1 or 0 value. The result register is always the 705 // Materialize a full 64-bit 1 or 0 value. The result register is always the
711 // last output of the instruction. 706 // last output of the instruction.
712 Label check; 707 Label check;
713 DCHECK_NE(0, static_cast<int>(instr->OutputCount())); 708 DCHECK_NE(0, static_cast<int>(instr->OutputCount()));
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 } 1026 }
1032 } 1027 }
1033 MarkLazyDeoptSite(); 1028 MarkLazyDeoptSite();
1034 } 1029 }
1035 1030
1036 #undef __ 1031 #undef __
1037 1032
1038 } // namespace internal 1033 } // namespace internal
1039 } // namespace compiler 1034 } // namespace compiler
1040 } // namespace v8 1035 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips64/instruction-selector-mips64.cc ('k') | src/compiler/x64/instruction-selector-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698