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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 Node* node = | 579 Node* node = |
580 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | 580 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
581 environment()->BindAccumulator(node); | 581 environment()->BindAccumulator(node); |
582 } | 582 } |
583 | 583 |
584 void BytecodeGraphBuilder::VisitLdaUndefined() { | 584 void BytecodeGraphBuilder::VisitLdaUndefined() { |
585 Node* node = jsgraph()->UndefinedConstant(); | 585 Node* node = jsgraph()->UndefinedConstant(); |
586 environment()->BindAccumulator(node); | 586 environment()->BindAccumulator(node); |
587 } | 587 } |
588 | 588 |
| 589 void BytecodeGraphBuilder::VisitLdrUndefined() { |
| 590 Node* node = jsgraph()->UndefinedConstant(); |
| 591 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), node); |
| 592 } |
| 593 |
589 void BytecodeGraphBuilder::VisitLdaNull() { | 594 void BytecodeGraphBuilder::VisitLdaNull() { |
590 Node* node = jsgraph()->NullConstant(); | 595 Node* node = jsgraph()->NullConstant(); |
591 environment()->BindAccumulator(node); | 596 environment()->BindAccumulator(node); |
592 } | 597 } |
593 | 598 |
594 void BytecodeGraphBuilder::VisitLdaTheHole() { | 599 void BytecodeGraphBuilder::VisitLdaTheHole() { |
595 Node* node = jsgraph()->TheHoleConstant(); | 600 Node* node = jsgraph()->TheHoleConstant(); |
596 environment()->BindAccumulator(node); | 601 environment()->BindAccumulator(node); |
597 } | 602 } |
598 | 603 |
(...skipping 17 matching lines...) Expand all Loading... |
616 Node* value = environment()->LookupAccumulator(); | 621 Node* value = environment()->LookupAccumulator(); |
617 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value); | 622 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value); |
618 } | 623 } |
619 | 624 |
620 void BytecodeGraphBuilder::VisitMov() { | 625 void BytecodeGraphBuilder::VisitMov() { |
621 Node* value = | 626 Node* value = |
622 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 627 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
623 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); | 628 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); |
624 } | 629 } |
625 | 630 |
626 void BytecodeGraphBuilder::BuildLoadGlobal( | 631 Node* BytecodeGraphBuilder::BuildLoadGlobal(TypeofMode typeof_mode) { |
627 TypeofMode typeof_mode) { | |
628 FrameStateBeforeAndAfter states(this); | |
629 Handle<Name> name = | 632 Handle<Name> name = |
630 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 633 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
631 VectorSlotPair feedback = | 634 VectorSlotPair feedback = |
632 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 635 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
| 636 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); |
| 637 return NewNode(op, GetFunctionClosure()); |
| 638 } |
633 | 639 |
634 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); | 640 void BytecodeGraphBuilder::VisitLdaGlobal() { |
635 Node* node = NewNode(op, GetFunctionClosure()); | 641 FrameStateBeforeAndAfter states(this); |
| 642 Node* node = BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
636 environment()->BindAccumulator(node, &states); | 643 environment()->BindAccumulator(node, &states); |
637 } | 644 } |
638 | 645 |
639 void BytecodeGraphBuilder::VisitLdaGlobal() { | 646 void BytecodeGraphBuilder::VisitLdrGlobal() { |
640 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); | 647 FrameStateBeforeAndAfter states(this); |
| 648 Node* node = BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
| 649 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(2), node, |
| 650 &states); |
641 } | 651 } |
642 | 652 |
643 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { | 653 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { |
644 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); | 654 FrameStateBeforeAndAfter states(this); |
| 655 Node* node = BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
| 656 environment()->BindAccumulator(node, &states); |
645 } | 657 } |
646 | 658 |
647 void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { | 659 void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { |
648 FrameStateBeforeAndAfter states(this); | 660 FrameStateBeforeAndAfter states(this); |
649 Handle<Name> name = | 661 Handle<Name> name = |
650 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 662 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
651 VectorSlotPair feedback = | 663 VectorSlotPair feedback = |
652 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 664 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
653 Node* value = environment()->LookupAccumulator(); | 665 Node* value = environment()->LookupAccumulator(); |
654 | 666 |
655 const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback); | 667 const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback); |
656 Node* node = NewNode(op, value, GetFunctionClosure()); | 668 Node* node = NewNode(op, value, GetFunctionClosure()); |
657 environment()->RecordAfterState(node, &states); | 669 environment()->RecordAfterState(node, &states); |
658 } | 670 } |
659 | 671 |
660 void BytecodeGraphBuilder::VisitStaGlobalSloppy() { | 672 void BytecodeGraphBuilder::VisitStaGlobalSloppy() { |
661 BuildStoreGlobal(LanguageMode::SLOPPY); | 673 BuildStoreGlobal(LanguageMode::SLOPPY); |
662 } | 674 } |
663 | 675 |
664 void BytecodeGraphBuilder::VisitStaGlobalStrict() { | 676 void BytecodeGraphBuilder::VisitStaGlobalStrict() { |
665 BuildStoreGlobal(LanguageMode::STRICT); | 677 BuildStoreGlobal(LanguageMode::STRICT); |
666 } | 678 } |
667 | 679 |
668 void BytecodeGraphBuilder::VisitLdaContextSlot() { | 680 Node* BytecodeGraphBuilder::BuildLoadContextSlot() { |
669 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | 681 // TODO(mythria): LoadContextSlots are unrolled by the required depth when |
670 // generating bytecode. Hence the value of depth is always 0. Update this | 682 // generating bytecode. Hence the value of depth is always 0. Update this |
671 // code, when the implementation changes. | 683 // code, when the implementation changes. |
672 // TODO(mythria): immutable flag is also set to false. This information is not | 684 // TODO(mythria): immutable flag is also set to false. This information is not |
673 // available in bytecode array. update this code when the implementation | 685 // available in bytecode array. update this code when the implementation |
674 // changes. | 686 // changes. |
675 const Operator* op = javascript()->LoadContext( | 687 const Operator* op = javascript()->LoadContext( |
676 0, bytecode_iterator().GetIndexOperand(1), false); | 688 0, bytecode_iterator().GetIndexOperand(1), false); |
677 Node* context = | 689 Node* context = |
678 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 690 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
679 Node* node = NewNode(op, context); | 691 return NewNode(op, context); |
| 692 } |
| 693 |
| 694 void BytecodeGraphBuilder::VisitLdaContextSlot() { |
| 695 Node* node = BuildLoadContextSlot(); |
680 environment()->BindAccumulator(node); | 696 environment()->BindAccumulator(node); |
681 } | 697 } |
682 | 698 |
| 699 void BytecodeGraphBuilder::VisitLdrContextSlot() { |
| 700 Node* node = BuildLoadContextSlot(); |
| 701 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(2), node); |
| 702 } |
| 703 |
683 void BytecodeGraphBuilder::VisitStaContextSlot() { | 704 void BytecodeGraphBuilder::VisitStaContextSlot() { |
684 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | 705 // TODO(mythria): LoadContextSlots are unrolled by the required depth when |
685 // generating bytecode. Hence the value of depth is always 0. Update this | 706 // generating bytecode. Hence the value of depth is always 0. Update this |
686 // code, when the implementation changes. | 707 // code, when the implementation changes. |
687 const Operator* op = | 708 const Operator* op = |
688 javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(1)); | 709 javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(1)); |
689 Node* context = | 710 Node* context = |
690 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 711 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
691 Node* value = environment()->LookupAccumulator(); | 712 Node* value = environment()->LookupAccumulator(); |
692 NewNode(op, context, value); | 713 NewNode(op, context, value); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 746 } |
726 | 747 |
727 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { | 748 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { |
728 BuildStaLookupSlot(LanguageMode::SLOPPY); | 749 BuildStaLookupSlot(LanguageMode::SLOPPY); |
729 } | 750 } |
730 | 751 |
731 void BytecodeGraphBuilder::VisitStaLookupSlotStrict() { | 752 void BytecodeGraphBuilder::VisitStaLookupSlotStrict() { |
732 BuildStaLookupSlot(LanguageMode::STRICT); | 753 BuildStaLookupSlot(LanguageMode::STRICT); |
733 } | 754 } |
734 | 755 |
735 void BytecodeGraphBuilder::BuildNamedLoad() { | 756 Node* BytecodeGraphBuilder::BuildNamedLoad() { |
736 FrameStateBeforeAndAfter states(this); | |
737 Node* object = | 757 Node* object = |
738 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 758 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
739 Handle<Name> name = | 759 Handle<Name> name = |
740 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | 760 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
741 VectorSlotPair feedback = | 761 VectorSlotPair feedback = |
742 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 762 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
743 | 763 |
744 const Operator* op = javascript()->LoadNamed(name, feedback); | 764 const Operator* op = javascript()->LoadNamed(name, feedback); |
745 Node* node = NewNode(op, object, GetFunctionClosure()); | 765 return NewNode(op, object, GetFunctionClosure()); |
| 766 } |
| 767 |
| 768 void BytecodeGraphBuilder::VisitLoadIC() { |
| 769 FrameStateBeforeAndAfter states(this); |
| 770 Node* node = BuildNamedLoad(); |
746 environment()->BindAccumulator(node, &states); | 771 environment()->BindAccumulator(node, &states); |
747 } | 772 } |
748 | 773 |
749 void BytecodeGraphBuilder::VisitLoadIC() { BuildNamedLoad(); } | 774 void BytecodeGraphBuilder::VisitLdrNamedProperty() { |
| 775 FrameStateBeforeAndAfter states(this); |
| 776 Node* node = BuildNamedLoad(); |
| 777 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(3), node, |
| 778 &states); |
| 779 } |
750 | 780 |
751 void BytecodeGraphBuilder::BuildKeyedLoad() { | 781 Node* BytecodeGraphBuilder::BuildKeyedLoad() { |
752 FrameStateBeforeAndAfter states(this); | |
753 Node* key = environment()->LookupAccumulator(); | 782 Node* key = environment()->LookupAccumulator(); |
754 Node* object = | 783 Node* object = |
755 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 784 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
756 VectorSlotPair feedback = | 785 VectorSlotPair feedback = |
757 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 786 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
758 | 787 |
759 const Operator* op = javascript()->LoadProperty(feedback); | 788 const Operator* op = javascript()->LoadProperty(feedback); |
760 Node* node = NewNode(op, object, key, GetFunctionClosure()); | 789 return NewNode(op, object, key, GetFunctionClosure()); |
| 790 } |
| 791 |
| 792 void BytecodeGraphBuilder::VisitKeyedLoadIC() { |
| 793 FrameStateBeforeAndAfter states(this); |
| 794 Node* node = BuildKeyedLoad(); |
761 environment()->BindAccumulator(node, &states); | 795 environment()->BindAccumulator(node, &states); |
762 } | 796 } |
763 | 797 |
764 void BytecodeGraphBuilder::VisitKeyedLoadIC() { BuildKeyedLoad(); } | 798 void BytecodeGraphBuilder::VisitLdrKeyedProperty() { |
| 799 FrameStateBeforeAndAfter states(this); |
| 800 Node* node = BuildKeyedLoad(); |
| 801 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(2), node, |
| 802 &states); |
| 803 } |
765 | 804 |
766 void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) { | 805 void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) { |
767 FrameStateBeforeAndAfter states(this); | 806 FrameStateBeforeAndAfter states(this); |
768 Node* value = environment()->LookupAccumulator(); | 807 Node* value = environment()->LookupAccumulator(); |
769 Node* object = | 808 Node* object = |
770 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 809 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
771 Handle<Name> name = | 810 Handle<Name> name = |
772 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | 811 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
773 VectorSlotPair feedback = | 812 VectorSlotPair feedback = |
774 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 813 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 // Phi does not exist yet, introduce one. | 1732 // Phi does not exist yet, introduce one. |
1694 value = NewPhi(inputs, value, control); | 1733 value = NewPhi(inputs, value, control); |
1695 value->ReplaceInput(inputs - 1, other); | 1734 value->ReplaceInput(inputs - 1, other); |
1696 } | 1735 } |
1697 return value; | 1736 return value; |
1698 } | 1737 } |
1699 | 1738 |
1700 } // namespace compiler | 1739 } // namespace compiler |
1701 } // namespace internal | 1740 } // namespace internal |
1702 } // namespace v8 | 1741 } // namespace v8 |
OLD | NEW |