Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1419003002: [Interpreter] Unify global and unallocated variable access. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix unallocated variable error Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
799 "f({arg : \"test\"}, \"arg\")", 795 "function f(a, b) { \"use strict\"; return a[b]; }\n"
800 0, 796 "f({arg : \"test\"}, \"arg\")",
801 3, 797 0,
802 6, 798 3,
803 { 799 6,
804 B(Ldar), A(2, 3), // 800 {
805 B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), // 801 B(Ldar), A(2, 3), //
806 B(Return), // 802 B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), //
807 }, 803 B(Return), //
808 0, 804 },
809 }}; 805 0,
806 }};
810 for (size_t i = 0; i < arraysize(snippets); i++) { 807 for (size_t i = 0; i < arraysize(snippets); i++) {
811 Handle<BytecodeArray> bytecode_array = 808 Handle<BytecodeArray> bytecode_array =
812 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 809 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
813 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 810 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
814 } 811 }
815 } 812 }
816 813
817 814
818 TEST(PropertyStores) { 815 TEST(PropertyStores) {
819 InitializedHandleScope handle_scope; 816 InitializedHandleScope handle_scope;
820 BytecodeGeneratorHelper helper; 817 BytecodeGeneratorHelper helper;
821 Zone zone; 818 Zone zone;
822 819
823 FeedbackVectorSpec feedback_spec(&zone); 820 FeedbackVectorSpec feedback_spec(&zone);
824 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); 821 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot();
825 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); 822 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot();
826 823
827 Handle<i::TypeFeedbackVector> vector = 824 Handle<i::TypeFeedbackVector> vector =
828 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 825 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
829 826
830 ExpectedSnippet<const char*> snippets[] = { 827 ExpectedSnippet<const char*> snippets[] = {
831 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})", 828 {"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})",
832 kPointerSize, 829 0,
833 2, 830 2,
834 12, 831 8,
835 { 832 {
836 B(LdaConstant), U8(0), // 833 B(LdaConstant), U8(1), //
837 B(Star), R(0), // 834 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
838 B(LdaConstant), U8(1), // 835 B(LdaUndefined), //
839 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // 836 B(Return), //
840 B(LdaUndefined), //
841 B(Return), //
842 }, 837 },
843 2, 838 2,
844 {"name", "val"}}, 839 {"name", "val"}},
845 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})", 840 {"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})",
846 kPointerSize, 841 0,
847 2, 842 2,
848 12, 843 8,
849 { 844 {
850 B(LdaConstant), U8(0), // 845 B(LdaConstant), U8(1), //
851 B(Star), R(0), // 846 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
852 B(LdaConstant), U8(1), // 847 B(LdaUndefined), //
853 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // 848 B(Return), //
854 B(LdaUndefined), //
855 B(Return), //
856 }, 849 },
857 2, 850 2,
858 {"key", "val"}}, 851 {"key", "val"}},
859 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})", 852 {"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})",
860 kPointerSize, 853 kPointerSize,
861 2, 854 2,
862 12, 855 12,
863 { 856 {
864 B(LdaSmi8), U8(100), // 857 B(LdaSmi8), U8(100), //
865 B(Star), R(0), // 858 B(Star), R(0), //
866 B(LdaConstant), U8(0), // 859 B(LdaConstant), U8(0), //
867 B(KeyedStoreICSloppy), // 860 B(KeyedStoreICSloppy), A(1, 2), R(0), //
868 A(1, 2), R(0), U8(vector->GetIndex(slot1)), // 861 U8(vector->GetIndex(slot1)), //
869 B(LdaUndefined), // 862 B(LdaUndefined), //
870 B(Return), // 863 B(Return), //
871 }, 864 },
872 1, 865 1,
873 {"val"}}, 866 {"val"}},
874 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")", 867 {"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")",
875 0, 868 0,
876 3, 869 3,
877 8, 870 8,
878 { 871 {
879 B(LdaConstant), U8(0), // 872 B(LdaConstant), U8(0), //
880 B(KeyedStoreICSloppy), // 873 B(KeyedStoreICSloppy), A(1, 3), A(2, 3), //
881 A(1, 3), A(2, 3), U8(vector->GetIndex(slot1)), // 874 U8(vector->GetIndex(slot1)), //
882 B(LdaUndefined), // 875 B(LdaUndefined), //
883 B(Return), // 876 B(Return), //
884 }, 877 },
885 1, 878 1,
886 {"val"}}, 879 {"val"}},
887 {"function f(a) { a.name = a[-124]; }\n" 880 {"function f(a) { a.name = a[-124]; }\n"
888 "f({\"-124\" : \"test\", name : 123 })", 881 "f({\"-124\" : \"test\", name : 123 })",
889 kPointerSize, 882 0,
890 2, 883 2,
891 15, 884 11,
892 { 885 {
893 B(LdaConstant), U8(0), // 886 B(LdaSmi8), U8(-124), //
894 B(Star), R(0), // 887 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
895 B(LdaSmi8), U8(-124), // 888 B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot2)), //
896 B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), // 889 B(LdaUndefined), //
897 B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot2)), // 890 B(Return), //
898 B(LdaUndefined), //
899 B(Return), //
900 }, 891 },
901 1, 892 1,
902 {"name"}}, 893 {"name"}},
903 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n" 894 {"function f(a) { \"use strict\"; a.name = \"val\"; }\n"
904 "f({name : \"test\"})", 895 "f({name : \"test\"})",
905 kPointerSize, 896 0,
906 2, 897 2,
907 12, 898 8,
908 { 899 {
909 B(LdaConstant), U8(0), // 900 B(LdaConstant), U8(1), //
910 B(Star), R(0), // 901 B(StoreICStrict), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
911 B(LdaConstant), U8(1), // 902 B(LdaUndefined), //
912 B(StoreICStrict), A(1, 2), R(0), U8(vector->GetIndex(slot1)), // 903 B(Return), //
913 B(LdaUndefined), //
914 B(Return), //
915 }, 904 },
916 2, 905 2,
917 {"name", "val"}}, 906 {"name", "val"}},
918 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n" 907 {"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n"
919 "f({arg : \"test\"}, \"arg\")", 908 "f({arg : \"test\"}, \"arg\")",
920 0, 909 0,
921 3, 910 3,
922 8, 911 8,
923 { 912 {
924 B(LdaConstant), U8(0), // 913 B(LdaConstant), U8(0), //
(...skipping 25 matching lines...) Expand all
950 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); 939 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
951 USE(slot1); 940 USE(slot1);
952 941
953 Handle<i::TypeFeedbackVector> vector = 942 Handle<i::TypeFeedbackVector> vector =
954 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 943 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
955 944
956 ExpectedSnippet<const char*> snippets[] = { 945 ExpectedSnippet<const char*> snippets[] = {
957 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", 946 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")",
958 2 * kPointerSize, 947 2 * kPointerSize,
959 2, 948 2,
960 16, 949 15,
961 { 950 {
962 B(Ldar), A(1, 2), // 951 B(Ldar), A(1, 2), //
963 B(Star), R(1), // 952 B(Star), R(1), //
964 B(LdaConstant), U8(0), // 953 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
965 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 954 B(Star), R(0), //
966 B(Star), R(0), // 955 B(Call), R(0), R(1), U8(0), //
967 B(Call), R(0), R(1), U8(0), // 956 B(Return), //
968 B(Return), //
969 }, 957 },
970 1, 958 1,
971 {"func"}}, 959 {"func"}},
972 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", 960 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)",
973 4 * kPointerSize, 961 4 * kPointerSize,
974 4, 962 4,
975 24, 963 23,
976 { 964 {
977 B(Ldar), A(1, 4), // 965 B(Ldar), A(1, 4), //
978 B(Star), R(1), // 966 B(Star), R(1), //
979 B(LdaConstant), U8(0), // 967 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
980 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 968 B(Star), R(0), //
981 B(Star), R(0), // 969 B(Ldar), A(2, 4), //
982 B(Ldar), A(2, 4), // 970 B(Star), R(2), //
983 B(Star), R(2), // 971 B(Ldar), A(3, 4), //
984 B(Ldar), A(3, 4), // 972 B(Star), R(3), //
985 B(Star), R(3), // 973 B(Call), R(0), R(1), U8(2), //
986 B(Call), R(0), R(1), U8(2), // 974 B(Return) //
987 B(Return) //
988 }, 975 },
989 1, 976 1,
990 {"func"}}, 977 {"func"}},
991 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", 978 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)",
992 4 * kPointerSize, 979 4 * kPointerSize,
993 3, 980 3,
994 26, 981 25,
995 { 982 {
996 B(Ldar), A(1, 3), // 983 B(Ldar), A(1, 3), //
997 B(Star), R(1), // 984 B(Star), R(1), //
998 B(LdaConstant), U8(0), // 985 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
999 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 986 B(Star), R(0), //
1000 B(Star), R(0), // 987 B(Ldar), A(2, 3), //
1001 B(Ldar), A(2, 3), // 988 B(Add), A(2, 3), //
1002 B(Add), A(2, 3), // 989 B(Star), R(2), //
1003 B(Star), R(2), // 990 B(Ldar), A(2, 3), //
1004 B(Ldar), A(2, 3), // 991 B(Star), R(3), //
1005 B(Star), R(3), // 992 B(Call), R(0), R(1), U8(2), //
1006 B(Call), R(0), R(1), U8(2), // 993 B(Return), //
1007 B(Return), //
1008 }, 994 },
1009 1, 995 1,
1010 {"func"}}}; 996 {"func"}}};
1011 for (size_t i = 0; i < arraysize(snippets); i++) { 997 for (size_t i = 0; i < arraysize(snippets); i++) {
1012 Handle<BytecodeArray> bytecode_array = 998 Handle<BytecodeArray> bytecode_array =
1013 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 999 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
1014 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1000 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1015 } 1001 }
1016 } 1002 }
1017 1003
1018 1004
1019 TEST(LoadGlobal) { 1005 TEST(LoadGlobal) {
1020 InitializedHandleScope handle_scope; 1006 InitializedHandleScope handle_scope;
1021 BytecodeGeneratorHelper helper; 1007 BytecodeGeneratorHelper helper;
1022 Zone zone; 1008 Zone zone;
1023 1009
1024 int context_reg = Register::function_context().index();
1025 int global_index = Context::GLOBAL_OBJECT_INDEX;
1026
1027 FeedbackVectorSpec feedback_spec(&zone); 1010 FeedbackVectorSpec feedback_spec(&zone);
1028 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); 1011 FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
1029 1012
1030 Handle<i::TypeFeedbackVector> vector = 1013 Handle<i::TypeFeedbackVector> vector =
1031 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 1014 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1032 1015
1033 ExpectedSnippet<InstanceType> snippets[] = { 1016 ExpectedSnippet<const char*> snippets[] = {
1034 { 1017 {"var a = 1;\nfunction f() { return a; }\nf()",
1035 "var a = 1;\nfunction f() { return a; }\nf()", 1018 0,
1036 kPointerSize, 1019 1,
1037 1, 1020 4,
1038 11, 1021 {
1039 { 1022 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
1040 B(LdaContextSlot), R(context_reg), U8(global_index), // 1023 B(Return) //
1041 B(Star), R(0), // 1024 },
1042 B(LdaConstant), U8(0), // 1025 1,
1043 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // 1026 {"a"}},
1044 B(Return) // 1027 {"function t() { }\nfunction f() { return t; }\nf()",
1045 }, 1028 0,
1046 1, 1029 1,
1047 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}, 1030 4,
1048 }, 1031 {
1049 { 1032 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
1050 "function t() { }\nfunction f() { return t; }\nf()", 1033 B(Return) //
1051 kPointerSize, 1034 },
1052 1, 1035 1,
1053 11, 1036 {"t"}},
1054 { 1037 {"'use strict'; var a = 1;\nfunction f() { return a; }\nf()",
1055 B(LdaContextSlot), R(context_reg), U8(global_index), // 1038 0,
1056 B(Star), R(0), // 1039 1,
1057 B(LdaConstant), U8(0), // 1040 4,
1058 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // 1041 {
1059 B(Return) // 1042 B(LdaGlobalStrict), U8(0), U8(vector->GetIndex(slot)), //
1060 }, 1043 B(Return) //
1061 1, 1044 },
1062 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}, 1045 1,
1063 }, 1046 {"a"}},
1047 {"a = 1;\nfunction f() { return a; }\nf()",
1048 0,
1049 1,
1050 4,
1051 {
1052 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
1053 B(Return) //
1054 },
1055 1,
1056 {"a"}},
1064 }; 1057 };
1065 1058
1066 for (size_t i = 0; i < arraysize(snippets); i++) { 1059 for (size_t i = 0; i < arraysize(snippets); i++) {
1067 Handle<BytecodeArray> bytecode_array = 1060 Handle<BytecodeArray> bytecode_array =
1068 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1061 helper.MakeBytecode(snippets[i].code_snippet, "f");
1069 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1062 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1070 } 1063 }
1071 } 1064 }
1072 1065
1073 1066
1074 TEST(StoreGlobal) { 1067 TEST(StoreGlobal) {
1075 InitializedHandleScope handle_scope; 1068 InitializedHandleScope handle_scope;
1076 BytecodeGeneratorHelper helper; 1069 BytecodeGeneratorHelper helper;
1077 Zone zone; 1070 Zone zone;
1078 1071
1079 int context_reg = Register::function_context().index();
1080 int global_index = Context::GLOBAL_OBJECT_INDEX;
1081
1082 FeedbackVectorSpec feedback_spec(&zone); 1072 FeedbackVectorSpec feedback_spec(&zone);
1083 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); 1073 FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot();
1084
1085 Handle<i::TypeFeedbackVector> vector =
1086 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1087
1088 ExpectedSnippet<InstanceType> snippets[] = {
1089 {
1090 "var a = 1;\nfunction f() { a = 2; }\nf()",
1091 3 * kPointerSize,
1092 1,
1093 21,
1094 {
1095 B(LdaSmi8), U8(2), //
1096 B(Star), R(0), //
1097 B(LdaContextSlot), R(context_reg), U8(global_index), //
1098 B(Star), R(1), //
1099 B(LdaConstant), U8(0), //
1100 B(Star), R(2), //
1101 B(Ldar), R(0), //
1102 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), //
1103 B(LdaUndefined), //
1104 B(Return) //
1105 },
1106 1,
1107 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE},
1108 },
1109 {
1110 "var a = \"test\"; function f(b) { a = b; }\nf(\"global\")",
1111 3 * kPointerSize,
1112 2,
1113 21,
1114 {
1115 B(Ldar), R(helper.kLastParamIndex), //
1116 B(Star), R(0), //
1117 B(LdaContextSlot), R(context_reg), U8(global_index), //
1118 B(Star), R(1), //
1119 B(LdaConstant), U8(0), //
1120 B(Star), R(2), //
1121 B(Ldar), R(0), //
1122 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), //
1123 B(LdaUndefined), //
1124 B(Return) //
1125 },
1126 1,
1127 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE},
1128 },
1129 {
1130 "'use strict'; var a = 1;\nfunction f() { a = 2; }\nf()",
1131 3 * kPointerSize,
1132 1,
1133 21,
1134 {
1135 B(LdaSmi8), U8(2), //
1136 B(Star), R(0), //
1137 B(LdaContextSlot), R(context_reg), U8(global_index), //
1138 B(Star), R(1), //
1139 B(LdaConstant), U8(0), //
1140 B(Star), R(2), //
1141 B(Ldar), R(0), //
1142 B(StoreICStrict), R(1), R(2), U8(vector->GetIndex(slot1)), //
1143 B(LdaUndefined), //
1144 B(Return) //
1145 },
1146 1,
1147 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE},
1148 },
1149 };
1150
1151 for (size_t i = 0; i < arraysize(snippets); i++) {
1152 Handle<BytecodeArray> bytecode_array =
1153 helper.MakeBytecode(snippets[i].code_snippet, "f");
1154 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
1155 }
1156 }
1157
1158
1159 TEST(CallGlobal) {
1160 InitializedHandleScope handle_scope;
1161 BytecodeGeneratorHelper helper;
1162 Zone zone;
1163
1164 int context_reg = Register::function_context().index();
1165 int global_index = Context::GLOBAL_OBJECT_INDEX;
1166
1167 FeedbackVectorSpec feedback_spec(&zone);
1168 FeedbackVectorSlot slot1 = feedback_spec.AddCallICSlot();
1169 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
1170 USE(slot1);
1171
1172 Handle<i::TypeFeedbackVector> vector =
1173 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1174
1175 ExpectedSnippet<InstanceType> snippets[] = {
1176 {
1177 "function t() { }\nfunction f() { return t(); }\nf()",
1178 3 * kPointerSize,
1179 1,
1180 20,
1181 {
1182 B(LdaUndefined), //
1183 B(Star), R(1), //
1184 B(LdaContextSlot), R(context_reg), U8(global_index), //
1185 B(Star), R(2), //
1186 B(LdaConstant), U8(0), //
1187 B(LoadICSloppy), R(2), U8(vector->GetIndex(slot2)), //
1188 B(Star), R(0), //
1189 B(Call), R(0), R(1), U8(0), //
1190 B(Return) //
1191 },
1192 1,
1193 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE},
1194 },
1195 {
1196 "function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()",
1197 5 * kPointerSize,
1198 1,
1199 32,
1200 {
1201 B(LdaUndefined), //
1202 B(Star), R(1), //
1203 B(LdaContextSlot), R(context_reg), U8(global_index), //
1204 B(Star), R(2), //
1205 B(LdaConstant), U8(0), //
1206 B(LoadICSloppy), R(2), U8(vector->GetIndex(slot2)), //
1207 B(Star), R(0), //
1208 B(LdaSmi8), U8(1), //
1209 B(Star), R(2), //
1210 B(LdaSmi8), U8(2), //
1211 B(Star), R(3), //
1212 B(LdaSmi8), U8(3), //
1213 B(Star), R(4), //
1214 B(Call), R(0), R(1), U8(3), //
1215 B(Return) //
1216 },
1217 1,
1218 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE},
1219 },
1220 };
1221
1222 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1223 for (size_t i = 0; i < num_snippets; i++) {
1224 Handle<BytecodeArray> bytecode_array =
1225 helper.MakeBytecode(snippets[i].code_snippet, "f");
1226 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
1227 }
1228 }
1229
1230
1231 TEST(LoadUnallocated) {
1232 InitializedHandleScope handle_scope;
1233 BytecodeGeneratorHelper helper;
1234 Zone zone;
1235
1236 int context_reg = Register::function_context().index();
1237 int global_index = Context::GLOBAL_OBJECT_INDEX;
1238
1239 FeedbackVectorSpec feedback_spec(&zone);
1240 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot();
1241 1074
1242 Handle<i::TypeFeedbackVector> vector = 1075 Handle<i::TypeFeedbackVector> vector =
1243 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 1076 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1244 1077
1245 ExpectedSnippet<const char*> snippets[] = { 1078 ExpectedSnippet<const char*> snippets[] = {
1246 {"a = 1;\nfunction f() { return a; }\nf()", 1079 {"var a = 1;\nfunction f() { a = 2; }\nf()",
1247 1 * kPointerSize, 1080 0,
1248 1, 1081 1,
1249 11, 1082 7,
1250 {B(LdaContextSlot), R(context_reg), U8(global_index), // 1083 {
1251 B(Star), R(0), // 1084 B(LdaSmi8), U8(2), //
1252 B(LdaConstant), U8(0), // 1085 B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
1253 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // 1086 B(LdaUndefined), //
1254 B(Return)}, 1087 B(Return) //
1088 },
1255 1, 1089 1,
1256 {"a"}}, 1090 {"a"}},
1257 {"function f() { return t; }\nt = 1;\nf()", 1091 {"var a = \"test\"; function f(b) { a = b; }\nf(\"global\")",
1258 1 * kPointerSize, 1092 0,
1093 2,
1094 7,
1095 {
1096 B(Ldar), R(helper.kLastParamIndex), //
1097 B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
1098 B(LdaUndefined), //
1099 B(Return) //
1100 },
1259 1, 1101 1,
1260 11, 1102 {"a"}},
1261 {B(LdaContextSlot), R(context_reg), U8(global_index), // 1103 {"'use strict'; var a = 1;\nfunction f() { a = 2; }\nf()",
1262 B(Star), R(0), // 1104 0,
1263 B(LdaConstant), U8(0), //
1264 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
1265 B(Return)},
1266 1, 1105 1,
1267 {"t"}}, 1106 7,
1107 {
1108 B(LdaSmi8), U8(2), //
1109 B(StaGlobalStrict), U8(0), U8(vector->GetIndex(slot)), //
1110 B(LdaUndefined), //
1111 B(Return) //
1112 },
1113 1,
1114 {"a"}},
1115 {"a = 1;\nfunction f() { a = 2; }\nf()",
1116 0,
1117 1,
1118 7,
1119 {
1120 B(LdaSmi8), U8(2), //
1121 B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
1122 B(LdaUndefined), //
1123 B(Return) //
1124 },
1125 1,
1126 {"a"}},
1268 }; 1127 };
1269 1128
1270 for (size_t i = 0; i < arraysize(snippets); i++) { 1129 for (size_t i = 0; i < arraysize(snippets); i++) {
1271 Handle<BytecodeArray> bytecode_array = 1130 Handle<BytecodeArray> bytecode_array =
1272 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1131 helper.MakeBytecode(snippets[i].code_snippet, "f");
1273 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1132 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1274 } 1133 }
1275 } 1134 }
1276 1135
1277 1136
1278 TEST(StoreUnallocated) { 1137 TEST(CallGlobal) {
1279 InitializedHandleScope handle_scope; 1138 InitializedHandleScope handle_scope;
1280 BytecodeGeneratorHelper helper; 1139 BytecodeGeneratorHelper helper;
1281 Zone zone; 1140 Zone zone;
1282 1141
1283 int context_reg = Register::function_context().index();
1284 int global_index = Context::GLOBAL_OBJECT_INDEX;
1285
1286 FeedbackVectorSpec feedback_spec(&zone); 1142 FeedbackVectorSpec feedback_spec(&zone);
1287 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); 1143 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot();
1144 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
1145 USE(slot1);
1288 1146
1289 Handle<i::TypeFeedbackVector> vector = 1147 Handle<i::TypeFeedbackVector> vector =
1290 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 1148 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1291 1149
1292 ExpectedSnippet<const char*> snippets[] = { 1150 ExpectedSnippet<const char*> snippets[] = {
1293 {"a = 1;\nfunction f() { a = 2; }\nf()", 1151 {"function t() { }\nfunction f() { return t(); }\nf()",
1294 3 * kPointerSize, 1152 2 * kPointerSize,
1295 1, 1153 1,
1296 21, 1154 13,
1297 {B(LdaSmi8), U8(2), // 1155 {
1298 B(Star), R(0), // 1156 B(LdaUndefined), //
1299 B(LdaContextSlot), R(context_reg), U8(global_index), // 1157 B(Star), R(1), //
1300 B(Star), R(1), // 1158 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
1301 B(LdaConstant), U8(0), // 1159 B(Star), R(0), //
1302 B(Star), R(2), // 1160 B(Call), R(0), R(1), U8(0), //
1303 B(Ldar), R(0), // 1161 B(Return) //
1304 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), // 1162 },
1305 B(LdaUndefined), //
1306 B(Return)},
1307 1, 1163 1,
1308 {"a"}}, 1164 {"t"}},
1309 {"function f() { t = 4; }\nf()\nt = 1;", 1165 {"function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()",
1310 3 * kPointerSize, 1166 5 * kPointerSize,
1311 1, 1167 1,
1312 21, 1168 25,
1313 {B(LdaSmi8), U8(4), // 1169 {
1314 B(Star), R(0), // 1170 B(LdaUndefined), //
1315 B(LdaContextSlot), R(context_reg), U8(global_index), // 1171 B(Star), R(1), //
1316 B(Star), R(1), // 1172 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
1317 B(LdaConstant), U8(0), // 1173 B(Star), R(0), //
1318 B(Star), R(2), // 1174 B(LdaSmi8), U8(1), //
1319 B(Ldar), R(0), // 1175 B(Star), R(2), //
1320 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), // 1176 B(LdaSmi8), U8(2), //
1321 B(LdaUndefined), // 1177 B(Star), R(3), //
1322 B(Return)}, 1178 B(LdaSmi8), U8(3), //
1179 B(Star), R(4), //
1180 B(Call), R(0), R(1), U8(3), //
1181 B(Return) //
1182 },
1323 1, 1183 1,
1324 {"t"}}, 1184 {"t"}},
1325 }; 1185 };
1326 1186
1327 for (size_t i = 0; i < arraysize(snippets); i++) { 1187 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1188 for (size_t i = 0; i < num_snippets; i++) {
1328 Handle<BytecodeArray> bytecode_array = 1189 Handle<BytecodeArray> bytecode_array =
1329 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1190 helper.MakeBytecode(snippets[i].code_snippet, "f");
1330 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1191 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1331 } 1192 }
1332 } 1193 }
1333 1194
1334 1195
1335 TEST(CallRuntime) { 1196 TEST(CallRuntime) {
1336 InitializedHandleScope handle_scope; 1197 InitializedHandleScope handle_scope;
1337 BytecodeGeneratorHelper helper; 1198 BytecodeGeneratorHelper helper;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1409 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1549 } 1410 }
1550 } 1411 }
1551 1412
1552 1413
1553 TEST(DeclareGlobals) { 1414 TEST(DeclareGlobals) {
1554 InitializedHandleScope handle_scope; 1415 InitializedHandleScope handle_scope;
1555 BytecodeGeneratorHelper helper; 1416 BytecodeGeneratorHelper helper;
1556 Zone zone; 1417 Zone zone;
1557 1418
1558 int context_reg = Register::function_context().index(); 1419 // Create different feedback vector specs to be precise on slot numbering.
1559 int global_index = Context::GLOBAL_OBJECT_INDEX; 1420 FeedbackVectorSpec feedback_spec_stores(&zone);
1421 FeedbackVectorSlot store_slot_1 = feedback_spec_stores.AddStoreICSlot();
1422 FeedbackVectorSlot store_slot_2 = feedback_spec_stores.AddStoreICSlot();
1423 USE(store_slot_1);
1560 1424
1561 // Create different feedback vector specs to be precise on slot numbering. 1425 Handle<i::TypeFeedbackVector> store_vector =
1562 FeedbackVectorSpec feedback_spec_ss(&zone); 1426 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_stores);
1563 FeedbackVectorSlot slot_ss_1 = feedback_spec_ss.AddStoreICSlot();
1564 FeedbackVectorSlot slot_ss_2 = feedback_spec_ss.AddStoreICSlot();
1565 USE(slot_ss_1);
1566 1427
1567 Handle<i::TypeFeedbackVector> vector_ss = 1428 FeedbackVectorSpec feedback_spec_loads(&zone);
1568 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_ss); 1429 FeedbackVectorSlot load_slot_1 = feedback_spec_loads.AddLoadICSlot();
1569 1430
1570 FeedbackVectorSpec feedback_spec_l(&zone); 1431 Handle<i::TypeFeedbackVector> load_vector =
1571 FeedbackVectorSlot slot_l_1 = feedback_spec_l.AddLoadICSlot(); 1432 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_loads);
1572
1573 Handle<i::TypeFeedbackVector> vector_l =
1574 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_l);
1575
1576 1433
1577 ExpectedSnippet<InstanceType> snippets[] = { 1434 ExpectedSnippet<InstanceType> snippets[] = {
1578 {"var a = 1;", 1435 {"var a = 1;",
1579 4 * kPointerSize, 1436 4 * kPointerSize,
1580 1, 1437 1,
1581 30, 1438 30,
1582 { 1439 {
1583 B(LdaConstant), U8(0), // 1440 B(LdaConstant), U8(0), //
1584 B(Star), R(1), // 1441 B(Star), R(1), //
1585 B(LdaZero), // 1442 B(LdaZero), //
1586 B(Star), R(2), // 1443 B(Star), R(2), //
1587 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 1444 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
1588 B(LdaConstant), U8(1), // 1445 B(LdaConstant), U8(1), //
1589 B(Star), R(1), // 1446 B(Star), R(1), //
1590 B(LdaZero), // 1447 B(LdaZero), //
1591 B(Star), R(2), // 1448 B(Star), R(2), //
1592 B(LdaSmi8), U8(1), // 1449 B(LdaSmi8), U8(1), //
1593 B(Star), R(3), // 1450 B(Star), R(3), //
1594 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), // 1451 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
1595 U8(3), // 1452 B(LdaUndefined), //
1596 B(LdaUndefined), // 1453 B(Return) //
1597 B(Return) //
1598 }, 1454 },
1599 2, 1455 2,
1600 {InstanceType::FIXED_ARRAY_TYPE, 1456 {InstanceType::FIXED_ARRAY_TYPE,
1601 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 1457 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
1602 {"function f() {}", 1458 {"function f() {}",
1603 2 * kPointerSize, 1459 2 * kPointerSize,
1604 1, 1460 1,
1605 14, 1461 14,
1606 { 1462 {
1607 B(LdaConstant), U8(0), // 1463 B(LdaConstant), U8(0), //
1608 B(Star), R(0), // 1464 B(Star), R(0), //
1609 B(LdaZero), // 1465 B(LdaZero), //
1610 B(Star), R(1), // 1466 B(Star), R(1), //
1611 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), // 1467 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), //
1612 B(LdaUndefined), // 1468 B(LdaUndefined), //
1613 B(Return) // 1469 B(Return) //
1614 }, 1470 },
1615 1, 1471 1,
1616 {InstanceType::FIXED_ARRAY_TYPE}}, 1472 {InstanceType::FIXED_ARRAY_TYPE}},
1617 {"var a = 1;\na=2;", 1473 {"var a = 1;\na=2;",
1618 4 * kPointerSize, 1474 4 * kPointerSize,
1619 1, 1475 1,
1620 52, 1476 38,
1621 { 1477 {
1622 B(LdaConstant), U8(0), // 1478 B(LdaConstant), U8(0), //
1623 B(Star), R(1), // 1479 B(Star), R(1), //
1624 B(LdaZero), // 1480 B(LdaZero), //
1625 B(Star), R(2), // 1481 B(Star), R(2), //
1626 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 1482 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
1627 B(LdaConstant), U8(1), // 1483 B(LdaConstant), U8(1), //
1628 B(Star), R(1), // 1484 B(Star), R(1), //
1629 B(LdaZero), // 1485 B(LdaZero), //
1630 B(Star), R(2), // 1486 B(Star), R(2), //
1631 B(LdaSmi8), U8(1), // 1487 B(LdaSmi8), U8(1), //
1632 B(Star), R(3), // 1488 B(Star), R(3), //
1633 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), // 1489 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
1634 U8(3), // 1490 B(LdaSmi8), U8(2), //
1635 B(LdaSmi8), U8(2), // 1491 B(StaGlobalSloppy), U8(1), //
1636 B(Star), R(1), // 1492 U8(store_vector->GetIndex(store_slot_2)), //
1637 B(LdaContextSlot), R(context_reg), U8(global_index), // 1493 B(Star), R(0), //
1638 B(Star), R(2), // 1494 B(Ldar), R(0), //
1639 B(LdaConstant), U8(1), // 1495 B(Return) //
1640 B(Star), R(3), //
1641 B(Ldar), R(1), //
1642 B(StoreICSloppy), R(2), R(3), U8(vector_ss->GetIndex(slot_ss_2)), //
1643 B(Star), R(0), //
1644 B(Ldar), R(0), //
1645 B(Return) //
1646 }, 1496 },
1647 2, 1497 2,
1648 {InstanceType::FIXED_ARRAY_TYPE, 1498 {InstanceType::FIXED_ARRAY_TYPE,
1649 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 1499 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
1650 {"function f() {}\nf();", 1500 {"function f() {}\nf();",
1651 4 * kPointerSize, 1501 3 * kPointerSize,
1652 1, 1502 1,
1653 36, 1503 29,
1654 { 1504 {
1655 B(LdaConstant), U8(0), // 1505 B(LdaConstant), U8(0), //
1656 B(Star), R(1), // 1506 B(Star), R(1), //
1657 B(LdaZero), // 1507 B(LdaZero), //
1658 B(Star), R(2), // 1508 B(Star), R(2), //
1659 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 1509 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
1660 B(LdaUndefined), // 1510 B(LdaUndefined), //
1661 B(Star), R(2), // 1511 B(Star), R(2), //
1662 B(LdaContextSlot), R(context_reg), U8(global_index), // 1512 B(LdaGlobalSloppy), U8(1), //
1663 B(Star), R(3), // 1513 U8(load_vector->GetIndex(load_slot_1)), //
1664 B(LdaConstant), U8(1), //
1665 B(LoadICSloppy), R(3), U8(vector_l->GetIndex(slot_l_1)), //
1666 B(Star), R(1), // 1514 B(Star), R(1), //
1667 B(Call), R(1), R(2), U8(0), // 1515 B(Call), R(1), R(2), U8(0), //
1668 B(Star), R(0), // 1516 B(Star), R(0), //
1669 B(Ldar), R(0), // 1517 B(Ldar), R(0), //
1670 B(Return) // 1518 B(Return) //
1671 }, 1519 },
1672 2, 1520 2,
1673 {InstanceType::FIXED_ARRAY_TYPE, 1521 {InstanceType::FIXED_ARRAY_TYPE,
1674 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 1522 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
1675 }; 1523 };
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 B(Star), R(0), // 1946 B(Star), R(0), //
2099 B(LdaConstant), U8(1), // 1947 B(LdaConstant), U8(1), //
2100 B(CreateRegExpLiteral), U8(0), R(0), // 1948 B(CreateRegExpLiteral), U8(0), R(0), //
2101 B(Return), // 1949 B(Return), //
2102 }, 1950 },
2103 2, 1951 2,
2104 {"i", "(\\w+)\\s(\\w+)"}}, 1952 {"i", "(\\w+)\\s(\\w+)"}},
2105 {"return /ab+d/.exec('abdd');", 1953 {"return /ab+d/.exec('abdd');",
2106 3 * kPointerSize, 1954 3 * kPointerSize,
2107 1, 1955 1,
2108 27, 1956 26,
2109 { 1957 {
2110 B(LdaConstant), U8(0), // 1958 B(LdaConstant), U8(0), //
2111 B(Star), R(2), // 1959 B(Star), R(2), //
2112 B(LdaConstant), U8(1), // 1960 B(LdaConstant), U8(1), //
2113 B(CreateRegExpLiteral), U8(0), R(2), // 1961 B(CreateRegExpLiteral), U8(0), R(2), //
2114 B(Star), R(1), // 1962 B(Star), R(1), //
2115 B(LdaConstant), U8(2), // 1963 B(LoadICSloppy), R(1), U8(2), U8(vector->GetIndex(slot2)), //
2116 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 1964 B(Star), R(0), //
2117 B(Star), R(0), // 1965 B(LdaConstant), U8(3), //
2118 B(LdaConstant), U8(3), // 1966 B(Star), R(2), //
2119 B(Star), R(2), // 1967 B(Call), R(0), R(1), U8(1), //
2120 B(Call), R(0), R(1), U8(1), // 1968 B(Return), //
2121 B(Return), //
2122 }, 1969 },
2123 4, 1970 4,
2124 {"", "ab+d", "exec", "abdd"}}, 1971 {"", "ab+d", "exec", "abdd"}},
2125 }; 1972 };
2126 1973
2127 for (size_t i = 0; i < arraysize(snippets); i++) { 1974 for (size_t i = 0; i < arraysize(snippets); i++) {
2128 Handle<BytecodeArray> bytecode_array = 1975 Handle<BytecodeArray> bytecode_array =
2129 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 1976 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2130 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1977 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2131 } 1978 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 Handle<BytecodeArray> bytecode_array = 2087 Handle<BytecodeArray> bytecode_array =
2241 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2088 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2242 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2089 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2243 } 2090 }
2244 } 2091 }
2245 2092
2246 2093
2247 TEST(ObjectLiterals) { 2094 TEST(ObjectLiterals) {
2248 InitializedHandleScope handle_scope; 2095 InitializedHandleScope handle_scope;
2249 BytecodeGeneratorHelper helper; 2096 BytecodeGeneratorHelper helper;
2097 Zone zone;
2098
2099 FeedbackVectorSpec feedback_spec(&zone);
2100 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot();
2101
2102 Handle<i::TypeFeedbackVector> vector =
2103 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2250 2104
2251 int simple_flags = ObjectLiteral::kFastElements | 2105 int simple_flags = ObjectLiteral::kFastElements |
2252 ObjectLiteral::kShallowProperties | 2106 ObjectLiteral::kShallowProperties |
2253 ObjectLiteral::kDisableMementos; 2107 ObjectLiteral::kDisableMementos;
2254 int deep_elements_flags = 2108 int deep_elements_flags =
2255 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; 2109 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
2256 ExpectedSnippet<InstanceType> snippets[] = { 2110 ExpectedSnippet<InstanceType> snippets[] = {
2257 {"return { };", 2111 {"return { };",
2258 0, 2112 0,
2259 1, 2113 1,
(...skipping 10 matching lines...) Expand all
2270 1, 2124 1,
2271 6, 2125 6,
2272 { 2126 {
2273 B(LdaConstant), U8(0), // 2127 B(LdaConstant), U8(0), //
2274 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2128 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
2275 B(Return) // 2129 B(Return) //
2276 }, 2130 },
2277 1, 2131 1,
2278 {InstanceType::FIXED_ARRAY_TYPE}}, 2132 {InstanceType::FIXED_ARRAY_TYPE}},
2279 {"var a = 1; return { name: 'string', val: a };", 2133 {"var a = 1; return { name: 'string', val: a };",
2280 3 * kPointerSize, 2134 2 * kPointerSize,
2281 1, 2135 1,
2282 24, 2136 20,
2283 { 2137 {
2284 B(LdaSmi8), U8(1), // 2138 B(LdaSmi8), U8(1), //
2285 B(Star), R(0), // 2139 B(Star), R(0), //
2286 B(LdaConstant), U8(0), // 2140 B(LdaConstant), U8(0), //
2287 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2141 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
2288 B(Star), R(1), // 2142 B(Star), R(1), //
2289 B(LdaConstant), U8(1), // 2143 B(Ldar), R(0), //
2290 B(Star), R(2), // 2144 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
2291 B(Ldar), R(0), // 2145 B(Ldar), R(1), //
2292 B(StoreICSloppy), R(1), R(2), U8(3), // 2146 B(Return), //
2293 B(Ldar), R(1), //
2294 B(Return), //
2295 }, 2147 },
2296 2, 2148 2,
2297 {InstanceType::FIXED_ARRAY_TYPE, 2149 {InstanceType::FIXED_ARRAY_TYPE,
2298 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2150 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2299 {"var a = 1; return { val: a, val: a + 1 };", 2151 {"var a = 1; return { val: a, val: a + 1 };",
2300 3 * kPointerSize, 2152 2 * kPointerSize,
2301 1, 2153 1,
2302 26, 2154 22,
2303 { 2155 {
2304 B(LdaSmi8), U8(1), // 2156 B(LdaSmi8), U8(1), //
2305 B(Star), R(0), // 2157 B(Star), R(0), //
2306 B(LdaConstant), U8(0), // 2158 B(LdaConstant), U8(0), //
2307 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2159 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
2308 B(Star), R(1), // 2160 B(Star), R(1), //
2309 B(LdaConstant), U8(1), // 2161 B(LdaSmi8), U8(1), //
2310 B(Star), R(2), // 2162 B(Add), R(0), //
2311 B(LdaSmi8), U8(1), // 2163 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
2312 B(Add), R(0), // 2164 B(Ldar), R(1), //
2313 B(StoreICSloppy), R(1), R(2), U8(3), // 2165 B(Return), //
2314 B(Ldar), R(1), //
2315 B(Return), //
2316 }, 2166 },
2317 2, 2167 2,
2318 {InstanceType::FIXED_ARRAY_TYPE, 2168 {InstanceType::FIXED_ARRAY_TYPE,
2319 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2169 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2320 {"return { func: function() { } };", 2170 {"return { func: function() { } };",
2321 2 * kPointerSize, 2171 1 * kPointerSize,
2322 1, 2172 1,
2323 22, 2173 18,
2324 { 2174 {
2325 B(LdaConstant), U8(0), // 2175 B(LdaConstant), U8(0), //
2326 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2176 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
2327 B(Star), R(0), // 2177 B(Star), R(0), //
2328 B(LdaConstant), U8(1), // 2178 B(LdaConstant), U8(2), //
2329 B(Star), R(1), // 2179 B(CreateClosure), U8(0), //
2330 B(LdaConstant), U8(2), // 2180 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
2331 B(CreateClosure), U8(0), // 2181 B(Ldar), R(0), //
2332 B(StoreICSloppy), R(0), R(1), U8(3), // 2182 B(Return), //
2333 B(Ldar), R(0), //
2334 B(Return), //
2335 }, 2183 },
2336 3, 2184 3,
2337 {InstanceType::FIXED_ARRAY_TYPE, 2185 {InstanceType::FIXED_ARRAY_TYPE,
2338 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 2186 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
2339 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2187 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2340 {"return { func(a) { return a; } };", 2188 {"return { func(a) { return a; } };",
2341 2 * kPointerSize, 2189 1 * kPointerSize,
2342 1, 2190 1,
2343 22, 2191 18,
2344 { 2192 {
2345 B(LdaConstant), U8(0), // 2193 B(LdaConstant), U8(0), //
2346 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2194 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
2347 B(Star), R(0), // 2195 B(Star), R(0), //
2348 B(LdaConstant), U8(1), // 2196 B(LdaConstant), U8(2), //
2349 B(Star), R(1), // 2197 B(CreateClosure), U8(0), //
2350 B(LdaConstant), U8(2), // 2198 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
2351 B(CreateClosure), U8(0), // 2199 B(Ldar), R(0), //
2352 B(StoreICSloppy), R(0), R(1), U8(3), // 2200 B(Return), //
2353 B(Ldar), R(0), //
2354 B(Return), //
2355 }, 2201 },
2356 3, 2202 3,
2357 {InstanceType::FIXED_ARRAY_TYPE, 2203 {InstanceType::FIXED_ARRAY_TYPE,
2358 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 2204 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
2359 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2205 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2360 {"return { get a() { return 2; } };", 2206 {"return { get a() { return 2; } };",
2361 5 * kPointerSize, 2207 5 * kPointerSize,
2362 1, 2208 1,
2363 31, 2209 31,
2364 { 2210 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 U8(4), // 2341 U8(4), //
2496 B(Ldar), R(1), // 2342 B(Ldar), R(1), //
2497 B(Return), // 2343 B(Return), //
2498 }, 2344 },
2499 2, 2345 2,
2500 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 2346 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
2501 InstanceType::FIXED_ARRAY_TYPE}}, 2347 InstanceType::FIXED_ARRAY_TYPE}},
2502 {"var a = 'test'; return { val: a, [a]: 1 }", 2348 {"var a = 'test'; return { val: a, [a]: 1 }",
2503 5 * kPointerSize, 2349 5 * kPointerSize,
2504 1, 2350 1,
2505 41, 2351 37,
2506 { 2352 {
2507 B(LdaConstant), U8(0), // 2353 B(LdaConstant), U8(0), //
2508 B(Star), R(0), // 2354 B(Star), R(0), //
2509 B(LdaConstant), U8(1), // 2355 B(LdaConstant), U8(1), //
2510 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2356 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
2511 B(Star), R(1), // 2357 B(Star), R(1), //
2512 B(LdaConstant), U8(2), //
2513 B(Star), R(2), //
2514 B(Ldar), R(0), // 2358 B(Ldar), R(0), //
2515 B(StoreICSloppy), R(1), R(2), U8(3), // 2359 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), //
2516 B(Ldar), R(0), // 2360 B(Ldar), R(0), //
2517 B(ToName), // 2361 B(ToName), //
2518 B(Star), R(2), // 2362 B(Star), R(2), //
2519 B(LdaSmi8), U8(1), // 2363 B(LdaSmi8), U8(1), //
2520 B(Star), R(3), // 2364 B(Star), R(3), //
2521 B(LdaZero), // 2365 B(LdaZero), //
2522 B(Star), R(4), // 2366 B(Star), R(4), //
2523 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // 2367 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
2524 U8(4), // 2368 U8(4), //
2525 B(Ldar), R(1), // 2369 B(Ldar), R(1), //
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 U8(4), // 2423 U8(4), //
2580 B(LdaConstant), U8(3), // 2424 B(LdaConstant), U8(3), //
2581 B(ToName), // 2425 B(ToName), //
2582 B(Star), R(2), // 2426 B(Star), R(2), //
2583 B(LdaConstant), U8(4), // 2427 B(LdaConstant), U8(4), //
2584 B(CreateClosure), U8(0), // 2428 B(CreateClosure), U8(0), //
2585 B(Star), R(3), // 2429 B(Star), R(3), //
2586 B(LdaZero), // 2430 B(LdaZero), //
2587 B(Star), R(4), // 2431 B(Star), R(4), //
2588 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // 2432 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), //
2589 R(1), U8(4), // 2433 R(1), U8(4), //
2590 B(LdaConstant), U8(3), // 2434 B(LdaConstant), U8(3), //
2591 B(ToName), // 2435 B(ToName), //
2592 B(Star), R(2), // 2436 B(Star), R(2), //
2593 B(LdaConstant), U8(5), // 2437 B(LdaConstant), U8(5), //
2594 B(CreateClosure), U8(0), // 2438 B(CreateClosure), U8(0), //
2595 B(Star), R(3), // 2439 B(Star), R(3), //
2596 B(LdaZero), // 2440 B(LdaZero), //
2597 B(Star), R(4), // 2441 B(Star), R(4), //
2598 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // 2442 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), //
2599 R(1), U8(4), // 2443 R(1), U8(4), //
2600 B(Ldar), R(1), // 2444 B(Ldar), R(1), //
2601 B(Return), // 2445 B(Return), //
2602 }, 2446 },
2603 6, 2447 6,
2604 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 2448 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
2605 InstanceType::FIXED_ARRAY_TYPE, 2449 InstanceType::FIXED_ARRAY_TYPE,
2606 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 2450 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
2607 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 2451 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
2608 InstanceType::SHARED_FUNCTION_INFO_TYPE, 2452 InstanceType::SHARED_FUNCTION_INFO_TYPE,
2609 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2453 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2610 }; 2454 };
2611 2455
2612 for (size_t i = 0; i < arraysize(snippets); i++) { 2456 for (size_t i = 0; i < arraysize(snippets); i++) {
2613 Handle<BytecodeArray> bytecode_array = 2457 Handle<BytecodeArray> bytecode_array =
2614 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2458 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2615 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2459 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2616 } 2460 }
2617 } 2461 }
2618 2462
2619 2463
2620 TEST(TopLevelObjectLiterals) { 2464 TEST(TopLevelObjectLiterals) {
2621 InitializedHandleScope handle_scope; 2465 InitializedHandleScope handle_scope;
2622 BytecodeGeneratorHelper helper; 2466 BytecodeGeneratorHelper helper;
2623 2467
2624 int has_function_flags = ObjectLiteral::kFastElements | 2468 int has_function_flags = ObjectLiteral::kFastElements |
2625 ObjectLiteral::kHasFunction | 2469 ObjectLiteral::kHasFunction |
2626 ObjectLiteral::kDisableMementos; 2470 ObjectLiteral::kDisableMementos;
2627 ExpectedSnippet<InstanceType> snippets[] = { 2471 ExpectedSnippet<InstanceType> snippets[] = {
2628 {"var a = { func: function() { } };", 2472 {"var a = { func: function() { } };",
2629 6 * kPointerSize, 2473 5 * kPointerSize,
2630 1, 2474 1,
2631 54, 2475 50,
2632 { 2476 {
2633 B(LdaConstant), U8(0), // 2477 B(LdaConstant), U8(0), //
2634 B(Star), R(1), // 2478 B(Star), R(1), //
2635 B(LdaZero), // 2479 B(LdaZero), //
2636 B(Star), R(2), // 2480 B(Star), R(2), //
2637 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 2481 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
2638 B(LdaConstant), U8(1), // 2482 B(LdaConstant), U8(1), //
2639 B(Star), R(1), // 2483 B(Star), R(1), //
2640 B(LdaZero), // 2484 B(LdaZero), //
2641 B(Star), R(2), // 2485 B(Star), R(2), //
2642 B(LdaConstant), U8(2), // 2486 B(LdaConstant), U8(2), //
2643 B(CreateObjectLiteral), U8(0), U8(has_function_flags), // 2487 B(CreateObjectLiteral), U8(0), U8(has_function_flags), //
2644 B(Star), R(4), // 2488 B(Star), R(4), //
2645 B(LdaConstant), U8(3), //
2646 B(Star), R(5), //
2647 B(LdaConstant), U8(4), // 2489 B(LdaConstant), U8(4), //
2648 B(CreateClosure), U8(1), // 2490 B(CreateClosure), U8(1), //
2649 B(StoreICSloppy), R(4), R(5), U8(5), // 2491 B(StoreICSloppy), R(4), U8(3), U8(5), //
2650 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), // 2492 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), //
2651 B(Ldar), R(4), // 2493 B(Ldar), R(4), //
2652 B(Star), R(3), // 2494 B(Star), R(3), //
2653 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // 2495 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
2654 B(LdaUndefined), // 2496 B(LdaUndefined), //
2655 B(Return), // 2497 B(Return), //
2656 }, 2498 },
2657 5, 2499 5,
2658 {InstanceType::FIXED_ARRAY_TYPE, 2500 {InstanceType::FIXED_ARRAY_TYPE,
2659 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 2501 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2633 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2792 } 2634 }
2793 } 2635 }
2794 2636
2795 2637
2796 TEST(CallNew) { 2638 TEST(CallNew) {
2797 InitializedHandleScope handle_scope; 2639 InitializedHandleScope handle_scope;
2798 BytecodeGeneratorHelper helper; 2640 BytecodeGeneratorHelper helper;
2799 Zone zone; 2641 Zone zone;
2800 2642
2801 int context_reg = Register::function_context().index();
2802 int global_index = Context::GLOBAL_OBJECT_INDEX;
2803
2804 FeedbackVectorSpec feedback_spec(&zone); 2643 FeedbackVectorSpec feedback_spec(&zone);
2805 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); 2644 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot();
2806 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); 2645 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
2807 USE(slot1); 2646 USE(slot1);
2808 2647
2809 Handle<i::TypeFeedbackVector> vector = 2648 Handle<i::TypeFeedbackVector> vector =
2810 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 2649 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2811 2650
2812 ExpectedSnippet<InstanceType> snippets[] = { 2651 ExpectedSnippet<InstanceType> snippets[] = {
2813 {"function bar() { this.value = 0; }\n" 2652 {"function bar() { this.value = 0; }\n"
2814 "function f() { return new bar(); }\n" 2653 "function f() { return new bar(); }\n"
2815 "f()", 2654 "f()",
2816 2 * kPointerSize, 2655 1 * kPointerSize,
2817 1, 2656 1,
2818 17, 2657 10,
2819 { 2658 {
2820 B(LdaContextSlot), R(context_reg), U8(global_index), // 2659 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
2821 B(Star), R(1), // 2660 B(Star), R(0), //
2822 B(LdaConstant), U8(0), // 2661 B(New), R(0), R(0), U8(0), //
2823 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 2662 B(Return), //
2824 B(Star), R(0), //
2825 B(New), R(0), R(0), U8(0), //
2826 B(Return), //
2827 }, 2663 },
2828 1, 2664 1,
2829 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2665 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2830 {"function bar(x) { this.value = 18; this.x = x;}\n" 2666 {"function bar(x) { this.value = 18; this.x = x;}\n"
2831 "function f() { return new bar(3); }\n" 2667 "function f() { return new bar(3); }\n"
2832 "f()", 2668 "f()",
2833 2 * kPointerSize, 2669 2 * kPointerSize,
2834 1, 2670 1,
2835 21, 2671 14,
2836 { 2672 {
2837 B(LdaContextSlot), R(context_reg), U8(global_index), // 2673 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
2838 B(Star), R(1), // 2674 B(Star), R(0), //
2839 B(LdaConstant), U8(0), // 2675 B(LdaSmi8), U8(3), //
2840 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 2676 B(Star), R(1), //
2841 B(Star), R(0), // 2677 B(New), R(0), R(1), U8(1), //
2842 B(LdaSmi8), U8(3), // 2678 B(Return), //
2843 B(Star), R(1), //
2844 B(New), R(0), R(1), U8(1), //
2845 B(Return), //
2846 }, 2679 },
2847 1, 2680 1,
2848 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2681 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2849 {"function bar(w, x, y, z) {\n" 2682 {"function bar(w, x, y, z) {\n"
2850 " this.value = 18;\n" 2683 " this.value = 18;\n"
2851 " this.x = x;\n" 2684 " this.x = x;\n"
2852 " this.y = y;\n" 2685 " this.y = y;\n"
2853 " this.z = z;\n" 2686 " this.z = z;\n"
2854 "}\n" 2687 "}\n"
2855 "function f() { return new bar(3, 4, 5); }\n" 2688 "function f() { return new bar(3, 4, 5); }\n"
2856 "f()", 2689 "f()",
2857 4 * kPointerSize, 2690 4 * kPointerSize,
2858 1, 2691 1,
2859 29, 2692 22,
2860 { 2693 {
2861 B(LdaContextSlot), R(context_reg), U8(global_index), // 2694 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
2862 B(Star), R(1), // 2695 B(Star), R(0), //
2863 B(LdaConstant), U8(0), // 2696 B(LdaSmi8), U8(3), //
2864 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 2697 B(Star), R(1), //
2865 B(Star), R(0), // 2698 B(LdaSmi8), U8(4), //
2866 B(LdaSmi8), U8(3), // 2699 B(Star), R(2), //
2867 B(Star), R(1), // 2700 B(LdaSmi8), U8(5), //
2868 B(LdaSmi8), U8(4), // 2701 B(Star), R(3), //
2869 B(Star), R(2), // 2702 B(New), R(0), R(1), U8(3), //
2870 B(LdaSmi8), U8(5), // 2703 B(Return), //
2871 B(Star), R(3), //
2872 B(New), R(0), R(1), U8(3), //
2873 B(Return), //
2874 }, 2704 },
2875 1, 2705 1,
2876 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2706 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2877 }; 2707 };
2878 2708
2879 for (size_t i = 0; i < arraysize(snippets); i++) { 2709 for (size_t i = 0; i < arraysize(snippets); i++) {
2880 Handle<BytecodeArray> bytecode_array = 2710 Handle<BytecodeArray> bytecode_array =
2881 helper.MakeBytecode(snippets[i].code_snippet, "f"); 2711 helper.MakeBytecode(snippets[i].code_snippet, "f");
2882 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 2712 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
2883 } 2713 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 for (size_t i = 0; i < arraysize(snippets); i++) { 2912 for (size_t i = 0; i < arraysize(snippets); i++) {
3083 Handle<BytecodeArray> bytecode_array = 2913 Handle<BytecodeArray> bytecode_array =
3084 helper.MakeBytecodeForFunction(snippets[i].code_snippet); 2914 helper.MakeBytecodeForFunction(snippets[i].code_snippet);
3085 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2915 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3086 } 2916 }
3087 } 2917 }
3088 2918
3089 } // namespace interpreter 2919 } // namespace interpreter
3090 } // namespace internal 2920 } // namespace internal
3091 } // namespace v8 2921 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698