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

Side by Side Diff: src/cfg.cc

Issue 165237: Factored out common Instruction code in the CFG builder that depends only... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « src/cfg.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 PrintF("--- Code ---\n"); 194 PrintF("--- Code ---\n");
195 code->Disassemble(*fun->name()->ToCString()); 195 code->Disassemble(*fun->name()->ToCString());
196 } 196 }
197 #endif 197 #endif
198 198
199 return code; 199 return code;
200 } 200 }
201 201
202 202
203 void MoveInstr::FastAllocate(TempLocation* temp) { 203 void ZeroOperandInstruction::FastAllocate(TempLocation* temp) {
204 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); 204 temp->set_where(TempLocation::STACK);
205 if (temp == value()) {
206 temp->set_where(TempLocation::ACCUMULATOR);
207 } else {
208 temp->set_where(TempLocation::STACK);
209 }
210 } 205 }
211 206
212 207
213 void PropLoadInstr::FastAllocate(TempLocation* temp) { 208 void OneOperandInstruction::FastAllocate(TempLocation* temp) {
214 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); 209 temp->set_where((temp == value_)
215 if (temp == object() || temp == key()) { 210 ? TempLocation::ACCUMULATOR
216 temp->set_where(TempLocation::ACCUMULATOR); 211 : TempLocation::STACK);
217 } else {
218 temp->set_where(TempLocation::STACK);
219 }
220 } 212 }
221 213
222 214
223 void BinaryOpInstr::FastAllocate(TempLocation* temp) { 215 void TwoOperandInstruction::FastAllocate(TempLocation* temp) {
224 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); 216 temp->set_where((temp == value0_ || temp == value1_)
225 if (temp == left() || temp == right()) { 217 ? TempLocation::ACCUMULATOR
226 temp->set_where(TempLocation::ACCUMULATOR); 218 : TempLocation::STACK);
227 } else {
228 temp->set_where(TempLocation::STACK);
229 }
230 }
231
232
233 void ReturnInstr::FastAllocate(TempLocation* temp) {
234 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
235 if (temp == value()) {
236 temp->set_where(TempLocation::ACCUMULATOR);
237 } else {
238 temp->set_where(TempLocation::STACK);
239 }
240 } 219 }
241 220
242 221
243 void PositionInstr::Compile(MacroAssembler* masm) { 222 void PositionInstr::Compile(MacroAssembler* masm) {
244 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) { 223 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) {
245 masm->RecordStatementPosition(pos_); 224 masm->RecordStatementPosition(pos_);
246 masm->RecordPosition(pos_); 225 masm->RecordPosition(pos_);
247 } 226 }
248 } 227 }
249 228
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 #ifdef DEBUG 611 #ifdef DEBUG
633 // CFG printing support (via depth-first, preorder block traversal). 612 // CFG printing support (via depth-first, preorder block traversal).
634 613
635 void Cfg::Print() { 614 void Cfg::Print() {
636 entry_->Print(); 615 entry_->Print();
637 entry_->Unmark(); 616 entry_->Unmark();
638 } 617 }
639 618
640 619
641 void Constant::Print() { 620 void Constant::Print() {
642 PrintF("Constant("); 621 PrintF("Constant ");
643 handle_->Print(); 622 handle_->Print();
644 PrintF(")");
645 } 623 }
646 624
647 625
648 void Nowhere::Print() { 626 void Nowhere::Print() {
649 PrintF("Nowhere"); 627 PrintF("Nowhere");
650 } 628 }
651 629
652 630
653 void SlotLocation::Print() { 631 void SlotLocation::Print() {
654 PrintF("Slot("); 632 PrintF("Slot ");
655 switch (type_) { 633 switch (type_) {
656 case Slot::PARAMETER: 634 case Slot::PARAMETER:
657 PrintF("PARAMETER, %d)", index_); 635 PrintF("(PARAMETER, %d)", index_);
658 break; 636 break;
659 case Slot::LOCAL: 637 case Slot::LOCAL:
660 PrintF("LOCAL, %d)", index_); 638 PrintF("(LOCAL, %d)", index_);
661 break; 639 break;
662 default: 640 default:
663 UNREACHABLE(); 641 UNREACHABLE();
664 } 642 }
665 } 643 }
666 644
667 645
668 void TempLocation::Print() { 646 void TempLocation::Print() {
669 PrintF("Temp(%d)", number()); 647 PrintF("Temp %d", number());
648 }
649
650
651 void OneOperandInstruction::Print() {
652 PrintF("(");
653 location()->Print();
654 PrintF(", ");
655 value_->Print();
656 PrintF(")");
657 }
658
659
660 void TwoOperandInstruction::Print() {
661 PrintF("(");
662 location()->Print();
663 PrintF(", ");
664 value0_->Print();
665 PrintF(", ");
666 value1_->Print();
667 PrintF(")");
670 } 668 }
671 669
672 670
673 void MoveInstr::Print() { 671 void MoveInstr::Print() {
674 PrintF("Move("); 672 PrintF("Move ");
675 location()->Print(); 673 OneOperandInstruction::Print();
676 PrintF(", "); 674 PrintF("\n");
677 value_->Print();
678 PrintF(")\n");
679 } 675 }
680 676
681 677
682 void PropLoadInstr::Print() { 678 void PropLoadInstr::Print() {
683 PrintF("PropLoad("); 679 PrintF("PropLoad ");
684 location()->Print(); 680 TwoOperandInstruction::Print();
685 PrintF(", "); 681 PrintF("\n");
686 object()->Print();
687 PrintF(", ");
688 key()->Print();
689 PrintF(")\n");
690 } 682 }
691 683
692 684
693 void BinaryOpInstr::Print() { 685 void BinaryOpInstr::Print() {
694 PrintF("BinaryOp("); 686 switch (op()) {
695 location()->Print(); 687 case Token::OR:
696 PrintF(", %s, ", Token::Name(op())); 688 // Two character operand.
697 left()->Print(); 689 PrintF("BinaryOp[OR] ");
698 PrintF(", "); 690 break;
699 right()->Print(); 691 case Token::AND:
700 PrintF(")\n"); 692 case Token::SHL:
693 case Token::SAR:
694 case Token::SHR:
695 case Token::ADD:
696 case Token::SUB:
697 case Token::MUL:
698 case Token::DIV:
699 case Token::MOD:
700 // Three character operands.
701 PrintF("BinaryOp[%s] ", Token::Name(op()));
702 break;
703 case Token::COMMA:
704 // Five character operand.
705 PrintF("BinaryOp[COMMA] ");
706 break;
707 case Token::BIT_OR:
708 // Six character operand.
709 PrintF("BinaryOp[BIT_OR] ");
710 break;
711 case Token::BIT_XOR:
712 case Token::BIT_AND:
713 // Seven character operands.
714 PrintF("BinaryOp[%s] ", Token::Name(op()));
William Hesse 2009/08/10 12:47:08 If we print this on two lines, or don't print "Bin
Kevin Millikin (Chromium) 2009/08/10 12:59:11 Printing on two lines seems annoying. I'd much ra
715 break;
716 default:
717 UNREACHABLE();
718 }
719 TwoOperandInstruction::Print();
720 PrintF("\n");
701 } 721 }
702 722
703 723
704 void ReturnInstr::Print() { 724 void ReturnInstr::Print() {
705 PrintF("Return("); 725 PrintF("Return ");
706 value_->Print(); 726 OneOperandInstruction::Print();
707 PrintF(")\n"); 727 PrintF("\n");
708 } 728 }
709 729
710 730
711 void InstructionBlock::Print() { 731 void InstructionBlock::Print() {
712 if (!is_marked_) { 732 if (!is_marked_) {
713 is_marked_ = true; 733 is_marked_ = true;
714 PrintF("L%d:\n", number()); 734 PrintF("L%d:\n", number());
William Hesse 2009/08/10 12:47:08 number is a pretty non-descriptive name for the no
Kevin Millikin (Chromium) 2009/08/10 12:59:11 CfgNode::number() doesn't seem non-descriptive for
715 for (int i = 0, len = instructions_.length(); i < len; i++) { 735 for (int i = 0, len = instructions_.length(); i < len; i++) {
716 instructions_[i]->Print(); 736 instructions_[i]->Print();
717 } 737 }
718 PrintF("Goto L%d\n\n", successor_->number()); 738 PrintF("Goto L%d\n\n", successor_->number());
719 successor_->Print(); 739 successor_->Print();
720 } 740 }
721 } 741 }
722 742
723 743
724 void EntryNode::Print() { 744 void EntryNode::Print() {
725 if (!is_marked_) { 745 if (!is_marked_) {
726 is_marked_ = true; 746 is_marked_ = true;
727 successor_->Print(); 747 successor_->Print();
728 } 748 }
729 } 749 }
730 750
731 751
732 void ExitNode::Print() { 752 void ExitNode::Print() {
733 if (!is_marked_) { 753 if (!is_marked_) {
734 is_marked_ = true; 754 is_marked_ = true;
735 PrintF("L%d:\nExit\n\n", number()); 755 PrintF("L%d:\nExit\n\n", number());
736 } 756 }
737 } 757 }
738 758
739 #endif // DEBUG 759 #endif // DEBUG
740 760
741 } } // namespace v8::internal 761 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/cfg.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698