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

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

Issue 1626423003: Support computed properties for ES2015 Function.name (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Mostly working Created 4 years, 10 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
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 3808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3819 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot(); 3819 FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot();
3820 3820
3821 Handle<i::TypeFeedbackVector> vector = 3821 Handle<i::TypeFeedbackVector> vector =
3822 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 3822 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
3823 3823
3824 int simple_flags = ObjectLiteral::kFastElements | 3824 int simple_flags = ObjectLiteral::kFastElements |
3825 ObjectLiteral::kShallowProperties | 3825 ObjectLiteral::kShallowProperties |
3826 ObjectLiteral::kDisableMementos; 3826 ObjectLiteral::kDisableMementos;
3827 int deep_elements_flags = 3827 int deep_elements_flags =
3828 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; 3828 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
3829
3830 // clang-format off
3829 ExpectedSnippet<InstanceType> snippets[] = { 3831 ExpectedSnippet<InstanceType> snippets[] = {
3830 {"return { };", 3832 {"return { };",
3831 kPointerSize, 3833 kPointerSize,
3832 1, 3834 1,
3833 7, 3835 7,
3834 { 3836 {
3835 B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), // 3837 B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), //
3836 B(Star), R(0), // 3838 B(Star), R(0), //
3837 B(Return) // 3839 B(Return) //
3838 }, 3840 },
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4023 B(Star), R(0), // 4025 B(Star), R(0), //
4024 B(Mov), R(0), R(1), // 4026 B(Mov), R(0), R(1), //
4025 B(LdaNull), B(Star), R(2), // 4027 B(LdaNull), B(Star), R(2), //
4026 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), // 4028 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), //
4027 B(Ldar), R(0), // 4029 B(Ldar), R(0), //
4028 B(Return), // 4030 B(Return), //
4029 }, 4031 },
4030 1, 4032 1,
4031 {InstanceType::FIXED_ARRAY_TYPE}}, 4033 {InstanceType::FIXED_ARRAY_TYPE}},
4032 {"var a = 'test'; return { [a]: 1 }", 4034 {"var a = 'test'; return { [a]: 1 }",
4033 6 * kPointerSize, 4035 7 * kPointerSize,
4034 1, 4036 1,
4035 33, 4037 36,
4036 { 4038 {
4037 B(LdaConstant), U8(0), // 4039 B(LdaConstant), U8(0), //
4038 B(Star), R(0), // 4040 B(Star), R(0), //
4039 B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), // 4041 B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), //
4040 B(Star), R(1), // 4042 B(Star), R(1), //
4041 B(Mov), R(1), R(2), // 4043 B(Mov), R(1), R(2), //
4042 B(Ldar), R(0), // 4044 B(Ldar), R(0), //
4043 B(ToName), // 4045 B(ToName), //
4044 B(Star), R(3), // 4046 B(Star), R(3), //
4045 B(LdaSmi8), U8(1), // 4047 B(LdaSmi8), U8(1), //
4046 B(Star), R(4), // 4048 B(Star), R(4), //
4047 B(LdaZero), // 4049 B(LdaZero), //
4048 B(Star), R(5), // 4050 B(Star), R(5), //
4049 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(2), // 4051 B(LdaZero), //
4050 U8(4), // 4052 B(Star), R(6), //
4053 B(CallRuntime), U16(Runtime::kDefineDataPropertyInLiteral), R(2), //
4054 U8(5), //
4051 B(Ldar), R(1), // 4055 B(Ldar), R(1), //
4052 B(Return), // 4056 B(Return), //
4053 }, 4057 },
4054 2, 4058 2,
4055 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 4059 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
4056 InstanceType::FIXED_ARRAY_TYPE}}, 4060 InstanceType::FIXED_ARRAY_TYPE}},
4057 {"var a = 'test'; return { val: a, [a]: 1 }", 4061 {"var a = 'test'; return { val: a, [a]: 1 }",
4058 6 * kPointerSize, 4062 7 * kPointerSize,
4059 1, 4063 1,
4060 39, 4064 42,
4061 { 4065 {
4062 B(LdaConstant), U8(0), // 4066 B(LdaConstant), U8(0), //
4063 B(Star), R(0), // 4067 B(Star), R(0), //
4064 B(CreateObjectLiteral), U8(1), U8(0), U8(deep_elements_flags), // 4068 B(CreateObjectLiteral), U8(1), U8(0), U8(deep_elements_flags), //
4065 B(Star), R(1), // 4069 B(Star), R(1), //
4066 B(Ldar), R(0), // 4070 B(Ldar), R(0), //
4067 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), // 4071 B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), //
4068 B(Mov), R(1), R(2), // 4072 B(Mov), R(1), R(2), //
4069 B(Ldar), R(0), // 4073 B(Ldar), R(0), //
4070 B(ToName), // 4074 B(ToName), //
4071 B(Star), R(3), // 4075 B(Star), R(3), //
4072 B(LdaSmi8), U8(1), // 4076 B(LdaSmi8), U8(1), //
4073 B(Star), R(4), // 4077 B(Star), R(4), //
4074 B(LdaZero), // 4078 B(LdaZero), //
4075 B(Star), R(5), // 4079 B(Star), R(5), //
4076 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(2), // 4080 B(LdaZero), //
4077 U8(4), // 4081 B(Star), R(6), //
4082 B(CallRuntime), U16(Runtime::kDefineDataPropertyInLiteral), R(2), //
4083 U8(5), //
4078 B(Ldar), R(1), // 4084 B(Ldar), R(1), //
4079 B(Return), // 4085 B(Return), //
4080 }, 4086 },
4081 3, 4087 3,
4082 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 4088 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
4083 InstanceType::FIXED_ARRAY_TYPE, 4089 InstanceType::FIXED_ARRAY_TYPE,
4084 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 4090 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
4085 {"var a = 'test'; return { [a]: 1, __proto__: {} }", 4091 {"var a = 'test'; return { [a]: 1, __proto__: {} }",
4086 6 * kPointerSize, 4092 7 * kPointerSize,
4087 1, 4093 1,
4088 49, 4094 52,
4089 { 4095 {
4090 B(LdaConstant), U8(0), // 4096 B(LdaConstant), U8(0), //
4091 B(Star), R(0), // 4097 B(Star), R(0), //
4092 B(CreateObjectLiteral), U8(1), U8(1), U8(simple_flags), // 4098 B(CreateObjectLiteral), U8(1), U8(1), U8(simple_flags), //
4093 B(Star), R(1), // 4099 B(Star), R(1), //
4094 B(Mov), R(1), R(2), // 4100 B(Mov), R(1), R(2), //
4095 B(Ldar), R(0), // 4101 B(Ldar), R(0), //
4096 B(ToName), // 4102 B(ToName), //
4097 B(Star), R(3), // 4103 B(Star), R(3), //
4098 B(LdaSmi8), U8(1), // 4104 B(LdaSmi8), U8(1), //
4099 B(Star), R(4), // 4105 B(Star), R(4), //
4100 B(LdaZero), // 4106 B(LdaZero), //
4101 B(Star), R(5), // 4107 B(Star), R(5), //
4102 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(2), // 4108 B(LdaZero), //
4103 U8(4), // 4109 B(Star), R(6), //
4110 B(CallRuntime), U16(Runtime::kDefineDataPropertyInLiteral), R(2), //
4111 U8(5), //
4104 B(Mov), R(1), R(2), // 4112 B(Mov), R(1), R(2), //
4105 B(CreateObjectLiteral), U8(1), U8(0), U8(13), // 4113 B(CreateObjectLiteral), U8(1), U8(0), U8(13), //
4106 B(Star), R(4), // 4114 B(Star), R(4), //
4107 B(Star), R(3), // 4115 B(Star), R(3), //
4108 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(2), U8(2), // 4116 B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(2), U8(2), //
4109 B(Ldar), R(1), // 4117 B(Ldar), R(1), //
4110 B(Return), // 4118 B(Return), //
4111 }, 4119 },
4112 2, 4120 2,
4113 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 4121 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
4114 InstanceType::FIXED_ARRAY_TYPE}}, 4122 InstanceType::FIXED_ARRAY_TYPE}},
4115 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };", 4123 {"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };",
4116 6 * kPointerSize, 4124 7 * kPointerSize,
4117 1, 4125 1,
4118 73, 4126 76,
4119 { 4127 {
4120 B(LdaConstant), U8(0), // 4128 B(LdaConstant), U8(0), //
4121 B(Star), R(0), // 4129 B(Star), R(0), //
4122 B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), // 4130 B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), //
4123 B(Star), R(1), // 4131 B(Star), R(1), //
4124 B(Mov), R(1), R(2), // 4132 B(Mov), R(1), R(2), //
4125 B(Ldar), R(0), // 4133 B(Ldar), R(0), //
4126 B(ToName), // 4134 B(ToName), //
4127 B(Star), R(3), // 4135 B(Star), R(3), //
4128 B(LdaConstant), U8(2), // 4136 B(LdaConstant), U8(2), //
4129 B(Star), R(4), // 4137 B(Star), R(4), //
4130 B(LdaZero), // 4138 B(LdaZero), //
4131 B(Star), R(5), // 4139 B(Star), R(5), //
4132 B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(2), // 4140 B(LdaZero), //
4133 U8(4), // 4141 B(Star), R(6), //
4142 B(CallRuntime), U16(Runtime::kDefineDataPropertyInLiteral), R(2), //
4143 U8(5), //
4134 B(Mov), R(1), R(2), // 4144 B(Mov), R(1), R(2), //
4135 B(LdaConstant), U8(3), // 4145 B(LdaConstant), U8(3), //
4136 B(Star), R(3), // 4146 B(Star), R(3), //
4137 B(CreateClosure), U8(4), U8(0), // 4147 B(CreateClosure), U8(4), U8(0), //
4138 B(Star), R(4), // 4148 B(Star), R(4), //
4139 B(LdaZero), // 4149 B(LdaZero), //
4140 B(Star), R(5), // 4150 B(Star), R(5), //
4141 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), // 4151 B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), //
4142 R(2), U8(4), // 4152 R(2), U8(4), //
4143 B(Mov), R(1), R(2), // 4153 B(Mov), R(1), R(2), //
4144 B(LdaConstant), U8(3), // 4154 B(LdaConstant), U8(3), //
4145 B(Star), R(3), // 4155 B(Star), R(3), //
4146 B(CreateClosure), U8(5), U8(0), // 4156 B(CreateClosure), U8(5), U8(0), //
4147 B(Star), R(4), // 4157 B(Star), R(4), //
4148 B(LdaZero), // 4158 B(LdaZero), //
4149 B(Star), R(5), // 4159 B(Star), R(5), //
4150 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), // 4160 B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), //
4151 R(2), U8(4), // 4161 R(2), U8(4), //
4152 B(Ldar), R(1), // 4162 B(Ldar), R(1), //
4153 B(Return), // 4163 B(Return), //
4154 }, 4164 },
4155 6, 4165 6,
4156 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 4166 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
4157 InstanceType::FIXED_ARRAY_TYPE, 4167 InstanceType::FIXED_ARRAY_TYPE,
4158 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 4168 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
4159 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 4169 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
4160 InstanceType::SHARED_FUNCTION_INFO_TYPE, 4170 InstanceType::SHARED_FUNCTION_INFO_TYPE,
4161 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 4171 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
4162 }; 4172 };
4173 // clang-format on
4163 4174
4164 for (size_t i = 0; i < arraysize(snippets); i++) { 4175 for (size_t i = 0; i < arraysize(snippets); i++) {
4165 Handle<BytecodeArray> bytecode_array = 4176 Handle<BytecodeArray> bytecode_array =
4166 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 4177 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
4167 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 4178 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
4168 } 4179 }
4169 } 4180 }
4170 4181
4171 4182
4172 TEST(ObjectLiteralsWide) { 4183 TEST(ObjectLiteralsWide) {
(...skipping 3386 matching lines...) Expand 10 before | Expand all | Expand 10 after
7559 Handle<BytecodeArray> bytecode_array = 7570 Handle<BytecodeArray> bytecode_array =
7560 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 7571 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
7561 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 7572 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
7562 } 7573 }
7563 FLAG_harmony_do_expressions = old_flag; 7574 FLAG_harmony_do_expressions = old_flag;
7564 } 7575 }
7565 7576
7566 } // namespace interpreter 7577 } // namespace interpreter
7567 } // namespace internal 7578 } // namespace internal
7568 } // namespace v8 7579 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698