| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/interpreter/bytecode-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" |
| 9 #include "src/interpreter/bytecode-generator.h" | 9 #include "src/interpreter/bytecode-generator.h" |
| 10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
| (...skipping 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3697 0, | 3697 0, |
| 3698 1, | 3698 1, |
| 3699 5, | 3699 5, |
| 3700 { | 3700 { |
| 3701 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3701 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3702 B(Return) // | 3702 B(Return) // |
| 3703 }, | 3703 }, |
| 3704 1, | 3704 1, |
| 3705 {InstanceType::FIXED_ARRAY_TYPE}}, | 3705 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 3706 {"var a = 1; return { name: 'string', val: a };", | 3706 {"var a = 1; return { name: 'string', val: a };", |
| 3707 2 * kPointerSize, | 3707 6 * kPointerSize, |
| 3708 1, | 3708 1, |
| 3709 19, | 3709 19, |
| 3710 { | 3710 { |
| 3711 B(LdaSmi8), U8(1), // | 3711 B(LdaSmi8), U8(1), // |
| 3712 B(Star), R(0), // | 3712 B(Star), R(0), // |
| 3713 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3713 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3714 B(Star), R(1), // | 3714 B(Star), R(1), // |
| 3715 B(Ldar), R(0), // | 3715 B(Ldar), R(0), // |
| 3716 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // | 3716 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // |
| 3717 B(Ldar), R(1), // | 3717 B(Ldar), R(1), // |
| 3718 B(Return), // | 3718 B(Return), // |
| 3719 }, | 3719 }, |
| 3720 2, | 3720 2, |
| 3721 {InstanceType::FIXED_ARRAY_TYPE, | 3721 {InstanceType::FIXED_ARRAY_TYPE, |
| 3722 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 3722 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 3723 {"var a = 1; return { val: a, val: a + 1 };", | 3723 {"var a = 1; return { val: a, val: a + 1 };", |
| 3724 3 * kPointerSize, | 3724 6 * kPointerSize, |
| 3725 1, | 3725 1, |
| 3726 25, | 3726 25, |
| 3727 { | 3727 { |
| 3728 B(LdaSmi8), U8(1), // | 3728 B(LdaSmi8), U8(1), // |
| 3729 B(Star), R(0), // | 3729 B(Star), R(0), // |
| 3730 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3730 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3731 B(Star), R(1), // | 3731 B(Star), R(1), // |
| 3732 B(Ldar), R(0), // | 3732 B(Ldar), R(0), // |
| 3733 B(Star), R(2), // | 3733 B(Star), R(2), // |
| 3734 B(LdaSmi8), U8(1), // | 3734 B(LdaSmi8), U8(1), // |
| 3735 B(Add), R(2), // | 3735 B(Add), R(2), // |
| 3736 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // | 3736 B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), // |
| 3737 B(Ldar), R(1), // | 3737 B(Ldar), R(1), // |
| 3738 B(Return), // | 3738 B(Return), // |
| 3739 }, | 3739 }, |
| 3740 2, | 3740 2, |
| 3741 {InstanceType::FIXED_ARRAY_TYPE, | 3741 {InstanceType::FIXED_ARRAY_TYPE, |
| 3742 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 3742 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 3743 {"return { func: function() { } };", | 3743 {"return { func: function() { } };", |
| 3744 1 * kPointerSize, | 3744 5 * kPointerSize, |
| 3745 1, | 3745 1, |
| 3746 16, | 3746 16, |
| 3747 { | 3747 { |
| 3748 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3748 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3749 B(Star), R(0), // | 3749 B(Star), R(0), // |
| 3750 B(CreateClosure), U8(1), U8(0), // | 3750 B(CreateClosure), U8(1), U8(0), // |
| 3751 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot1)), // | 3751 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot1)), // |
| 3752 B(Ldar), R(0), // | 3752 B(Ldar), R(0), // |
| 3753 B(Return), // | 3753 B(Return), // |
| 3754 }, | 3754 }, |
| 3755 3, | 3755 3, |
| 3756 {InstanceType::FIXED_ARRAY_TYPE, | 3756 {InstanceType::FIXED_ARRAY_TYPE, |
| 3757 InstanceType::SHARED_FUNCTION_INFO_TYPE, | 3757 InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 3758 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 3758 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 3759 {"return { func(a) { return a; } };", | 3759 {"return { func(a) { return a; } };", |
| 3760 1 * kPointerSize, | 3760 5 * kPointerSize, |
| 3761 1, | 3761 1, |
| 3762 16, | 3762 16, |
| 3763 { | 3763 { |
| 3764 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3764 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3765 B(Star), R(0), // | 3765 B(Star), R(0), // |
| 3766 B(CreateClosure), U8(1), U8(0), // | 3766 B(CreateClosure), U8(1), U8(0), // |
| 3767 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot1)), // | 3767 B(StoreICSloppy), R(0), U8(2), U8(vector->GetIndex(slot1)), // |
| 3768 B(Ldar), R(0), // | 3768 B(Ldar), R(0), // |
| 3769 B(Return), // | 3769 B(Return), // |
| 3770 }, | 3770 }, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3839 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // | 3839 B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), // |
| 3840 R(0), U8(5), // | 3840 R(0), U8(5), // |
| 3841 B(Ldar), R(0), // | 3841 B(Ldar), R(0), // |
| 3842 B(Return), // | 3842 B(Return), // |
| 3843 }, | 3843 }, |
| 3844 3, | 3844 3, |
| 3845 {InstanceType::FIXED_ARRAY_TYPE, | 3845 {InstanceType::FIXED_ARRAY_TYPE, |
| 3846 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3846 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3847 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3847 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3848 {"var a = 1; return { 1: a };", | 3848 {"var a = 1; return { 1: a };", |
| 3849 5 * kPointerSize, | 3849 6 * kPointerSize, |
| 3850 1, | 3850 1, |
| 3851 29, | 3851 29, |
| 3852 { | 3852 { |
| 3853 B(LdaSmi8), U8(1), // | 3853 B(LdaSmi8), U8(1), // |
| 3854 B(Star), R(0), // | 3854 B(Star), R(0), // |
| 3855 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3855 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3856 B(Star), R(1), // | 3856 B(Star), R(1), // |
| 3857 B(LdaSmi8), U8(1), // | 3857 B(LdaSmi8), U8(1), // |
| 3858 B(Star), R(2), // | 3858 B(Star), R(2), // |
| 3859 B(Ldar), R(0), // | 3859 B(Ldar), R(0), // |
| 3860 B(Star), R(3), // | 3860 B(Star), R(3), // |
| 3861 B(LdaZero), // | 3861 B(LdaZero), // |
| 3862 B(Star), R(4), // | 3862 B(Star), R(4), // |
| 3863 B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), // | 3863 B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), // |
| 3864 B(Ldar), R(1), // | 3864 B(Ldar), R(1), // |
| 3865 B(Return), // | 3865 B(Return), // |
| 3866 }, | 3866 }, |
| 3867 1, | 3867 1, |
| 3868 {InstanceType::FIXED_ARRAY_TYPE}}, | 3868 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 3869 {"return { __proto__: null }", | 3869 {"return { __proto__: null }", |
| 3870 2 * kPointerSize, | 3870 5 * kPointerSize, |
| 3871 1, | 3871 1, |
| 3872 17, | 3872 17, |
| 3873 { | 3873 { |
| 3874 B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), // | 3874 B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), // |
| 3875 B(Star), R(0), // | 3875 B(Star), R(0), // |
| 3876 B(LdaNull), B(Star), R(1), // | 3876 B(LdaNull), B(Star), R(1), // |
| 3877 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), // | 3877 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), // |
| 3878 B(Ldar), R(0), // | 3878 B(Ldar), R(0), // |
| 3879 B(Return), // | 3879 B(Return), // |
| 3880 }, | 3880 }, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3898 B(Star), R(4), // | 3898 B(Star), R(4), // |
| 3899 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // | 3899 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), // |
| 3900 U8(4), // | 3900 U8(4), // |
| 3901 B(Ldar), R(1), // | 3901 B(Ldar), R(1), // |
| 3902 B(Return), // | 3902 B(Return), // |
| 3903 }, | 3903 }, |
| 3904 2, | 3904 2, |
| 3905 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 3905 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 3906 InstanceType::FIXED_ARRAY_TYPE}}, | 3906 InstanceType::FIXED_ARRAY_TYPE}}, |
| 3907 {"var a = 'test'; return { val: a, [a]: 1 }", | 3907 {"var a = 'test'; return { val: a, [a]: 1 }", |
| 3908 5 * kPointerSize, | 3908 6 * kPointerSize, |
| 3909 1, | 3909 1, |
| 3910 36, | 3910 36, |
| 3911 { | 3911 { |
| 3912 B(LdaConstant), U8(0), // | 3912 B(LdaConstant), U8(0), // |
| 3913 B(Star), R(0), // | 3913 B(Star), R(0), // |
| 3914 B(CreateObjectLiteral), U8(1), U8(0), U8(deep_elements_flags), // | 3914 B(CreateObjectLiteral), U8(1), U8(0), U8(deep_elements_flags), // |
| 3915 B(Star), R(1), // | 3915 B(Star), R(1), // |
| 3916 B(Ldar), R(0), // | 3916 B(Ldar), R(0), // |
| 3917 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), // | 3917 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), // |
| 3918 B(Ldar), R(0), // | 3918 B(Ldar), R(0), // |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4050 | 4050 |
| 4051 TEST(TopLevelObjectLiterals) { | 4051 TEST(TopLevelObjectLiterals) { |
| 4052 InitializedHandleScope handle_scope; | 4052 InitializedHandleScope handle_scope; |
| 4053 BytecodeGeneratorHelper helper; | 4053 BytecodeGeneratorHelper helper; |
| 4054 | 4054 |
| 4055 int has_function_flags = ObjectLiteral::kFastElements | | 4055 int has_function_flags = ObjectLiteral::kFastElements | |
| 4056 ObjectLiteral::kHasFunction | | 4056 ObjectLiteral::kHasFunction | |
| 4057 ObjectLiteral::kDisableMementos; | 4057 ObjectLiteral::kDisableMementos; |
| 4058 ExpectedSnippet<InstanceType> snippets[] = { | 4058 ExpectedSnippet<InstanceType> snippets[] = { |
| 4059 {"var a = { func: function() { } };", | 4059 {"var a = { func: function() { } };", |
| 4060 5 * kPointerSize, | 4060 9 * kPointerSize, |
| 4061 1, | 4061 1, |
| 4062 48, | 4062 48, |
| 4063 { | 4063 { |
| 4064 B(LdaConstant), U8(0), // | 4064 B(LdaConstant), U8(0), // |
| 4065 B(Star), R(1), // | 4065 B(Star), R(1), // |
| 4066 B(LdaZero), // | 4066 B(LdaZero), // |
| 4067 B(Star), R(2), // | 4067 B(Star), R(2), // |
| 4068 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 4068 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
| 4069 B(LdaConstant), U8(1), // | 4069 B(LdaConstant), U8(1), // |
| 4070 B(Star), R(1), // | 4070 B(Star), R(1), // |
| (...skipping 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6718 std::string(function_epilogue); | 6718 std::string(function_epilogue); |
| 6719 Handle<BytecodeArray> bytecode_array = | 6719 Handle<BytecodeArray> bytecode_array = |
| 6720 helper.MakeBytecode(script.c_str(), "t", "f"); | 6720 helper.MakeBytecode(script.c_str(), "t", "f"); |
| 6721 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6721 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6722 } | 6722 } |
| 6723 } | 6723 } |
| 6724 | 6724 |
| 6725 } // namespace interpreter | 6725 } // namespace interpreter |
| 6726 } // namespace internal | 6726 } // namespace internal |
| 6727 } // namespace v8 | 6727 } // namespace v8 |
| OLD | NEW |