OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 552 matching lines...) Loading... |
563 set_branch_analysis(nullptr); | 563 set_branch_analysis(nullptr); |
564 set_bytecode_iterator(nullptr); | 564 set_bytecode_iterator(nullptr); |
565 DCHECK(exception_handlers_.empty()); | 565 DCHECK(exception_handlers_.empty()); |
566 } | 566 } |
567 | 567 |
568 void BytecodeGraphBuilder::VisitLdaZero() { | 568 void BytecodeGraphBuilder::VisitLdaZero() { |
569 Node* node = jsgraph()->ZeroConstant(); | 569 Node* node = jsgraph()->ZeroConstant(); |
570 environment()->BindAccumulator(node); | 570 environment()->BindAccumulator(node); |
571 } | 571 } |
572 | 572 |
573 void BytecodeGraphBuilder::VisitLdaSmi8() { | 573 void BytecodeGraphBuilder::VisitLdaSmi() { |
574 Node* node = jsgraph()->Constant(bytecode_iterator().GetImmediateOperand(0)); | 574 Node* node = jsgraph()->Constant(bytecode_iterator().GetImmediateOperand(0)); |
575 environment()->BindAccumulator(node); | 575 environment()->BindAccumulator(node); |
576 } | 576 } |
577 | 577 |
578 void BytecodeGraphBuilder::VisitLdaConstantWide() { | |
579 Node* node = | |
580 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | |
581 environment()->BindAccumulator(node); | |
582 } | |
583 | |
584 void BytecodeGraphBuilder::VisitLdaConstant() { | 578 void BytecodeGraphBuilder::VisitLdaConstant() { |
585 Node* node = | 579 Node* node = |
586 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | 580 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
587 environment()->BindAccumulator(node); | 581 environment()->BindAccumulator(node); |
588 } | 582 } |
589 | 583 |
590 void BytecodeGraphBuilder::VisitLdaUndefined() { | 584 void BytecodeGraphBuilder::VisitLdaUndefined() { |
591 Node* node = jsgraph()->UndefinedConstant(); | 585 Node* node = jsgraph()->UndefinedConstant(); |
592 environment()->BindAccumulator(node); | 586 environment()->BindAccumulator(node); |
593 } | 587 } |
(...skipping 28 matching lines...) Loading... |
622 Node* value = environment()->LookupAccumulator(); | 616 Node* value = environment()->LookupAccumulator(); |
623 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value); | 617 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value); |
624 } | 618 } |
625 | 619 |
626 void BytecodeGraphBuilder::VisitMov() { | 620 void BytecodeGraphBuilder::VisitMov() { |
627 Node* value = | 621 Node* value = |
628 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 622 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
629 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); | 623 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); |
630 } | 624 } |
631 | 625 |
632 void BytecodeGraphBuilder::VisitMovWide() { VisitMov(); } | |
633 | |
634 void BytecodeGraphBuilder::BuildLoadGlobal( | 626 void BytecodeGraphBuilder::BuildLoadGlobal( |
635 TypeofMode typeof_mode) { | 627 TypeofMode typeof_mode) { |
636 FrameStateBeforeAndAfter states(this); | 628 FrameStateBeforeAndAfter states(this); |
637 Handle<Name> name = | 629 Handle<Name> name = |
638 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 630 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
639 VectorSlotPair feedback = | 631 VectorSlotPair feedback = |
640 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 632 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
641 | 633 |
642 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); | 634 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); |
643 Node* node = NewNode(op, GetFunctionClosure()); | 635 Node* node = NewNode(op, GetFunctionClosure()); |
644 environment()->BindAccumulator(node, &states); | 636 environment()->BindAccumulator(node, &states); |
645 } | 637 } |
646 | 638 |
647 void BytecodeGraphBuilder::VisitLdaGlobal() { | 639 void BytecodeGraphBuilder::VisitLdaGlobal() { |
648 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); | 640 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
649 } | 641 } |
650 | 642 |
651 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { | 643 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { |
652 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); | 644 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
653 } | 645 } |
654 | 646 |
655 void BytecodeGraphBuilder::VisitLdaGlobalWide() { | |
656 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); | |
657 } | |
658 | |
659 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofWide() { | |
660 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); | |
661 } | |
662 | |
663 void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { | 647 void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { |
664 FrameStateBeforeAndAfter states(this); | 648 FrameStateBeforeAndAfter states(this); |
665 Handle<Name> name = | 649 Handle<Name> name = |
666 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 650 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
667 VectorSlotPair feedback = | 651 VectorSlotPair feedback = |
668 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 652 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
669 Node* value = environment()->LookupAccumulator(); | 653 Node* value = environment()->LookupAccumulator(); |
670 | 654 |
671 const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback); | 655 const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback); |
672 Node* node = NewNode(op, value, GetFunctionClosure()); | 656 Node* node = NewNode(op, value, GetFunctionClosure()); |
673 environment()->RecordAfterState(node, &states); | 657 environment()->RecordAfterState(node, &states); |
674 } | 658 } |
675 | 659 |
676 void BytecodeGraphBuilder::VisitStaGlobalSloppy() { | 660 void BytecodeGraphBuilder::VisitStaGlobalSloppy() { |
677 BuildStoreGlobal(LanguageMode::SLOPPY); | 661 BuildStoreGlobal(LanguageMode::SLOPPY); |
678 } | 662 } |
679 | 663 |
680 void BytecodeGraphBuilder::VisitStaGlobalStrict() { | 664 void BytecodeGraphBuilder::VisitStaGlobalStrict() { |
681 BuildStoreGlobal(LanguageMode::STRICT); | 665 BuildStoreGlobal(LanguageMode::STRICT); |
682 } | 666 } |
683 | 667 |
684 void BytecodeGraphBuilder::VisitStaGlobalSloppyWide() { | |
685 BuildStoreGlobal(LanguageMode::SLOPPY); | |
686 } | |
687 | |
688 void BytecodeGraphBuilder::VisitStaGlobalStrictWide() { | |
689 BuildStoreGlobal(LanguageMode::STRICT); | |
690 } | |
691 | |
692 void BytecodeGraphBuilder::VisitLdaContextSlot() { | 668 void BytecodeGraphBuilder::VisitLdaContextSlot() { |
693 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | 669 // TODO(mythria): LoadContextSlots are unrolled by the required depth when |
694 // generating bytecode. Hence the value of depth is always 0. Update this | 670 // generating bytecode. Hence the value of depth is always 0. Update this |
695 // code, when the implementation changes. | 671 // code, when the implementation changes. |
696 // TODO(mythria): immutable flag is also set to false. This information is not | 672 // TODO(mythria): immutable flag is also set to false. This information is not |
697 // available in bytecode array. update this code when the implementation | 673 // available in bytecode array. update this code when the implementation |
698 // changes. | 674 // changes. |
699 const Operator* op = javascript()->LoadContext( | 675 const Operator* op = javascript()->LoadContext( |
700 0, bytecode_iterator().GetIndexOperand(1), false); | 676 0, bytecode_iterator().GetIndexOperand(1), false); |
701 Node* context = | 677 Node* context = |
702 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 678 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
703 Node* node = NewNode(op, context); | 679 Node* node = NewNode(op, context); |
704 environment()->BindAccumulator(node); | 680 environment()->BindAccumulator(node); |
705 } | 681 } |
706 | 682 |
707 void BytecodeGraphBuilder::VisitLdaContextSlotWide() { VisitLdaContextSlot(); } | |
708 | |
709 void BytecodeGraphBuilder::VisitStaContextSlot() { | 683 void BytecodeGraphBuilder::VisitStaContextSlot() { |
710 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | 684 // TODO(mythria): LoadContextSlots are unrolled by the required depth when |
711 // generating bytecode. Hence the value of depth is always 0. Update this | 685 // generating bytecode. Hence the value of depth is always 0. Update this |
712 // code, when the implementation changes. | 686 // code, when the implementation changes. |
713 const Operator* op = | 687 const Operator* op = |
714 javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(1)); | 688 javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(1)); |
715 Node* context = | 689 Node* context = |
716 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 690 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
717 Node* value = environment()->LookupAccumulator(); | 691 Node* value = environment()->LookupAccumulator(); |
718 NewNode(op, context, value); | 692 NewNode(op, context, value); |
719 } | 693 } |
720 | 694 |
721 void BytecodeGraphBuilder::VisitStaContextSlotWide() { VisitStaContextSlot(); } | |
722 | |
723 void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { | 695 void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { |
724 FrameStateBeforeAndAfter states(this); | 696 FrameStateBeforeAndAfter states(this); |
725 Node* name = | 697 Node* name = |
726 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | 698 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
727 const Operator* op = | 699 const Operator* op = |
728 javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF | 700 javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
729 ? Runtime::kLoadLookupSlot | 701 ? Runtime::kLoadLookupSlot |
730 : Runtime::kLoadLookupSlotInsideTypeof); | 702 : Runtime::kLoadLookupSlotInsideTypeof); |
731 Node* value = NewNode(op, name); | 703 Node* value = NewNode(op, name); |
732 environment()->BindAccumulator(value, &states); | 704 environment()->BindAccumulator(value, &states); |
(...skipping 12 matching lines...) Loading... |
745 Node* value = environment()->LookupAccumulator(); | 717 Node* value = environment()->LookupAccumulator(); |
746 Node* name = | 718 Node* name = |
747 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | 719 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
748 const Operator* op = javascript()->CallRuntime( | 720 const Operator* op = javascript()->CallRuntime( |
749 is_strict(language_mode) ? Runtime::kStoreLookupSlot_Strict | 721 is_strict(language_mode) ? Runtime::kStoreLookupSlot_Strict |
750 : Runtime::kStoreLookupSlot_Sloppy); | 722 : Runtime::kStoreLookupSlot_Sloppy); |
751 Node* store = NewNode(op, name, value); | 723 Node* store = NewNode(op, name, value); |
752 environment()->BindAccumulator(store, &states); | 724 environment()->BindAccumulator(store, &states); |
753 } | 725 } |
754 | 726 |
755 void BytecodeGraphBuilder::VisitLdaLookupSlotWide() { VisitLdaLookupSlot(); } | |
756 | |
757 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeofWide() { | |
758 VisitLdaLookupSlotInsideTypeof(); | |
759 } | |
760 | |
761 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { | 727 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { |
762 BuildStaLookupSlot(LanguageMode::SLOPPY); | 728 BuildStaLookupSlot(LanguageMode::SLOPPY); |
763 } | 729 } |
764 | 730 |
765 void BytecodeGraphBuilder::VisitStaLookupSlotStrict() { | 731 void BytecodeGraphBuilder::VisitStaLookupSlotStrict() { |
766 BuildStaLookupSlot(LanguageMode::STRICT); | 732 BuildStaLookupSlot(LanguageMode::STRICT); |
767 } | 733 } |
768 | 734 |
769 void BytecodeGraphBuilder::VisitStaLookupSlotSloppyWide() { | |
770 VisitStaLookupSlotSloppy(); | |
771 } | |
772 | |
773 void BytecodeGraphBuilder::VisitStaLookupSlotStrictWide() { | |
774 VisitStaLookupSlotStrict(); | |
775 } | |
776 | |
777 void BytecodeGraphBuilder::BuildNamedLoad() { | 735 void BytecodeGraphBuilder::BuildNamedLoad() { |
778 FrameStateBeforeAndAfter states(this); | 736 FrameStateBeforeAndAfter states(this); |
779 Node* object = | 737 Node* object = |
780 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 738 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
781 Handle<Name> name = | 739 Handle<Name> name = |
782 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | 740 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
783 VectorSlotPair feedback = | 741 VectorSlotPair feedback = |
784 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 742 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
785 | 743 |
786 const Operator* op = javascript()->LoadNamed(name, feedback); | 744 const Operator* op = javascript()->LoadNamed(name, feedback); |
787 Node* node = NewNode(op, object, GetFunctionClosure()); | 745 Node* node = NewNode(op, object, GetFunctionClosure()); |
788 environment()->BindAccumulator(node, &states); | 746 environment()->BindAccumulator(node, &states); |
789 } | 747 } |
790 | 748 |
791 void BytecodeGraphBuilder::VisitLoadIC() { BuildNamedLoad(); } | 749 void BytecodeGraphBuilder::VisitLoadIC() { BuildNamedLoad(); } |
792 | 750 |
793 void BytecodeGraphBuilder::VisitLoadICWide() { BuildNamedLoad(); } | |
794 | |
795 void BytecodeGraphBuilder::BuildKeyedLoad() { | 751 void BytecodeGraphBuilder::BuildKeyedLoad() { |
796 FrameStateBeforeAndAfter states(this); | 752 FrameStateBeforeAndAfter states(this); |
797 Node* key = environment()->LookupAccumulator(); | 753 Node* key = environment()->LookupAccumulator(); |
798 Node* object = | 754 Node* object = |
799 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 755 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
800 VectorSlotPair feedback = | 756 VectorSlotPair feedback = |
801 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 757 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
802 | 758 |
803 const Operator* op = javascript()->LoadProperty(feedback); | 759 const Operator* op = javascript()->LoadProperty(feedback); |
804 Node* node = NewNode(op, object, key, GetFunctionClosure()); | 760 Node* node = NewNode(op, object, key, GetFunctionClosure()); |
805 environment()->BindAccumulator(node, &states); | 761 environment()->BindAccumulator(node, &states); |
806 } | 762 } |
807 | 763 |
808 void BytecodeGraphBuilder::VisitKeyedLoadIC() { BuildKeyedLoad(); } | 764 void BytecodeGraphBuilder::VisitKeyedLoadIC() { BuildKeyedLoad(); } |
809 | 765 |
810 void BytecodeGraphBuilder::VisitKeyedLoadICWide() { BuildKeyedLoad(); } | |
811 | |
812 void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) { | 766 void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) { |
813 FrameStateBeforeAndAfter states(this); | 767 FrameStateBeforeAndAfter states(this); |
814 Node* value = environment()->LookupAccumulator(); | 768 Node* value = environment()->LookupAccumulator(); |
815 Node* object = | 769 Node* object = |
816 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 770 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
817 Handle<Name> name = | 771 Handle<Name> name = |
818 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | 772 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
819 VectorSlotPair feedback = | 773 VectorSlotPair feedback = |
820 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 774 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
821 | 775 |
822 const Operator* op = javascript()->StoreNamed(language_mode, name, feedback); | 776 const Operator* op = javascript()->StoreNamed(language_mode, name, feedback); |
823 Node* node = NewNode(op, object, value, GetFunctionClosure()); | 777 Node* node = NewNode(op, object, value, GetFunctionClosure()); |
824 environment()->RecordAfterState(node, &states); | 778 environment()->RecordAfterState(node, &states); |
825 } | 779 } |
826 | 780 |
827 void BytecodeGraphBuilder::VisitStoreICSloppy() { | 781 void BytecodeGraphBuilder::VisitStoreICSloppy() { |
828 BuildNamedStore(LanguageMode::SLOPPY); | 782 BuildNamedStore(LanguageMode::SLOPPY); |
829 } | 783 } |
830 | 784 |
831 void BytecodeGraphBuilder::VisitStoreICStrict() { | 785 void BytecodeGraphBuilder::VisitStoreICStrict() { |
832 BuildNamedStore(LanguageMode::STRICT); | 786 BuildNamedStore(LanguageMode::STRICT); |
833 } | 787 } |
834 | 788 |
835 void BytecodeGraphBuilder::VisitStoreICSloppyWide() { | |
836 BuildNamedStore(LanguageMode::SLOPPY); | |
837 } | |
838 | |
839 void BytecodeGraphBuilder::VisitStoreICStrictWide() { | |
840 BuildNamedStore(LanguageMode::STRICT); | |
841 } | |
842 | |
843 void BytecodeGraphBuilder::BuildKeyedStore(LanguageMode language_mode) { | 789 void BytecodeGraphBuilder::BuildKeyedStore(LanguageMode language_mode) { |
844 FrameStateBeforeAndAfter states(this); | 790 FrameStateBeforeAndAfter states(this); |
845 Node* value = environment()->LookupAccumulator(); | 791 Node* value = environment()->LookupAccumulator(); |
846 Node* object = | 792 Node* object = |
847 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 793 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
848 Node* key = | 794 Node* key = |
849 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); | 795 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
850 VectorSlotPair feedback = | 796 VectorSlotPair feedback = |
851 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 797 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
852 | 798 |
853 const Operator* op = javascript()->StoreProperty(language_mode, feedback); | 799 const Operator* op = javascript()->StoreProperty(language_mode, feedback); |
854 Node* node = NewNode(op, object, key, value, GetFunctionClosure()); | 800 Node* node = NewNode(op, object, key, value, GetFunctionClosure()); |
855 environment()->RecordAfterState(node, &states); | 801 environment()->RecordAfterState(node, &states); |
856 } | 802 } |
857 | 803 |
858 void BytecodeGraphBuilder::VisitKeyedStoreICSloppy() { | 804 void BytecodeGraphBuilder::VisitKeyedStoreICSloppy() { |
859 BuildKeyedStore(LanguageMode::SLOPPY); | 805 BuildKeyedStore(LanguageMode::SLOPPY); |
860 } | 806 } |
861 | 807 |
862 void BytecodeGraphBuilder::VisitKeyedStoreICStrict() { | 808 void BytecodeGraphBuilder::VisitKeyedStoreICStrict() { |
863 BuildKeyedStore(LanguageMode::STRICT); | 809 BuildKeyedStore(LanguageMode::STRICT); |
864 } | 810 } |
865 | 811 |
866 void BytecodeGraphBuilder::VisitKeyedStoreICSloppyWide() { | |
867 BuildKeyedStore(LanguageMode::SLOPPY); | |
868 } | |
869 | |
870 void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide() { | |
871 BuildKeyedStore(LanguageMode::STRICT); | |
872 } | |
873 | |
874 void BytecodeGraphBuilder::VisitPushContext() { | 812 void BytecodeGraphBuilder::VisitPushContext() { |
875 Node* new_context = environment()->LookupAccumulator(); | 813 Node* new_context = environment()->LookupAccumulator(); |
876 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), | 814 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), |
877 environment()->Context()); | 815 environment()->Context()); |
878 environment()->SetContext(new_context); | 816 environment()->SetContext(new_context); |
879 } | 817 } |
880 | 818 |
881 void BytecodeGraphBuilder::VisitPopContext() { | 819 void BytecodeGraphBuilder::VisitPopContext() { |
882 Node* context = | 820 Node* context = |
883 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 821 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
884 environment()->SetContext(context); | 822 environment()->SetContext(context); |
885 } | 823 } |
886 | 824 |
887 void BytecodeGraphBuilder::VisitCreateClosure() { | 825 void BytecodeGraphBuilder::VisitCreateClosure() { |
888 Handle<SharedFunctionInfo> shared_info = Handle<SharedFunctionInfo>::cast( | 826 Handle<SharedFunctionInfo> shared_info = Handle<SharedFunctionInfo>::cast( |
889 bytecode_iterator().GetConstantForIndexOperand(0)); | 827 bytecode_iterator().GetConstantForIndexOperand(0)); |
890 PretenureFlag tenured = | 828 PretenureFlag tenured = |
891 bytecode_iterator().GetImmediateOperand(1) ? TENURED : NOT_TENURED; | 829 bytecode_iterator().GetFlagOperand(1) ? TENURED : NOT_TENURED; |
892 const Operator* op = javascript()->CreateClosure(shared_info, tenured); | 830 const Operator* op = javascript()->CreateClosure(shared_info, tenured); |
893 Node* closure = NewNode(op); | 831 Node* closure = NewNode(op); |
894 environment()->BindAccumulator(closure); | 832 environment()->BindAccumulator(closure); |
895 } | 833 } |
896 | 834 |
897 void BytecodeGraphBuilder::VisitCreateClosureWide() { VisitCreateClosure(); } | |
898 | |
899 void BytecodeGraphBuilder::BuildCreateArguments(CreateArgumentsType type) { | 835 void BytecodeGraphBuilder::BuildCreateArguments(CreateArgumentsType type) { |
900 FrameStateBeforeAndAfter states(this); | 836 FrameStateBeforeAndAfter states(this); |
901 const Operator* op = javascript()->CreateArguments(type); | 837 const Operator* op = javascript()->CreateArguments(type); |
902 Node* object = NewNode(op, GetFunctionClosure()); | 838 Node* object = NewNode(op, GetFunctionClosure()); |
903 environment()->BindAccumulator(object, &states); | 839 environment()->BindAccumulator(object, &states); |
904 } | 840 } |
905 | 841 |
906 void BytecodeGraphBuilder::VisitCreateMappedArguments() { | 842 void BytecodeGraphBuilder::VisitCreateMappedArguments() { |
907 BuildCreateArguments(CreateArgumentsType::kMappedArguments); | 843 BuildCreateArguments(CreateArgumentsType::kMappedArguments); |
908 } | 844 } |
909 | 845 |
910 void BytecodeGraphBuilder::VisitCreateUnmappedArguments() { | 846 void BytecodeGraphBuilder::VisitCreateUnmappedArguments() { |
911 BuildCreateArguments(CreateArgumentsType::kUnmappedArguments); | 847 BuildCreateArguments(CreateArgumentsType::kUnmappedArguments); |
912 } | 848 } |
913 | 849 |
914 void BytecodeGraphBuilder::VisitCreateRestParameter() { | 850 void BytecodeGraphBuilder::VisitCreateRestParameter() { |
915 BuildCreateArguments(CreateArgumentsType::kRestParameter); | 851 BuildCreateArguments(CreateArgumentsType::kRestParameter); |
916 } | 852 } |
917 | 853 |
918 void BytecodeGraphBuilder::BuildCreateLiteral(const Operator* op) { | 854 void BytecodeGraphBuilder::BuildCreateLiteral(const Operator* op) { |
919 FrameStateBeforeAndAfter states(this); | 855 FrameStateBeforeAndAfter states(this); |
920 Node* literal = NewNode(op, GetFunctionClosure()); | 856 Node* literal = NewNode(op, GetFunctionClosure()); |
921 environment()->BindAccumulator(literal, &states); | 857 environment()->BindAccumulator(literal, &states); |
922 } | 858 } |
923 | 859 |
924 void BytecodeGraphBuilder::BuildCreateRegExpLiteral() { | 860 void BytecodeGraphBuilder::VisitCreateRegExpLiteral() { |
925 Handle<String> constant_pattern = | 861 Handle<String> constant_pattern = |
926 Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 862 Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
927 int literal_index = bytecode_iterator().GetIndexOperand(1); | 863 int literal_index = bytecode_iterator().GetIndexOperand(1); |
928 int literal_flags = bytecode_iterator().GetImmediateOperand(2); | 864 int literal_flags = bytecode_iterator().GetFlagOperand(2); |
929 const Operator* op = javascript()->CreateLiteralRegExp( | 865 const Operator* op = javascript()->CreateLiteralRegExp( |
930 constant_pattern, literal_flags, literal_index); | 866 constant_pattern, literal_flags, literal_index); |
931 BuildCreateLiteral(op); | 867 BuildCreateLiteral(op); |
932 } | 868 } |
933 | 869 |
934 void BytecodeGraphBuilder::VisitCreateRegExpLiteral() { | 870 void BytecodeGraphBuilder::VisitCreateArrayLiteral() { |
935 BuildCreateRegExpLiteral(); | |
936 } | |
937 | |
938 void BytecodeGraphBuilder::VisitCreateRegExpLiteralWide() { | |
939 BuildCreateRegExpLiteral(); | |
940 } | |
941 | |
942 void BytecodeGraphBuilder::BuildCreateArrayLiteral() { | |
943 Handle<FixedArray> constant_elements = Handle<FixedArray>::cast( | 871 Handle<FixedArray> constant_elements = Handle<FixedArray>::cast( |
944 bytecode_iterator().GetConstantForIndexOperand(0)); | 872 bytecode_iterator().GetConstantForIndexOperand(0)); |
945 int literal_index = bytecode_iterator().GetIndexOperand(1); | 873 int literal_index = bytecode_iterator().GetIndexOperand(1); |
946 int literal_flags = bytecode_iterator().GetImmediateOperand(2); | 874 int literal_flags = bytecode_iterator().GetFlagOperand(2); |
947 int number_of_elements = constant_elements->length(); | 875 int number_of_elements = constant_elements->length(); |
948 const Operator* op = javascript()->CreateLiteralArray( | 876 const Operator* op = javascript()->CreateLiteralArray( |
949 constant_elements, literal_flags, literal_index, number_of_elements); | 877 constant_elements, literal_flags, literal_index, number_of_elements); |
950 BuildCreateLiteral(op); | 878 BuildCreateLiteral(op); |
951 } | 879 } |
952 | 880 |
953 void BytecodeGraphBuilder::VisitCreateArrayLiteral() { | 881 void BytecodeGraphBuilder::VisitCreateObjectLiteral() { |
954 BuildCreateArrayLiteral(); | |
955 } | |
956 | |
957 void BytecodeGraphBuilder::VisitCreateArrayLiteralWide() { | |
958 BuildCreateArrayLiteral(); | |
959 } | |
960 | |
961 void BytecodeGraphBuilder::BuildCreateObjectLiteral() { | |
962 Handle<FixedArray> constant_properties = Handle<FixedArray>::cast( | 882 Handle<FixedArray> constant_properties = Handle<FixedArray>::cast( |
963 bytecode_iterator().GetConstantForIndexOperand(0)); | 883 bytecode_iterator().GetConstantForIndexOperand(0)); |
964 int literal_index = bytecode_iterator().GetIndexOperand(1); | 884 int literal_index = bytecode_iterator().GetIndexOperand(1); |
965 int literal_flags = bytecode_iterator().GetImmediateOperand(2); | 885 int literal_flags = bytecode_iterator().GetFlagOperand(2); |
966 // TODO(mstarzinger): Thread through number of properties. | 886 // TODO(mstarzinger): Thread through number of properties. |
967 int number_of_properties = constant_properties->length() / 2; | 887 int number_of_properties = constant_properties->length() / 2; |
968 const Operator* op = javascript()->CreateLiteralObject( | 888 const Operator* op = javascript()->CreateLiteralObject( |
969 constant_properties, literal_flags, literal_index, number_of_properties); | 889 constant_properties, literal_flags, literal_index, number_of_properties); |
970 BuildCreateLiteral(op); | 890 BuildCreateLiteral(op); |
971 } | 891 } |
972 | 892 |
973 void BytecodeGraphBuilder::VisitCreateObjectLiteral() { | |
974 BuildCreateObjectLiteral(); | |
975 } | |
976 | |
977 void BytecodeGraphBuilder::VisitCreateObjectLiteralWide() { | |
978 BuildCreateObjectLiteral(); | |
979 } | |
980 | |
981 | |
982 Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op, | 893 Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op, |
983 Node* callee, | 894 Node* callee, |
984 interpreter::Register receiver, | 895 interpreter::Register receiver, |
985 size_t arity) { | 896 size_t arity) { |
986 Node** all = local_zone()->NewArray<Node*>(static_cast<int>(arity)); | 897 Node** all = local_zone()->NewArray<Node*>(static_cast<int>(arity)); |
987 all[0] = callee; | 898 all[0] = callee; |
988 all[1] = environment()->LookupRegister(receiver); | 899 all[1] = environment()->LookupRegister(receiver); |
989 int receiver_index = receiver.index(); | 900 int receiver_index = receiver.index(); |
990 for (int i = 2; i < static_cast<int>(arity); ++i) { | 901 for (int i = 2; i < static_cast<int>(arity); ++i) { |
991 all[i] = environment()->LookupRegister( | 902 all[i] = environment()->LookupRegister( |
(...skipping 17 matching lines...) Loading... |
1009 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 920 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
1010 | 921 |
1011 const Operator* call = javascript()->CallFunction( | 922 const Operator* call = javascript()->CallFunction( |
1012 arg_count + 1, feedback, receiver_hint, tail_call_mode); | 923 arg_count + 1, feedback, receiver_hint, tail_call_mode); |
1013 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 924 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1014 environment()->BindAccumulator(value, &states); | 925 environment()->BindAccumulator(value, &states); |
1015 } | 926 } |
1016 | 927 |
1017 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } | 928 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } |
1018 | 929 |
1019 void BytecodeGraphBuilder::VisitCallWide() { | |
1020 BuildCall(TailCallMode::kDisallow); | |
1021 } | |
1022 | |
1023 void BytecodeGraphBuilder::VisitTailCall() { BuildCall(TailCallMode::kAllow); } | 930 void BytecodeGraphBuilder::VisitTailCall() { BuildCall(TailCallMode::kAllow); } |
1024 | 931 |
1025 void BytecodeGraphBuilder::VisitTailCallWide() { | 932 void BytecodeGraphBuilder::VisitCallJSRuntime() { |
1026 BuildCall(TailCallMode::kAllow); | |
1027 } | |
1028 | |
1029 void BytecodeGraphBuilder::BuildCallJSRuntime() { | |
1030 FrameStateBeforeAndAfter states(this); | 933 FrameStateBeforeAndAfter states(this); |
1031 Node* callee = | 934 Node* callee = |
1032 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); | 935 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); |
1033 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 936 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1034 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 937 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1035 | 938 |
1036 // Create node to perform the JS runtime call. | 939 // Create node to perform the JS runtime call. |
1037 const Operator* call = javascript()->CallFunction(arg_count + 1); | 940 const Operator* call = javascript()->CallFunction(arg_count + 1); |
1038 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 941 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1039 environment()->BindAccumulator(value, &states); | 942 environment()->BindAccumulator(value, &states); |
1040 } | 943 } |
1041 | 944 |
1042 void BytecodeGraphBuilder::VisitCallJSRuntime() { BuildCallJSRuntime(); } | |
1043 | 945 |
1044 void BytecodeGraphBuilder::VisitCallJSRuntimeWide() { BuildCallJSRuntime(); } | |
1045 | 946 |
1046 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( | 947 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( |
1047 const Operator* call_runtime_op, interpreter::Register first_arg, | 948 const Operator* call_runtime_op, interpreter::Register first_arg, |
1048 size_t arity) { | 949 size_t arity) { |
1049 Node** all = local_zone()->NewArray<Node*>(arity); | 950 Node** all = local_zone()->NewArray<Node*>(arity); |
1050 int first_arg_index = first_arg.index(); | 951 int first_arg_index = first_arg.index(); |
1051 for (int i = 0; i < static_cast<int>(arity); ++i) { | 952 for (int i = 0; i < static_cast<int>(arity); ++i) { |
1052 all[i] = environment()->LookupRegister( | 953 all[i] = environment()->LookupRegister( |
1053 interpreter::Register(first_arg_index + i)); | 954 interpreter::Register(first_arg_index + i)); |
1054 } | 955 } |
1055 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false); | 956 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false); |
1056 return value; | 957 return value; |
1057 } | 958 } |
1058 | 959 |
1059 void BytecodeGraphBuilder::BuildCallRuntime() { | 960 void BytecodeGraphBuilder::VisitCallRuntime() { |
1060 FrameStateBeforeAndAfter states(this); | 961 FrameStateBeforeAndAfter states(this); |
1061 Runtime::FunctionId functionId = | 962 Runtime::FunctionId functionId = |
1062 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); | 963 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); |
1063 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 964 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1064 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 965 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1065 | 966 |
1066 // Create node to perform the runtime call. | 967 // Create node to perform the runtime call. |
1067 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 968 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
1068 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 969 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
1069 environment()->BindAccumulator(value, &states); | 970 environment()->BindAccumulator(value, &states); |
1070 } | 971 } |
1071 | 972 |
1072 void BytecodeGraphBuilder::VisitCallRuntime() { BuildCallRuntime(); } | 973 void BytecodeGraphBuilder::VisitCallRuntimeForPair() { |
1073 | |
1074 void BytecodeGraphBuilder::VisitCallRuntimeWide() { BuildCallRuntime(); } | |
1075 | |
1076 void BytecodeGraphBuilder::BuildCallRuntimeForPair() { | |
1077 FrameStateBeforeAndAfter states(this); | 974 FrameStateBeforeAndAfter states(this); |
1078 Runtime::FunctionId functionId = | 975 Runtime::FunctionId functionId = |
1079 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); | 976 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); |
1080 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 977 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1081 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 978 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1082 interpreter::Register first_return = | 979 interpreter::Register first_return = |
1083 bytecode_iterator().GetRegisterOperand(3); | 980 bytecode_iterator().GetRegisterOperand(3); |
1084 | 981 |
1085 // Create node to perform the runtime call. | 982 // Create node to perform the runtime call. |
1086 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 983 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
1087 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 984 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
1088 environment()->BindRegistersToProjections(first_return, return_pair, &states); | 985 environment()->BindRegistersToProjections(first_return, return_pair, &states); |
1089 } | 986 } |
1090 | 987 |
1091 void BytecodeGraphBuilder::VisitCallRuntimeForPair() { | |
1092 BuildCallRuntimeForPair(); | |
1093 } | |
1094 | |
1095 void BytecodeGraphBuilder::VisitCallRuntimeForPairWide() { | |
1096 BuildCallRuntimeForPair(); | |
1097 } | |
1098 | |
1099 Node* BytecodeGraphBuilder::ProcessCallNewArguments( | 988 Node* BytecodeGraphBuilder::ProcessCallNewArguments( |
1100 const Operator* call_new_op, Node* callee, Node* new_target, | 989 const Operator* call_new_op, Node* callee, Node* new_target, |
1101 interpreter::Register first_arg, size_t arity) { | 990 interpreter::Register first_arg, size_t arity) { |
1102 Node** all = local_zone()->NewArray<Node*>(arity); | 991 Node** all = local_zone()->NewArray<Node*>(arity); |
1103 all[0] = new_target; | 992 all[0] = new_target; |
1104 int first_arg_index = first_arg.index(); | 993 int first_arg_index = first_arg.index(); |
1105 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { | 994 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { |
1106 all[i] = environment()->LookupRegister( | 995 all[i] = environment()->LookupRegister( |
1107 interpreter::Register(first_arg_index + i - 1)); | 996 interpreter::Register(first_arg_index + i - 1)); |
1108 } | 997 } |
1109 all[arity - 1] = callee; | 998 all[arity - 1] = callee; |
1110 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); | 999 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); |
1111 return value; | 1000 return value; |
1112 } | 1001 } |
1113 | 1002 |
1114 void BytecodeGraphBuilder::BuildCallConstruct() { | 1003 void BytecodeGraphBuilder::VisitNew() { |
1115 FrameStateBeforeAndAfter states(this); | 1004 FrameStateBeforeAndAfter states(this); |
1116 interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0); | 1005 interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0); |
1117 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1006 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1118 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1007 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1119 | 1008 |
1120 Node* new_target = environment()->LookupAccumulator(); | 1009 Node* new_target = environment()->LookupAccumulator(); |
1121 Node* callee = environment()->LookupRegister(callee_reg); | 1010 Node* callee = environment()->LookupRegister(callee_reg); |
1122 // TODO(turbofan): Pass the feedback here. | 1011 // TODO(turbofan): Pass the feedback here. |
1123 const Operator* call = javascript()->CallConstruct( | 1012 const Operator* call = javascript()->CallConstruct( |
1124 static_cast<int>(arg_count) + 2, VectorSlotPair()); | 1013 static_cast<int>(arg_count) + 2, VectorSlotPair()); |
1125 Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg, | 1014 Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg, |
1126 arg_count + 2); | 1015 arg_count + 2); |
1127 environment()->BindAccumulator(value, &states); | 1016 environment()->BindAccumulator(value, &states); |
1128 } | 1017 } |
1129 | 1018 |
1130 void BytecodeGraphBuilder::VisitNew() { BuildCallConstruct(); } | |
1131 | |
1132 void BytecodeGraphBuilder::VisitNewWide() { BuildCallConstruct(); } | |
1133 | |
1134 void BytecodeGraphBuilder::BuildThrow() { | 1019 void BytecodeGraphBuilder::BuildThrow() { |
1135 FrameStateBeforeAndAfter states(this); | 1020 FrameStateBeforeAndAfter states(this); |
1136 Node* value = environment()->LookupAccumulator(); | 1021 Node* value = environment()->LookupAccumulator(); |
1137 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); | 1022 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); |
1138 environment()->BindAccumulator(call, &states); | 1023 environment()->BindAccumulator(call, &states); |
1139 } | 1024 } |
1140 | 1025 |
1141 void BytecodeGraphBuilder::VisitThrow() { | 1026 void BytecodeGraphBuilder::VisitThrow() { |
1142 BuildThrow(); | 1027 BuildThrow(); |
1143 Node* call = environment()->LookupAccumulator(); | 1028 Node* call = environment()->LookupAccumulator(); |
(...skipping 180 matching lines...) Loading... |
1324 } | 1209 } |
1325 | 1210 |
1326 void BytecodeGraphBuilder::VisitToNumber() { | 1211 void BytecodeGraphBuilder::VisitToNumber() { |
1327 BuildCastOperator(javascript()->ToNumber()); | 1212 BuildCastOperator(javascript()->ToNumber()); |
1328 } | 1213 } |
1329 | 1214 |
1330 void BytecodeGraphBuilder::VisitJump() { BuildJump(); } | 1215 void BytecodeGraphBuilder::VisitJump() { BuildJump(); } |
1331 | 1216 |
1332 void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); } | 1217 void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); } |
1333 | 1218 |
1334 void BytecodeGraphBuilder::VisitJumpConstantWide() { BuildJump(); } | |
1335 | 1219 |
1336 void BytecodeGraphBuilder::VisitJumpIfTrue() { | 1220 void BytecodeGraphBuilder::VisitJumpIfTrue() { |
1337 BuildJumpIfEqual(jsgraph()->TrueConstant()); | 1221 BuildJumpIfEqual(jsgraph()->TrueConstant()); |
1338 } | 1222 } |
1339 | 1223 |
1340 void BytecodeGraphBuilder::VisitJumpIfTrueConstant() { | 1224 void BytecodeGraphBuilder::VisitJumpIfTrueConstant() { |
1341 BuildJumpIfEqual(jsgraph()->TrueConstant()); | 1225 BuildJumpIfEqual(jsgraph()->TrueConstant()); |
1342 } | 1226 } |
1343 | 1227 |
1344 void BytecodeGraphBuilder::VisitJumpIfTrueConstantWide() { | |
1345 BuildJumpIfEqual(jsgraph()->TrueConstant()); | |
1346 } | |
1347 | |
1348 void BytecodeGraphBuilder::VisitJumpIfFalse() { | 1228 void BytecodeGraphBuilder::VisitJumpIfFalse() { |
1349 BuildJumpIfEqual(jsgraph()->FalseConstant()); | 1229 BuildJumpIfEqual(jsgraph()->FalseConstant()); |
1350 } | 1230 } |
1351 | 1231 |
1352 void BytecodeGraphBuilder::VisitJumpIfFalseConstant() { | 1232 void BytecodeGraphBuilder::VisitJumpIfFalseConstant() { |
1353 BuildJumpIfEqual(jsgraph()->FalseConstant()); | 1233 BuildJumpIfEqual(jsgraph()->FalseConstant()); |
1354 } | 1234 } |
1355 | 1235 |
1356 void BytecodeGraphBuilder::VisitJumpIfFalseConstantWide() { | |
1357 BuildJumpIfEqual(jsgraph()->FalseConstant()); | |
1358 } | |
1359 | |
1360 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() { | 1236 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() { |
1361 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | 1237 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); |
1362 } | 1238 } |
1363 | 1239 |
1364 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() { | 1240 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() { |
1365 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | 1241 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); |
1366 } | 1242 } |
1367 | 1243 |
1368 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstantWide() { | |
1369 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | |
1370 } | |
1371 | |
1372 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() { | 1244 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() { |
1373 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | 1245 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); |
1374 } | 1246 } |
1375 | 1247 |
1376 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() { | 1248 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() { |
1377 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | 1249 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); |
1378 } | 1250 } |
1379 | 1251 |
1380 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstantWide() { | |
1381 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | |
1382 } | |
1383 | |
1384 void BytecodeGraphBuilder::VisitJumpIfNotHole() { BuildJumpIfNotHole(); } | 1252 void BytecodeGraphBuilder::VisitJumpIfNotHole() { BuildJumpIfNotHole(); } |
1385 | 1253 |
1386 void BytecodeGraphBuilder::VisitJumpIfNotHoleConstant() { | 1254 void BytecodeGraphBuilder::VisitJumpIfNotHoleConstant() { |
1387 BuildJumpIfNotHole(); | 1255 BuildJumpIfNotHole(); |
1388 } | 1256 } |
1389 | 1257 |
1390 void BytecodeGraphBuilder::VisitJumpIfNotHoleConstantWide() { | |
1391 BuildJumpIfNotHole(); | |
1392 } | |
1393 | |
1394 void BytecodeGraphBuilder::VisitJumpIfNull() { | 1258 void BytecodeGraphBuilder::VisitJumpIfNull() { |
1395 BuildJumpIfEqual(jsgraph()->NullConstant()); | 1259 BuildJumpIfEqual(jsgraph()->NullConstant()); |
1396 } | 1260 } |
1397 | 1261 |
1398 void BytecodeGraphBuilder::VisitJumpIfNullConstant() { | 1262 void BytecodeGraphBuilder::VisitJumpIfNullConstant() { |
1399 BuildJumpIfEqual(jsgraph()->NullConstant()); | 1263 BuildJumpIfEqual(jsgraph()->NullConstant()); |
1400 } | 1264 } |
1401 | 1265 |
1402 void BytecodeGraphBuilder::VisitJumpIfNullConstantWide() { | |
1403 BuildJumpIfEqual(jsgraph()->NullConstant()); | |
1404 } | |
1405 | |
1406 void BytecodeGraphBuilder::VisitJumpIfUndefined() { | 1266 void BytecodeGraphBuilder::VisitJumpIfUndefined() { |
1407 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); | 1267 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); |
1408 } | 1268 } |
1409 | 1269 |
1410 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant() { | 1270 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant() { |
1411 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); | 1271 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); |
1412 } | 1272 } |
1413 | 1273 |
1414 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstantWide() { | |
1415 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); | |
1416 } | |
1417 | |
1418 void BytecodeGraphBuilder::VisitStackCheck() { | 1274 void BytecodeGraphBuilder::VisitStackCheck() { |
1419 FrameStateBeforeAndAfter states(this); | 1275 FrameStateBeforeAndAfter states(this); |
1420 Node* node = NewNode(javascript()->StackCheck()); | 1276 Node* node = NewNode(javascript()->StackCheck()); |
1421 environment()->RecordAfterState(node, &states); | 1277 environment()->RecordAfterState(node, &states); |
1422 } | 1278 } |
1423 | 1279 |
1424 void BytecodeGraphBuilder::VisitReturn() { | 1280 void BytecodeGraphBuilder::VisitReturn() { |
1425 Node* control = | 1281 Node* control = |
1426 NewNode(common()->Return(), environment()->LookupAccumulator()); | 1282 NewNode(common()->Return(), environment()->LookupAccumulator()); |
1427 MergeControlToLeaveFunction(control); | 1283 MergeControlToLeaveFunction(control); |
(...skipping 15 matching lines...) Loading... |
1443 void BytecodeGraphBuilder::BuildForInPrepare() { | 1299 void BytecodeGraphBuilder::BuildForInPrepare() { |
1444 FrameStateBeforeAndAfter states(this); | 1300 FrameStateBeforeAndAfter states(this); |
1445 Node* receiver = environment()->LookupAccumulator(); | 1301 Node* receiver = environment()->LookupAccumulator(); |
1446 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); | 1302 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); |
1447 environment()->BindRegistersToProjections( | 1303 environment()->BindRegistersToProjections( |
1448 bytecode_iterator().GetRegisterOperand(0), prepare, &states); | 1304 bytecode_iterator().GetRegisterOperand(0), prepare, &states); |
1449 } | 1305 } |
1450 | 1306 |
1451 void BytecodeGraphBuilder::VisitForInPrepare() { BuildForInPrepare(); } | 1307 void BytecodeGraphBuilder::VisitForInPrepare() { BuildForInPrepare(); } |
1452 | 1308 |
1453 void BytecodeGraphBuilder::VisitForInPrepareWide() { BuildForInPrepare(); } | |
1454 | |
1455 void BytecodeGraphBuilder::VisitForInDone() { | 1309 void BytecodeGraphBuilder::VisitForInDone() { |
1456 FrameStateBeforeAndAfter states(this); | 1310 FrameStateBeforeAndAfter states(this); |
1457 Node* index = | 1311 Node* index = |
1458 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1312 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1459 Node* cache_length = | 1313 Node* cache_length = |
1460 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); | 1314 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
1461 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); | 1315 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); |
1462 environment()->BindAccumulator(exit_cond, &states); | 1316 environment()->BindAccumulator(exit_cond, &states); |
1463 } | 1317 } |
1464 | 1318 |
1465 void BytecodeGraphBuilder::BuildForInNext() { | 1319 void BytecodeGraphBuilder::BuildForInNext() { |
1466 FrameStateBeforeAndAfter states(this); | 1320 FrameStateBeforeAndAfter states(this); |
1467 Node* receiver = | 1321 Node* receiver = |
1468 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1322 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1469 Node* index = | 1323 Node* index = |
1470 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); | 1324 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
1471 int catch_reg_pair_index = bytecode_iterator().GetRegisterOperand(2).index(); | 1325 int catch_reg_pair_index = bytecode_iterator().GetRegisterOperand(2).index(); |
1472 Node* cache_type = environment()->LookupRegister( | 1326 Node* cache_type = environment()->LookupRegister( |
1473 interpreter::Register(catch_reg_pair_index)); | 1327 interpreter::Register(catch_reg_pair_index)); |
1474 Node* cache_array = environment()->LookupRegister( | 1328 Node* cache_array = environment()->LookupRegister( |
1475 interpreter::Register(catch_reg_pair_index + 1)); | 1329 interpreter::Register(catch_reg_pair_index + 1)); |
1476 | 1330 |
1477 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array, | 1331 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array, |
1478 cache_type, index); | 1332 cache_type, index); |
1479 environment()->BindAccumulator(value, &states); | 1333 environment()->BindAccumulator(value, &states); |
1480 } | 1334 } |
1481 | 1335 |
1482 void BytecodeGraphBuilder::VisitForInNext() { BuildForInNext(); } | 1336 void BytecodeGraphBuilder::VisitForInNext() { BuildForInNext(); } |
1483 | 1337 |
1484 void BytecodeGraphBuilder::VisitForInNextWide() { BuildForInNext(); } | |
1485 | |
1486 void BytecodeGraphBuilder::VisitForInStep() { | 1338 void BytecodeGraphBuilder::VisitForInStep() { |
1487 FrameStateBeforeAndAfter states(this); | 1339 FrameStateBeforeAndAfter states(this); |
1488 Node* index = | 1340 Node* index = |
1489 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1341 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1490 index = NewNode(javascript()->ForInStep(), index); | 1342 index = NewNode(javascript()->ForInStep(), index); |
1491 environment()->BindAccumulator(index, &states); | 1343 environment()->BindAccumulator(index, &states); |
1492 } | 1344 } |
1493 | 1345 |
| 1346 void BytecodeGraphBuilder::VisitWide() { |
| 1347 // Consumed by the BytecodeArrayIterator. |
| 1348 UNREACHABLE(); |
| 1349 } |
| 1350 |
| 1351 void BytecodeGraphBuilder::VisitExtraWide() { |
| 1352 // Consumed by the BytecodeArrayIterator. |
| 1353 UNREACHABLE(); |
| 1354 } |
| 1355 |
1494 void BytecodeGraphBuilder::SwitchToMergeEnvironment(int current_offset) { | 1356 void BytecodeGraphBuilder::SwitchToMergeEnvironment(int current_offset) { |
1495 if (merge_environments_[current_offset] != nullptr) { | 1357 if (merge_environments_[current_offset] != nullptr) { |
1496 if (environment() != nullptr) { | 1358 if (environment() != nullptr) { |
1497 merge_environments_[current_offset]->Merge(environment()); | 1359 merge_environments_[current_offset]->Merge(environment()); |
1498 } | 1360 } |
1499 set_environment(merge_environments_[current_offset]); | 1361 set_environment(merge_environments_[current_offset]); |
1500 } | 1362 } |
1501 } | 1363 } |
1502 | 1364 |
1503 void BytecodeGraphBuilder::BuildLoopHeaderEnvironment(int current_offset) { | 1365 void BytecodeGraphBuilder::BuildLoopHeaderEnvironment(int current_offset) { |
(...skipping 252 matching lines...) Loading... |
1756 // Phi does not exist yet, introduce one. | 1618 // Phi does not exist yet, introduce one. |
1757 value = NewPhi(inputs, value, control); | 1619 value = NewPhi(inputs, value, control); |
1758 value->ReplaceInput(inputs - 1, other); | 1620 value->ReplaceInput(inputs - 1, other); |
1759 } | 1621 } |
1760 return value; | 1622 return value; |
1761 } | 1623 } |
1762 | 1624 |
1763 } // namespace compiler | 1625 } // namespace compiler |
1764 } // namespace internal | 1626 } // namespace internal |
1765 } // namespace v8 | 1627 } // namespace v8 |
OLD | NEW |