| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/interpreter/bytecode-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" |
| 9 #include "src/interpreter/bytecode-generator.h" | 9 #include "src/interpreter/bytecode-generator.h" |
| 10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); | 723 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); |
| 724 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); | 724 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); |
| 725 | 725 |
| 726 Handle<i::TypeFeedbackVector> vector = | 726 Handle<i::TypeFeedbackVector> vector = |
| 727 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 727 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 728 | 728 |
| 729 ExpectedSnippet<const char*> snippets[] = { | 729 ExpectedSnippet<const char*> snippets[] = { |
| 730 {"function f(a) { return a.name; }\nf({name : \"test\"})", | 730 {"function f(a) { return a.name; }\nf({name : \"test\"})", |
| 731 0, | 731 0, |
| 732 2, | 732 2, |
| 733 6, | 733 5, |
| 734 { | 734 { |
| 735 B(LdaConstant), U8(0), // | 735 B(LoadICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // |
| 736 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // | 736 B(Return), // |
| 737 B(Return), // | |
| 738 }, | 737 }, |
| 739 1, | 738 1, |
| 740 {"name"}}, | 739 {"name"}}, |
| 741 {"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})", | 740 {"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})", |
| 742 0, | 741 0, |
| 743 2, | 742 2, |
| 744 6, | 743 5, |
| 745 { | 744 { |
| 746 B(LdaConstant), U8(0), // | 745 B(LoadICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // |
| 747 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // | 746 B(Return) // |
| 748 B(Return) // | |
| 749 }, | 747 }, |
| 750 1, | 748 1, |
| 751 {"key"}}, | 749 {"key"}}, |
| 752 {"function f(a) { return a[100]; }\nf({100 : \"test\"})", | 750 {"function f(a) { return a[100]; }\nf({100 : \"test\"})", |
| 753 0, | 751 0, |
| 754 2, | 752 2, |
| 755 6, | 753 6, |
| 756 { | 754 { |
| 757 B(LdaSmi8), U8(100), // | 755 B(LdaSmi8), U8(100), // |
| 758 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // | 756 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 759 B(Return) // | 757 B(Return) // |
| 760 }, | 758 }, |
| 761 0}, | 759 0}, |
| 762 {"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")", | 760 {"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")", |
| 763 0, | 761 0, |
| 764 3, | 762 3, |
| 765 6, | 763 6, |
| 766 { | 764 { |
| 767 B(Ldar), A(1, 2), // | 765 B(Ldar), A(1, 2), // |
| 768 B(KeyedLoadICSloppy), A(1, 3), U8(vector->GetIndex(slot1)), // | 766 B(KeyedLoadICSloppy), A(1, 3), U8(vector->GetIndex(slot1)), // |
| 769 B(Return) // | 767 B(Return) // |
| 770 }, | 768 }, |
| 771 0}, | 769 0}, |
| 772 {"function f(a) { var b = a.name; return a[-124]; }\n" | 770 {"function f(a) { var b = a.name; return a[-124]; }\n" |
| 773 "f({\"-124\" : \"test\", name : 123 })", | 771 "f({\"-124\" : \"test\", name : 123 })", |
| 774 kPointerSize, | 772 kPointerSize, |
| 775 2, | 773 2, |
| 776 13, | 774 12, |
| 777 { | 775 { |
| 778 B(LdaConstant), U8(0), // | 776 B(LoadICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // |
| 779 B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // | 777 B(Star), R(0), // |
| 780 B(Star), R(0), // | 778 B(LdaSmi8), U8(-124), // |
| 781 B(LdaSmi8), U8(-124), // | 779 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot2)), // |
| 782 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot2)), // | 780 B(Return), // |
| 783 B(Return), // | |
| 784 }, | 781 }, |
| 785 1, | 782 1, |
| 786 {"name"}}, | 783 {"name"}}, |
| 787 {"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})", | 784 {"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})", |
| 788 0, | 785 0, |
| 789 2, | 786 2, |
| 790 6, | 787 5, |
| 791 { | 788 { |
| 792 B(LdaConstant), U8(0), // | 789 B(LoadICStrict), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // |
| 793 B(LoadICStrict), A(1, 2), U8(vector->GetIndex(slot1)), // | 790 B(Return), // |
| 794 B(Return), // | |
| 795 }, | 791 }, |
| 796 1, | 792 1, |
| 797 {"name"}}, | 793 {"name"}}, |
| 798 {"function f(a, b) { \"use strict\"; return a[b]; }\n" | 794 { |
| 795 "function f(a, b) { \"use strict\"; return a[b]; }\n" |
| 799 "f({arg : \"test\"}, \"arg\")", | 796 "f({arg : \"test\"}, \"arg\")", |
| 800 0, | 797 0, |
| 801 3, | 798 3, |
| 802 6, | 799 6, |
| 803 { | 800 { |
| 804 B(Ldar), A(2, 3), // | 801 B(Ldar), A(2, 3), // |
| 805 B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), // | 802 B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), // |
| 806 B(Return), // | 803 B(Return), // |
| 807 }, | 804 }, |
| 808 0, | 805 0, }}; |
| 809 }}; | |
| 810 for (size_t i = 0; i < arraysize(snippets); i++) { | 806 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 811 Handle<BytecodeArray> bytecode_array = | 807 Handle<BytecodeArray> bytecode_array = |
| 812 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 808 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 813 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 809 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 814 } | 810 } |
| 815 } | 811 } |
| 816 | 812 |
| 817 | 813 |
| 818 TEST(PropertyStores) { | 814 TEST(PropertyStores) { |
| 819 InitializedHandleScope handle_scope; | 815 InitializedHandleScope handle_scope; |
| 820 BytecodeGeneratorHelper helper; | 816 BytecodeGeneratorHelper helper; |
| 821 Zone zone; | 817 Zone zone; |
| 822 | 818 |
| 823 FeedbackVectorSpec feedback_spec(&zone); | 819 FeedbackVectorSpec feedback_spec(&zone); |
| 824 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); | 820 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); |
| 825 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); | 821 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); |
| 826 | 822 |
| 827 Handle<i::TypeFeedbackVector> vector = | 823 Handle<i::TypeFeedbackVector> vector = |
| 828 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 824 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 829 | 825 |
| 830 ExpectedSnippet<const char*> snippets[] = { | 826 ExpectedSnippet<const char*> snippets[] = { |
| 831 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", | 827 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", |
| 832 kPointerSize, | 828 0, |
| 833 2, | 829 2, |
| 834 12, | 830 8, |
| 835 { | 831 { |
| 836 B(LdaConstant), U8(0), // | 832 B(LdaConstant), U8(1), // |
| 837 B(Star), R(0), // | 833 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // |
| 838 B(LdaConstant), U8(1), // | 834 B(LdaUndefined), // |
| 839 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // | 835 B(Return), // |
| 840 B(LdaUndefined), // | |
| 841 B(Return), // | |
| 842 }, | 836 }, |
| 843 2, | 837 2, |
| 844 {"name", "val"}}, | 838 {"name", "val"}}, |
| 845 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", | 839 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", |
| 846 kPointerSize, | 840 0, |
| 847 2, | 841 2, |
| 848 12, | 842 8, |
| 849 { | 843 { |
| 850 B(LdaConstant), U8(0), // | 844 B(LdaConstant), U8(1), // |
| 851 B(Star), R(0), // | 845 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // |
| 852 B(LdaConstant), U8(1), // | 846 B(LdaUndefined), // |
| 853 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // | 847 B(Return), // |
| 854 B(LdaUndefined), // | |
| 855 B(Return), // | |
| 856 }, | 848 }, |
| 857 2, | 849 2, |
| 858 {"key", "val"}}, | 850 {"key", "val"}}, |
| 859 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", | 851 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", |
| 860 kPointerSize, | 852 kPointerSize, |
| 861 2, | 853 2, |
| 862 12, | 854 12, |
| 863 { | 855 { |
| 864 B(LdaSmi8), U8(100), // | 856 B(LdaSmi8), U8(100), // |
| 865 B(Star), R(0), // | 857 B(Star), R(0), // |
| 866 B(LdaConstant), U8(0), // | 858 B(LdaConstant), U8(0), // |
| 867 B(KeyedStoreICSloppy), // | 859 B(KeyedStoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // |
| 868 A(1, 2), R(0), U8(vector->GetIndex(slot1)), // | 860 B(LdaUndefined), // |
| 869 B(LdaUndefined), // | 861 B(Return), // |
| 870 B(Return), // | |
| 871 }, | 862 }, |
| 872 1, | 863 1, |
| 873 {"val"}}, | 864 {"val"}}, |
| 874 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")", | 865 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")", |
| 875 0, | 866 0, |
| 876 3, | 867 3, |
| 877 8, | 868 8, |
| 878 { | 869 { |
| 879 B(LdaConstant), U8(0), // | 870 B(LdaConstant), U8(0), // |
| 880 B(KeyedStoreICSloppy), // | 871 B(KeyedStoreICSloppy), A(1, 3), A(2, 3), // |
| 881 A(1, 3), A(2, 3), U8(vector->GetIndex(slot1)), // | 872 U8(vector->GetIndex(slot1)), // |
| 882 B(LdaUndefined), // | 873 B(LdaUndefined), // |
| 883 B(Return), // | 874 B(Return), // |
| 884 }, | 875 }, |
| 885 1, | 876 1, |
| 886 {"val"}}, | 877 {"val"}}, |
| 887 {"function f(a) { a.name = a[-124]; }\n" | 878 {"function f(a) { a.name = a[-124]; }\n" |
| 888 "f({\"-124\" : \"test\", name : 123 })", | 879 "f({\"-124\" : \"test\", name : 123 })", |
| 889 kPointerSize, | 880 0, |
| 890 2, | 881 2, |
| 891 15, | 882 11, |
| 892 { | 883 { |
| 893 B(LdaConstant), U8(0), // | 884 B(LdaSmi8), U8(-124), // |
| 894 B(Star), R(0), // | 885 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // |
| 895 B(LdaSmi8), U8(-124), // | 886 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot2)), // |
| 896 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // | 887 B(LdaUndefined), // |
| 897 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot2)), // | 888 B(Return), // |
| 898 B(LdaUndefined), // | |
| 899 B(Return), // | |
| 900 }, | 889 }, |
| 901 1, | 890 1, |
| 902 {"name"}}, | 891 {"name"}}, |
| 903 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" | 892 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" |
| 904 "f({name : \"test\"})", | 893 "f({name : \"test\"})", |
| 905 kPointerSize, | 894 0, |
| 906 2, | 895 2, |
| 907 12, | 896 8, |
| 908 { | 897 { |
| 909 B(LdaConstant), U8(0), // | 898 B(LdaConstant), U8(1), // |
| 910 B(Star), R(0), // | 899 B(StoreICStrict), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), // |
| 911 B(LdaConstant), U8(1), // | 900 B(LdaUndefined), // |
| 912 B(StoreICStrict), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // | 901 B(Return), // |
| 913 B(LdaUndefined), // | |
| 914 B(Return), // | |
| 915 }, | 902 }, |
| 916 2, | 903 2, |
| 917 {"name", "val"}}, | 904 {"name", "val"}}, |
| 918 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" | 905 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" |
| 919 "f({arg : \"test\"}, \"arg\")", | 906 "f({arg : \"test\"}, \"arg\")", |
| 920 0, | 907 0, |
| 921 3, | 908 3, |
| 922 8, | 909 8, |
| 923 { | 910 { |
| 924 B(LdaConstant), U8(0), // | 911 B(LdaConstant), U8(0), // |
| 925 B(KeyedStoreICStrict), A(1, 3), A(2, 3), // | 912 B(KeyedStoreICStrict), A(1, 3), A(2, 3), // |
| 926 U8(vector->GetIndex(slot1)), // | 913 U8(vector->GetIndex(slot1)), // |
| 927 B(LdaUndefined), // | 914 B(LdaUndefined), // |
| 928 B(Return), // | 915 B(Return), // |
| 929 }, | 916 }, |
| 930 1, | 917 1, |
| 931 {"val"}}}; | 918 {"val"}}}; |
| 932 for (size_t i = 0; i < arraysize(snippets); i++) { | 919 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 933 Handle<BytecodeArray> bytecode_array = | 920 Handle<BytecodeArray> bytecode_array = |
| 934 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 921 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 935 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 922 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 936 } | 923 } |
| 937 } | 924 } |
| 938 | 925 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 950 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); | 937 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); |
| 951 USE(slot1); | 938 USE(slot1); |
| 952 | 939 |
| 953 Handle<i::TypeFeedbackVector> vector = | 940 Handle<i::TypeFeedbackVector> vector = |
| 954 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 941 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 955 | 942 |
| 956 ExpectedSnippet<const char*> snippets[] = { | 943 ExpectedSnippet<const char*> snippets[] = { |
| 957 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", | 944 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", |
| 958 2 * kPointerSize, | 945 2 * kPointerSize, |
| 959 2, | 946 2, |
| 960 16, | 947 15, |
| 961 { | 948 { |
| 962 B(Ldar), A(1, 2), // | 949 B(Ldar), A(1, 2), // |
| 963 B(Star), R(1), // | 950 B(Star), R(1), // |
| 964 B(LdaConstant), U8(0), // | 951 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), // |
| 965 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 952 B(Star), R(0), // |
| 966 B(Star), R(0), // | 953 B(Call), R(0), R(1), U8(0), // |
| 967 B(Call), R(0), R(1), U8(0), // | 954 B(Return), // |
| 968 B(Return), // | |
| 969 }, | 955 }, |
| 970 1, | 956 1, |
| 971 {"func"}}, | 957 {"func"}}, |
| 972 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", | 958 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", |
| 973 4 * kPointerSize, | 959 4 * kPointerSize, |
| 974 4, | 960 4, |
| 975 24, | 961 23, |
| 976 { | 962 { |
| 977 B(Ldar), A(1, 4), // | 963 B(Ldar), A(1, 4), // |
| 978 B(Star), R(1), // | 964 B(Star), R(1), // |
| 979 B(LdaConstant), U8(0), // | 965 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), // |
| 980 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 966 B(Star), R(0), // |
| 981 B(Star), R(0), // | 967 B(Ldar), A(2, 4), // |
| 982 B(Ldar), A(2, 4), // | 968 B(Star), R(2), // |
| 983 B(Star), R(2), // | 969 B(Ldar), A(3, 4), // |
| 984 B(Ldar), A(3, 4), // | 970 B(Star), R(3), // |
| 985 B(Star), R(3), // | 971 B(Call), R(0), R(1), U8(2), // |
| 986 B(Call), R(0), R(1), U8(2), // | 972 B(Return) // |
| 987 B(Return) // | |
| 988 }, | 973 }, |
| 989 1, | 974 1, |
| 990 {"func"}}, | 975 {"func"}}, |
| 991 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", | 976 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", |
| 992 4 * kPointerSize, | 977 4 * kPointerSize, |
| 993 3, | 978 3, |
| 994 26, | 979 25, |
| 995 { | 980 { |
| 996 B(Ldar), A(1, 3), // | 981 B(Ldar), A(1, 3), // |
| 997 B(Star), R(1), // | 982 B(Star), R(1), // |
| 998 B(LdaConstant), U8(0), // | 983 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), // |
| 999 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 984 B(Star), R(0), // |
| 1000 B(Star), R(0), // | 985 B(Ldar), A(2, 3), // |
| 1001 B(Ldar), A(2, 3), // | 986 B(Add), A(2, 3), // |
| 1002 B(Add), A(2, 3), // | 987 B(Star), R(2), // |
| 1003 B(Star), R(2), // | 988 B(Ldar), A(2, 3), // |
| 1004 B(Ldar), A(2, 3), // | 989 B(Star), R(3), // |
| 1005 B(Star), R(3), // | 990 B(Call), R(0), R(1), U8(2), // |
| 1006 B(Call), R(0), R(1), U8(2), // | 991 B(Return), // |
| 1007 B(Return), // | |
| 1008 }, | 992 }, |
| 1009 1, | 993 1, |
| 1010 {"func"}}}; | 994 {"func"}}}; |
| 1011 for (size_t i = 0; i < arraysize(snippets); i++) { | 995 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1012 Handle<BytecodeArray> bytecode_array = | 996 Handle<BytecodeArray> bytecode_array = |
| 1013 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 997 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1014 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 998 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1015 } | 999 } |
| 1016 } | 1000 } |
| 1017 | 1001 |
| 1018 | 1002 |
| 1019 TEST(LoadGlobal) { | 1003 TEST(LoadGlobal) { |
| 1020 InitializedHandleScope handle_scope; | 1004 InitializedHandleScope handle_scope; |
| 1021 BytecodeGeneratorHelper helper; | 1005 BytecodeGeneratorHelper helper; |
| 1006 Zone zone; |
| 1022 | 1007 |
| 1023 if (!FLAG_global_var_shortcuts) return; | 1008 FeedbackVectorSpec feedback_spec(&zone); |
| 1009 FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); |
| 1024 | 1010 |
| 1025 ExpectedSnippet<int> snippets[] = { | 1011 Handle<i::TypeFeedbackVector> vector = |
| 1026 { | 1012 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 1027 "var a = 1;\nfunction f() { return a; }\nf()", | 1013 |
| 1028 0, | 1014 ExpectedSnippet<const char*> snippets[] = { |
| 1029 1, | 1015 {"var a = 1;\nfunction f() { return a; }\nf()", |
| 1030 3, | 1016 0, |
| 1031 { | 1017 1, |
| 1032 B(LdaGlobal), _, // | 1018 4, |
| 1033 B(Return) // | 1019 { |
| 1034 }, | 1020 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), // |
| 1035 }, | 1021 B(Return) // |
| 1036 { | 1022 }, |
| 1037 "function t() { }\nfunction f() { return t; }\nf()", | 1023 1, |
| 1038 0, | 1024 {"a"}}, |
| 1039 1, | 1025 {"function t() { }\nfunction f() { return t; }\nf()", |
| 1040 3, | 1026 0, |
| 1041 { | 1027 1, |
| 1042 B(LdaGlobal), _, // | 1028 4, |
| 1043 B(Return) // | 1029 { |
| 1044 }, | 1030 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), // |
| 1045 }, | 1031 B(Return) // |
| 1032 }, |
| 1033 1, |
| 1034 {"t"}}, |
| 1035 {"'use strict'; var a = 1;\nfunction f() { return a; }\nf()", |
| 1036 0, |
| 1037 1, |
| 1038 4, |
| 1039 { |
| 1040 B(LdaGlobalStrict), U8(0), U8(vector->GetIndex(slot)), // |
| 1041 B(Return) // |
| 1042 }, |
| 1043 1, |
| 1044 {"a"}}, |
| 1045 {"a = 1;\nfunction f() { return a; }\nf()", |
| 1046 0, |
| 1047 1, |
| 1048 4, |
| 1049 { |
| 1050 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), // |
| 1051 B(Return) // |
| 1052 }, |
| 1053 1, |
| 1054 {"a"}}, |
| 1046 }; | 1055 }; |
| 1047 | 1056 |
| 1048 for (size_t i = 0; i < arraysize(snippets); i++) { | 1057 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1049 Handle<BytecodeArray> bytecode_array = | 1058 Handle<BytecodeArray> bytecode_array = |
| 1050 helper.MakeBytecode(snippets[i].code_snippet, "f"); | 1059 helper.MakeBytecode(snippets[i].code_snippet, "f"); |
| 1051 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | 1060 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1052 } | 1061 } |
| 1053 } | 1062 } |
| 1054 | 1063 |
| 1055 | 1064 |
| 1056 TEST(StoreGlobal) { | 1065 TEST(StoreGlobal) { |
| 1057 InitializedHandleScope handle_scope; | 1066 InitializedHandleScope handle_scope; |
| 1058 BytecodeGeneratorHelper helper; | 1067 BytecodeGeneratorHelper helper; |
| 1059 | |
| 1060 if (!FLAG_global_var_shortcuts) return; | |
| 1061 | |
| 1062 ExpectedSnippet<InstanceType> snippets[] = { | |
| 1063 { | |
| 1064 "var a = 1;\nfunction f() { a = 2; }\nf()", | |
| 1065 0, | |
| 1066 1, | |
| 1067 6, | |
| 1068 { | |
| 1069 B(LdaSmi8), U8(2), // | |
| 1070 B(StaGlobalSloppy), _, // | |
| 1071 B(LdaUndefined), // | |
| 1072 B(Return) // | |
| 1073 }, | |
| 1074 }, | |
| 1075 { | |
| 1076 "var a = \"test\"; function f(b) { a = b; }\nf(\"global\")", | |
| 1077 0, | |
| 1078 2, | |
| 1079 6, | |
| 1080 { | |
| 1081 B(Ldar), R(helper.kLastParamIndex), // | |
| 1082 B(StaGlobalSloppy), _, // | |
| 1083 B(LdaUndefined), // | |
| 1084 B(Return) // | |
| 1085 }, | |
| 1086 }, | |
| 1087 { | |
| 1088 "'use strict'; var a = 1;\nfunction f() { a = 2; }\nf()", | |
| 1089 0, | |
| 1090 1, | |
| 1091 6, | |
| 1092 { | |
| 1093 B(LdaSmi8), U8(2), // | |
| 1094 B(StaGlobalStrict), _, // | |
| 1095 B(LdaUndefined), // | |
| 1096 B(Return) // | |
| 1097 }, | |
| 1098 }, | |
| 1099 }; | |
| 1100 | |
| 1101 for (size_t i = 0; i < arraysize(snippets); i++) { | |
| 1102 Handle<BytecodeArray> bytecode_array = | |
| 1103 helper.MakeBytecode(snippets[i].code_snippet, "f"); | |
| 1104 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | |
| 1105 } | |
| 1106 } | |
| 1107 | |
| 1108 | |
| 1109 TEST(CallGlobal) { | |
| 1110 InitializedHandleScope handle_scope; | |
| 1111 BytecodeGeneratorHelper helper; | |
| 1112 | |
| 1113 if (!FLAG_global_var_shortcuts) return; | |
| 1114 | |
| 1115 ExpectedSnippet<int> snippets[] = { | |
| 1116 { | |
| 1117 "function t() { }\nfunction f() { return t(); }\nf()", | |
| 1118 2 * kPointerSize, | |
| 1119 1, | |
| 1120 12, | |
| 1121 { | |
| 1122 B(LdaUndefined), // | |
| 1123 B(Star), R(1), // | |
| 1124 B(LdaGlobal), _, // | |
| 1125 B(Star), R(0), // | |
| 1126 B(Call), R(0), R(1), U8(0), // | |
| 1127 B(Return) // | |
| 1128 }, | |
| 1129 }, | |
| 1130 { | |
| 1131 "function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()", | |
| 1132 5 * kPointerSize, | |
| 1133 1, | |
| 1134 24, | |
| 1135 { | |
| 1136 B(LdaUndefined), // | |
| 1137 B(Star), R(1), // | |
| 1138 B(LdaGlobal), _, // | |
| 1139 B(Star), R(0), // | |
| 1140 B(LdaSmi8), U8(1), // | |
| 1141 B(Star), R(2), // | |
| 1142 B(LdaSmi8), U8(2), // | |
| 1143 B(Star), R(3), // | |
| 1144 B(LdaSmi8), U8(3), // | |
| 1145 B(Star), R(4), // | |
| 1146 B(Call), R(0), R(1), U8(3), // | |
| 1147 B(Return) // | |
| 1148 }, | |
| 1149 }, | |
| 1150 }; | |
| 1151 | |
| 1152 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); | |
| 1153 for (size_t i = 0; i < num_snippets; i++) { | |
| 1154 Handle<BytecodeArray> bytecode_array = | |
| 1155 helper.MakeBytecode(snippets[i].code_snippet, "f"); | |
| 1156 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | |
| 1157 } | |
| 1158 } | |
| 1159 | |
| 1160 | |
| 1161 TEST(LoadUnallocated) { | |
| 1162 InitializedHandleScope handle_scope; | |
| 1163 BytecodeGeneratorHelper helper; | |
| 1164 Zone zone; | 1068 Zone zone; |
| 1165 | 1069 |
| 1166 int context_reg = Register::function_context().index(); | |
| 1167 int global_index = Context::GLOBAL_OBJECT_INDEX; | |
| 1168 | |
| 1169 FeedbackVectorSpec feedback_spec(&zone); | 1070 FeedbackVectorSpec feedback_spec(&zone); |
| 1170 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); | 1071 FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot(); |
| 1171 | 1072 |
| 1172 Handle<i::TypeFeedbackVector> vector = | 1073 Handle<i::TypeFeedbackVector> vector = |
| 1173 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 1074 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 1174 | 1075 |
| 1175 ExpectedSnippet<const char*> snippets[] = { | 1076 ExpectedSnippet<const char*> snippets[] = { |
| 1176 {"a = 1;\nfunction f() { return a; }\nf()", | 1077 {"var a = 1;\nfunction f() { a = 2; }\nf()", |
| 1177 1 * kPointerSize, | 1078 0, |
| 1178 1, | 1079 1, |
| 1179 11, | 1080 7, |
| 1180 {B(LdaContextSlot), R(context_reg), U8(global_index), // | 1081 { |
| 1181 B(Star), R(0), // | 1082 B(LdaSmi8), U8(2), // |
| 1182 B(LdaConstant), U8(0), // | 1083 B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), // |
| 1183 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | 1084 B(LdaUndefined), // |
| 1184 B(Return)}, | 1085 B(Return) // |
| 1086 }, |
| 1185 1, | 1087 1, |
| 1186 {"a"}}, | 1088 {"a"}}, |
| 1187 {"function f() { return t; }\nt = 1;\nf()", | 1089 {"var a = \"test\"; function f(b) { a = b; }\nf(\"global\")", |
| 1188 1 * kPointerSize, | 1090 0, |
| 1091 2, |
| 1092 7, |
| 1093 { |
| 1094 B(Ldar), R(helper.kLastParamIndex), // |
| 1095 B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), // |
| 1096 B(LdaUndefined), // |
| 1097 B(Return) // |
| 1098 }, |
| 1189 1, | 1099 1, |
| 1190 11, | 1100 {"a"}}, |
| 1191 {B(LdaContextSlot), R(context_reg), U8(global_index), // | 1101 {"'use strict'; var a = 1;\nfunction f() { a = 2; }\nf()", |
| 1192 B(Star), R(0), // | 1102 0, |
| 1193 B(LdaConstant), U8(0), // | |
| 1194 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // | |
| 1195 B(Return)}, | |
| 1196 1, | 1103 1, |
| 1197 {"t"}}, | 1104 7, |
| 1105 { |
| 1106 B(LdaSmi8), U8(2), // |
| 1107 B(StaGlobalStrict), U8(0), U8(vector->GetIndex(slot)), // |
| 1108 B(LdaUndefined), // |
| 1109 B(Return) // |
| 1110 }, |
| 1111 1, |
| 1112 {"a"}}, |
| 1113 {"a = 1;\nfunction f() { a = 2; }\nf()", |
| 1114 0, |
| 1115 1, |
| 1116 7, |
| 1117 { |
| 1118 B(LdaSmi8), U8(2), // |
| 1119 B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), // |
| 1120 B(LdaUndefined), // |
| 1121 B(Return) // |
| 1122 }, |
| 1123 1, |
| 1124 {"a"}}, |
| 1198 }; | 1125 }; |
| 1199 | 1126 |
| 1200 for (size_t i = 0; i < arraysize(snippets); i++) { | 1127 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1201 Handle<BytecodeArray> bytecode_array = | 1128 Handle<BytecodeArray> bytecode_array = |
| 1202 helper.MakeBytecode(snippets[i].code_snippet, "f"); | 1129 helper.MakeBytecode(snippets[i].code_snippet, "f"); |
| 1203 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1130 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1204 } | 1131 } |
| 1205 } | 1132 } |
| 1206 | 1133 |
| 1207 | 1134 |
| 1208 TEST(StoreUnallocated) { | 1135 TEST(CallGlobal) { |
| 1209 InitializedHandleScope handle_scope; | 1136 InitializedHandleScope handle_scope; |
| 1210 BytecodeGeneratorHelper helper; | 1137 BytecodeGeneratorHelper helper; |
| 1211 Zone zone; | 1138 Zone zone; |
| 1212 | 1139 |
| 1213 int context_reg = Register::function_context().index(); | |
| 1214 int global_index = Context::GLOBAL_OBJECT_INDEX; | |
| 1215 | |
| 1216 FeedbackVectorSpec feedback_spec(&zone); | 1140 FeedbackVectorSpec feedback_spec(&zone); |
| 1217 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); | 1141 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); |
| 1142 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); |
| 1143 USE(slot1); |
| 1218 | 1144 |
| 1219 Handle<i::TypeFeedbackVector> vector = | 1145 Handle<i::TypeFeedbackVector> vector = |
| 1220 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 1146 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 1221 | 1147 |
| 1222 ExpectedSnippet<const char*> snippets[] = { | 1148 ExpectedSnippet<const char*> snippets[] = { |
| 1223 {"a = 1;\nfunction f() { a = 2; }\nf()", | 1149 {"function t() { }\nfunction f() { return t(); }\nf()", |
| 1224 3 * kPointerSize, | 1150 2 * kPointerSize, |
| 1225 1, | 1151 1, |
| 1226 21, | 1152 13, |
| 1227 {B(LdaSmi8), U8(2), // | 1153 { |
| 1228 B(Star), R(0), // | 1154 B(LdaUndefined), // |
| 1229 B(LdaContextSlot), R(context_reg), U8(global_index), // | 1155 B(Star), R(1), // |
| 1230 B(Star), R(1), // | 1156 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), // |
| 1231 B(LdaConstant), U8(0), // | 1157 B(Star), R(0), // |
| 1232 B(Star), R(2), // | 1158 B(Call), R(0), R(1), U8(0), // |
| 1233 B(Ldar), R(0), // | 1159 B(Return) // |
| 1234 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), // | 1160 }, |
| 1235 B(LdaUndefined), // | |
| 1236 B(Return)}, | |
| 1237 1, | 1161 1, |
| 1238 {"a"}}, | 1162 {"t"}}, |
| 1239 {"function f() { t = 4; }\nf()\nt = 1;", | 1163 {"function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()", |
| 1240 3 * kPointerSize, | 1164 5 * kPointerSize, |
| 1241 1, | 1165 1, |
| 1242 21, | 1166 25, |
| 1243 {B(LdaSmi8), U8(4), // | 1167 { |
| 1244 B(Star), R(0), // | 1168 B(LdaUndefined), // |
| 1245 B(LdaContextSlot), R(context_reg), U8(global_index), // | 1169 B(Star), R(1), // |
| 1246 B(Star), R(1), // | 1170 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), // |
| 1247 B(LdaConstant), U8(0), // | 1171 B(Star), R(0), // |
| 1248 B(Star), R(2), // | 1172 B(LdaSmi8), U8(1), // |
| 1249 B(Ldar), R(0), // | 1173 B(Star), R(2), // |
| 1250 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), // | 1174 B(LdaSmi8), U8(2), // |
| 1251 B(LdaUndefined), // | 1175 B(Star), R(3), // |
| 1252 B(Return)}, | 1176 B(LdaSmi8), U8(3), // |
| 1177 B(Star), R(4), // |
| 1178 B(Call), R(0), R(1), U8(3), // |
| 1179 B(Return) // |
| 1180 }, |
| 1253 1, | 1181 1, |
| 1254 {"t"}}, | 1182 {"t"}}, |
| 1255 }; | 1183 }; |
| 1256 | 1184 |
| 1257 for (size_t i = 0; i < arraysize(snippets); i++) { | 1185 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
| 1186 for (size_t i = 0; i < num_snippets; i++) { |
| 1258 Handle<BytecodeArray> bytecode_array = | 1187 Handle<BytecodeArray> bytecode_array = |
| 1259 helper.MakeBytecode(snippets[i].code_snippet, "f"); | 1188 helper.MakeBytecode(snippets[i].code_snippet, "f"); |
| 1260 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1189 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1261 } | 1190 } |
| 1262 } | 1191 } |
| 1263 | 1192 |
| 1264 | 1193 |
| 1265 TEST(CallRuntime) { | 1194 TEST(CallRuntime) { |
| 1266 InitializedHandleScope handle_scope; | 1195 InitializedHandleScope handle_scope; |
| 1267 BytecodeGeneratorHelper helper; | 1196 BytecodeGeneratorHelper helper; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 }; | 1402 }; |
| 1474 | 1403 |
| 1475 for (size_t i = 0; i < arraysize(snippets); i++) { | 1404 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1476 Handle<BytecodeArray> bytecode_array = | 1405 Handle<BytecodeArray> bytecode_array = |
| 1477 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1406 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1478 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1407 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1479 } | 1408 } |
| 1480 } | 1409 } |
| 1481 | 1410 |
| 1482 | 1411 |
| 1483 // Tests !FLAG_global_var_shortcuts mode. | |
| 1484 TEST(DeclareGlobals) { | 1412 TEST(DeclareGlobals) { |
| 1485 InitializedHandleScope handle_scope; | 1413 InitializedHandleScope handle_scope; |
| 1486 BytecodeGeneratorHelper helper; | 1414 BytecodeGeneratorHelper helper; |
| 1487 Zone zone; | 1415 Zone zone; |
| 1488 | 1416 |
| 1489 if (FLAG_global_var_shortcuts) return; | 1417 // Create different feedback vector specs to be precise on slot numbering. |
| 1418 FeedbackVectorSpec feedback_spec_stores(&zone); |
| 1419 FeedbackVectorSlot store_slot_1 = feedback_spec_stores.AddStoreICSlot(); |
| 1420 FeedbackVectorSlot store_slot_2 = feedback_spec_stores.AddStoreICSlot(); |
| 1421 USE(store_slot_1); |
| 1490 | 1422 |
| 1491 int context_reg = Register::function_context().index(); | 1423 Handle<i::TypeFeedbackVector> store_vector = |
| 1492 int global_index = Context::GLOBAL_OBJECT_INDEX; | 1424 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_stores); |
| 1493 | 1425 |
| 1494 // Create different feedback vector specs to be precise on slot numbering. | 1426 FeedbackVectorSpec feedback_spec_loads(&zone); |
| 1495 FeedbackVectorSpec feedback_spec_ss(&zone); | 1427 FeedbackVectorSlot load_slot_1 = feedback_spec_loads.AddLoadICSlot(); |
| 1496 FeedbackVectorSlot slot_ss_1 = feedback_spec_ss.AddStoreICSlot(); | |
| 1497 FeedbackVectorSlot slot_ss_2 = feedback_spec_ss.AddStoreICSlot(); | |
| 1498 USE(slot_ss_1); | |
| 1499 | 1428 |
| 1500 Handle<i::TypeFeedbackVector> vector_ss = | 1429 Handle<i::TypeFeedbackVector> load_vector = |
| 1501 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_ss); | 1430 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_loads); |
| 1502 | |
| 1503 FeedbackVectorSpec feedback_spec_l(&zone); | |
| 1504 FeedbackVectorSlot slot_l_1 = feedback_spec_l.AddLoadICSlot(); | |
| 1505 | |
| 1506 Handle<i::TypeFeedbackVector> vector_l = | |
| 1507 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_l); | |
| 1508 | |
| 1509 | 1431 |
| 1510 ExpectedSnippet<InstanceType> snippets[] = { | 1432 ExpectedSnippet<InstanceType> snippets[] = { |
| 1511 {"var a = 1;", | 1433 {"var a = 1;", |
| 1512 4 * kPointerSize, | 1434 4 * kPointerSize, |
| 1513 1, | 1435 1, |
| 1514 30, | 1436 30, |
| 1515 { | 1437 { |
| 1516 B(LdaConstant), U8(0), // | 1438 B(LdaConstant), U8(0), // |
| 1517 B(Star), R(1), // | 1439 B(Star), R(1), // |
| 1518 B(LdaZero), // | 1440 B(LdaZero), // |
| 1519 B(Star), R(2), // | 1441 B(Star), R(2), // |
| 1520 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 1442 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
| 1521 B(LdaConstant), U8(1), // | 1443 B(LdaConstant), U8(1), // |
| 1522 B(Star), R(1), // | 1444 B(Star), R(1), // |
| 1523 B(LdaZero), // | 1445 B(LdaZero), // |
| 1524 B(Star), R(2), // | 1446 B(Star), R(2), // |
| 1525 B(LdaSmi8), U8(1), // | 1447 B(LdaSmi8), U8(1), // |
| 1526 B(Star), R(3), // | 1448 B(Star), R(3), // |
| 1527 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), // | 1449 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // |
| 1528 U8(3), // | 1450 B(LdaUndefined), // |
| 1529 B(LdaUndefined), // | 1451 B(Return) // |
| 1530 B(Return) // | |
| 1531 }, | 1452 }, |
| 1532 2, | 1453 2, |
| 1533 {InstanceType::FIXED_ARRAY_TYPE, | 1454 {InstanceType::FIXED_ARRAY_TYPE, |
| 1534 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1455 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1535 {"function f() {}", | 1456 {"function f() {}", |
| 1536 2 * kPointerSize, | 1457 2 * kPointerSize, |
| 1537 1, | 1458 1, |
| 1538 14, | 1459 14, |
| 1539 { | 1460 { |
| 1540 B(LdaConstant), U8(0), // | 1461 B(LdaConstant), U8(0), // |
| 1541 B(Star), R(0), // | 1462 B(Star), R(0), // |
| 1542 B(LdaZero), // | 1463 B(LdaZero), // |
| 1543 B(Star), R(1), // | 1464 B(Star), R(1), // |
| 1544 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), // | 1465 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), // |
| 1545 B(LdaUndefined), // | 1466 B(LdaUndefined), // |
| 1546 B(Return) // | 1467 B(Return) // |
| 1547 }, | 1468 }, |
| 1548 1, | 1469 1, |
| 1549 {InstanceType::FIXED_ARRAY_TYPE}}, | 1470 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 1550 {"var a = 1;\na=2;", | 1471 {"var a = 1;\na=2;", |
| 1551 4 * kPointerSize, | 1472 4 * kPointerSize, |
| 1552 1, | 1473 1, |
| 1553 52, | 1474 38, |
| 1554 { | 1475 { |
| 1555 B(LdaConstant), U8(0), // | 1476 B(LdaConstant), U8(0), // |
| 1556 B(Star), R(1), // | 1477 B(Star), R(1), // |
| 1557 B(LdaZero), // | 1478 B(LdaZero), // |
| 1558 B(Star), R(2), // | 1479 B(Star), R(2), // |
| 1559 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 1480 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
| 1560 B(LdaConstant), U8(1), // | 1481 B(LdaConstant), U8(1), // |
| 1561 B(Star), R(1), // | 1482 B(Star), R(1), // |
| 1562 B(LdaZero), // | 1483 B(LdaZero), // |
| 1563 B(Star), R(2), // | 1484 B(Star), R(2), // |
| 1564 B(LdaSmi8), U8(1), // | 1485 B(LdaSmi8), U8(1), // |
| 1565 B(Star), R(3), // | 1486 B(Star), R(3), // |
| 1566 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), // | 1487 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // |
| 1567 U8(3), // | 1488 B(LdaSmi8), U8(2), // |
| 1568 B(LdaSmi8), U8(2), // | 1489 B(StaGlobalSloppy), U8(1), U8(store_vector->GetIndex(store_slot_2)), // |
| 1569 B(Star), R(1), // | 1490 B(Star), R(0), // |
| 1570 B(LdaContextSlot), R(context_reg), U8(global_index), // | 1491 B(Ldar), R(0), // |
| 1571 B(Star), R(2), // | 1492 B(Return) // |
| 1572 B(LdaConstant), U8(1), // | |
| 1573 B(Star), R(3), // | |
| 1574 B(Ldar), R(1), // | |
| 1575 B(StoreICSloppy), R(2), R(3), U8(vector_ss->GetIndex(slot_ss_2)), // | |
| 1576 B(Star), R(0), // | |
| 1577 B(Ldar), R(0), // | |
| 1578 B(Return) // | |
| 1579 }, | 1493 }, |
| 1580 2, | 1494 2, |
| 1581 {InstanceType::FIXED_ARRAY_TYPE, | 1495 {InstanceType::FIXED_ARRAY_TYPE, |
| 1582 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1496 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1583 {"function f() {}\nf();", | 1497 {"function f() {}\nf();", |
| 1584 4 * kPointerSize, | 1498 3 * kPointerSize, |
| 1585 1, | 1499 1, |
| 1586 36, | 1500 29, |
| 1587 { | 1501 { |
| 1588 B(LdaConstant), U8(0), // | 1502 B(LdaConstant), U8(0), // |
| 1589 B(Star), R(1), // | 1503 B(Star), R(1), // |
| 1590 B(LdaZero), // | 1504 B(LdaZero), // |
| 1591 B(Star), R(2), // | 1505 B(Star), R(2), // |
| 1592 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 1506 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
| 1593 B(LdaUndefined), // | 1507 B(LdaUndefined), // |
| 1594 B(Star), R(2), // | 1508 B(Star), R(2), // |
| 1595 B(LdaContextSlot), R(context_reg), U8(global_index), // | 1509 B(LdaGlobalSloppy), U8(1), U8(load_vector->GetIndex(load_slot_1)), // |
| 1596 B(Star), R(3), // | 1510 B(Star), R(1), // |
| 1597 B(LdaConstant), U8(1), // | 1511 B(Call), R(1), R(2), U8(0), // |
| 1598 B(LoadICSloppy), R(3), U8(vector_l->GetIndex(slot_l_1)), // | 1512 B(Star), R(0), // |
| 1599 B(Star), R(1), // | 1513 B(Ldar), R(0), // |
| 1600 B(Call), R(1), R(2), U8(0), // | 1514 B(Return) // |
| 1601 B(Star), R(0), // | |
| 1602 B(Ldar), R(0), // | |
| 1603 B(Return) // | |
| 1604 }, | 1515 }, |
| 1605 2, | 1516 2, |
| 1606 {InstanceType::FIXED_ARRAY_TYPE, | 1517 {InstanceType::FIXED_ARRAY_TYPE, |
| 1607 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1518 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 1608 }; | 1519 }; |
| 1609 | 1520 |
| 1610 for (size_t i = 0; i < arraysize(snippets); i++) { | 1521 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1611 Handle<BytecodeArray> bytecode_array = | |
| 1612 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | |
| 1613 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | |
| 1614 } | |
| 1615 } | |
| 1616 | |
| 1617 | |
| 1618 // Tests FLAG_global_var_shortcuts mode. | |
| 1619 // TODO(ishell): remove when FLAG_global_var_shortcuts is removed. | |
| 1620 TEST(DeclareGlobals2) { | |
| 1621 InitializedHandleScope handle_scope; | |
| 1622 BytecodeGeneratorHelper helper; | |
| 1623 | |
| 1624 if (!FLAG_global_var_shortcuts) return; | |
| 1625 | |
| 1626 ExpectedSnippet<InstanceType> snippets[] = { | |
| 1627 {"var a = 1;", | |
| 1628 5 * kPointerSize, | |
| 1629 1, | |
| 1630 45, | |
| 1631 { | |
| 1632 B(Ldar), R(Register::function_closure().index()), // | |
| 1633 B(Star), R(2), // | |
| 1634 B(LdaConstant), U8(0), // | |
| 1635 B(Star), R(3), // | |
| 1636 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // | |
| 1637 B(PushContext), R(1), // | |
| 1638 B(LdaConstant), U8(1), // | |
| 1639 B(Star), R(2), // | |
| 1640 B(LdaZero), // | |
| 1641 B(Star), R(3), // | |
| 1642 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // | |
| 1643 B(LdaConstant), U8(2), // | |
| 1644 B(Star), R(2), // | |
| 1645 B(LdaZero), // | |
| 1646 B(Star), R(3), // | |
| 1647 B(LdaSmi8), U8(1), // | |
| 1648 B(Star), R(4), // | |
| 1649 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // | |
| 1650 B(LdaUndefined), // | |
| 1651 B(Return), // | |
| 1652 }, | |
| 1653 3, | |
| 1654 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | |
| 1655 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | |
| 1656 {"function f() {}", | |
| 1657 3 * kPointerSize, | |
| 1658 1, | |
| 1659 29, | |
| 1660 { | |
| 1661 B(Ldar), R(Register::function_closure().index()), // | |
| 1662 B(Star), R(1), // | |
| 1663 B(LdaConstant), U8(0), // | |
| 1664 B(Star), R(2), // | |
| 1665 B(CallRuntime), U16(Runtime::kNewScriptContext), R(1), U8(2), // | |
| 1666 B(PushContext), R(0), // | |
| 1667 B(LdaConstant), U8(1), // | |
| 1668 B(Star), R(1), // | |
| 1669 B(LdaZero), // | |
| 1670 B(Star), R(2), // | |
| 1671 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | |
| 1672 B(LdaUndefined), // | |
| 1673 B(Return) // | |
| 1674 }, | |
| 1675 2, | |
| 1676 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, | |
| 1677 {"var a = 1;\na=2;", | |
| 1678 5 * kPointerSize, | |
| 1679 1, | |
| 1680 52, | |
| 1681 { | |
| 1682 B(Ldar), R(Register::function_closure().index()), // | |
| 1683 B(Star), R(2), // | |
| 1684 B(LdaConstant), U8(0), // | |
| 1685 B(Star), R(3), // | |
| 1686 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // | |
| 1687 B(PushContext), R(1), // | |
| 1688 B(LdaConstant), U8(1), // | |
| 1689 B(Star), R(2), // | |
| 1690 B(LdaZero), // | |
| 1691 B(Star), R(3), // | |
| 1692 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // | |
| 1693 B(LdaConstant), U8(2), // | |
| 1694 B(Star), R(2), // | |
| 1695 B(LdaZero), // | |
| 1696 B(Star), R(3), // | |
| 1697 B(LdaSmi8), U8(1), // | |
| 1698 B(Star), R(4), // | |
| 1699 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // | |
| 1700 U8(3), // | |
| 1701 B(LdaSmi8), U8(2), // | |
| 1702 B(StaGlobalSloppy), _, // | |
| 1703 B(Star), R(0), // | |
| 1704 B(Ldar), R(0), // | |
| 1705 B(Return) // | |
| 1706 }, | |
| 1707 3, | |
| 1708 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | |
| 1709 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | |
| 1710 {"function f() {}\nf();", | |
| 1711 4 * kPointerSize, | |
| 1712 1, | |
| 1713 43, | |
| 1714 { | |
| 1715 B(Ldar), R(Register::function_closure().index()), // | |
| 1716 B(Star), R(2), // | |
| 1717 B(LdaConstant), U8(0), // | |
| 1718 B(Star), R(3), // | |
| 1719 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // | |
| 1720 B(PushContext), R(1), // | |
| 1721 B(LdaConstant), U8(1), // | |
| 1722 B(Star), R(2), // | |
| 1723 B(LdaZero), // | |
| 1724 B(Star), R(3), // | |
| 1725 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // | |
| 1726 B(LdaUndefined), // | |
| 1727 B(Star), R(3), // | |
| 1728 B(LdaGlobal), _, // | |
| 1729 B(Star), R(2), // | |
| 1730 B(Call), R(2), R(3), U8(0), // | |
| 1731 B(Star), R(0), // | |
| 1732 B(Ldar), R(0), // | |
| 1733 B(Return) // | |
| 1734 }, | |
| 1735 2, | |
| 1736 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}}, | |
| 1737 }; | |
| 1738 | |
| 1739 for (size_t i = 0; i < arraysize(snippets); i++) { | |
| 1740 Handle<BytecodeArray> bytecode_array = | 1522 Handle<BytecodeArray> bytecode_array = |
| 1741 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 1523 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
| 1742 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | 1524 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); |
| 1743 } | 1525 } |
| 1744 } | 1526 } |
| 1745 | 1527 |
| 1746 | 1528 |
| 1747 TEST(BasicLoops) { | 1529 TEST(BasicLoops) { |
| 1748 InitializedHandleScope handle_scope; | 1530 InitializedHandleScope handle_scope; |
| 1749 BytecodeGeneratorHelper helper; | 1531 BytecodeGeneratorHelper helper; |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 | 1918 |
| 2137 Handle<i::TypeFeedbackVector> vector = | 1919 Handle<i::TypeFeedbackVector> vector = |
| 2138 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 1920 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 2139 | 1921 |
| 2140 ExpectedSnippet<const char*> snippets[] = { | 1922 ExpectedSnippet<const char*> snippets[] = { |
| 2141 {"return /ab+d/;", | 1923 {"return /ab+d/;", |
| 2142 1 * kPointerSize, | 1924 1 * kPointerSize, |
| 2143 1, | 1925 1, |
| 2144 10, | 1926 10, |
| 2145 { | 1927 { |
| 2146 B(LdaConstant), U8(0), // | 1928 B(LdaConstant), U8(0), // |
| 2147 B(Star), R(0), // | 1929 B(Star), R(0), // |
| 2148 B(LdaConstant), U8(1), // | 1930 B(LdaConstant), U8(1), // |
| 2149 B(CreateRegExpLiteral), U8(0), R(0), // | 1931 B(CreateRegExpLiteral), U8(0), R(0), // |
| 2150 B(Return), // | 1932 B(Return), // |
| 2151 }, | 1933 }, |
| 2152 2, | 1934 2, |
| 2153 {"", "ab+d"}}, | 1935 {"", "ab+d"}}, |
| 2154 {"return /(\\w+)\\s(\\w+)/i;", | 1936 {"return /(\\w+)\\s(\\w+)/i;", |
| 2155 1 * kPointerSize, | 1937 1 * kPointerSize, |
| 2156 1, | 1938 1, |
| 2157 10, | 1939 10, |
| 2158 { | 1940 { |
| 2159 B(LdaConstant), U8(0), // | 1941 B(LdaConstant), U8(0), // |
| 2160 B(Star), R(0), // | 1942 B(Star), R(0), // |
| 2161 B(LdaConstant), U8(1), // | 1943 B(LdaConstant), U8(1), // |
| 2162 B(CreateRegExpLiteral), U8(0), R(0), // | 1944 B(CreateRegExpLiteral), U8(0), R(0), // |
| 2163 B(Return), // | 1945 B(Return), // |
| 2164 }, | 1946 }, |
| 2165 2, | 1947 2, |
| 2166 {"i", "(\\w+)\\s(\\w+)"}}, | 1948 {"i", "(\\w+)\\s(\\w+)"}}, |
| 2167 {"return /ab+d/.exec('abdd');", | 1949 {"return /ab+d/.exec('abdd');", |
| 2168 3 * kPointerSize, | 1950 3 * kPointerSize, |
| 2169 1, | 1951 1, |
| 2170 27, | 1952 26, |
| 2171 { | 1953 { |
| 2172 B(LdaConstant), U8(0), // | 1954 B(LdaConstant), U8(0), // |
| 2173 B(Star), R(2), // | 1955 B(Star), R(2), // |
| 2174 B(LdaConstant), U8(1), // | 1956 B(LdaConstant), U8(1), // |
| 2175 B(CreateRegExpLiteral), U8(0), R(2), // | 1957 B(CreateRegExpLiteral), U8(0), R(2), // |
| 2176 B(Star), R(1), // | 1958 B(Star), R(1), // |
| 2177 B(LdaConstant), U8(2), // | 1959 B(LoadICSloppy), R(1), U8(2), U8(vector->GetIndex(slot2)), // |
| 2178 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 1960 B(Star), R(0), // |
| 2179 B(Star), R(0), // | 1961 B(LdaConstant), U8(3), // |
| 2180 B(LdaConstant), U8(3), // | 1962 B(Star), R(2), // |
| 2181 B(Star), R(2), // | 1963 B(Call), R(0), R(1), U8(1), // |
| 2182 B(Call), R(0), R(1), U8(1), // | 1964 B(Return), // |
| 2183 B(Return), // | |
| 2184 }, | 1965 }, |
| 2185 4, | 1966 4, |
| 2186 {"", "ab+d", "exec", "abdd"}}, | 1967 {"", "ab+d", "exec", "abdd"}}, |
| 2187 }; | 1968 }; |
| 2188 | 1969 |
| 2189 for (size_t i = 0; i < arraysize(snippets); i++) { | 1970 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2190 Handle<BytecodeArray> bytecode_array = | 1971 Handle<BytecodeArray> bytecode_array = |
| 2191 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 1972 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2192 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1973 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2193 } | 1974 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 Handle<BytecodeArray> bytecode_array = | 2083 Handle<BytecodeArray> bytecode_array = |
| 2303 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2084 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2304 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2085 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2305 } | 2086 } |
| 2306 } | 2087 } |
| 2307 | 2088 |
| 2308 | 2089 |
| 2309 TEST(ObjectLiterals) { | 2090 TEST(ObjectLiterals) { |
| 2310 InitializedHandleScope handle_scope; | 2091 InitializedHandleScope handle_scope; |
| 2311 BytecodeGeneratorHelper helper; | 2092 BytecodeGeneratorHelper helper; |
| 2093 Zone zone; |
| 2094 |
| 2095 FeedbackVectorSpec feedback_spec(&zone); |
| 2096 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); |
| 2097 |
| 2098 Handle<i::TypeFeedbackVector> vector = |
| 2099 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 2312 | 2100 |
| 2313 int simple_flags = ObjectLiteral::kFastElements | | 2101 int simple_flags = ObjectLiteral::kFastElements | |
| 2314 ObjectLiteral::kShallowProperties | | 2102 ObjectLiteral::kShallowProperties | |
| 2315 ObjectLiteral::kDisableMementos; | 2103 ObjectLiteral::kDisableMementos; |
| 2316 int deep_elements_flags = | 2104 int deep_elements_flags = |
| 2317 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; | 2105 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; |
| 2318 ExpectedSnippet<InstanceType> snippets[] = { | 2106 ExpectedSnippet<InstanceType> snippets[] = { |
| 2319 {"return { };", | 2107 {"return { };", |
| 2320 0, | 2108 0, |
| 2321 1, | 2109 1, |
| 2322 6, | 2110 6, |
| 2323 { | 2111 { |
| 2324 B(LdaConstant), U8(0), // | 2112 B(LdaConstant), U8(0), // |
| 2325 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 2113 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 2326 B(Return) // | 2114 B(Return) // |
| 2327 }, | 2115 }, |
| 2328 1, | 2116 1, |
| 2329 {InstanceType::FIXED_ARRAY_TYPE}}, | 2117 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2330 {"return { name: 'string', val: 9.2 };", | 2118 {"return { name: 'string', val: 9.2 };", |
| 2331 0, | 2119 0, |
| 2332 1, | 2120 1, |
| 2333 6, | 2121 6, |
| 2334 { | 2122 { |
| 2335 B(LdaConstant), U8(0), // | 2123 B(LdaConstant), U8(0), // |
| 2336 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2124 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2337 B(Return) // | 2125 B(Return) // |
| 2338 }, | 2126 }, |
| 2339 1, | 2127 1, |
| 2340 {InstanceType::FIXED_ARRAY_TYPE}}, | 2128 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2341 {"var a = 1; return { name: 'string', val: a };", | 2129 {"var a = 1; return { name: 'string', val: a };", |
| 2342 3 * kPointerSize, | 2130 2 * kPointerSize, |
| 2343 1, | 2131 1, |
| 2344 24, | 2132 20, |
| 2345 { | 2133 { |
| 2346 B(LdaSmi8), U8(1), // | 2134 B(LdaSmi8), U8(1), // |
| 2347 B(Star), R(0), // | 2135 B(Star), R(0), // |
| 2348 B(LdaConstant), U8(0), // | 2136 B(LdaConstant), U8(0), // |
| 2349 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2137 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2350 B(Star), R(1), // | 2138 B(Star), R(1), // |
| 2351 B(LdaConstant), U8(1), // | 2139 B(Ldar), R(0), // |
| 2352 B(Star), R(2), // | 2140 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // |
| 2353 B(Ldar), R(0), // | 2141 B(Ldar), R(1), // |
| 2354 B(StoreICSloppy), R(1), R(2), U8(3), // | 2142 B(Return), // |
| 2355 B(Ldar), R(1), // | |
| 2356 B(Return), // | |
| 2357 }, | 2143 }, |
| 2358 2, | 2144 2, |
| 2359 {InstanceType::FIXED_ARRAY_TYPE, | 2145 {InstanceType::FIXED_ARRAY_TYPE, |
| 2360 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2146 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2361 {"var a = 1; return { val: a, val: a + 1 };", | 2147 {"var a = 1; return { val: a, val: a + 1 };", |
| 2362 3 * kPointerSize, | 2148 2 * kPointerSize, |
| 2363 1, | 2149 1, |
| 2364 26, | 2150 22, |
| 2365 { | 2151 { |
| 2366 B(LdaSmi8), U8(1), // | 2152 B(LdaSmi8), U8(1), // |
| 2367 B(Star), R(0), // | 2153 B(Star), R(0), // |
| 2368 B(LdaConstant), U8(0), // | 2154 B(LdaConstant), U8(0), // |
| 2369 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2155 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2370 B(Star), R(1), // | 2156 B(Star), R(1), // |
| 2371 B(LdaConstant), U8(1), // | 2157 B(LdaSmi8), U8(1), // |
| 2372 B(Star), R(2), // | 2158 B(Add), R(0), // |
| 2373 B(LdaSmi8), U8(1), // | 2159 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // |
| 2374 B(Add), R(0), // | 2160 B(Ldar), R(1), // |
| 2375 B(StoreICSloppy), R(1), R(2), U8(3), // | 2161 B(Return), // |
| 2376 B(Ldar), R(1), // | |
| 2377 B(Return), // | |
| 2378 }, | 2162 }, |
| 2379 2, | 2163 2, |
| 2380 {InstanceType::FIXED_ARRAY_TYPE, | 2164 {InstanceType::FIXED_ARRAY_TYPE, |
| 2381 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2165 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2382 {"return { func: function() { } };", | 2166 {"return { func: function() { } };", |
| 2383 2 * kPointerSize, | 2167 1 * kPointerSize, |
| 2384 1, | 2168 1, |
| 2385 22, | 2169 18, |
| 2386 { | 2170 { |
| 2387 B(LdaConstant), U8(0), // | 2171 B(LdaConstant), U8(0), // |
| 2388 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2172 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2389 B(Star), R(0), // | 2173 B(Star), R(0), // |
| 2390 B(LdaConstant), U8(1), // | 2174 B(LdaConstant), U8(2), // |
| 2391 B(Star), R(1), // | 2175 B(CreateClosure), U8(0), // |
| 2392 B(LdaConstant), U8(2), // | 2176 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // |
| 2393 B(CreateClosure), U8(0), // | 2177 B(Ldar), R(0), // |
| 2394 B(StoreICSloppy), R(0), R(1), U8(3), // | 2178 B(Return), // |
| 2395 B(Ldar), R(0), // | |
| 2396 B(Return), // | |
| 2397 }, | 2179 }, |
| 2398 3, | 2180 3, |
| 2399 {InstanceType::FIXED_ARRAY_TYPE, | 2181 {InstanceType::FIXED_ARRAY_TYPE, |
| 2400 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2182 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2401 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2183 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2402 {"return { func(a) { return a; } };", | 2184 {"return { func(a) { return a; } };", |
| 2403 2 * kPointerSize, | 2185 1 * kPointerSize, |
| 2404 1, | 2186 1, |
| 2405 22, | 2187 18, |
| 2406 { | 2188 { |
| 2407 B(LdaConstant), U8(0), // | 2189 B(LdaConstant), U8(0), // |
| 2408 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2190 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2409 B(Star), R(0), // | 2191 B(Star), R(0), // |
| 2410 B(LdaConstant), U8(1), // | 2192 B(LdaConstant), U8(2), // |
| 2411 B(Star), R(1), // | 2193 B(CreateClosure), U8(0), // |
| 2412 B(LdaConstant), U8(2), // | 2194 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // |
| 2413 B(CreateClosure), U8(0), // | 2195 B(Ldar), R(0), // |
| 2414 B(StoreICSloppy), R(0), R(1), U8(3), // | 2196 B(Return), // |
| 2415 B(Ldar), R(0), // | |
| 2416 B(Return), // | |
| 2417 }, | 2197 }, |
| 2418 3, | 2198 3, |
| 2419 {InstanceType::FIXED_ARRAY_TYPE, | 2199 {InstanceType::FIXED_ARRAY_TYPE, |
| 2420 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2200 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2421 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2201 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2422 {"return { get a() { return 2; } };", | 2202 {"return { get a() { return 2; } };", |
| 2423 5 * kPointerSize, | 2203 5 * kPointerSize, |
| 2424 1, | 2204 1, |
| 2425 31, | 2205 31, |
| 2426 { | 2206 { |
| 2427 B(LdaConstant), U8(0), // | 2207 B(LdaConstant), U8(0), // |
| 2428 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2208 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2429 B(Star), R(0), // | 2209 B(Star), R(0), // |
| 2430 B(LdaConstant), U8(1), // | 2210 B(LdaConstant), U8(1), // |
| 2431 B(Star), R(1), // | 2211 B(Star), R(1), // |
| 2432 B(LdaConstant), U8(2), // | 2212 B(LdaConstant), U8(2), // |
| 2433 B(CreateClosure), U8(0), // | 2213 B(CreateClosure), U8(0), // |
| 2434 B(Star), R(2), // | 2214 B(Star), R(2), // |
| 2435 B(LdaNull), // | 2215 B(LdaNull), // |
| 2436 B(Star), R(3), // | 2216 B(Star), R(3), // |
| 2437 B(LdaZero), // | 2217 B(LdaZero), // |
| 2438 B(Star), R(4), // | 2218 B(Star), R(4), // |
| 2439 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 2219 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 2440 R(0), U8(5), // | 2220 R(0), U8(5), // |
| 2441 B(Ldar), R(0), // | 2221 B(Ldar), R(0), // |
| 2442 B(Return), // | 2222 B(Return), // |
| 2443 }, | 2223 }, |
| 2444 3, | 2224 3, |
| 2445 {InstanceType::FIXED_ARRAY_TYPE, | 2225 {InstanceType::FIXED_ARRAY_TYPE, |
| 2446 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2226 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2447 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2227 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2448 {"return { get a() { return this.x; }, set a(val) { this.x = val } };", | 2228 {"return { get a() { return this.x; }, set a(val) { this.x = val } };", |
| 2449 5 * kPointerSize, | 2229 5 * kPointerSize, |
| 2450 1, | 2230 1, |
| 2451 34, | 2231 34, |
| 2452 { | 2232 { |
| 2453 B(LdaConstant), U8(0), // | 2233 B(LdaConstant), U8(0), // |
| 2454 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2234 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2455 B(Star), R(0), // | 2235 B(Star), R(0), // |
| 2456 B(LdaConstant), U8(1), // | 2236 B(LdaConstant), U8(1), // |
| 2457 B(Star), R(1), // | 2237 B(Star), R(1), // |
| 2458 B(LdaConstant), U8(2), // | 2238 B(LdaConstant), U8(2), // |
| 2459 B(CreateClosure), U8(0), // | 2239 B(CreateClosure), U8(0), // |
| 2460 B(Star), R(2), // | 2240 B(Star), R(2), // |
| 2461 B(LdaConstant), U8(3), // | 2241 B(LdaConstant), U8(3), // |
| 2462 B(CreateClosure), U8(0), // | 2242 B(CreateClosure), U8(0), // |
| 2463 B(Star), R(3), // | 2243 B(Star), R(3), // |
| 2464 B(LdaZero), // | 2244 B(LdaZero), // |
| 2465 B(Star), R(4), // | 2245 B(Star), R(4), // |
| 2466 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 2246 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 2467 R(0), U8(5), // | 2247 R(0), U8(5), // |
| 2468 B(Ldar), R(0), // | 2248 B(Ldar), R(0), // |
| 2469 B(Return), // | 2249 B(Return), // |
| 2470 }, | 2250 }, |
| 2471 4, | 2251 4, |
| 2472 {InstanceType::FIXED_ARRAY_TYPE, | 2252 {InstanceType::FIXED_ARRAY_TYPE, |
| 2473 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2253 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2474 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 2254 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 2475 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2255 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2476 {"return { set b(val) { this.y = val } };", | 2256 {"return { set b(val) { this.y = val } };", |
| 2477 5 * kPointerSize, | 2257 5 * kPointerSize, |
| 2478 1, | 2258 1, |
| 2479 31, | 2259 31, |
| 2480 { | 2260 { |
| 2481 B(LdaConstant), U8(0), // | 2261 B(LdaConstant), U8(0), // |
| 2482 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2262 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2483 B(Star), R(0), // | 2263 B(Star), R(0), // |
| 2484 B(LdaConstant), U8(1), // | 2264 B(LdaConstant), U8(1), // |
| 2485 B(Star), R(1), // | 2265 B(Star), R(1), // |
| 2486 B(LdaNull), // | 2266 B(LdaNull), // |
| 2487 B(Star), R(2), // | 2267 B(Star), R(2), // |
| 2488 B(LdaConstant), U8(2), // | 2268 B(LdaConstant), U8(2), // |
| 2489 B(CreateClosure), U8(0), // | 2269 B(CreateClosure), U8(0), // |
| 2490 B(Star), R(3), // | 2270 B(Star), R(3), // |
| 2491 B(LdaZero), // | 2271 B(LdaZero), // |
| 2492 B(Star), R(4), // | 2272 B(Star), R(4), // |
| 2493 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 2273 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 2494 R(0), U8(5), // | 2274 R(0), U8(5), // |
| 2495 B(Ldar), R(0), // | 2275 B(Ldar), R(0), // |
| 2496 B(Return), // | 2276 B(Return), // |
| 2497 }, | 2277 }, |
| 2498 3, | 2278 3, |
| 2499 {InstanceType::FIXED_ARRAY_TYPE, | 2279 {InstanceType::FIXED_ARRAY_TYPE, |
| 2500 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2280 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2501 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2281 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2502 {"var a = 1; return { 1: a };", | 2282 {"var a = 1; return { 1: a };", |
| 2503 5 * kPointerSize, | 2283 5 * kPointerSize, |
| 2504 1, | 2284 1, |
| 2505 30, | 2285 30, |
| 2506 { | 2286 { |
| 2507 B(LdaSmi8), U8(1), // | 2287 B(LdaSmi8), U8(1), // |
| 2508 B(Star), R(0), // | 2288 B(Star), R(0), // |
| 2509 B(LdaConstant), U8(0), // | 2289 B(LdaConstant), U8(0), // |
| 2510 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2290 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2511 B(Star), R(1), // | 2291 B(Star), R(1), // |
| 2512 B(LdaSmi8), U8(1), // | 2292 B(LdaSmi8), U8(1), // |
| 2513 B(Star), R(2), // | 2293 B(Star), R(2), // |
| 2514 B(Ldar), R(0), // | 2294 B(Ldar), R(0), // |
| 2515 B(Star), R(3), // | 2295 B(Star), R(3), // |
| 2516 B(LdaZero), // | 2296 B(LdaZero), // |
| 2517 B(Star), R(4), // | 2297 B(Star), R(4), // |
| 2518 B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), // | 2298 B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), // |
| 2519 B(Ldar), R(1), // | 2299 B(Ldar), R(1), // |
| 2520 B(Return), // | 2300 B(Return), // |
| 2521 }, | 2301 }, |
| 2522 1, | 2302 1, |
| 2523 {InstanceType::FIXED_ARRAY_TYPE}}, | 2303 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2524 {"return { __proto__: null }", | 2304 {"return { __proto__: null }", |
| 2525 2 * kPointerSize, | 2305 2 * kPointerSize, |
| 2526 1, | 2306 1, |
| 2527 18, | 2307 18, |
| 2528 { | 2308 { |
| 2529 B(LdaConstant), U8(0), // | 2309 B(LdaConstant), U8(0), // |
| 2530 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 2310 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 2531 B(Star), R(0), // | 2311 B(Star), R(0), // |
| 2532 B(LdaNull), B(Star), R(1), // | 2312 B(LdaNull), B(Star), R(1), // |
| 2533 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), // | 2313 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), // |
| 2534 B(Ldar), R(0), // | 2314 B(Ldar), R(0), // |
| 2535 B(Return), // | 2315 B(Return), // |
| 2536 }, | 2316 }, |
| 2537 1, | 2317 1, |
| 2538 {InstanceType::FIXED_ARRAY_TYPE}}, | 2318 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2539 {"var a = 'test'; return { [a]: 1 }", | 2319 {"var a = 'test'; return { [a]: 1 }", |
| 2540 5 * kPointerSize, | 2320 5 * kPointerSize, |
| 2541 1, | 2321 1, |
| 2542 31, | 2322 31, |
| 2543 { | 2323 { |
| 2544 B(LdaConstant), U8(0), // | 2324 B(LdaConstant), U8(0), // |
| 2545 B(Star), R(0), // | 2325 B(Star), R(0), // |
| 2546 B(LdaConstant), U8(1), // | 2326 B(LdaConstant), U8(1), // |
| 2547 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 2327 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 2548 B(Star), R(1), // | 2328 B(Star), R(1), // |
| 2549 B(Ldar), R(0), // | 2329 B(Ldar), R(0), // |
| 2550 B(ToName), // | 2330 B(ToName), // |
| 2551 B(Star), R(2), // | 2331 B(Star), R(2), // |
| 2552 B(LdaSmi8), U8(1), // | 2332 B(LdaSmi8), U8(1), // |
| 2553 B(Star), R(3), // | 2333 B(Star), R(3), // |
| 2554 B(LdaZero), // | 2334 B(LdaZero), // |
| 2555 B(Star), R(4), // | 2335 B(Star), R(4), // |
| 2556 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2336 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2557 U8(4), // | 2337 U8(4), // |
| 2558 B(Ldar), R(1), // | 2338 B(Ldar), R(1), // |
| 2559 B(Return), // | 2339 B(Return), // |
| 2560 }, | 2340 }, |
| 2561 2, | 2341 2, |
| 2562 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2342 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2563 InstanceType::FIXED_ARRAY_TYPE}}, | 2343 InstanceType::FIXED_ARRAY_TYPE}}, |
| 2564 {"var a = 'test'; return { val: a, [a]: 1 }", | 2344 {"var a = 'test'; return { val: a, [a]: 1 }", |
| 2565 5 * kPointerSize, | 2345 5 * kPointerSize, |
| 2566 1, | 2346 1, |
| 2567 41, | 2347 37, |
| 2568 { | 2348 { |
| 2569 B(LdaConstant), U8(0), // | 2349 B(LdaConstant), U8(0), // |
| 2570 B(Star), R(0), // | 2350 B(Star), R(0), // |
| 2571 B(LdaConstant), U8(1), // | 2351 B(LdaConstant), U8(1), // |
| 2572 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | 2352 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| 2573 B(Star), R(1), // | 2353 B(Star), R(1), // |
| 2574 B(LdaConstant), U8(2), // | 2354 B(Ldar), R(0), // |
| 2575 B(Star), R(2), // | 2355 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), // |
| 2576 B(Ldar), R(0), // | 2356 B(Ldar), R(0), // |
| 2577 B(StoreICSloppy), R(1), R(2), U8(3), // | 2357 B(ToName), // |
| 2578 B(Ldar), R(0), // | 2358 B(Star), R(2), // |
| 2579 B(ToName), // | 2359 B(LdaSmi8), U8(1), // |
| 2580 B(Star), R(2), // | 2360 B(Star), R(3), // |
| 2581 B(LdaSmi8), U8(1), // | 2361 B(LdaZero), // |
| 2582 B(Star), R(3), // | 2362 B(Star), R(4), // |
| 2583 B(LdaZero), // | 2363 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2584 B(Star), R(4), // | 2364 U8(4), // |
| 2585 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2365 B(Ldar), R(1), // |
| 2586 U8(4), // | 2366 B(Return), // |
| 2587 B(Ldar), R(1), // | |
| 2588 B(Return), // | |
| 2589 }, | 2367 }, |
| 2590 3, | 2368 3, |
| 2591 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2369 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2592 InstanceType::FIXED_ARRAY_TYPE, | 2370 InstanceType::FIXED_ARRAY_TYPE, |
| 2593 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2371 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2594 {"var a = 'test'; return { [a]: 1, __proto__: {} }", | 2372 {"var a = 'test'; return { [a]: 1, __proto__: {} }", |
| 2595 5 * kPointerSize, | 2373 5 * kPointerSize, |
| 2596 1, | 2374 1, |
| 2597 43, | 2375 43, |
| 2598 { | 2376 { |
| 2599 B(LdaConstant), U8(0), // | 2377 B(LdaConstant), U8(0), // |
| 2600 B(Star), R(0), // | 2378 B(Star), R(0), // |
| 2601 B(LdaConstant), U8(1), // | 2379 B(LdaConstant), U8(1), // |
| 2602 B(CreateObjectLiteral), U8(1), U8(simple_flags), // | 2380 B(CreateObjectLiteral), U8(1), U8(simple_flags), // |
| 2603 B(Star), R(1), // | 2381 B(Star), R(1), // |
| 2604 B(Ldar), R(0), // | 2382 B(Ldar), R(0), // |
| 2605 B(ToName), // | 2383 B(ToName), // |
| 2606 B(Star), R(2), // | 2384 B(Star), R(2), // |
| 2607 B(LdaSmi8), U8(1), // | 2385 B(LdaSmi8), U8(1), // |
| 2608 B(Star), R(3), // | 2386 B(Star), R(3), // |
| 2609 B(LdaZero), // | 2387 B(LdaZero), // |
| 2610 B(Star), R(4), // | 2388 B(Star), R(4), // |
| 2611 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2389 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2612 U8(4), // | 2390 U8(4), // |
| 2613 B(LdaConstant), U8(1), // | 2391 B(LdaConstant), U8(1), // |
| 2614 B(CreateObjectLiteral), U8(0), U8(13), // | 2392 B(CreateObjectLiteral), U8(0), U8(13), // |
| 2615 B(Star), R(2), // | 2393 B(Star), R(2), // |
| 2616 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // | 2394 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // |
| 2617 B(Ldar), R(1), // | 2395 B(Ldar), R(1), // |
| 2618 B(Return), // | 2396 B(Return), // |
| 2619 }, | 2397 }, |
| 2620 2, | 2398 2, |
| 2621 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2399 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2622 InstanceType::FIXED_ARRAY_TYPE}}, | 2400 InstanceType::FIXED_ARRAY_TYPE}}, |
| 2623 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", | 2401 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", |
| 2624 5 * kPointerSize, | 2402 5 * kPointerSize, |
| 2625 1, | 2403 1, |
| 2626 69, | 2404 69, |
| 2627 { | 2405 { |
| 2628 B(LdaConstant), U8(0), // | 2406 B(LdaConstant), U8(0), // |
| 2629 B(Star), R(0), // | 2407 B(Star), R(0), // |
| 2630 B(LdaConstant), U8(1), // | 2408 B(LdaConstant), U8(1), // |
| 2631 B(CreateObjectLiteral), U8(0), U8(simple_flags), // | 2409 B(CreateObjectLiteral), U8(0), U8(simple_flags), // |
| 2632 B(Star), R(1), // | 2410 B(Star), R(1), // |
| 2633 B(Ldar), R(0), // | 2411 B(Ldar), R(0), // |
| 2634 B(ToName), // | 2412 B(ToName), // |
| 2635 B(Star), R(2), // | 2413 B(Star), R(2), // |
| 2636 B(LdaConstant), U8(2), // | 2414 B(LdaConstant), U8(2), // |
| 2637 B(Star), R(3), // | 2415 B(Star), R(3), // |
| 2638 B(LdaZero), // | 2416 B(LdaZero), // |
| 2639 B(Star), R(4), // | 2417 B(Star), R(4), // |
| 2640 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 2418 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 2641 U8(4), // | 2419 U8(4), // |
| 2642 B(LdaConstant), U8(3), // | 2420 B(LdaConstant), U8(3), // |
| 2643 B(ToName), // | 2421 B(ToName), // |
| 2644 B(Star), R(2), // | 2422 B(Star), R(2), // |
| 2645 B(LdaConstant), U8(4), // | 2423 B(LdaConstant), U8(4), // |
| 2646 B(CreateClosure), U8(0), // | 2424 B(CreateClosure), U8(0), // |
| 2647 B(Star), R(3), // | 2425 B(Star), R(3), // |
| 2648 B(LdaZero), // | 2426 B(LdaZero), // |
| 2649 B(Star), R(4), // | 2427 B(Star), R(4), // |
| 2650 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // | 2428 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // |
| 2651 R(1), U8(4), // | 2429 R(1), U8(4), // |
| 2652 B(LdaConstant), U8(3), // | 2430 B(LdaConstant), U8(3), // |
| 2653 B(ToName), // | 2431 B(ToName), // |
| 2654 B(Star), R(2), // | 2432 B(Star), R(2), // |
| 2655 B(LdaConstant), U8(5), // | 2433 B(LdaConstant), U8(5), // |
| 2656 B(CreateClosure), U8(0), // | 2434 B(CreateClosure), U8(0), // |
| 2657 B(Star), R(3), // | 2435 B(Star), R(3), // |
| 2658 B(LdaZero), // | 2436 B(LdaZero), // |
| 2659 B(Star), R(4), // | 2437 B(Star), R(4), // |
| 2660 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // | 2438 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), R(1) // |
| 2661 R(1), U8(4), // | 2439 U8(4), // |
| 2662 B(Ldar), R(1), // | 2440 B(Ldar), R(1), // |
| 2663 B(Return), // | 2441 B(Return), // |
| 2664 }, | 2442 }, |
| 2665 6, | 2443 6, |
| 2666 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2444 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2667 InstanceType::FIXED_ARRAY_TYPE, | 2445 InstanceType::FIXED_ARRAY_TYPE, |
| 2668 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2446 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2669 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2447 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2670 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 2448 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 2671 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2449 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2672 }; | 2450 }; |
| 2673 | 2451 |
| 2674 for (size_t i = 0; i < arraysize(snippets); i++) { | 2452 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2675 Handle<BytecodeArray> bytecode_array = | 2453 Handle<BytecodeArray> bytecode_array = |
| 2676 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2454 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2677 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2455 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2678 } | 2456 } |
| 2679 } | 2457 } |
| 2680 | 2458 |
| 2681 | 2459 |
| 2682 // Tests !FLAG_global_var_shortcuts mode. | |
| 2683 TEST(TopLevelObjectLiterals) { | 2460 TEST(TopLevelObjectLiterals) { |
| 2684 InitializedHandleScope handle_scope; | 2461 InitializedHandleScope handle_scope; |
| 2685 BytecodeGeneratorHelper helper; | 2462 BytecodeGeneratorHelper helper; |
| 2686 | 2463 |
| 2687 if (FLAG_global_var_shortcuts) return; | |
| 2688 | |
| 2689 int has_function_flags = ObjectLiteral::kFastElements | | 2464 int has_function_flags = ObjectLiteral::kFastElements | |
| 2690 ObjectLiteral::kHasFunction | | 2465 ObjectLiteral::kHasFunction | |
| 2691 ObjectLiteral::kDisableMementos; | 2466 ObjectLiteral::kDisableMementos; |
| 2692 ExpectedSnippet<InstanceType> snippets[] = { | 2467 ExpectedSnippet<InstanceType> snippets[] = { |
| 2693 {"var a = { func: function() { } };", | 2468 {"var a = { func: function() { } };", |
| 2694 6 * kPointerSize, | 2469 5 * kPointerSize, |
| 2695 1, | 2470 1, |
| 2696 54, | 2471 50, |
| 2697 { | 2472 { |
| 2698 B(LdaConstant), U8(0), // | 2473 B(LdaConstant), U8(0), // |
| 2699 B(Star), R(1), // | 2474 B(Star), R(1), // |
| 2700 B(LdaZero), // | 2475 B(LdaZero), // |
| 2701 B(Star), R(2), // | 2476 B(Star), R(2), // |
| 2702 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 2477 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
| 2703 B(LdaConstant), U8(1), // | 2478 B(LdaConstant), U8(1), // |
| 2704 B(Star), R(1), // | 2479 B(Star), R(1), // |
| 2705 B(LdaZero), // | 2480 B(LdaZero), // |
| 2706 B(Star), R(2), // | 2481 B(Star), R(2), // |
| 2707 B(LdaConstant), U8(2), // | 2482 B(LdaConstant), U8(2), // |
| 2708 B(CreateObjectLiteral), U8(0), U8(has_function_flags), // | 2483 B(CreateObjectLiteral), U8(0), U8(has_function_flags), // |
| 2709 B(Star), R(4), // | 2484 B(Star), R(4), // |
| 2710 B(LdaConstant), U8(3), // | 2485 B(LdaConstant), U8(4), // |
| 2711 B(Star), R(5), // | 2486 B(CreateClosure), U8(1), // |
| 2712 B(LdaConstant), U8(4), // | 2487 B(StoreICSloppy), R(4), U8(3), U8(5), // |
| 2713 B(CreateClosure), U8(1), // | 2488 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), // |
| 2714 B(StoreICSloppy), R(4), R(5), U8(5), // | 2489 B(Ldar), R(4), // |
| 2715 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), // | 2490 B(Star), R(3), // |
| 2716 B(Ldar), R(4), // | 2491 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // |
| 2717 B(Star), R(3), // | 2492 B(LdaUndefined), // |
| 2718 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // | 2493 B(Return), // |
| 2719 B(LdaUndefined), // | |
| 2720 B(Return), // | |
| 2721 }, | 2494 }, |
| 2722 5, | 2495 5, |
| 2723 {InstanceType::FIXED_ARRAY_TYPE, | 2496 {InstanceType::FIXED_ARRAY_TYPE, |
| 2724 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2497 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2725 InstanceType::FIXED_ARRAY_TYPE, | 2498 InstanceType::FIXED_ARRAY_TYPE, |
| 2726 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 2499 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 2727 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | |
| 2728 }; | |
| 2729 | |
| 2730 for (size_t i = 0; i < arraysize(snippets); i++) { | |
| 2731 Handle<BytecodeArray> bytecode_array = | |
| 2732 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | |
| 2733 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | |
| 2734 } | |
| 2735 } | |
| 2736 | |
| 2737 | |
| 2738 // Tests FLAG_global_var_shortcuts mode. | |
| 2739 // TODO(ishell): remove when FLAG_global_var_shortcuts is removed. | |
| 2740 TEST(TopLevelObjectLiterals2) { | |
| 2741 InitializedHandleScope handle_scope; | |
| 2742 BytecodeGeneratorHelper helper; | |
| 2743 | |
| 2744 if (!FLAG_global_var_shortcuts) return; | |
| 2745 | |
| 2746 int has_function_flags = ObjectLiteral::kFastElements | | |
| 2747 ObjectLiteral::kHasFunction | | |
| 2748 ObjectLiteral::kDisableMementos; | |
| 2749 ExpectedSnippet<InstanceType> snippets[] = { | |
| 2750 {"var a = { func: function() { } };", | |
| 2751 7 * kPointerSize, | |
| 2752 1, | |
| 2753 69, | |
| 2754 { | |
| 2755 B(Ldar), R(Register::function_closure().index()), // | |
| 2756 B(Star), R(2), // | |
| 2757 B(LdaConstant), U8(0), // | |
| 2758 B(Star), R(3), // | |
| 2759 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), // | |
| 2760 B(PushContext), R(1), // | |
| 2761 B(LdaConstant), U8(1), // | |
| 2762 B(Star), R(2), // | |
| 2763 B(LdaZero), // | |
| 2764 B(Star), R(3), // | |
| 2765 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // | |
| 2766 B(LdaConstant), U8(2), // | |
| 2767 B(Star), R(2), // | |
| 2768 B(LdaZero), // | |
| 2769 B(Star), R(3), // | |
| 2770 B(LdaConstant), U8(3), // | |
| 2771 B(CreateObjectLiteral), U8(0), U8(has_function_flags), // | |
| 2772 B(Star), R(5), // | |
| 2773 B(LdaConstant), U8(4), // | |
| 2774 B(Star), R(6), // | |
| 2775 B(LdaConstant), U8(5), // | |
| 2776 B(CreateClosure), U8(1), // | |
| 2777 B(StoreICSloppy), R(5), R(6), U8(3), // | |
| 2778 B(CallRuntime), U16(Runtime::kToFastProperties), R(5), U8(1), // | |
| 2779 B(Ldar), R(5), // | |
| 2780 B(Star), R(4), // | |
| 2781 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), // | |
| 2782 B(LdaUndefined), // | |
| 2783 B(Return), | |
| 2784 }, | |
| 2785 6, | |
| 2786 {InstanceType::FIXED_ARRAY_TYPE, | |
| 2787 InstanceType::FIXED_ARRAY_TYPE, | |
| 2788 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | |
| 2789 InstanceType::FIXED_ARRAY_TYPE, | |
| 2790 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | |
| 2791 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2500 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2792 }; | 2501 }; |
| 2793 | 2502 |
| 2794 for (size_t i = 0; i < arraysize(snippets); i++) { | 2503 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2795 Handle<BytecodeArray> bytecode_array = | 2504 Handle<BytecodeArray> bytecode_array = |
| 2796 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 2505 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
| 2797 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2506 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2798 } | 2507 } |
| 2799 } | 2508 } |
| 2800 | 2509 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2915 }; | 2624 }; |
| 2916 | 2625 |
| 2917 for (size_t i = 0; i < arraysize(snippets); i++) { | 2626 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2918 Handle<BytecodeArray> bytecode_array = | 2627 Handle<BytecodeArray> bytecode_array = |
| 2919 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2628 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2920 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2629 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2921 } | 2630 } |
| 2922 } | 2631 } |
| 2923 | 2632 |
| 2924 | 2633 |
| 2925 // Tests !FLAG_global_var_shortcuts mode. | |
| 2926 TEST(CallNew) { | 2634 TEST(CallNew) { |
| 2927 InitializedHandleScope handle_scope; | 2635 InitializedHandleScope handle_scope; |
| 2928 BytecodeGeneratorHelper helper; | 2636 BytecodeGeneratorHelper helper; |
| 2929 Zone zone; | 2637 Zone zone; |
| 2930 | 2638 |
| 2931 if (FLAG_global_var_shortcuts) return; | |
| 2932 | |
| 2933 int context_reg = Register::function_context().index(); | |
| 2934 int global_index = Context::GLOBAL_OBJECT_INDEX; | |
| 2935 | |
| 2936 FeedbackVectorSpec feedback_spec(&zone); | 2639 FeedbackVectorSpec feedback_spec(&zone); |
| 2937 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); | 2640 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); |
| 2938 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); | 2641 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); |
| 2939 USE(slot1); | 2642 USE(slot1); |
| 2940 | 2643 |
| 2941 Handle<i::TypeFeedbackVector> vector = | 2644 Handle<i::TypeFeedbackVector> vector = |
| 2942 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 2645 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 2943 | 2646 |
| 2944 ExpectedSnippet<InstanceType> snippets[] = { | 2647 ExpectedSnippet<InstanceType> snippets[] = { |
| 2945 {"function bar() { this.value = 0; }\n" | 2648 {"function bar() { this.value = 0; }\n" |
| 2946 "function f() { return new bar(); }\n" | 2649 "function f() { return new bar(); }\n" |
| 2947 "f()", | 2650 "f()", |
| 2948 2 * kPointerSize, | 2651 1 * kPointerSize, |
| 2949 1, | 2652 1, |
| 2950 17, | 2653 10, |
| 2951 { | 2654 { |
| 2952 B(LdaContextSlot), R(context_reg), U8(global_index), // | 2655 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), // |
| 2953 B(Star), R(1), // | 2656 B(Star), R(0), // |
| 2954 B(LdaConstant), U8(0), // | 2657 B(New), R(0), R(0), U8(0), // |
| 2955 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 2658 B(Return), // |
| 2956 B(Star), R(0), // | |
| 2957 B(New), R(0), R(0), U8(0), // | |
| 2958 B(Return), // | |
| 2959 }, | 2659 }, |
| 2960 1, | 2660 1, |
| 2961 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2661 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2962 {"function bar(x) { this.value = 18; this.x = x;}\n" | 2662 {"function bar(x) { this.value = 18; this.x = x;}\n" |
| 2963 "function f() { return new bar(3); }\n" | 2663 "function f() { return new bar(3); }\n" |
| 2964 "f()", | 2664 "f()", |
| 2965 2 * kPointerSize, | 2665 2 * kPointerSize, |
| 2966 1, | 2666 1, |
| 2967 21, | 2667 14, |
| 2968 { | 2668 { |
| 2969 B(LdaContextSlot), R(context_reg), U8(global_index), // | 2669 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), // |
| 2970 B(Star), R(1), // | 2670 B(Star), R(0), // |
| 2971 B(LdaConstant), U8(0), // | 2671 B(LdaSmi8), U8(3), // |
| 2972 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 2672 B(Star), R(1), // |
| 2973 B(Star), R(0), // | 2673 B(New), R(0), R(1), U8(1), // |
| 2974 B(LdaSmi8), U8(3), // | 2674 B(Return), // |
| 2975 B(Star), R(1), // | |
| 2976 B(New), R(0), R(1), U8(1), // | |
| 2977 B(Return), // | |
| 2978 }, | 2675 }, |
| 2979 1, | 2676 1, |
| 2980 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2677 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 2981 {"function bar(w, x, y, z) {\n" | 2678 {"function bar(w, x, y, z) {\n" |
| 2982 " this.value = 18;\n" | 2679 " this.value = 18;\n" |
| 2983 " this.x = x;\n" | 2680 " this.x = x;\n" |
| 2984 " this.y = y;\n" | 2681 " this.y = y;\n" |
| 2985 " this.z = z;\n" | 2682 " this.z = z;\n" |
| 2986 "}\n" | 2683 "}\n" |
| 2987 "function f() { return new bar(3, 4, 5); }\n" | 2684 "function f() { return new bar(3, 4, 5); }\n" |
| 2988 "f()", | 2685 "f()", |
| 2989 4 * kPointerSize, | 2686 4 * kPointerSize, |
| 2990 1, | 2687 1, |
| 2991 29, | 2688 22, |
| 2992 { | 2689 { |
| 2993 B(LdaContextSlot), R(context_reg), U8(global_index), // | 2690 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), // |
| 2994 B(Star), R(1), // | 2691 B(Star), R(0), // |
| 2995 B(LdaConstant), U8(0), // | 2692 B(LdaSmi8), U8(3), // |
| 2996 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 2693 B(Star), R(1), // |
| 2997 B(Star), R(0), // | 2694 B(LdaSmi8), U8(4), // |
| 2998 B(LdaSmi8), U8(3), // | 2695 B(Star), R(2), // |
| 2999 B(Star), R(1), // | 2696 B(LdaSmi8), U8(5), // |
| 3000 B(LdaSmi8), U8(4), // | 2697 B(Star), R(3), // |
| 3001 B(Star), R(2), // | 2698 B(New), R(0), R(1), U8(3), // |
| 3002 B(LdaSmi8), U8(5), // | 2699 B(Return), // |
| 3003 B(Star), R(3), // | |
| 3004 B(New), R(0), R(1), U8(3), // | |
| 3005 B(Return), // | |
| 3006 }, | 2700 }, |
| 3007 1, | 2701 1, |
| 3008 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 2702 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 3009 }; | 2703 }; |
| 3010 | 2704 |
| 3011 for (size_t i = 0; i < arraysize(snippets); i++) { | 2705 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 3012 Handle<BytecodeArray> bytecode_array = | 2706 Handle<BytecodeArray> bytecode_array = |
| 3013 helper.MakeBytecode(snippets[i].code_snippet, "f"); | 2707 helper.MakeBytecode(snippets[i].code_snippet, "f"); |
| 3014 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | 2708 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); |
| 3015 } | 2709 } |
| 3016 } | 2710 } |
| 3017 | 2711 |
| 3018 | 2712 |
| 3019 // Tests FLAG_global_var_shortcuts mode. | |
| 3020 // TODO(ishell): remove when FLAG_global_var_shortcuts is removed. | |
| 3021 TEST(CallNew2) { | |
| 3022 InitializedHandleScope handle_scope; | |
| 3023 BytecodeGeneratorHelper helper; | |
| 3024 | |
| 3025 if (!FLAG_global_var_shortcuts) return; | |
| 3026 | |
| 3027 ExpectedSnippet<InstanceType> snippets[] = { | |
| 3028 {"function bar() { this.value = 0; }\n" | |
| 3029 "function f() { return new bar(); }\n" | |
| 3030 "f()", | |
| 3031 kPointerSize, | |
| 3032 1, | |
| 3033 9, | |
| 3034 { | |
| 3035 B(LdaGlobal), _, // | |
| 3036 B(Star), R(0), // | |
| 3037 B(New), R(0), R(0), U8(0), // | |
| 3038 B(Return), // | |
| 3039 }, | |
| 3040 0}, | |
| 3041 {"function bar(x) { this.value = 18; this.x = x;}\n" | |
| 3042 "function f() { return new bar(3); }\n" | |
| 3043 "f()", | |
| 3044 2 * kPointerSize, | |
| 3045 1, | |
| 3046 13, | |
| 3047 { | |
| 3048 B(LdaGlobal), _, // | |
| 3049 B(Star), R(0), // | |
| 3050 B(LdaSmi8), U8(3), // | |
| 3051 B(Star), R(1), // | |
| 3052 B(New), R(0), R(1), U8(1), // | |
| 3053 B(Return), // | |
| 3054 }, | |
| 3055 0}, | |
| 3056 {"function bar(w, x, y, z) {\n" | |
| 3057 " this.value = 18;\n" | |
| 3058 " this.x = x;\n" | |
| 3059 " this.y = y;\n" | |
| 3060 " this.z = z;\n" | |
| 3061 "}\n" | |
| 3062 "function f() { return new bar(3, 4, 5); }\n" | |
| 3063 "f()", | |
| 3064 4 * kPointerSize, | |
| 3065 1, | |
| 3066 21, | |
| 3067 { | |
| 3068 B(LdaGlobal), _, // | |
| 3069 B(Star), R(0), // | |
| 3070 B(LdaSmi8), U8(3), // | |
| 3071 B(Star), R(1), // | |
| 3072 B(LdaSmi8), U8(4), // | |
| 3073 B(Star), R(2), // | |
| 3074 B(LdaSmi8), U8(5), // | |
| 3075 B(Star), R(3), // | |
| 3076 B(New), R(0), R(1), U8(3), // | |
| 3077 B(Return), // | |
| 3078 }, | |
| 3079 0}}; | |
| 3080 | |
| 3081 for (size_t i = 0; i < arraysize(snippets); i++) { | |
| 3082 Handle<BytecodeArray> bytecode_array = | |
| 3083 helper.MakeBytecode(snippets[i].code_snippet, "f"); | |
| 3084 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | |
| 3085 } | |
| 3086 } | |
| 3087 | |
| 3088 | |
| 3089 TEST(ContextVariables) { | 2713 TEST(ContextVariables) { |
| 3090 InitializedHandleScope handle_scope; | 2714 InitializedHandleScope handle_scope; |
| 3091 BytecodeGeneratorHelper helper; | 2715 BytecodeGeneratorHelper helper; |
| 3092 | 2716 |
| 3093 int closure = Register::function_closure().index(); | 2717 int closure = Register::function_closure().index(); |
| 3094 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 2718 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 3095 ExpectedSnippet<InstanceType> snippets[] = { | 2719 ExpectedSnippet<InstanceType> snippets[] = { |
| 3096 {"var a; return function() { a = 1; };", | 2720 {"var a; return function() { a = 1; };", |
| 3097 1 * kPointerSize, | 2721 1 * kPointerSize, |
| 3098 1, | 2722 1, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3284 for (size_t i = 0; i < arraysize(snippets); i++) { | 2908 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 3285 Handle<BytecodeArray> bytecode_array = | 2909 Handle<BytecodeArray> bytecode_array = |
| 3286 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 2910 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
| 3287 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2911 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 3288 } | 2912 } |
| 3289 } | 2913 } |
| 3290 | 2914 |
| 3291 } // namespace interpreter | 2915 } // namespace interpreter |
| 3292 } // namespace internal | 2916 } // namespace internal |
| 3293 } // namespace v8 | 2917 } // namespace v8 |
| OLD | NEW |