Chromium Code Reviews| Index: test/cctest/interpreter/test-bytecode-generator.cc |
| diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc |
| index f36a9e9cda75468a4ac110dd13dcf1f1086f09f3..1c3df7eb04abc6e440bae9dd51438604e2d6e926 100644 |
| --- a/test/cctest/interpreter/test-bytecode-generator.cc |
| +++ b/test/cctest/interpreter/test-bytecode-generator.cc |
| @@ -1834,7 +1834,147 @@ TEST(UnaryOperators) { |
| B(Return), // |
| }, |
| 0}, |
| - }; |
| + {"var x = 13;" |
| + "return ~x;", |
| + 1 * kPointerSize, |
| + 1, |
| + 9, |
| + { |
| + B(LdaSmi8), U8(13), // |
| + B(Star), R(0), // |
| + B(LdaSmi8), U8(-1), // |
| + B(BitwiseXor), R(0), // |
| + B(Return), // |
| + }, |
| + 0}, |
| + {"var x = 13;" |
| + "return +x;", |
| + 1 * kPointerSize, |
| + 1, |
| + 9, |
| + { |
| + B(LdaSmi8), U8(13), // |
| + B(Star), R(0), // |
| + B(LdaSmi8), U8(1), // |
| + B(Mul), R(0), // |
| + B(Return), // |
| + }, |
| + 0}, |
| + {"var x = 13;" |
| + "return -x;", |
| + 1 * kPointerSize, |
| + 1, |
| + 9, |
| + { |
| + B(LdaSmi8), U8(13), // |
| + B(Star), R(0), // |
| + B(LdaSmi8), U8(-1), // |
| + B(Mul), R(0), // |
| + B(Return), // |
| + }, |
| + 0}}; |
| + |
| + for (size_t i = 0; i < arraysize(snippets); i++) { |
| + Handle<BytecodeArray> bytecode_array = |
| + helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| + CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| + } |
| +} |
| + |
| + |
| +TEST(Delete) { |
|
rmcilroy
2015/10/26 14:31:07
Could you also make have a TEST(GlobalDelete) with
mythria
2015/10/27 10:50:48
Done.
|
| + InitializedHandleScope handle_scope; |
| + BytecodeGeneratorHelper helper; |
| + |
| + int deep_elements_flags = |
| + ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; |
| + int closure = Register::function_closure().index(); |
| + int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| + |
| + ExpectedSnippet<InstanceType> snippets[] = { |
| + {"var a = {x:13, y:14}; return delete a.x;", |
| + 1 * kPointerSize, |
| + 1, |
| + 12, |
| + { |
| + B(LdaConstant), U8(0), // |
| + B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| + B(Star), R(0), // |
| + B(LdaConstant), U8(1), // |
| + B(DeletePropertySloppy), R(0), // |
| + B(Return) |
| + }, |
| + 2, |
| + {InstanceType::FIXED_ARRAY_TYPE, |
| + InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| + {"'use strict'; var a = {x:13, y:14}; return delete a.x;", |
| + 1 * kPointerSize, |
| + 1, |
| + 12, |
| + { |
| + B(LdaConstant), U8(0), // |
| + B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| + B(Star), R(0), // |
| + B(LdaConstant), U8(1), // |
| + B(DeletePropertyStrict), R(0), // |
| + B(Return) |
| + }, |
| + 2, |
| + {InstanceType::FIXED_ARRAY_TYPE, |
| + InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| + {"var a = {1:13, 2:14}; return delete a[2];", |
| + 1 * kPointerSize, |
| + 1, |
| + 12, |
| + { |
| + B(LdaConstant), U8(0), // |
| + B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| + B(Star), R(0), // |
| + B(LdaSmi8), U8(2), // |
| + B(DeletePropertySloppy), R(0), // |
| + B(Return) |
| + }, |
| + 1, |
| + {InstanceType::FIXED_ARRAY_TYPE} |
| + }, |
| + {"var a = 10; return delete a;", |
| + 1 * kPointerSize, |
| + 1, |
| + 6, |
| + { |
| + B(LdaSmi8), U8(10), // |
| + B(Star), R(0), // |
| + B(LdaFalse), // |
| + B(Return) |
| + }, |
| + 0 |
| + }, |
| + {"'use strict';" |
| + "var a = {1:10};" |
| + "(function f1() {return a;});" |
| + "return delete a[1];", |
| + 2 * kPointerSize, |
| + 1, |
| + 29, |
| + { |
| + B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| + R(closure), U8(1), // |
| + B(PushContext), R(0), // |
| + B(LdaConstant), U8(0), // |
| + B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // |
| + B(StaContextSlot), R(0), U8(first_context_slot), // |
| + B(LdaConstant), U8(1), // |
| + B(CreateClosure), U8(0), // |
| + B(LdaContextSlot), R(0), U8(first_context_slot), // |
| + B(Star), R(1), // |
| + B(LdaSmi8), U8(1), // |
| + B(DeletePropertyStrict), R(1), // |
| + B(Return) |
| + }, |
| + 2, |
| + {InstanceType::FIXED_ARRAY_TYPE, |
| + InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| + }; |
|
rmcilroy
2015/10/26 14:31:07
nit - could you also test your unresolvable refere
mythria
2015/10/27 10:50:48
Done.
|
| for (size_t i = 0; i < arraysize(snippets); i++) { |
| Handle<BytecodeArray> bytecode_array = |