| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 } | 426 } |
| 427 | 427 |
| 428 | 428 |
| 429 void FlowGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 429 void FlowGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
| 430 SetStackOverflow(); | 430 SetStackOverflow(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 | 433 |
| 434 #ifdef DEBUG | 434 #ifdef DEBUG |
| 435 | 435 |
| 436 // Print a textual representation of an instruction in a flow graph. Using | 436 // Print a textual representation of an instruction in a flow graph. |
| 437 // the AstVisitor is overkill because there is no recursion here. It is | |
| 438 // however only used for printing in debug mode. | |
| 439 class InstructionPrinter: public AstVisitor { | 437 class InstructionPrinter: public AstVisitor { |
| 440 public: | 438 public: |
| 441 InstructionPrinter() {} | 439 InstructionPrinter() {} |
| 442 | 440 |
| 443 private: | 441 private: |
| 444 // Overridden from the base class. | 442 // Overridden from the base class. |
| 445 virtual void VisitExpressions(ZoneList<Expression*>* exprs); | 443 virtual void VisitExpressions(ZoneList<Expression*>* exprs); |
| 446 | 444 |
| 447 // AST node visit functions. | 445 // AST node visit functions. |
| 448 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 446 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 UNREACHABLE(); | 585 UNREACHABLE(); |
| 588 } | 586 } |
| 589 | 587 |
| 590 | 588 |
| 591 void InstructionPrinter::VisitVariableProxy(VariableProxy* expr) { | 589 void InstructionPrinter::VisitVariableProxy(VariableProxy* expr) { |
| 592 Variable* var = expr->AsVariable(); | 590 Variable* var = expr->AsVariable(); |
| 593 if (var != NULL) { | 591 if (var != NULL) { |
| 594 PrintF("%s", *var->name()->ToCString()); | 592 PrintF("%s", *var->name()->ToCString()); |
| 595 } else { | 593 } else { |
| 596 ASSERT(expr->AsProperty() != NULL); | 594 ASSERT(expr->AsProperty() != NULL); |
| 597 VisitProperty(expr->AsProperty()); | 595 Visit(expr->AsProperty()); |
| 598 } | 596 } |
| 599 } | 597 } |
| 600 | 598 |
| 601 | 599 |
| 602 void InstructionPrinter::VisitLiteral(Literal* expr) { | 600 void InstructionPrinter::VisitLiteral(Literal* expr) { |
| 603 expr->handle()->Print(); | 601 expr->handle()->Print(); |
| 604 } | 602 } |
| 605 | 603 |
| 606 | 604 |
| 607 void InstructionPrinter::VisitRegExpLiteral(RegExpLiteral* expr) { | 605 void InstructionPrinter::VisitRegExpLiteral(RegExpLiteral* expr) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 if (HasPredecessor()) { | 717 if (HasPredecessor()) { |
| 720 PrintF("L%d:", number()); | 718 PrintF("L%d:", number()); |
| 721 } | 719 } |
| 722 | 720 |
| 723 // Number and print the instructions. Since AST child nodes are visited | 721 // Number and print the instructions. Since AST child nodes are visited |
| 724 // before their parents, the parent nodes can refer to them by number. | 722 // before their parents, the parent nodes can refer to them by number. |
| 725 InstructionPrinter printer; | 723 InstructionPrinter printer; |
| 726 for (int i = 0; i < instructions_.length(); ++i) { | 724 for (int i = 0; i < instructions_.length(); ++i) { |
| 727 PrintF("\n%d ", instruction_number); | 725 PrintF("\n%d ", instruction_number); |
| 728 instructions_[i]->set_num(instruction_number++); | 726 instructions_[i]->set_num(instruction_number++); |
| 729 printer.Visit(instructions_[i]); | 727 instructions_[i]->Accept(&printer); |
| 730 } | 728 } |
| 731 | 729 |
| 732 // If this is the exit, print "exit". If there is a single successor, | 730 // If this is the exit, print "exit". If there is a single successor, |
| 733 // print "goto" successor on a separate line. If there are two | 731 // print "goto" successor on a separate line. If there are two |
| 734 // successors, print "goto" successor on the same line as the last | 732 // successors, print "goto" successor on the same line as the last |
| 735 // instruction in the block. There is a blank line between blocks (and | 733 // instruction in the block. There is a blank line between blocks (and |
| 736 // after the last one). | 734 // after the last one). |
| 737 if (left_successor_ == NULL) { | 735 if (left_successor_ == NULL) { |
| 738 PrintF("\nexit\n\n"); | 736 PrintF("\nexit\n\n"); |
| 739 } else if (right_successor_ == NULL) { | 737 } else if (right_successor_ == NULL) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 756 int number = 0; | 754 int number = 0; |
| 757 for (int i = postorder_.length() - 1; i >= 0; --i) { | 755 for (int i = postorder_.length() - 1; i >= 0; --i) { |
| 758 number = postorder_[i]->PrintAsText(number); | 756 number = postorder_[i]->PrintAsText(number); |
| 759 } | 757 } |
| 760 } | 758 } |
| 761 | 759 |
| 762 #endif // DEBUG | 760 #endif // DEBUG |
| 763 | 761 |
| 764 | 762 |
| 765 } } // namespace v8::internal | 763 } } // namespace v8::internal |
| OLD | NEW |