| 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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 661 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
| 662 VectorSlotPair feedback = | 662 VectorSlotPair feedback = |
| 663 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 663 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
| 664 | 664 |
| 665 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); | 665 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); |
| 666 Node* node = NewNode(op, BuildLoadFeedbackVector()); | 666 Node* node = NewNode(op, BuildLoadFeedbackVector()); |
| 667 environment()->BindAccumulator(node, &states); | 667 environment()->BindAccumulator(node, &states); |
| 668 } | 668 } |
| 669 | 669 |
| 670 void BytecodeGraphBuilder::VisitLdaGlobalSloppy() { | 670 void BytecodeGraphBuilder::VisitLdaGlobalSloppy() { |
| 671 DCHECK(is_sloppy(language_mode())); | |
| 672 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); | 671 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
| 673 } | 672 } |
| 674 | 673 |
| 675 void BytecodeGraphBuilder::VisitLdaGlobalStrict() { | 674 void BytecodeGraphBuilder::VisitLdaGlobalStrict() { |
| 676 DCHECK(is_strict(language_mode())); | |
| 677 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); | 675 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
| 678 } | 676 } |
| 679 | 677 |
| 680 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppy() { | 678 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppy() { |
| 681 DCHECK(is_sloppy(language_mode())); | |
| 682 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); | 679 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
| 683 } | 680 } |
| 684 | 681 |
| 685 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrict() { | 682 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrict() { |
| 686 DCHECK(is_strict(language_mode())); | |
| 687 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); | 683 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
| 688 } | 684 } |
| 689 | 685 |
| 690 void BytecodeGraphBuilder::VisitLdaGlobalSloppyWide() { | 686 void BytecodeGraphBuilder::VisitLdaGlobalSloppyWide() { |
| 691 DCHECK(is_sloppy(language_mode())); | |
| 692 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); | 687 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
| 693 } | 688 } |
| 694 | 689 |
| 695 void BytecodeGraphBuilder::VisitLdaGlobalStrictWide() { | 690 void BytecodeGraphBuilder::VisitLdaGlobalStrictWide() { |
| 696 DCHECK(is_strict(language_mode())); | |
| 697 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); | 691 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
| 698 } | 692 } |
| 699 | 693 |
| 700 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppyWide() { | 694 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppyWide() { |
| 701 DCHECK(is_sloppy(language_mode())); | |
| 702 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); | 695 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
| 703 } | 696 } |
| 704 | 697 |
| 705 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrictWide() { | 698 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrictWide() { |
| 706 DCHECK(is_strict(language_mode())); | |
| 707 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); | 699 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
| 708 } | 700 } |
| 709 | 701 |
| 710 void BytecodeGraphBuilder::BuildStoreGlobal() { | 702 void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { |
| 711 FrameStateBeforeAndAfter states(this); | 703 FrameStateBeforeAndAfter states(this); |
| 712 Handle<Name> name = | 704 Handle<Name> name = |
| 713 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 705 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
| 714 VectorSlotPair feedback = | 706 VectorSlotPair feedback = |
| 715 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 707 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
| 716 Node* value = environment()->LookupAccumulator(); | 708 Node* value = environment()->LookupAccumulator(); |
| 717 | 709 |
| 718 const Operator* op = | 710 const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback); |
| 719 javascript()->StoreGlobal(language_mode(), name, feedback); | |
| 720 Node* node = NewNode(op, value, BuildLoadFeedbackVector()); | 711 Node* node = NewNode(op, value, BuildLoadFeedbackVector()); |
| 721 environment()->RecordAfterState(node, &states); | 712 environment()->RecordAfterState(node, &states); |
| 722 } | 713 } |
| 723 | 714 |
| 724 void BytecodeGraphBuilder::VisitStaGlobalSloppy() { | 715 void BytecodeGraphBuilder::VisitStaGlobalSloppy() { |
| 725 DCHECK(is_sloppy(language_mode())); | 716 BuildStoreGlobal(LanguageMode::SLOPPY); |
| 726 BuildStoreGlobal(); | |
| 727 } | 717 } |
| 728 | 718 |
| 729 void BytecodeGraphBuilder::VisitStaGlobalStrict() { | 719 void BytecodeGraphBuilder::VisitStaGlobalStrict() { |
| 730 DCHECK(is_strict(language_mode())); | 720 BuildStoreGlobal(LanguageMode::STRICT); |
| 731 BuildStoreGlobal(); | |
| 732 } | 721 } |
| 733 | 722 |
| 734 void BytecodeGraphBuilder::VisitStaGlobalSloppyWide() { | 723 void BytecodeGraphBuilder::VisitStaGlobalSloppyWide() { |
| 735 DCHECK(is_sloppy(language_mode())); | 724 BuildStoreGlobal(LanguageMode::SLOPPY); |
| 736 BuildStoreGlobal(); | |
| 737 } | 725 } |
| 738 | 726 |
| 739 void BytecodeGraphBuilder::VisitStaGlobalStrictWide() { | 727 void BytecodeGraphBuilder::VisitStaGlobalStrictWide() { |
| 740 DCHECK(is_strict(language_mode())); | 728 BuildStoreGlobal(LanguageMode::STRICT); |
| 741 BuildStoreGlobal(); | |
| 742 } | 729 } |
| 743 | 730 |
| 744 void BytecodeGraphBuilder::VisitLdaContextSlot() { | 731 void BytecodeGraphBuilder::VisitLdaContextSlot() { |
| 745 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | 732 // TODO(mythria): LoadContextSlots are unrolled by the required depth when |
| 746 // generating bytecode. Hence the value of depth is always 0. Update this | 733 // generating bytecode. Hence the value of depth is always 0. Update this |
| 747 // code, when the implementation changes. | 734 // code, when the implementation changes. |
| 748 // TODO(mythria): immutable flag is also set to false. This information is not | 735 // TODO(mythria): immutable flag is also set to false. This information is not |
| 749 // available in bytecode array. update this code when the implementation | 736 // available in bytecode array. update this code when the implementation |
| 750 // changes. | 737 // changes. |
| 751 const Operator* op = javascript()->LoadContext( | 738 const Operator* op = javascript()->LoadContext( |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 void BytecodeGraphBuilder::VisitKeyedLoadICSloppyWide() { | 870 void BytecodeGraphBuilder::VisitKeyedLoadICSloppyWide() { |
| 884 DCHECK(is_sloppy(language_mode())); | 871 DCHECK(is_sloppy(language_mode())); |
| 885 BuildKeyedLoad(); | 872 BuildKeyedLoad(); |
| 886 } | 873 } |
| 887 | 874 |
| 888 void BytecodeGraphBuilder::VisitKeyedLoadICStrictWide() { | 875 void BytecodeGraphBuilder::VisitKeyedLoadICStrictWide() { |
| 889 DCHECK(is_strict(language_mode())); | 876 DCHECK(is_strict(language_mode())); |
| 890 BuildKeyedLoad(); | 877 BuildKeyedLoad(); |
| 891 } | 878 } |
| 892 | 879 |
| 893 void BytecodeGraphBuilder::BuildNamedStore() { | 880 void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) { |
| 894 FrameStateBeforeAndAfter states(this); | 881 FrameStateBeforeAndAfter states(this); |
| 895 Node* value = environment()->LookupAccumulator(); | 882 Node* value = environment()->LookupAccumulator(); |
| 896 Node* object = | 883 Node* object = |
| 897 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 884 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 898 Handle<Name> name = | 885 Handle<Name> name = |
| 899 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | 886 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
| 900 VectorSlotPair feedback = | 887 VectorSlotPair feedback = |
| 901 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 888 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
| 902 | 889 |
| 903 const Operator* op = | 890 const Operator* op = javascript()->StoreNamed(language_mode, name, feedback); |
| 904 javascript()->StoreNamed(language_mode(), name, feedback); | |
| 905 Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); | 891 Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); |
| 906 environment()->RecordAfterState(node, &states); | 892 environment()->RecordAfterState(node, &states); |
| 907 } | 893 } |
| 908 | 894 |
| 909 void BytecodeGraphBuilder::VisitStoreICSloppy() { | 895 void BytecodeGraphBuilder::VisitStoreICSloppy() { |
| 910 DCHECK(is_sloppy(language_mode())); | 896 BuildNamedStore(LanguageMode::SLOPPY); |
| 911 BuildNamedStore(); | |
| 912 } | 897 } |
| 913 | 898 |
| 914 void BytecodeGraphBuilder::VisitStoreICStrict() { | 899 void BytecodeGraphBuilder::VisitStoreICStrict() { |
| 915 DCHECK(is_strict(language_mode())); | 900 BuildNamedStore(LanguageMode::STRICT); |
| 916 BuildNamedStore(); | |
| 917 } | 901 } |
| 918 | 902 |
| 919 void BytecodeGraphBuilder::VisitStoreICSloppyWide() { | 903 void BytecodeGraphBuilder::VisitStoreICSloppyWide() { |
| 920 DCHECK(is_sloppy(language_mode())); | 904 BuildNamedStore(LanguageMode::SLOPPY); |
| 921 BuildNamedStore(); | |
| 922 } | 905 } |
| 923 | 906 |
| 924 void BytecodeGraphBuilder::VisitStoreICStrictWide() { | 907 void BytecodeGraphBuilder::VisitStoreICStrictWide() { |
| 925 DCHECK(is_strict(language_mode())); | 908 BuildNamedStore(LanguageMode::STRICT); |
| 926 BuildNamedStore(); | |
| 927 } | 909 } |
| 928 | 910 |
| 929 void BytecodeGraphBuilder::BuildKeyedStore() { | 911 void BytecodeGraphBuilder::BuildKeyedStore(LanguageMode language_mode) { |
| 930 FrameStateBeforeAndAfter states(this); | 912 FrameStateBeforeAndAfter states(this); |
| 931 Node* value = environment()->LookupAccumulator(); | 913 Node* value = environment()->LookupAccumulator(); |
| 932 Node* object = | 914 Node* object = |
| 933 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 915 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 934 Node* key = | 916 Node* key = |
| 935 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); | 917 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
| 936 VectorSlotPair feedback = | 918 VectorSlotPair feedback = |
| 937 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 919 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
| 938 | 920 |
| 939 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); | 921 const Operator* op = javascript()->StoreProperty(language_mode, feedback); |
| 940 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); | 922 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); |
| 941 environment()->RecordAfterState(node, &states); | 923 environment()->RecordAfterState(node, &states); |
| 942 } | 924 } |
| 943 | 925 |
| 944 void BytecodeGraphBuilder::VisitKeyedStoreICSloppy() { | 926 void BytecodeGraphBuilder::VisitKeyedStoreICSloppy() { |
| 945 DCHECK(is_sloppy(language_mode())); | 927 BuildKeyedStore(LanguageMode::SLOPPY); |
| 946 BuildKeyedStore(); | |
| 947 } | 928 } |
| 948 | 929 |
| 949 void BytecodeGraphBuilder::VisitKeyedStoreICStrict() { | 930 void BytecodeGraphBuilder::VisitKeyedStoreICStrict() { |
| 950 DCHECK(is_strict(language_mode())); | 931 BuildKeyedStore(LanguageMode::STRICT); |
| 951 BuildKeyedStore(); | |
| 952 } | 932 } |
| 953 | 933 |
| 954 void BytecodeGraphBuilder::VisitKeyedStoreICSloppyWide() { | 934 void BytecodeGraphBuilder::VisitKeyedStoreICSloppyWide() { |
| 955 DCHECK(is_sloppy(language_mode())); | 935 BuildKeyedStore(LanguageMode::SLOPPY); |
| 956 BuildKeyedStore(); | |
| 957 } | 936 } |
| 958 | 937 |
| 959 void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide() { | 938 void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide() { |
| 960 DCHECK(is_strict(language_mode())); | 939 BuildKeyedStore(LanguageMode::STRICT); |
| 961 BuildKeyedStore(); | |
| 962 } | 940 } |
| 963 | 941 |
| 964 void BytecodeGraphBuilder::VisitPushContext() { | 942 void BytecodeGraphBuilder::VisitPushContext() { |
| 965 Node* new_context = environment()->LookupAccumulator(); | 943 Node* new_context = environment()->LookupAccumulator(); |
| 966 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), | 944 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), |
| 967 environment()->Context()); | 945 environment()->Context()); |
| 968 environment()->SetContext(new_context); | 946 environment()->SetContext(new_context); |
| 969 } | 947 } |
| 970 | 948 |
| 971 void BytecodeGraphBuilder::VisitPopContext() { | 949 void BytecodeGraphBuilder::VisitPopContext() { |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); | 1299 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); |
| 1322 environment()->BindAccumulator(node); | 1300 environment()->BindAccumulator(node); |
| 1323 } | 1301 } |
| 1324 | 1302 |
| 1325 void BytecodeGraphBuilder::VisitTypeOf() { | 1303 void BytecodeGraphBuilder::VisitTypeOf() { |
| 1326 Node* node = | 1304 Node* node = |
| 1327 NewNode(javascript()->TypeOf(), environment()->LookupAccumulator()); | 1305 NewNode(javascript()->TypeOf(), environment()->LookupAccumulator()); |
| 1328 environment()->BindAccumulator(node); | 1306 environment()->BindAccumulator(node); |
| 1329 } | 1307 } |
| 1330 | 1308 |
| 1331 void BytecodeGraphBuilder::BuildDelete() { | 1309 void BytecodeGraphBuilder::BuildDelete(LanguageMode language_mode) { |
| 1332 FrameStateBeforeAndAfter states(this); | 1310 FrameStateBeforeAndAfter states(this); |
| 1333 Node* key = environment()->LookupAccumulator(); | 1311 Node* key = environment()->LookupAccumulator(); |
| 1334 Node* object = | 1312 Node* object = |
| 1335 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1313 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1336 Node* node = | 1314 Node* node = |
| 1337 NewNode(javascript()->DeleteProperty(language_mode()), object, key); | 1315 NewNode(javascript()->DeleteProperty(language_mode), object, key); |
| 1338 environment()->BindAccumulator(node, &states); | 1316 environment()->BindAccumulator(node, &states); |
| 1339 } | 1317 } |
| 1340 | 1318 |
| 1341 void BytecodeGraphBuilder::VisitDeletePropertyStrict() { | 1319 void BytecodeGraphBuilder::VisitDeletePropertyStrict() { |
| 1342 DCHECK(is_strict(language_mode())); | 1320 BuildDelete(LanguageMode::STRICT); |
| 1343 BuildDelete(); | |
| 1344 } | 1321 } |
| 1345 | 1322 |
| 1346 void BytecodeGraphBuilder::VisitDeletePropertySloppy() { | 1323 void BytecodeGraphBuilder::VisitDeletePropertySloppy() { |
| 1347 DCHECK(is_sloppy(language_mode())); | 1324 BuildDelete(LanguageMode::SLOPPY); |
| 1348 BuildDelete(); | |
| 1349 } | 1325 } |
| 1350 | 1326 |
| 1351 void BytecodeGraphBuilder::VisitDeleteLookupSlot() { | 1327 void BytecodeGraphBuilder::VisitDeleteLookupSlot() { |
| 1352 FrameStateBeforeAndAfter states(this); | 1328 FrameStateBeforeAndAfter states(this); |
| 1353 Node* name = environment()->LookupAccumulator(); | 1329 Node* name = environment()->LookupAccumulator(); |
| 1354 const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot); | 1330 const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot); |
| 1355 Node* result = NewNode(op, environment()->Context(), name); | 1331 Node* result = NewNode(op, environment()->Context(), name); |
| 1356 environment()->BindAccumulator(result, &states); | 1332 environment()->BindAccumulator(result, &states); |
| 1357 } | 1333 } |
| 1358 | 1334 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 // Phi does not exist yet, introduce one. | 1813 // Phi does not exist yet, introduce one. |
| 1838 value = NewPhi(inputs, value, control); | 1814 value = NewPhi(inputs, value, control); |
| 1839 value->ReplaceInput(inputs - 1, other); | 1815 value->ReplaceInput(inputs - 1, other); |
| 1840 } | 1816 } |
| 1841 return value; | 1817 return value; |
| 1842 } | 1818 } |
| 1843 | 1819 |
| 1844 } // namespace compiler | 1820 } // namespace compiler |
| 1845 } // namespace internal | 1821 } // namespace internal |
| 1846 } // namespace v8 | 1822 } // namespace v8 |
| OLD | NEW |