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 7545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7556 }; | 7556 }; |
7557 | 7557 |
7558 for (size_t i = 0; i < arraysize(snippets); i++) { | 7558 for (size_t i = 0; i < arraysize(snippets); i++) { |
7559 Handle<BytecodeArray> bytecode_array = | 7559 Handle<BytecodeArray> bytecode_array = |
7560 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 7560 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
7561 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 7561 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
7562 } | 7562 } |
7563 FLAG_harmony_do_expressions = old_flag; | 7563 FLAG_harmony_do_expressions = old_flag; |
7564 } | 7564 } |
7565 | 7565 |
| 7566 TEST(WithStatement) { |
| 7567 InitializedHandleScope handle_scope; |
| 7568 BytecodeGeneratorHelper helper; |
| 7569 |
| 7570 int deep_elements_flags = |
| 7571 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; |
| 7572 int context = Register::current_context().index(); |
| 7573 int closure = Register::function_closure().index(); |
| 7574 int new_target = Register::new_target().index(); |
| 7575 |
| 7576 ExpectedSnippet<InstanceType> snippets[] = { |
| 7577 {"with ({x:42}) { return x; }", |
| 7578 5 * kPointerSize, |
| 7579 1, |
| 7580 46, |
| 7581 { |
| 7582 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 7583 U8(1), // |
| 7584 B(PushContext), R(0), // |
| 7585 B(Ldar), THIS(1), // |
| 7586 B(StaContextSlot), R(context), U8(4), // |
| 7587 B(CreateMappedArguments), // |
| 7588 B(StaContextSlot), R(context), U8(5), // |
| 7589 B(Ldar), R(new_target), // |
| 7590 B(StaContextSlot), R(context), U8(6), // |
| 7591 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 7592 B(Star), R(2), // |
| 7593 B(ToObject), // |
| 7594 B(Star), R(3), // |
| 7595 B(Ldar), R(closure), // |
| 7596 B(Star), R(4), // |
| 7597 B(CallRuntime), U16(Runtime::kPushWithContext), R(3), U8(2), // |
| 7598 B(PushContext), R(1), // |
| 7599 B(LdaLookupSlot), U8(1), // |
| 7600 B(PopContext), R(0), // |
| 7601 B(Return), // |
| 7602 }, |
| 7603 2, |
| 7604 {InstanceType::FIXED_ARRAY_TYPE, |
| 7605 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 7606 }; |
| 7607 |
| 7608 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 7609 Handle<BytecodeArray> bytecode_array = |
| 7610 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 7611 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 7612 } |
| 7613 } |
| 7614 |
7566 } // namespace interpreter | 7615 } // namespace interpreter |
7567 } // namespace internal | 7616 } // namespace internal |
7568 } // namespace v8 | 7617 } // namespace v8 |
OLD | NEW |