OLD | NEW |
---|---|
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 30 matching lines...) Expand all Loading... | |
41 namespace v8 { | 41 namespace v8 { |
42 namespace internal { | 42 namespace internal { |
43 | 43 |
44 | 44 |
45 class CodeGenSelector: public AstVisitor { | 45 class CodeGenSelector: public AstVisitor { |
46 public: | 46 public: |
47 enum CodeGenTag { NORMAL, FAST }; | 47 enum CodeGenTag { NORMAL, FAST }; |
48 | 48 |
49 CodeGenSelector() | 49 CodeGenSelector() |
50 : has_supported_syntax_(true), | 50 : has_supported_syntax_(true), |
51 location_(Location::Uninitialized()) { | 51 context_(Expression::kUninitialized) { |
52 } | 52 } |
53 | 53 |
54 CodeGenTag Select(FunctionLiteral* fun); | 54 CodeGenTag Select(FunctionLiteral* fun); |
55 | 55 |
56 private: | 56 private: |
57 // Visit an expression in a given expression context. | |
58 void ProcessExpression(Expression::Context context, Expression* expr) { | |
William Hesse
2009/10/29 15:15:25
Could this be called VisitExpression?
I think the
Kevin Millikin (Chromium)
2009/10/29 16:36:10
I will change the order of arguments, and I'm open
| |
59 Expression::Context saved = context_; | |
60 context_ = context; | |
61 Visit(expr); | |
62 expr->set_context(context); | |
63 context_ = saved; | |
64 } | |
65 | |
57 void VisitDeclarations(ZoneList<Declaration*>* decls); | 66 void VisitDeclarations(ZoneList<Declaration*>* decls); |
58 void VisitStatements(ZoneList<Statement*>* stmts); | 67 void VisitStatements(ZoneList<Statement*>* stmts); |
59 | 68 |
60 // Visit an expression in effect context with a desired location of | |
61 // nowhere. | |
62 void VisitAsEffect(Expression* expr); | |
63 | |
64 // Visit an expression in value context with a desired location of | |
65 // temporary. | |
66 void VisitAsValue(Expression* expr); | |
67 | |
68 // AST node visit functions. | 69 // AST node visit functions. |
69 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 70 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
70 AST_NODE_LIST(DECLARE_VISIT) | 71 AST_NODE_LIST(DECLARE_VISIT) |
71 #undef DECLARE_VISIT | 72 #undef DECLARE_VISIT |
72 | 73 |
73 bool has_supported_syntax_; | 74 bool has_supported_syntax_; |
74 | 75 |
75 // The desired location of the currently visited expression. | 76 // The desired expression context of the currently visited expression. |
76 Location location_; | 77 Expression::Context context_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(CodeGenSelector); | 79 DISALLOW_COPY_AND_ASSIGN(CodeGenSelector); |
79 }; | 80 }; |
80 | 81 |
81 | 82 |
82 static Handle<Code> MakeCode(FunctionLiteral* literal, | 83 static Handle<Code> MakeCode(FunctionLiteral* literal, |
83 Handle<Script> script, | 84 Handle<Script> script, |
84 Handle<Context> context, | 85 Handle<Context> context, |
85 bool is_eval) { | 86 bool is_eval) { |
86 ASSERT(literal != NULL); | 87 ASSERT(literal != NULL); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 | 507 |
507 | 508 |
508 void CodeGenSelector::VisitStatements(ZoneList<Statement*>* stmts) { | 509 void CodeGenSelector::VisitStatements(ZoneList<Statement*>* stmts) { |
509 for (int i = 0, len = stmts->length(); i < len; i++) { | 510 for (int i = 0, len = stmts->length(); i < len; i++) { |
510 Visit(stmts->at(i)); | 511 Visit(stmts->at(i)); |
511 CHECK_BAILOUT; | 512 CHECK_BAILOUT; |
512 } | 513 } |
513 } | 514 } |
514 | 515 |
515 | 516 |
516 void CodeGenSelector::VisitAsEffect(Expression* expr) { | |
517 if (location_.is_effect()) { | |
518 Visit(expr); | |
519 } else { | |
520 Location saved = location_; | |
521 location_ = Location::Effect(); | |
522 Visit(expr); | |
523 location_ = saved; | |
524 } | |
525 } | |
526 | |
527 | |
528 void CodeGenSelector::VisitAsValue(Expression* expr) { | |
529 if (location_.is_value()) { | |
530 Visit(expr); | |
531 } else { | |
532 Location saved = location_; | |
533 location_ = Location::Value(); | |
534 Visit(expr); | |
535 location_ = saved; | |
536 } | |
537 } | |
538 | |
539 | |
540 void CodeGenSelector::VisitDeclaration(Declaration* decl) { | 517 void CodeGenSelector::VisitDeclaration(Declaration* decl) { |
541 Variable* var = decl->proxy()->var(); | 518 Variable* var = decl->proxy()->var(); |
542 if (!var->is_global() || var->mode() == Variable::CONST) { | 519 if (!var->is_global() || var->mode() == Variable::CONST) { |
543 BAILOUT("Non-global declaration"); | 520 BAILOUT("Non-global declaration"); |
544 } | 521 } |
545 } | 522 } |
546 | 523 |
547 | 524 |
548 void CodeGenSelector::VisitBlock(Block* stmt) { | 525 void CodeGenSelector::VisitBlock(Block* stmt) { |
549 VisitStatements(stmt->statements()); | 526 VisitStatements(stmt->statements()); |
550 } | 527 } |
551 | 528 |
552 | 529 |
553 void CodeGenSelector::VisitExpressionStatement(ExpressionStatement* stmt) { | 530 void CodeGenSelector::VisitExpressionStatement(ExpressionStatement* stmt) { |
554 VisitAsEffect(stmt->expression()); | 531 ProcessExpression(Expression::kEffect, stmt->expression()); |
555 } | 532 } |
556 | 533 |
557 | 534 |
558 void CodeGenSelector::VisitEmptyStatement(EmptyStatement* stmt) { | 535 void CodeGenSelector::VisitEmptyStatement(EmptyStatement* stmt) { |
559 // EmptyStatement is supported. | 536 // EmptyStatement is supported. |
560 } | 537 } |
561 | 538 |
562 | 539 |
563 void CodeGenSelector::VisitIfStatement(IfStatement* stmt) { | 540 void CodeGenSelector::VisitIfStatement(IfStatement* stmt) { |
564 BAILOUT("IfStatement"); | 541 BAILOUT("IfStatement"); |
565 } | 542 } |
566 | 543 |
567 | 544 |
568 void CodeGenSelector::VisitContinueStatement(ContinueStatement* stmt) { | 545 void CodeGenSelector::VisitContinueStatement(ContinueStatement* stmt) { |
569 BAILOUT("ContinueStatement"); | 546 BAILOUT("ContinueStatement"); |
570 } | 547 } |
571 | 548 |
572 | 549 |
573 void CodeGenSelector::VisitBreakStatement(BreakStatement* stmt) { | 550 void CodeGenSelector::VisitBreakStatement(BreakStatement* stmt) { |
574 BAILOUT("BreakStatement"); | 551 BAILOUT("BreakStatement"); |
575 } | 552 } |
576 | 553 |
577 | 554 |
578 void CodeGenSelector::VisitReturnStatement(ReturnStatement* stmt) { | 555 void CodeGenSelector::VisitReturnStatement(ReturnStatement* stmt) { |
579 VisitAsValue(stmt->expression()); | 556 ProcessExpression(Expression::kValue, stmt->expression()); |
580 } | 557 } |
581 | 558 |
582 | 559 |
583 void CodeGenSelector::VisitWithEnterStatement(WithEnterStatement* stmt) { | 560 void CodeGenSelector::VisitWithEnterStatement(WithEnterStatement* stmt) { |
584 BAILOUT("WithEnterStatement"); | 561 BAILOUT("WithEnterStatement"); |
585 } | 562 } |
586 | 563 |
587 | 564 |
588 void CodeGenSelector::VisitWithExitStatement(WithExitStatement* stmt) { | 565 void CodeGenSelector::VisitWithExitStatement(WithExitStatement* stmt) { |
589 BAILOUT("WithExitStatement"); | 566 BAILOUT("WithExitStatement"); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 | 604 |
628 void CodeGenSelector::VisitDebuggerStatement(DebuggerStatement* stmt) { | 605 void CodeGenSelector::VisitDebuggerStatement(DebuggerStatement* stmt) { |
629 BAILOUT("DebuggerStatement"); | 606 BAILOUT("DebuggerStatement"); |
630 } | 607 } |
631 | 608 |
632 | 609 |
633 void CodeGenSelector::VisitFunctionLiteral(FunctionLiteral* expr) { | 610 void CodeGenSelector::VisitFunctionLiteral(FunctionLiteral* expr) { |
634 if (!expr->AllowsLazyCompilation()) { | 611 if (!expr->AllowsLazyCompilation()) { |
635 BAILOUT("FunctionLiteral does not allow lazy compilation"); | 612 BAILOUT("FunctionLiteral does not allow lazy compilation"); |
636 } | 613 } |
637 expr->set_location(location_); | |
638 } | 614 } |
639 | 615 |
640 | 616 |
641 void CodeGenSelector::VisitFunctionBoilerplateLiteral( | 617 void CodeGenSelector::VisitFunctionBoilerplateLiteral( |
642 FunctionBoilerplateLiteral* expr) { | 618 FunctionBoilerplateLiteral* expr) { |
643 BAILOUT("FunctionBoilerplateLiteral"); | 619 BAILOUT("FunctionBoilerplateLiteral"); |
644 } | 620 } |
645 | 621 |
646 | 622 |
647 void CodeGenSelector::VisitConditional(Conditional* expr) { | 623 void CodeGenSelector::VisitConditional(Conditional* expr) { |
(...skipping 16 matching lines...) Expand all Loading... | |
664 // This is a variable rewritten to an explicit property access | 640 // This is a variable rewritten to an explicit property access |
665 // on the arguments object. | 641 // on the arguments object. |
666 BAILOUT("non-global/non-slot variable reference"); | 642 BAILOUT("non-global/non-slot variable reference"); |
667 } | 643 } |
668 | 644 |
669 Slot::Type type = slot->type(); | 645 Slot::Type type = slot->type(); |
670 if (type != Slot::PARAMETER && type != Slot::LOCAL) { | 646 if (type != Slot::PARAMETER && type != Slot::LOCAL) { |
671 BAILOUT("non-parameter/non-local slot reference"); | 647 BAILOUT("non-parameter/non-local slot reference"); |
672 } | 648 } |
673 } | 649 } |
674 expr->set_location(location_); | |
675 } | 650 } |
676 | 651 |
677 | 652 |
678 void CodeGenSelector::VisitLiteral(Literal* expr) { | 653 void CodeGenSelector::VisitLiteral(Literal* expr) { |
679 expr->set_location(location_); | 654 /* Nothing to do. */ |
680 } | 655 } |
681 | 656 |
682 | 657 |
683 void CodeGenSelector::VisitRegExpLiteral(RegExpLiteral* expr) { | 658 void CodeGenSelector::VisitRegExpLiteral(RegExpLiteral* expr) { |
684 expr->set_location(location_); | 659 /* Nothing to do. */ |
685 } | 660 } |
686 | 661 |
687 | 662 |
688 void CodeGenSelector::VisitObjectLiteral(ObjectLiteral* expr) { | 663 void CodeGenSelector::VisitObjectLiteral(ObjectLiteral* expr) { |
689 ZoneList<ObjectLiteral::Property*>* properties = expr->properties(); | 664 ZoneList<ObjectLiteral::Property*>* properties = expr->properties(); |
690 | 665 |
691 for (int i = 0, len = properties->length(); i < len; i++) { | 666 for (int i = 0, len = properties->length(); i < len; i++) { |
692 ObjectLiteral::Property* property = properties->at(i); | 667 ObjectLiteral::Property* property = properties->at(i); |
693 if (property->IsCompileTimeValue()) continue; | 668 if (property->IsCompileTimeValue()) continue; |
694 | 669 |
695 switch (property->kind()) { | 670 switch (property->kind()) { |
696 case ObjectLiteral::Property::CONSTANT: | 671 case ObjectLiteral::Property::CONSTANT: |
697 UNREACHABLE(); | 672 UNREACHABLE(); |
698 | 673 |
699 // For (non-compile-time) materialized literals and computed | 674 // For (non-compile-time) materialized literals and computed |
700 // properties with symbolic keys we will use an IC and therefore not | 675 // properties with symbolic keys we will use an IC and therefore not |
701 // generate code for the key. | 676 // generate code for the key. |
702 case ObjectLiteral::Property::COMPUTED: // Fall through. | 677 case ObjectLiteral::Property::COMPUTED: // Fall through. |
703 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 678 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
704 if (property->key()->handle()->IsSymbol()) { | 679 if (property->key()->handle()->IsSymbol()) { |
705 break; | 680 break; |
706 } | 681 } |
707 // Fall through. | 682 // Fall through. |
708 | 683 |
709 // In all other cases we need the key's value on the stack | 684 // In all other cases we need the key's value on the stack |
710 // for a runtime call. (Relies on TEMP meaning STACK.) | 685 // for a runtime call. (Relies on TEMP meaning STACK.) |
711 case ObjectLiteral::Property::GETTER: // Fall through. | 686 case ObjectLiteral::Property::GETTER: // Fall through. |
712 case ObjectLiteral::Property::SETTER: // Fall through. | 687 case ObjectLiteral::Property::SETTER: // Fall through. |
713 case ObjectLiteral::Property::PROTOTYPE: | 688 case ObjectLiteral::Property::PROTOTYPE: |
714 VisitAsValue(property->key()); | 689 ProcessExpression(Expression::kValue, property->key()); |
715 CHECK_BAILOUT; | 690 CHECK_BAILOUT; |
716 break; | 691 break; |
717 } | 692 } |
718 VisitAsValue(property->value()); | 693 ProcessExpression(Expression::kValue, property->value()); |
719 CHECK_BAILOUT; | 694 CHECK_BAILOUT; |
720 } | 695 } |
721 expr->set_location(location_); | |
722 } | 696 } |
723 | 697 |
724 | 698 |
725 void CodeGenSelector::VisitArrayLiteral(ArrayLiteral* expr) { | 699 void CodeGenSelector::VisitArrayLiteral(ArrayLiteral* expr) { |
726 ZoneList<Expression*>* subexprs = expr->values(); | 700 ZoneList<Expression*>* subexprs = expr->values(); |
727 for (int i = 0, len = subexprs->length(); i < len; i++) { | 701 for (int i = 0, len = subexprs->length(); i < len; i++) { |
728 Expression* subexpr = subexprs->at(i); | 702 Expression* subexpr = subexprs->at(i); |
729 if (subexpr->AsLiteral() != NULL) continue; | 703 if (subexpr->AsLiteral() != NULL) continue; |
730 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 704 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
731 VisitAsValue(subexpr); | 705 ProcessExpression(Expression::kValue, subexpr); |
732 CHECK_BAILOUT; | 706 CHECK_BAILOUT; |
733 } | 707 } |
734 expr->set_location(location_); | |
735 } | 708 } |
736 | 709 |
737 | 710 |
738 void CodeGenSelector::VisitCatchExtensionObject(CatchExtensionObject* expr) { | 711 void CodeGenSelector::VisitCatchExtensionObject(CatchExtensionObject* expr) { |
739 BAILOUT("CatchExtensionObject"); | 712 BAILOUT("CatchExtensionObject"); |
740 } | 713 } |
741 | 714 |
742 | 715 |
743 void CodeGenSelector::VisitAssignment(Assignment* expr) { | 716 void CodeGenSelector::VisitAssignment(Assignment* expr) { |
744 // We support plain non-compound assignments to parameters and | 717 // We support plain non-compound assignments to parameters and |
(...skipping 13 matching lines...) Expand all Loading... | |
758 if (var == NULL) BAILOUT("non-variable assignment"); | 731 if (var == NULL) BAILOUT("non-variable assignment"); |
759 | 732 |
760 if (!var->is_global()) { | 733 if (!var->is_global()) { |
761 ASSERT(var->slot() != NULL); | 734 ASSERT(var->slot() != NULL); |
762 Slot::Type type = var->slot()->type(); | 735 Slot::Type type = var->slot()->type(); |
763 if (type != Slot::PARAMETER && type != Slot::LOCAL) { | 736 if (type != Slot::PARAMETER && type != Slot::LOCAL) { |
764 BAILOUT("non-parameter/non-local slot assignment"); | 737 BAILOUT("non-parameter/non-local slot assignment"); |
765 } | 738 } |
766 } | 739 } |
767 | 740 |
768 VisitAsValue(expr->value()); | 741 ProcessExpression(Expression::kValue, expr->value()); |
769 expr->set_location(location_); | |
770 } | 742 } |
771 | 743 |
772 | 744 |
773 void CodeGenSelector::VisitThrow(Throw* expr) { | 745 void CodeGenSelector::VisitThrow(Throw* expr) { |
774 BAILOUT("Throw"); | 746 BAILOUT("Throw"); |
775 } | 747 } |
776 | 748 |
777 | 749 |
778 void CodeGenSelector::VisitProperty(Property* expr) { | 750 void CodeGenSelector::VisitProperty(Property* expr) { |
779 VisitAsValue(expr->obj()); | 751 ProcessExpression(Expression::kValue, expr->obj()); |
780 CHECK_BAILOUT; | 752 CHECK_BAILOUT; |
781 VisitAsValue(expr->key()); | 753 ProcessExpression(Expression::kValue, expr->key()); |
782 expr->set_location(location_); | |
783 } | 754 } |
784 | 755 |
785 | 756 |
786 void CodeGenSelector::VisitCall(Call* expr) { | 757 void CodeGenSelector::VisitCall(Call* expr) { |
787 Expression* fun = expr->expression(); | 758 Expression* fun = expr->expression(); |
788 ZoneList<Expression*>* args = expr->arguments(); | 759 ZoneList<Expression*>* args = expr->arguments(); |
789 Variable* var = fun->AsVariableProxy()->AsVariable(); | 760 Variable* var = fun->AsVariableProxy()->AsVariable(); |
790 | 761 |
791 // Check for supported calls | 762 // Check for supported calls |
792 if (var != NULL && var->is_possibly_eval()) { | 763 if (var != NULL && var->is_possibly_eval()) { |
793 BAILOUT("Call to a function named 'eval'"); | 764 BAILOUT("Call to a function named 'eval'"); |
794 } else if (var != NULL && !var->is_this() && var->is_global()) { | 765 } else if (var != NULL && !var->is_this() && var->is_global()) { |
795 // ---------------------------------- | 766 // ---------------------------------- |
796 // JavaScript example: 'foo(1, 2, 3)' // foo is global | 767 // JavaScript example: 'foo(1, 2, 3)' // foo is global |
797 // ---------------------------------- | 768 // ---------------------------------- |
798 } else { | 769 } else { |
799 BAILOUT("Call to a non-global function"); | 770 BAILOUT("Call to a non-global function"); |
800 } | 771 } |
801 // Check all arguments to the call. (Relies on TEMP meaning STACK.) | 772 // Check all arguments to the call. (Relies on TEMP meaning STACK.) |
802 for (int i = 0; i < args->length(); i++) { | 773 for (int i = 0; i < args->length(); i++) { |
803 VisitAsValue(args->at(i)); | 774 ProcessExpression(Expression::kValue, args->at(i)); |
804 CHECK_BAILOUT; | 775 CHECK_BAILOUT; |
805 } | 776 } |
806 expr->set_location(location_); | |
807 } | 777 } |
808 | 778 |
809 | 779 |
810 void CodeGenSelector::VisitCallNew(CallNew* expr) { | 780 void CodeGenSelector::VisitCallNew(CallNew* expr) { |
811 VisitAsValue(expr->expression()); | 781 ProcessExpression(Expression::kValue, expr->expression()); |
812 CHECK_BAILOUT; | 782 CHECK_BAILOUT; |
813 ZoneList<Expression*>* args = expr->arguments(); | 783 ZoneList<Expression*>* args = expr->arguments(); |
814 // Check all arguments to the call | 784 // Check all arguments to the call |
815 for (int i = 0; i < args->length(); i++) { | 785 for (int i = 0; i < args->length(); i++) { |
816 VisitAsValue(args->at(i)); | 786 ProcessExpression(Expression::kValue, args->at(i)); |
817 CHECK_BAILOUT; | 787 CHECK_BAILOUT; |
818 } | 788 } |
819 expr->set_location(location_); | |
820 } | 789 } |
821 | 790 |
822 | 791 |
823 void CodeGenSelector::VisitCallRuntime(CallRuntime* expr) { | 792 void CodeGenSelector::VisitCallRuntime(CallRuntime* expr) { |
824 // In case of JS runtime function bail out. | 793 // In case of JS runtime function bail out. |
825 if (expr->function() == NULL) BAILOUT("call JS runtime function"); | 794 if (expr->function() == NULL) BAILOUT("call JS runtime function"); |
826 // Check for inline runtime call | 795 // Check for inline runtime call |
827 if (expr->name()->Get(0) == '_' && | 796 if (expr->name()->Get(0) == '_' && |
828 CodeGenerator::FindInlineRuntimeLUT(expr->name()) != NULL) { | 797 CodeGenerator::FindInlineRuntimeLUT(expr->name()) != NULL) { |
829 BAILOUT("inlined runtime call"); | 798 BAILOUT("inlined runtime call"); |
830 } | 799 } |
831 // Check all arguments to the call. (Relies on TEMP meaning STACK.) | 800 // Check all arguments to the call. (Relies on TEMP meaning STACK.) |
832 for (int i = 0; i < expr->arguments()->length(); i++) { | 801 for (int i = 0; i < expr->arguments()->length(); i++) { |
833 VisitAsValue(expr->arguments()->at(i)); | 802 ProcessExpression(Expression::kValue, expr->arguments()->at(i)); |
834 CHECK_BAILOUT; | 803 CHECK_BAILOUT; |
835 } | 804 } |
836 expr->set_location(location_); | |
837 } | 805 } |
838 | 806 |
839 | 807 |
840 void CodeGenSelector::VisitUnaryOperation(UnaryOperation* expr) { | 808 void CodeGenSelector::VisitUnaryOperation(UnaryOperation* expr) { |
841 BAILOUT("UnaryOperation"); | 809 BAILOUT("UnaryOperation"); |
842 } | 810 } |
843 | 811 |
844 | 812 |
845 void CodeGenSelector::VisitCountOperation(CountOperation* expr) { | 813 void CodeGenSelector::VisitCountOperation(CountOperation* expr) { |
846 BAILOUT("CountOperation"); | 814 BAILOUT("CountOperation"); |
847 } | 815 } |
848 | 816 |
849 | 817 |
850 void CodeGenSelector::VisitBinaryOperation(BinaryOperation* expr) { | 818 void CodeGenSelector::VisitBinaryOperation(BinaryOperation* expr) { |
851 switch (expr->op()) { | 819 switch (expr->op()) { |
852 case Token::COMMA: | 820 case Token::COMMA: |
853 VisitAsEffect(expr->left()); | 821 ProcessExpression(Expression::kEffect, expr->left()); |
854 CHECK_BAILOUT; | 822 CHECK_BAILOUT; |
855 Visit(expr->right()); // Location is the same as the parent location. | 823 ProcessExpression(context_, expr->right()); |
856 break; | 824 break; |
857 | 825 |
858 case Token::OR: | 826 case Token::OR: |
859 VisitAsValue(expr->left()); | 827 ProcessExpression(Expression::kValue, expr->left()); |
860 CHECK_BAILOUT; | 828 CHECK_BAILOUT; |
861 // The location for the right subexpression is the same as for the | 829 ProcessExpression(context_, expr->right()); |
862 // whole expression so we call Visit directly. | |
863 Visit(expr->right()); | |
864 break; | 830 break; |
865 | 831 |
866 case Token::ADD: | 832 case Token::ADD: |
867 case Token::SUB: | 833 case Token::SUB: |
868 case Token::DIV: | 834 case Token::DIV: |
869 case Token::MOD: | 835 case Token::MOD: |
870 case Token::MUL: | 836 case Token::MUL: |
871 case Token::BIT_OR: | 837 case Token::BIT_OR: |
872 case Token::BIT_AND: | 838 case Token::BIT_AND: |
873 case Token::BIT_XOR: | 839 case Token::BIT_XOR: |
874 case Token::SHL: | 840 case Token::SHL: |
875 case Token::SHR: | 841 case Token::SHR: |
876 case Token::SAR: | 842 case Token::SAR: |
877 VisitAsValue(expr->left()); | 843 ProcessExpression(Expression::kValue, expr->left()); |
878 CHECK_BAILOUT; | 844 CHECK_BAILOUT; |
879 VisitAsValue(expr->right()); | 845 ProcessExpression(Expression::kValue, expr->right()); |
880 break; | 846 break; |
881 | 847 |
882 default: | 848 default: |
883 BAILOUT("Unsupported binary operation"); | 849 BAILOUT("Unsupported binary operation"); |
884 } | 850 } |
885 expr->set_location(location_); | |
886 } | 851 } |
887 | 852 |
888 | 853 |
889 void CodeGenSelector::VisitCompareOperation(CompareOperation* expr) { | 854 void CodeGenSelector::VisitCompareOperation(CompareOperation* expr) { |
890 BAILOUT("CompareOperation"); | 855 BAILOUT("CompareOperation"); |
891 } | 856 } |
892 | 857 |
893 | 858 |
894 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) { | 859 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) { |
895 BAILOUT("ThisFunction"); | 860 BAILOUT("ThisFunction"); |
896 } | 861 } |
897 | 862 |
898 #undef BAILOUT | 863 #undef BAILOUT |
899 #undef CHECK_BAILOUT | 864 #undef CHECK_BAILOUT |
900 | 865 |
901 | 866 |
902 } } // namespace v8::internal | 867 } } // namespace v8::internal |
OLD | NEW |