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

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

Issue 1503963002: [Interpreter] Adds wide variant of CreateLiterals. Adds CreateLiterals to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: renamed BuildLiteral to BuildCreateLiteral. Created 5 years 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
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 // TODO(rmcilroy): Remove this define after this flag is turned on globally 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 B(LdaSmi8), U8(2), // 1597 B(LdaSmi8), U8(2), //
1598 B(Star), R(1), // 1598 B(Star), R(1), //
1599 B(CallRuntime), U16(Runtime::kAdd), R(0), U8(2), // 1599 B(CallRuntime), U16(Runtime::kAdd), R(0), U8(2), //
1600 B(Return) // 1600 B(Return) //
1601 }, 1601 },
1602 }, 1602 },
1603 { 1603 {
1604 "function f() { return %spread_iterable([1]) }\nf()", 1604 "function f() { return %spread_iterable([1]) }\nf()",
1605 2 * kPointerSize, 1605 2 * kPointerSize,
1606 1, 1606 1,
1607 16, 1607 15,
1608 { 1608 {
1609 B(LdaUndefined), // 1609 B(LdaUndefined), //
1610 B(Star), R(0), // 1610 B(Star), R(0), //
1611 B(LdaConstant), U8(0), // 1611 B(CreateArrayLiteral), U8(0), U8(0), U8(3), //
1612 B(CreateArrayLiteral), U8(0), U8(3), //
1613 B(Star), R(1), // 1612 B(Star), R(1), //
1614 B(CallJSRuntime), U16(Context::SPREAD_ITERABLE_INDEX), R(0), // 1613 B(CallJSRuntime), U16(Context::SPREAD_ITERABLE_INDEX), R(0), //
1615 U8(1), // 1614 U8(1), //
1616 B(Return), // 1615 B(Return), //
1617 }, 1616 },
1618 1, 1617 1,
1619 {InstanceType::FIXED_ARRAY_TYPE}, 1618 {InstanceType::FIXED_ARRAY_TYPE},
1620 }, 1619 },
1621 }; 1620 };
1622 1621
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 2599
2601 int deep_elements_flags = 2600 int deep_elements_flags =
2602 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; 2601 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
2603 int closure = Register::function_closure().index(); 2602 int closure = Register::function_closure().index();
2604 int first_context_slot = Context::MIN_CONTEXT_SLOTS; 2603 int first_context_slot = Context::MIN_CONTEXT_SLOTS;
2605 2604
2606 ExpectedSnippet<InstanceType> snippets[] = { 2605 ExpectedSnippet<InstanceType> snippets[] = {
2607 {"var a = {x:13, y:14}; return delete a.x;", 2606 {"var a = {x:13, y:14}; return delete a.x;",
2608 1 * kPointerSize, 2607 1 * kPointerSize,
2609 1, 2608 1,
2610 12, 2609 11,
2611 { 2610 {
2612 B(LdaConstant), U8(0), // 2611 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
2613 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2612 B(Star), R(0), //
2614 B(Star), R(0), // 2613 B(LdaConstant), U8(1), //
2615 B(LdaConstant), U8(1), // 2614 B(DeletePropertySloppy), R(0), //
2616 B(DeletePropertySloppy), R(0), //
2617 B(Return) 2615 B(Return)
2618 }, 2616 },
2619 2, 2617 2,
2620 {InstanceType::FIXED_ARRAY_TYPE, 2618 {InstanceType::FIXED_ARRAY_TYPE,
2621 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2619 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2622 {"'use strict'; var a = {x:13, y:14}; return delete a.x;", 2620 {"'use strict'; var a = {x:13, y:14}; return delete a.x;",
2623 1 * kPointerSize, 2621 1 * kPointerSize,
2624 1, 2622 1,
2625 12, 2623 11,
2626 { 2624 {
2627 B(LdaConstant), U8(0), // 2625 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
2628 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2626 B(Star), R(0), //
2629 B(Star), R(0), // 2627 B(LdaConstant), U8(1), //
2630 B(LdaConstant), U8(1), // 2628 B(DeletePropertyStrict), R(0), //
2631 B(DeletePropertyStrict), R(0), //
2632 B(Return) 2629 B(Return)
2633 }, 2630 },
2634 2, 2631 2,
2635 {InstanceType::FIXED_ARRAY_TYPE, 2632 {InstanceType::FIXED_ARRAY_TYPE,
2636 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2633 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2637 {"var a = {1:13, 2:14}; return delete a[2];", 2634 {"var a = {1:13, 2:14}; return delete a[2];",
2638 1 * kPointerSize, 2635 1 * kPointerSize,
2639 1, 2636 1,
2640 12, 2637 11,
2641 { 2638 {
2642 B(LdaConstant), U8(0), // 2639 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
2643 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2640 B(Star), R(0), //
2644 B(Star), R(0), // 2641 B(LdaSmi8), U8(2), //
2645 B(LdaSmi8), U8(2), // 2642 B(DeletePropertySloppy), R(0), //
2646 B(DeletePropertySloppy), R(0), //
2647 B(Return) 2643 B(Return)
2648 }, 2644 },
2649 1, 2645 1,
2650 {InstanceType::FIXED_ARRAY_TYPE}}, 2646 {InstanceType::FIXED_ARRAY_TYPE}},
2651 {"var a = 10; return delete a;", 2647 {"var a = 10; return delete a;",
2652 1 * kPointerSize, 2648 1 * kPointerSize,
2653 1, 2649 1,
2654 6, 2650 6,
2655 { 2651 {
2656 B(LdaSmi8), U8(10), // 2652 B(LdaSmi8), U8(10), //
2657 B(Star), R(0), // 2653 B(Star), R(0), //
2658 B(LdaFalse), // 2654 B(LdaFalse), //
2659 B(Return) 2655 B(Return)
2660 }, 2656 },
2661 0}, 2657 0},
2662 {"'use strict';" 2658 {"'use strict';"
2663 "var a = {1:10};" 2659 "var a = {1:10};"
2664 "(function f1() {return a;});" 2660 "(function f1() {return a;});"
2665 "return delete a[1];", 2661 "return delete a[1];",
2666 2 * kPointerSize, 2662 2 * kPointerSize,
2667 1, 2663 1,
2668 28, 2664 27,
2669 { 2665 {
2670 B(CallRuntime), U16(Runtime::kNewFunctionContext), // 2666 B(CallRuntime), U16(Runtime::kNewFunctionContext), //
2671 R(closure), U8(1), // 2667 R(closure), U8(1), //
2672 B(PushContext), R(0), // 2668 B(PushContext), R(0), //
2673 B(LdaConstant), U8(0), // 2669 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
2674 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 2670 B(StaContextSlot), R(0), U8(first_context_slot), //
2675 B(StaContextSlot), R(0), U8(first_context_slot), // 2671 B(CreateClosure), U8(1), U8(0), //
2676 B(CreateClosure), U8(1), U8(0), // 2672 B(LdaContextSlot), R(0), U8(first_context_slot), //
2677 B(LdaContextSlot), R(0), U8(first_context_slot), // 2673 B(Star), R(1), //
2678 B(Star), R(1), // 2674 B(LdaSmi8), U8(1), //
2679 B(LdaSmi8), U8(1), // 2675 B(DeletePropertyStrict), R(1), //
2680 B(DeletePropertyStrict), R(1), //
2681 B(Return) 2676 B(Return)
2682 }, 2677 },
2683 2, 2678 2,
2684 {InstanceType::FIXED_ARRAY_TYPE, 2679 {InstanceType::FIXED_ARRAY_TYPE,
2685 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2680 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2686 {"return delete 'test';", 2681 {"return delete 'test';",
2687 0 * kPointerSize, 2682 0 * kPointerSize,
2688 1, 2683 1,
2689 2, 2684 2,
2690 { 2685 {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); 2843 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
2849 uint8_t i_flags = JSRegExp::kIgnoreCase; 2844 uint8_t i_flags = JSRegExp::kIgnoreCase;
2850 2845
2851 Handle<i::TypeFeedbackVector> vector = 2846 Handle<i::TypeFeedbackVector> vector =
2852 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 2847 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2853 2848
2854 ExpectedSnippet<const char*> snippets[] = { 2849 ExpectedSnippet<const char*> snippets[] = {
2855 {"return /ab+d/;", 2850 {"return /ab+d/;",
2856 0 * kPointerSize, 2851 0 * kPointerSize,
2857 1, 2852 1,
2858 6, 2853 5,
2859 { 2854 {
2860 B(LdaConstant), U8(0), // 2855 B(CreateRegExpLiteral), U8(0), U8(0), U8(0), //
2861 B(CreateRegExpLiteral), U8(0), U8(0), // 2856 B(Return), //
2862 B(Return), //
2863 }, 2857 },
2864 1, 2858 1,
2865 {"ab+d"}}, 2859 {"ab+d"}},
2866 {"return /(\\w+)\\s(\\w+)/i;", 2860 {"return /(\\w+)\\s(\\w+)/i;",
2867 0 * kPointerSize, 2861 0 * kPointerSize,
2868 1, 2862 1,
2869 6, 2863 5,
2870 { 2864 {
2871 B(LdaConstant), U8(0), // 2865 B(CreateRegExpLiteral), U8(0), U8(0), U8(i_flags), //
2872 B(CreateRegExpLiteral), U8(0), U8(i_flags), // 2866 B(Return), //
2873 B(Return), //
2874 }, 2867 },
2875 1, 2868 1,
2876 {"(\\w+)\\s(\\w+)"}}, 2869 {"(\\w+)\\s(\\w+)"}},
2877 {"return /ab+d/.exec('abdd');", 2870 {"return /ab+d/.exec('abdd');",
2878 3 * kPointerSize, 2871 3 * kPointerSize,
2879 1, 2872 1,
2880 23, 2873 22,
2881 { 2874 {
2882 B(LdaConstant), U8(0), // 2875 B(CreateRegExpLiteral), U8(0), U8(0), U8(0), //
2883 B(CreateRegExpLiteral), U8(0), U8(0), //
2884 B(Star), R(1), // 2876 B(Star), R(1), //
2885 B(LoadICSloppy), R(1), U8(1), U8(vector->GetIndex(slot2)), // 2877 B(LoadICSloppy), R(1), U8(1), U8(vector->GetIndex(slot2)), //
2886 B(Star), R(0), // 2878 B(Star), R(0), //
2887 B(LdaConstant), U8(2), // 2879 B(LdaConstant), U8(2), //
2888 B(Star), R(2), // 2880 B(Star), R(2), //
2889 B(Call), R(0), R(1), U8(1), U8(vector->GetIndex(slot1)), // 2881 B(Call), R(0), R(1), U8(1), U8(vector->GetIndex(slot1)), //
2890 B(Return), // 2882 B(Return), //
2891 }, 2883 },
2892 3, 2884 3,
2893 {"ab+d", "exec", "abdd"}}, 2885 {"ab+d", "exec", "abdd"}},
2894 }; 2886 };
2895 2887
2896 for (size_t i = 0; i < arraysize(snippets); i++) { 2888 for (size_t i = 0; i < arraysize(snippets); i++) {
2897 Handle<BytecodeArray> bytecode_array = 2889 Handle<BytecodeArray> bytecode_array =
2898 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2890 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2899 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2891 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2900 } 2892 }
2901 } 2893 }
2902 2894
2903 2895
2896 TEST(RegExpLiteralsWide) {
2897 InitializedHandleScope handle_scope;
2898 BytecodeGeneratorHelper helper;
2899 Zone zone;
2900
2901 int wide_idx = 0;
2902
2903 ExpectedSnippet<InstanceType, 257> snippets[] = {
2904 {"var a;" REPEAT_256(SPACE, "a = 1.23;") "return /ab+d/;",
2905 1 * kPointerSize,
2906 1,
2907 1031,
2908 {
2909 REPEAT_256(COMMA, //
2910 B(LdaConstant), U8(wide_idx++), //
2911 B(Star), R(0)), //
2912 B(CreateRegExpLiteralWide), U16(256), U16(0), U8(0), //
2913 B(Return) //
2914 },
2915 257,
2916 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
2917 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2918 };
2919
2920 for (size_t i = 0; i < arraysize(snippets); i++) {
2921 Handle<BytecodeArray> bytecode_array =
2922 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2923 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2924 }
2925 }
2926
2927
2904 TEST(ArrayLiterals) { 2928 TEST(ArrayLiterals) {
2905 InitializedHandleScope handle_scope; 2929 InitializedHandleScope handle_scope;
2906 BytecodeGeneratorHelper helper; 2930 BytecodeGeneratorHelper helper;
2907 Zone zone; 2931 Zone zone;
2908 2932
2909 FeedbackVectorSpec feedback_spec(&zone); 2933 FeedbackVectorSpec feedback_spec(&zone);
2910 FeedbackVectorSlot slot1 = feedback_spec.AddKeyedStoreICSlot(); 2934 FeedbackVectorSlot slot1 = feedback_spec.AddKeyedStoreICSlot();
2911 FeedbackVectorSlot slot2 = feedback_spec.AddKeyedStoreICSlot(); 2935 FeedbackVectorSlot slot2 = feedback_spec.AddKeyedStoreICSlot();
2912 FeedbackVectorSlot slot3 = feedback_spec.AddKeyedStoreICSlot(); 2936 FeedbackVectorSlot slot3 = feedback_spec.AddKeyedStoreICSlot();
2913 2937
2914 Handle<i::TypeFeedbackVector> vector = 2938 Handle<i::TypeFeedbackVector> vector =
2915 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 2939 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2916 2940
2917 int simple_flags = 2941 int simple_flags =
2918 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements; 2942 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements;
2919 int deep_elements_flags = ArrayLiteral::kDisableMementos; 2943 int deep_elements_flags = ArrayLiteral::kDisableMementos;
2920 ExpectedSnippet<InstanceType> snippets[] = { 2944 ExpectedSnippet<InstanceType> snippets[] = {
2921 {"return [ 1, 2 ];", 2945 {"return [ 1, 2 ];",
2922 0, 2946 0,
2923 1, 2947 1,
2924 6, 2948 5,
2925 { 2949 {
2926 B(LdaConstant), U8(0), // 2950 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
2927 B(CreateArrayLiteral), U8(0), U8(simple_flags), // 2951 B(Return) //
2928 B(Return) //
2929 }, 2952 },
2930 1, 2953 1,
2931 {InstanceType::FIXED_ARRAY_TYPE}}, 2954 {InstanceType::FIXED_ARRAY_TYPE}},
2932 {"var a = 1; return [ a, a + 1 ];", 2955 {"var a = 1; return [ a, a + 1 ];",
2933 3 * kPointerSize, 2956 3 * kPointerSize,
2934 1, 2957 1,
2935 35, 2958 34,
2936 { 2959 {
2937 B(LdaSmi8), U8(1), // 2960 B(LdaSmi8), U8(1), //
2938 B(Star), R(0), // 2961 B(Star), R(0), //
2939 B(LdaConstant), U8(0), // 2962 B(CreateArrayLiteral), U8(0), U8(0), U8(3), //
2940 B(CreateArrayLiteral), U8(0), U8(3), //
2941 B(Star), R(2), // 2963 B(Star), R(2), //
2942 B(LdaZero), // 2964 B(LdaZero), //
2943 B(Star), R(1), // 2965 B(Star), R(1), //
2944 B(Ldar), R(0), // 2966 B(Ldar), R(0), //
2945 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // 2967 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), //
2946 B(LdaSmi8), U8(1), // 2968 B(LdaSmi8), U8(1), //
2947 B(Star), R(1), // 2969 B(Star), R(1), //
2948 B(LdaSmi8), U8(1), // 2970 B(LdaSmi8), U8(1), //
2949 B(Add), R(0), // 2971 B(Add), R(0), //
2950 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // 2972 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), //
2951 B(Ldar), R(2), // 2973 B(Ldar), R(2), //
2952 B(Return), // 2974 B(Return), //
2953 }, 2975 },
2954 1, 2976 1,
2955 {InstanceType::FIXED_ARRAY_TYPE}}, 2977 {InstanceType::FIXED_ARRAY_TYPE}},
2956 {"return [ [ 1, 2 ], [ 3 ] ];", 2978 {"return [ [ 1, 2 ], [ 3 ] ];",
2957 0, 2979 0,
2958 1, 2980 1,
2959 6, 2981 5,
2960 { 2982 {
2961 B(LdaConstant), U8(0), // 2983 B(CreateArrayLiteral), U8(0), U8(2), U8(deep_elements_flags), //
2962 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // 2984 B(Return) //
2963 B(Return) //
2964 }, 2985 },
2965 1, 2986 1,
2966 {InstanceType::FIXED_ARRAY_TYPE}}, 2987 {InstanceType::FIXED_ARRAY_TYPE}},
2967 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];", 2988 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];",
2968 5 * kPointerSize, 2989 5 * kPointerSize,
2969 1, 2990 1,
2970 67, 2991 64,
2971 { 2992 {
2972 B(LdaSmi8), U8(1), // 2993 B(LdaSmi8), U8(1), //
2973 B(Star), R(0), // 2994 B(Star), R(0), //
2974 B(LdaConstant), U8(0), // 2995 B(CreateArrayLiteral), U8(0), U8(2), U8(deep_elements_flags), //
2975 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), //
2976 B(Star), R(2), // 2996 B(Star), R(2), //
2977 B(LdaZero), // 2997 B(LdaZero), //
2978 B(Star), R(1), // 2998 B(Star), R(1), //
2979 B(LdaConstant), U8(1), // 2999 B(CreateArrayLiteral), U8(1), U8(0), U8(simple_flags), //
2980 B(CreateArrayLiteral), U8(0), U8(simple_flags), //
2981 B(Star), R(4), // 3000 B(Star), R(4), //
2982 B(LdaZero), // 3001 B(LdaZero), //
2983 B(Star), R(3), // 3002 B(Star), R(3), //
2984 B(Ldar), R(0), // 3003 B(Ldar), R(0), //
2985 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot1)), // 3004 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot1)), //
2986 B(Ldar), R(4), // 3005 B(Ldar), R(4), //
2987 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // 3006 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), //
2988 B(LdaSmi8), U8(1), // 3007 B(LdaSmi8), U8(1), //
2989 B(Star), R(1), // 3008 B(Star), R(1), //
2990 B(LdaConstant), U8(2), // 3009 B(CreateArrayLiteral), U8(2), U8(1), U8(simple_flags), //
2991 B(CreateArrayLiteral), U8(1), U8(simple_flags), //
2992 B(Star), R(4), // 3010 B(Star), R(4), //
2993 B(LdaZero), // 3011 B(LdaZero), //
2994 B(Star), R(3), // 3012 B(Star), R(3), //
2995 B(LdaSmi8), U8(2), // 3013 B(LdaSmi8), U8(2), //
2996 B(Add), R(0), // 3014 B(Add), R(0), //
2997 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), // 3015 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), //
2998 B(Ldar), R(4), // 3016 B(Ldar), R(4), //
2999 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // 3017 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), //
3000 B(Ldar), R(2), // 3018 B(Ldar), R(2), //
3001 B(Return), // 3019 B(Return), //
3002 }, 3020 },
3003 3, 3021 3,
3004 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, 3022 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
3005 InstanceType::FIXED_ARRAY_TYPE}}, 3023 InstanceType::FIXED_ARRAY_TYPE}},
3006 }; 3024 };
3007 3025
3008 for (size_t i = 0; i < arraysize(snippets); i++) { 3026 for (size_t i = 0; i < arraysize(snippets); i++) {
3009 Handle<BytecodeArray> bytecode_array = 3027 Handle<BytecodeArray> bytecode_array =
3010 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 3028 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3011 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3029 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3012 } 3030 }
3013 } 3031 }
3014 3032
3015 3033
3034 TEST(ArrayLiteralsWide) {
3035 InitializedHandleScope handle_scope;
3036 BytecodeGeneratorHelper helper;
3037 Zone zone;
3038
3039 int wide_idx = 0;
3040 int simple_flags =
3041 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements;
3042
3043 ExpectedSnippet<InstanceType, 257> snippets[] = {
3044 {"var a;" REPEAT_256(SPACE, "a = 1.23;") "return [ 1 , 2 ];",
3045 1 * kPointerSize,
3046 1,
3047 1031,
3048 {
3049 REPEAT_256(COMMA, //
3050 B(LdaConstant), U8(wide_idx++), //
3051 B(Star), R(0)), //
3052 B(CreateArrayLiteralWide), U16(256), U16(0), U8(simple_flags), //
3053 B(Return) //
3054 },
3055 257,
3056 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
3057 InstanceType::FIXED_ARRAY_TYPE}},
3058 };
3059
3060 for (size_t i = 0; i < arraysize(snippets); i++) {
3061 Handle<BytecodeArray> bytecode_array =
3062 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3063 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3064 }
3065 }
3066
3067
3016 TEST(ObjectLiterals) { 3068 TEST(ObjectLiterals) {
3017 InitializedHandleScope handle_scope; 3069 InitializedHandleScope handle_scope;
3018 BytecodeGeneratorHelper helper; 3070 BytecodeGeneratorHelper helper;
3019 Zone zone; 3071 Zone zone;
3020 3072
3021 FeedbackVectorSpec feedback_spec(&zone); 3073 FeedbackVectorSpec feedback_spec(&zone);
3022 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); 3074 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot();
3023 3075
3024 Handle<i::TypeFeedbackVector> vector = 3076 Handle<i::TypeFeedbackVector> vector =
3025 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 3077 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
3026 3078
3027 int simple_flags = ObjectLiteral::kFastElements | 3079 int simple_flags = ObjectLiteral::kFastElements |
3028 ObjectLiteral::kShallowProperties | 3080 ObjectLiteral::kShallowProperties |
3029 ObjectLiteral::kDisableMementos; 3081 ObjectLiteral::kDisableMementos;
3030 int deep_elements_flags = 3082 int deep_elements_flags =
3031 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; 3083 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
3032 ExpectedSnippet<InstanceType> snippets[] = { 3084 ExpectedSnippet<InstanceType> snippets[] = {
3033 {"return { };", 3085 {"return { };",
3034 0, 3086 0,
3035 1, 3087 1,
3036 6, 3088 5,
3037 { 3089 {
3038 B(LdaConstant), U8(0), // 3090 B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), //
3039 B(CreateObjectLiteral), U8(0), U8(simple_flags), // 3091 B(Return) //
3040 B(Return) //
3041 }, 3092 },
3042 1, 3093 1,
3043 {InstanceType::FIXED_ARRAY_TYPE}}, 3094 {InstanceType::FIXED_ARRAY_TYPE}},
3044 {"return { name: 'string', val: 9.2 };", 3095 {"return { name: 'string', val: 9.2 };",
3045 0, 3096 0,
3046 1, 3097 1,
3047 6, 3098 5,
3048 { 3099 {
3049 B(LdaConstant), U8(0), // 3100 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3050 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 3101 B(Return) //
3051 B(Return) //
3052 }, 3102 },
3053 1, 3103 1,
3054 {InstanceType::FIXED_ARRAY_TYPE}}, 3104 {InstanceType::FIXED_ARRAY_TYPE}},
3055 {"var a = 1; return { name: 'string', val: a };", 3105 {"var a = 1; return { name: 'string', val: a };",
3056 2 * kPointerSize, 3106 2 * kPointerSize,
3057 1, 3107 1,
3058 20, 3108 19,
3059 { 3109 {
3060 B(LdaSmi8), U8(1), // 3110 B(LdaSmi8), U8(1), //
3061 B(Star), R(0), // 3111 B(Star), R(0), //
3062 B(LdaConstant), U8(0), // 3112 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3063 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 3113 B(Star), R(1), //
3064 B(Star), R(1), // 3114 B(Ldar), R(0), //
3065 B(Ldar), R(0), // 3115 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
3066 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // 3116 B(Ldar), R(1), //
3067 B(Ldar), R(1), // 3117 B(Return), //
3068 B(Return), //
3069 }, 3118 },
3070 2, 3119 2,
3071 {InstanceType::FIXED_ARRAY_TYPE, 3120 {InstanceType::FIXED_ARRAY_TYPE,
3072 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 3121 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3073 {"var a = 1; return { val: a, val: a + 1 };", 3122 {"var a = 1; return { val: a, val: a + 1 };",
3074 2 * kPointerSize, 3123 2 * kPointerSize,
3075 1, 3124 1,
3076 22, 3125 21,
3077 { 3126 {
3078 B(LdaSmi8), U8(1), // 3127 B(LdaSmi8), U8(1), //
3079 B(Star), R(0), // 3128 B(Star), R(0), //
3080 B(LdaConstant), U8(0), // 3129 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3081 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 3130 B(Star), R(1), //
3082 B(Star), R(1), // 3131 B(LdaSmi8), U8(1), //
3083 B(LdaSmi8), U8(1), // 3132 B(Add), R(0), //
3084 B(Add), R(0), // 3133 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
3085 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // 3134 B(Ldar), R(1), //
3086 B(Ldar), R(1), // 3135 B(Return), //
3087 B(Return), //
3088 }, 3136 },
3089 2, 3137 2,
3090 {InstanceType::FIXED_ARRAY_TYPE, 3138 {InstanceType::FIXED_ARRAY_TYPE,
3091 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 3139 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3092 {"return { func: function() { } };", 3140 {"return { func: function() { } };",
3093 1 * kPointerSize, 3141 1 * kPointerSize,
3094 1, 3142 1,
3095 17, 3143 16,
3096 { 3144 {
3097 B(LdaConstant), U8(0), // 3145 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3098 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 3146 B(Star), R(0), //
3099 B(Star), R(0), // 3147 B(CreateClosure), U8(2), U8(0), //
3100 B(CreateClosure), U8(2), U8(0), // 3148 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
3101 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // 3149 B(Ldar), R(0), //
3102 B(Ldar), R(0), // 3150 B(Return), //
3103 B(Return), //
3104 }, 3151 },
3105 3, 3152 3,
3106 {InstanceType::FIXED_ARRAY_TYPE, 3153 {InstanceType::FIXED_ARRAY_TYPE,
3107 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3154 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3108 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3155 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3109 {"return { func(a) { return a; } };", 3156 {"return { func(a) { return a; } };",
3110 1 * kPointerSize, 3157 1 * kPointerSize,
3111 1, 3158 1,
3112 17, 3159 16,
3113 { 3160 {
3114 B(LdaConstant), U8(0), // 3161 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3115 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 3162 B(Star), R(0), //
3116 B(Star), R(0), // 3163 B(CreateClosure), U8(2), U8(0), //
3117 B(CreateClosure), U8(2), U8(0), // 3164 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
3118 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // 3165 B(Ldar), R(0), //
3119 B(Ldar), R(0), // 3166 B(Return), //
3120 B(Return), //
3121 }, 3167 },
3122 3, 3168 3,
3123 {InstanceType::FIXED_ARRAY_TYPE, 3169 {InstanceType::FIXED_ARRAY_TYPE,
3124 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3170 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3125 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3171 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3126 {"return { get a() { return 2; } };", 3172 {"return { get a() { return 2; } };",
3127 5 * kPointerSize, 3173 5 * kPointerSize,
3128 1, 3174 1,
3129 30, 3175 29,
3130 { 3176 {
3131 B(LdaConstant), U8(0), // 3177 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3132 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
3133 B(Star), R(0), // 3178 B(Star), R(0), //
3134 B(LdaConstant), U8(1), // 3179 B(LdaConstant), U8(1), //
3135 B(Star), R(1), // 3180 B(Star), R(1), //
3136 B(CreateClosure), U8(2), U8(0), // 3181 B(CreateClosure), U8(2), U8(0), //
3137 B(Star), R(2), // 3182 B(Star), R(2), //
3138 B(LdaNull), // 3183 B(LdaNull), //
3139 B(Star), R(3), // 3184 B(Star), R(3), //
3140 B(LdaZero), // 3185 B(LdaZero), //
3141 B(Star), R(4), // 3186 B(Star), R(4), //
3142 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // 3187 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
3143 R(0), U8(5), // 3188 R(0), U8(5), //
3144 B(Ldar), R(0), // 3189 B(Ldar), R(0), //
3145 B(Return), // 3190 B(Return), //
3146 }, 3191 },
3147 3, 3192 3,
3148 {InstanceType::FIXED_ARRAY_TYPE, 3193 {InstanceType::FIXED_ARRAY_TYPE,
3149 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3194 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3150 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3195 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3151 {"return { get a() { return this.x; }, set a(val) { this.x = val } };", 3196 {"return { get a() { return this.x; }, set a(val) { this.x = val } };",
3152 5 * kPointerSize, 3197 5 * kPointerSize,
3153 1, 3198 1,
3154 32, 3199 31,
3155 { 3200 {
3156 B(LdaConstant), U8(0), // 3201 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3157 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
3158 B(Star), R(0), // 3202 B(Star), R(0), //
3159 B(LdaConstant), U8(1), // 3203 B(LdaConstant), U8(1), //
3160 B(Star), R(1), // 3204 B(Star), R(1), //
3161 B(CreateClosure), U8(2), U8(0), // 3205 B(CreateClosure), U8(2), U8(0), //
3162 B(Star), R(2), // 3206 B(Star), R(2), //
3163 B(CreateClosure), U8(3), U8(0), // 3207 B(CreateClosure), U8(3), U8(0), //
3164 B(Star), R(3), // 3208 B(Star), R(3), //
3165 B(LdaZero), // 3209 B(LdaZero), //
3166 B(Star), R(4), // 3210 B(Star), R(4), //
3167 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // 3211 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
3168 R(0), U8(5), // 3212 R(0), U8(5), //
3169 B(Ldar), R(0), // 3213 B(Ldar), R(0), //
3170 B(Return), // 3214 B(Return), //
3171 }, 3215 },
3172 4, 3216 4,
3173 {InstanceType::FIXED_ARRAY_TYPE, 3217 {InstanceType::FIXED_ARRAY_TYPE,
3174 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3218 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3175 InstanceType::SHARED_FUNCTION_INFO_TYPE, 3219 InstanceType::SHARED_FUNCTION_INFO_TYPE,
3176 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3220 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3177 {"return { set b(val) { this.y = val } };", 3221 {"return { set b(val) { this.y = val } };",
3178 5 * kPointerSize, 3222 5 * kPointerSize,
3179 1, 3223 1,
3180 30, 3224 29,
3181 { 3225 {
3182 B(LdaConstant), U8(0), // 3226 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3183 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
3184 B(Star), R(0), // 3227 B(Star), R(0), //
3185 B(LdaConstant), U8(1), // 3228 B(LdaConstant), U8(1), //
3186 B(Star), R(1), // 3229 B(Star), R(1), //
3187 B(LdaNull), // 3230 B(LdaNull), //
3188 B(Star), R(2), // 3231 B(Star), R(2), //
3189 B(CreateClosure), U8(2), U8(0), // 3232 B(CreateClosure), U8(2), U8(0), //
3190 B(Star), R(3), // 3233 B(Star), R(3), //
3191 B(LdaZero), // 3234 B(LdaZero), //
3192 B(Star), R(4), // 3235 B(Star), R(4), //
3193 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // 3236 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
3194 R(0), U8(5), // 3237 R(0), U8(5), //
3195 B(Ldar), R(0), // 3238 B(Ldar), R(0), //
3196 B(Return), // 3239 B(Return), //
3197 }, 3240 },
3198 3, 3241 3,
3199 {InstanceType::FIXED_ARRAY_TYPE, 3242 {InstanceType::FIXED_ARRAY_TYPE,
3200 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3243 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3201 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3244 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3202 {"var a = 1; return { 1: a };", 3245 {"var a = 1; return { 1: a };",
3203 5 * kPointerSize, 3246 5 * kPointerSize,
3204 1, 3247 1,
3205 30, 3248 29,
3206 { 3249 {
3207 B(LdaSmi8), U8(1), // 3250 B(LdaSmi8), U8(1), //
3208 B(Star), R(0), // 3251 B(Star), R(0), //
3209 B(LdaConstant), U8(0), // 3252 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
3210 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // 3253 B(Star), R(1), //
3211 B(Star), R(1), // 3254 B(LdaSmi8), U8(1), //
3212 B(LdaSmi8), U8(1), // 3255 B(Star), R(2), //
3213 B(Star), R(2), // 3256 B(Ldar), R(0), //
3214 B(Ldar), R(0), // 3257 B(Star), R(3), //
3215 B(Star), R(3), // 3258 B(LdaZero), //
3216 B(LdaZero), // 3259 B(Star), R(4), //
3217 B(Star), R(4), // 3260 B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), //
3218 B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), // 3261 B(Ldar), R(1), //
3219 B(Ldar), R(1), // 3262 B(Return), //
3220 B(Return), //
3221 }, 3263 },
3222 1, 3264 1,
3223 {InstanceType::FIXED_ARRAY_TYPE}}, 3265 {InstanceType::FIXED_ARRAY_TYPE}},
3224 {"return { __proto__: null }", 3266 {"return { __proto__: null }",
3225 2 * kPointerSize, 3267 2 * kPointerSize,
3226 1, 3268 1,
3227 18, 3269 17,
3228 { 3270 {
3229 B(LdaConstant), U8(0), // 3271 B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), //
3230 B(CreateObjectLiteral), U8(0), U8(simple_flags), //
3231 B(Star), R(0), // 3272 B(Star), R(0), //
3232 B(LdaNull), B(Star), R(1), // 3273 B(LdaNull), B(Star), R(1), //
3233 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), // 3274 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), //
3234 B(Ldar), R(0), // 3275 B(Ldar), R(0), //
3235 B(Return), // 3276 B(Return), //
3236 }, 3277 },
3237 1, 3278 1,
3238 {InstanceType::FIXED_ARRAY_TYPE}}, 3279 {InstanceType::FIXED_ARRAY_TYPE}},
3239 {"var a = 'test'; return { [a]: 1 }", 3280 {"var a = 'test'; return { [a]: 1 }",
3240 5 * kPointerSize, 3281 5 * kPointerSize,
3241 1, 3282 1,
3242 31, 3283 30,
3243 { 3284 {
3244 B(LdaConstant), U8(0), // 3285 B(LdaConstant), U8(0), //
3245 B(Star), R(0), // 3286 B(Star), R(0), //
3246 B(LdaConstant), U8(1), // 3287 B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), //
3247 B(CreateObjectLiteral), U8(0), U8(simple_flags), //
3248 B(Star), R(1), // 3288 B(Star), R(1), //
3249 B(Ldar), R(0), // 3289 B(Ldar), R(0), //
3250 B(ToName), // 3290 B(ToName), //
3251 B(Star), R(2), // 3291 B(Star), R(2), //
3252 B(LdaSmi8), U8(1), // 3292 B(LdaSmi8), U8(1), //
3253 B(Star), R(3), // 3293 B(Star), R(3), //
3254 B(LdaZero), // 3294 B(LdaZero), //
3255 B(Star), R(4), // 3295 B(Star), R(4), //
3256 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // 3296 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
3257 U8(4), // 3297 U8(4), //
3258 B(Ldar), R(1), // 3298 B(Ldar), R(1), //
3259 B(Return), // 3299 B(Return), //
3260 }, 3300 },
3261 2, 3301 2,
3262 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3302 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3263 InstanceType::FIXED_ARRAY_TYPE}}, 3303 InstanceType::FIXED_ARRAY_TYPE}},
3264 {"var a = 'test'; return { val: a, [a]: 1 }", 3304 {"var a = 'test'; return { val: a, [a]: 1 }",
3265 5 * kPointerSize, 3305 5 * kPointerSize,
3266 1, 3306 1,
3267 37, 3307 36,
3268 { 3308 {
3269 B(LdaConstant), U8(0), // 3309 B(LdaConstant), U8(0), //
3270 B(Star), R(0), // 3310 B(Star), R(0), //
3271 B(LdaConstant), U8(1), // 3311 B(CreateObjectLiteral), U8(1), U8(0), U8(deep_elements_flags), //
3272 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
3273 B(Star), R(1), // 3312 B(Star), R(1), //
3274 B(Ldar), R(0), // 3313 B(Ldar), R(0), //
3275 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), // 3314 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), //
3276 B(Ldar), R(0), // 3315 B(Ldar), R(0), //
3277 B(ToName), // 3316 B(ToName), //
3278 B(Star), R(2), // 3317 B(Star), R(2), //
3279 B(LdaSmi8), U8(1), // 3318 B(LdaSmi8), U8(1), //
3280 B(Star), R(3), // 3319 B(Star), R(3), //
3281 B(LdaZero), // 3320 B(LdaZero), //
3282 B(Star), R(4), // 3321 B(Star), R(4), //
3283 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // 3322 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
3284 U8(4), // 3323 U8(4), //
3285 B(Ldar), R(1), // 3324 B(Ldar), R(1), //
3286 B(Return), // 3325 B(Return), //
3287 }, 3326 },
3288 3, 3327 3,
3289 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3328 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3290 InstanceType::FIXED_ARRAY_TYPE, 3329 InstanceType::FIXED_ARRAY_TYPE,
3291 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 3330 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3292 {"var a = 'test'; return { [a]: 1, __proto__: {} }", 3331 {"var a = 'test'; return { [a]: 1, __proto__: {} }",
3293 5 * kPointerSize, 3332 5 * kPointerSize,
3294 1, 3333 1,
3295 43, 3334 41,
3296 { 3335 {
3297 B(LdaConstant), U8(0), // 3336 B(LdaConstant), U8(0), //
3298 B(Star), R(0), // 3337 B(Star), R(0), //
3299 B(LdaConstant), U8(1), // 3338 B(CreateObjectLiteral), U8(1), U8(1), U8(simple_flags), //
3300 B(CreateObjectLiteral), U8(1), U8(simple_flags), //
3301 B(Star), R(1), // 3339 B(Star), R(1), //
3302 B(Ldar), R(0), // 3340 B(Ldar), R(0), //
3303 B(ToName), // 3341 B(ToName), //
3304 B(Star), R(2), // 3342 B(Star), R(2), //
3305 B(LdaSmi8), U8(1), // 3343 B(LdaSmi8), U8(1), //
3306 B(Star), R(3), // 3344 B(Star), R(3), //
3307 B(LdaZero), // 3345 B(LdaZero), //
3308 B(Star), R(4), // 3346 B(Star), R(4), //
3309 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // 3347 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
3310 U8(4), // 3348 U8(4), //
3311 B(LdaConstant), U8(1), // 3349 B(CreateObjectLiteral), U8(1), U8(0), U8(13), //
3312 B(CreateObjectLiteral), U8(0), U8(13), //
3313 B(Star), R(2), // 3350 B(Star), R(2), //
3314 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // 3351 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), //
3315 B(Ldar), R(1), // 3352 B(Ldar), R(1), //
3316 B(Return), // 3353 B(Return), //
3317 }, 3354 },
3318 2, 3355 2,
3319 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 3356 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
3320 InstanceType::FIXED_ARRAY_TYPE}}, 3357 InstanceType::FIXED_ARRAY_TYPE}},
3321 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", 3358 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };",
3322 5 * kPointerSize, 3359 5 * kPointerSize,
3323 1, 3360 1,
3324 65, 3361 64,
3325 { 3362 {
3326 B(LdaConstant), U8(0), // 3363 B(LdaConstant), U8(0), //
3327 B(Star), R(0), // 3364 B(Star), R(0), //
3328 B(LdaConstant), U8(1), // 3365 B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), //
3329 B(CreateObjectLiteral), U8(0), U8(simple_flags), //
3330 B(Star), R(1), // 3366 B(Star), R(1), //
3331 B(Ldar), R(0), // 3367 B(Ldar), R(0), //
3332 B(ToName), // 3368 B(ToName), //
3333 B(Star), R(2), // 3369 B(Star), R(2), //
3334 B(LdaConstant), U8(2), // 3370 B(LdaConstant), U8(2), //
3335 B(Star), R(3), // 3371 B(Star), R(3), //
3336 B(LdaZero), // 3372 B(LdaZero), //
3337 B(Star), R(4), // 3373 B(Star), R(4), //
3338 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // 3374 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
3339 U8(4), // 3375 U8(4), //
(...skipping 26 matching lines...) Expand all
3366 }; 3402 };
3367 3403
3368 for (size_t i = 0; i < arraysize(snippets); i++) { 3404 for (size_t i = 0; i < arraysize(snippets); i++) {
3369 Handle<BytecodeArray> bytecode_array = 3405 Handle<BytecodeArray> bytecode_array =
3370 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 3406 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3371 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3407 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3372 } 3408 }
3373 } 3409 }
3374 3410
3375 3411
3412 TEST(ObjectLiteralsWide) {
3413 InitializedHandleScope handle_scope;
3414 BytecodeGeneratorHelper helper;
3415 Zone zone;
3416
3417 int deep_elements_flags =
3418 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
3419 int wide_idx = 0;
3420
3421 ExpectedSnippet<InstanceType, 257> snippets[] = {
3422 {"var a;" REPEAT_256(SPACE,
3423 "a = 1.23;") "return { name: 'string', val: 9.2 };",
3424 1 * kPointerSize,
3425 1,
3426 1031,
3427 {
3428 REPEAT_256(COMMA, //
3429 B(LdaConstant), U8(wide_idx++), //
3430 B(Star), R(0)), //
3431 B(CreateObjectLiteralWide), U16(256), U16(0), //
3432 U8(deep_elements_flags), //
3433 B(Return) //
3434 },
3435 257,
3436 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
3437 InstanceType::FIXED_ARRAY_TYPE}},
3438 };
3439
3440 for (size_t i = 0; i < arraysize(snippets); i++) {
3441 Handle<BytecodeArray> bytecode_array =
3442 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3443 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3444 }
3445 }
3446
3447
3376 TEST(TopLevelObjectLiterals) { 3448 TEST(TopLevelObjectLiterals) {
3377 InitializedHandleScope handle_scope; 3449 InitializedHandleScope handle_scope;
3378 BytecodeGeneratorHelper helper; 3450 BytecodeGeneratorHelper helper;
3379 3451
3380 int has_function_flags = ObjectLiteral::kFastElements | 3452 int has_function_flags = ObjectLiteral::kFastElements |
3381 ObjectLiteral::kHasFunction | 3453 ObjectLiteral::kHasFunction |
3382 ObjectLiteral::kDisableMementos; 3454 ObjectLiteral::kDisableMementos;
3383 ExpectedSnippet<InstanceType> snippets[] = { 3455 ExpectedSnippet<InstanceType> snippets[] = {
3384 {"var a = { func: function() { } };", 3456 {"var a = { func: function() { } };",
3385 5 * kPointerSize, 3457 5 * kPointerSize,
3386 1, 3458 1,
3387 49, 3459 48,
3388 { 3460 {
3389 B(LdaConstant), U8(0), // 3461 B(LdaConstant), U8(0), //
3390 B(Star), R(1), // 3462 B(Star), R(1), //
3391 B(LdaZero), // 3463 B(LdaZero), //
3392 B(Star), R(2), // 3464 B(Star), R(2), //
3393 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 3465 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
3394 B(LdaConstant), U8(1), // 3466 B(LdaConstant), U8(1), //
3395 B(Star), R(1), // 3467 B(Star), R(1), //
3396 B(LdaZero), // 3468 B(LdaZero), //
3397 B(Star), R(2), // 3469 B(Star), R(2), //
3398 B(LdaConstant), U8(2), // 3470 B(CreateObjectLiteral), U8(2), U8(0), U8(has_function_flags), //
3399 B(CreateObjectLiteral), U8(0), U8(has_function_flags), //
3400 B(Star), R(4), // 3471 B(Star), R(4), //
3401 B(CreateClosure), U8(4), U8(1), // 3472 B(CreateClosure), U8(4), U8(1), //
3402 B(StoreICSloppy), R(4), U8(3), U8(5), // 3473 B(StoreICSloppy), R(4), U8(3), U8(5), //
3403 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), // 3474 B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), //
3404 B(Ldar), R(4), // 3475 B(Ldar), R(4), //
3405 B(Star), R(3), // 3476 B(Star), R(3), //
3406 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // 3477 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
3407 B(LdaUndefined), // 3478 B(LdaUndefined), //
3408 B(Return), // 3479 B(Return), //
3409 }, 3480 },
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 B(ToNumber), // 4027 B(ToNumber), //
3957 B(Star), R(1), // 4028 B(Star), R(1), //
3958 B(Dec), // 4029 B(Dec), //
3959 B(Star), R(0), // 4030 B(Star), R(0), //
3960 B(Ldar), R(1), // 4031 B(Ldar), R(1), //
3961 B(Return), // 4032 B(Return), //
3962 }}, 4033 }},
3963 {"var a = { val: 1 }; return a.val++;", 4034 {"var a = { val: 1 }; return a.val++;",
3964 2 * kPointerSize, 4035 2 * kPointerSize,
3965 1, 4036 1,
3966 22, 4037 21,
3967 { 4038 {
3968 B(LdaConstant), U8(0), // 4039 B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
3969 B(CreateObjectLiteral), U8(0), U8(object_literal_flags), // 4040 B(Star), R(0), //
3970 B(Star), R(0), // 4041 B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
3971 B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // 4042 B(ToNumber), //
3972 B(ToNumber), // 4043 B(Star), R(1), //
3973 B(Star), R(1), // 4044 B(Inc), //
3974 B(Inc), // 4045 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
3975 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), // 4046 B(Ldar), R(1), //
3976 B(Ldar), R(1), // 4047 B(Return), //
3977 B(Return), //
3978 }, 4048 },
3979 2, 4049 2,
3980 {InstanceType::FIXED_ARRAY_TYPE, 4050 {InstanceType::FIXED_ARRAY_TYPE,
3981 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4051 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3982 {"var a = { val: 1 }; return --a.val;", 4052 {"var a = { val: 1 }; return --a.val;",
3983 1 * kPointerSize, 4053 1 * kPointerSize,
3984 1, 4054 1,
3985 18, 4055 17,
3986 { 4056 {
3987 B(LdaConstant), U8(0), // 4057 B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
3988 B(CreateObjectLiteral), U8(0), U8(object_literal_flags), // 4058 B(Star), R(0), //
3989 B(Star), R(0), // 4059 B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
3990 B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // 4060 B(ToNumber), //
3991 B(ToNumber), // 4061 B(Dec), //
3992 B(Dec), // 4062 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
3993 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), // 4063 B(Return), //
3994 B(Return), //
3995 }, 4064 },
3996 2, 4065 2,
3997 {InstanceType::FIXED_ARRAY_TYPE, 4066 {InstanceType::FIXED_ARRAY_TYPE,
3998 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4067 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
3999 {"var name = 'var'; var a = { val: 1 }; return a[name]--;", 4068 {"var name = 'var'; var a = { val: 1 }; return a[name]--;",
4000 4 * kPointerSize, 4069 4 * kPointerSize,
4001 1, 4070 1,
4002 29, 4071 28,
4003 { 4072 {
4004 B(LdaConstant), U8(0), // 4073 B(LdaConstant), U8(0), //
4005 B(Star), R(0), // 4074 B(Star), R(0), //
4006 B(LdaConstant), U8(1), // 4075 B(CreateObjectLiteral), U8(1), U8(0), U8(object_literal_flags), //
4007 B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
4008 B(Star), R(1), // 4076 B(Star), R(1), //
4009 B(Ldar), R(0), // 4077 B(Ldar), R(0), //
4010 B(Star), R(2), // 4078 B(Star), R(2), //
4011 B(KeyedLoadICSloppy), R(1), U8(vector->GetIndex(slot1)), // 4079 B(KeyedLoadICSloppy), R(1), U8(vector->GetIndex(slot1)), //
4012 B(ToNumber), // 4080 B(ToNumber), //
4013 B(Star), R(3), // 4081 B(Star), R(3), //
4014 B(Dec), // 4082 B(Dec), //
4015 B(KeyedStoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot2)), // 4083 B(KeyedStoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot2)), //
4016 B(Ldar), R(3), // 4084 B(Ldar), R(3), //
4017 B(Return), // 4085 B(Return), //
4018 }, 4086 },
4019 2, 4087 2,
4020 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 4088 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
4021 InstanceType::FIXED_ARRAY_TYPE}}, 4089 InstanceType::FIXED_ARRAY_TYPE}},
4022 {"var name = 'var'; var a = { val: 1 }; return ++a[name];", 4090 {"var name = 'var'; var a = { val: 1 }; return ++a[name];",
4023 3 * kPointerSize, 4091 3 * kPointerSize,
4024 1, 4092 1,
4025 25, 4093 24,
4026 { 4094 {
4027 B(LdaConstant), U8(0), // 4095 B(LdaConstant), U8(0), //
4028 B(Star), R(0), // 4096 B(Star), R(0), //
4029 B(LdaConstant), U8(1), // 4097 B(CreateObjectLiteral), U8(1), U8(0), U8(object_literal_flags), //
4030 B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
4031 B(Star), R(1), // 4098 B(Star), R(1), //
4032 B(Ldar), R(0), // 4099 B(Ldar), R(0), //
4033 B(Star), R(2), // 4100 B(Star), R(2), //
4034 B(KeyedLoadICSloppy), R(1), U8(vector->GetIndex(slot1)), // 4101 B(KeyedLoadICSloppy), R(1), U8(vector->GetIndex(slot1)), //
4035 B(ToNumber), // 4102 B(ToNumber), //
4036 B(Inc), // 4103 B(Inc), //
4037 B(KeyedStoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot2)), // 4104 B(KeyedStoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot2)), //
4038 B(Return), // 4105 B(Return), //
4039 }, 4106 },
4040 2, 4107 2,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 B(Dec), // 4145 B(Dec), //
4079 B(StaContextSlot), R(1), U8(first_context_slot), // 4146 B(StaContextSlot), R(1), U8(first_context_slot), //
4080 B(Ldar), R(2), // 4147 B(Ldar), R(2), //
4081 B(Return), // 4148 B(Return), //
4082 }, 4149 },
4083 1, 4150 1,
4084 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 4151 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
4085 {"var idx = 1; var a = [1, 2]; return a[idx++] = 2;", 4152 {"var idx = 1; var a = [1, 2]; return a[idx++] = 2;",
4086 3 * kPointerSize, 4153 3 * kPointerSize,
4087 1, 4154 1,
4088 26, 4155 25,
4089 { 4156 {
4090 B(LdaSmi8), U8(1), // 4157 B(LdaSmi8), U8(1), //
4091 B(Star), R(0), // 4158 B(Star), R(0), //
4092 B(LdaConstant), U8(0), // 4159 B(CreateArrayLiteral), U8(0), U8(0), U8(array_literal_flags), //
4093 B(CreateArrayLiteral), U8(0), U8(array_literal_flags), //
4094 B(Star), R(1), // 4160 B(Star), R(1), //
4095 B(Ldar), R(0), // 4161 B(Ldar), R(0), //
4096 B(ToNumber), // 4162 B(ToNumber), //
4097 B(Star), R(2), // 4163 B(Star), R(2), //
4098 B(Inc), // 4164 B(Inc), //
4099 B(Star), R(0), // 4165 B(Star), R(0), //
4100 B(LdaSmi8), U8(2), // 4166 B(LdaSmi8), U8(2), //
4101 B(KeyedStoreICSloppy), R(1), R(2), // 4167 B(KeyedStoreICSloppy), R(1), R(2), //
4102 U8(store_vector->GetIndex(store_slot)), // 4168 U8(store_vector->GetIndex(store_slot)), //
4103 B(Return), // 4169 B(Return), //
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4234 B(Star), R(0), // 4300 B(Star), R(0), //
4235 B(LdaSmi8), U8(2), // 4301 B(LdaSmi8), U8(2), //
4236 B(Div), R(0), // 4302 B(Div), R(0), //
4237 B(Star), R(0), // 4303 B(Star), R(0), //
4238 B(LdaUndefined), // 4304 B(LdaUndefined), //
4239 B(Return), // 4305 B(Return), //
4240 }}, 4306 }},
4241 {"var a = { val: 2 }; a.name *= 2;", 4307 {"var a = { val: 2 }; a.name *= 2;",
4242 2 * kPointerSize, 4308 2 * kPointerSize,
4243 1, 4309 1,
4244 23, 4310 22,
4245 { 4311 {
4246 B(LdaConstant), U8(0), // 4312 B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
4247 B(CreateObjectLiteral), U8(0), U8(object_literal_flags), // 4313 B(Star), R(0), //
4248 B(Star), R(0), // 4314 B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
4249 B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), // 4315 B(Star), R(1), //
4250 B(Star), R(1), // 4316 B(LdaSmi8), U8(2), //
4251 B(LdaSmi8), U8(2), // 4317 B(Mul), R(1), //
4252 B(Mul), R(1), // 4318 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
4253 B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), // 4319 B(LdaUndefined), //
4254 B(LdaUndefined), // 4320 B(Return), //
4255 B(Return), //
4256 }, 4321 },
4257 2, 4322 2,
4258 {InstanceType::FIXED_ARRAY_TYPE, 4323 {InstanceType::FIXED_ARRAY_TYPE,
4259 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4324 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4260 {"var a = { 1: 2 }; a[1] ^= 2;", 4325 {"var a = { 1: 2 }; a[1] ^= 2;",
4261 3 * kPointerSize, 4326 3 * kPointerSize,
4262 1, 4327 1,
4263 26, 4328 25,
4264 { 4329 {
4265 B(LdaConstant), U8(0), // 4330 B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
4266 B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
4267 B(Star), R(0), // 4331 B(Star), R(0), //
4268 B(LdaSmi8), U8(1), // 4332 B(LdaSmi8), U8(1), //
4269 B(Star), R(1), // 4333 B(Star), R(1), //
4270 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // 4334 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
4271 B(Star), R(2), // 4335 B(Star), R(2), //
4272 B(LdaSmi8), U8(2), // 4336 B(LdaSmi8), U8(2), //
4273 B(BitwiseXor), R(2), // 4337 B(BitwiseXor), R(2), //
4274 B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot2)), // 4338 B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot2)), //
4275 B(LdaUndefined), // 4339 B(LdaUndefined), //
4276 B(Return), // 4340 B(Return), //
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 B(Jump), U8(-19), // 4614 B(Jump), U8(-19), //
4551 B(LdaUndefined), // 4615 B(LdaUndefined), //
4552 B(Return), // 4616 B(Return), //
4553 }, 4617 },
4554 1, 4618 1,
4555 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4619 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4556 {"var x = 0;\n" 4620 {"var x = 0;\n"
4557 "for (var p in [1,2,3]) { x += p; }", 4621 "for (var p in [1,2,3]) { x += p; }",
4558 5 * kPointerSize, 4622 5 * kPointerSize,
4559 1, 4623 1,
4560 53, 4624 52,
4561 { 4625 {
4562 B(LdaZero), // 4626 B(LdaZero), //
4563 B(Star), R(1), // 4627 B(Star), R(1), //
4564 B(LdaConstant), U8(0), // 4628 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
4565 B(CreateArrayLiteral), U8(0), U8(simple_flags), //
4566 B(JumpIfUndefined), U8(43), // 4629 B(JumpIfUndefined), U8(43), //
4567 B(JumpIfNull), U8(41), // 4630 B(JumpIfNull), U8(41), //
4568 B(ToObject), // 4631 B(ToObject), //
4569 B(Star), R(3), // 4632 B(Star), R(3), //
4570 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // 4633 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), //
4571 B(ForInPrepare), R(3), // 4634 B(ForInPrepare), R(3), //
4572 B(JumpIfUndefined), U8(29), // 4635 B(JumpIfUndefined), U8(29), //
4573 B(Star), R(4), // 4636 B(Star), R(4), //
4574 B(LdaZero), // 4637 B(LdaZero), //
4575 B(Star), R(3), // 4638 B(Star), R(3), //
(...skipping 13 matching lines...) Expand all
4589 }, 4652 },
4590 1, 4653 1,
4591 {InstanceType::FIXED_ARRAY_TYPE}}, 4654 {InstanceType::FIXED_ARRAY_TYPE}},
4592 {"var x = { 'a': 1, 'b': 2 };\n" 4655 {"var x = { 'a': 1, 'b': 2 };\n"
4593 "for (x['a'] in [10, 20, 30]) {\n" 4656 "for (x['a'] in [10, 20, 30]) {\n"
4594 " if (x['a'] == 10) continue;\n" 4657 " if (x['a'] == 10) continue;\n"
4595 " if (x['a'] == 20) break;\n" 4658 " if (x['a'] == 20) break;\n"
4596 "}", 4659 "}",
4597 4 * kPointerSize, 4660 4 * kPointerSize,
4598 1, 4661 1,
4599 83, 4662 81,
4600 { 4663 {
4601 B(LdaConstant), U8(0), // 4664 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
4602 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
4603 B(Star), R(0), // 4665 B(Star), R(0), //
4604 B(LdaConstant), U8(1), // 4666 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
4605 B(CreateArrayLiteral), U8(1), U8(simple_flags), //
4606 B(JumpIfUndefined), U8(69), // 4667 B(JumpIfUndefined), U8(69), //
4607 B(JumpIfNull), U8(67), // 4668 B(JumpIfNull), U8(67), //
4608 B(ToObject), // 4669 B(ToObject), //
4609 B(Star), R(1), // 4670 B(Star), R(1), //
4610 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // 4671 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), //
4611 B(ForInPrepare), R(1), // 4672 B(ForInPrepare), R(1), //
4612 B(JumpIfUndefined), U8(55), // 4673 B(JumpIfUndefined), U8(55), //
4613 B(Star), R(2), // 4674 B(Star), R(2), //
4614 B(LdaZero), // 4675 B(LdaZero), //
4615 B(Star), R(1), // 4676 B(Star), R(1), //
(...skipping 21 matching lines...) Expand all
4637 B(LdaUndefined), // 4698 B(LdaUndefined), //
4638 B(Return), // 4699 B(Return), //
4639 }, 4700 },
4640 3, 4701 3,
4641 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, 4702 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
4642 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4703 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4643 {"var x = [ 10, 11, 12 ] ;\n" 4704 {"var x = [ 10, 11, 12 ] ;\n"
4644 "for (x[0] in [1,2,3]) { return x[3]; }", 4705 "for (x[0] in [1,2,3]) { return x[3]; }",
4645 5 * kPointerSize, 4706 5 * kPointerSize,
4646 1, 4707 1,
4647 66, 4708 64,
4648 { 4709 {
4649 B(LdaConstant), U8(0), // 4710 B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
4650 B(CreateArrayLiteral), U8(0), U8(simple_flags), //
4651 B(Star), R(0), // 4711 B(Star), R(0), //
4652 B(LdaConstant), U8(1), // 4712 B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
4653 B(CreateArrayLiteral), U8(1), U8(simple_flags), //
4654 B(JumpIfUndefined), U8(52), // 4713 B(JumpIfUndefined), U8(52), //
4655 B(JumpIfNull), U8(50), // 4714 B(JumpIfNull), U8(50), //
4656 B(ToObject), // 4715 B(ToObject), //
4657 B(Star), R(1), // 4716 B(Star), R(1), //
4658 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), // 4717 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(1), U8(1), //
4659 B(ForInPrepare), R(1), // 4718 B(ForInPrepare), R(1), //
4660 B(JumpIfUndefined), U8(38), // 4719 B(JumpIfUndefined), U8(38), //
4661 B(Star), R(2), // 4720 B(Star), R(2), //
4662 B(LdaZero), // 4721 B(LdaZero), //
4663 B(Star), R(1), // 4722 B(Star), R(1), //
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
5460 for (size_t i = 0; i < arraysize(snippets); i++) { 5519 for (size_t i = 0; i < arraysize(snippets); i++) {
5461 Handle<BytecodeArray> bytecode_array = 5520 Handle<BytecodeArray> bytecode_array =
5462 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 5521 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
5463 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5522 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5464 } 5523 }
5465 } 5524 }
5466 5525
5467 } // namespace interpreter 5526 } // namespace interpreter
5468 } // namespace internal 5527 } // namespace internal
5469 } // namespace v8 5528 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698