OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/interpreter/bytecode-array-builder.h" | 7 #include "src/interpreter/bytecode-array-builder.h" |
8 #include "src/interpreter/bytecode-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" |
9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
10 #include "test/unittests/test-utils.h" | 10 #include "test/unittests/test-utils.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace interpreter { | 14 namespace interpreter { |
15 | 15 |
16 class BytecodeArrayBuilderTest : public TestWithIsolateAndZone { | 16 class BytecodeArrayBuilderTest : public TestWithIsolateAndZone { |
17 public: | 17 public: |
18 BytecodeArrayBuilderTest() {} | 18 BytecodeArrayBuilderTest() {} |
19 ~BytecodeArrayBuilderTest() override {} | 19 ~BytecodeArrayBuilderTest() override {} |
20 }; | 20 }; |
21 | 21 |
22 | 22 |
23 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { | 23 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { |
24 BytecodeArrayBuilder builder(isolate(), zone(), 0, 1, 131); | 24 BytecodeArrayBuilder builder(isolate(), zone(), 0, 1, 131); |
25 | 25 |
26 CHECK_EQ(builder.locals_count(), 131); | 26 CHECK_EQ(builder.locals_count(), 131); |
27 CHECK_EQ(builder.context_count(), 1); | 27 CHECK_EQ(builder.context_count(), 1); |
28 CHECK_EQ(builder.fixed_register_count(), 132); | 28 CHECK_EQ(builder.fixed_register_count(), 132); |
29 | 29 |
30 // Emit argument creation operations. CreateRestArguments should | 30 // Emit argument creation operations. |
31 // be output before any bytecodes that change constant pool. | |
32 builder.CreateArguments(CreateArgumentsType::kMappedArguments) | 31 builder.CreateArguments(CreateArgumentsType::kMappedArguments) |
33 .CreateArguments(CreateArgumentsType::kUnmappedArguments) | 32 .CreateArguments(CreateArgumentsType::kUnmappedArguments) |
34 .CreateRestArguments(0); | 33 .CreateArguments(CreateArgumentsType::kRestParameter); |
35 | 34 |
36 // Emit constant loads. | 35 // Emit constant loads. |
37 builder.LoadLiteral(Smi::FromInt(0)) | 36 builder.LoadLiteral(Smi::FromInt(0)) |
38 .LoadLiteral(Smi::FromInt(8)) | 37 .LoadLiteral(Smi::FromInt(8)) |
39 .LoadLiteral(Smi::FromInt(10000000)) | 38 .LoadLiteral(Smi::FromInt(10000000)) |
40 .LoadUndefined() | 39 .LoadUndefined() |
41 .LoadNull() | 40 .LoadNull() |
42 .LoadTheHole() | 41 .LoadTheHole() |
43 .LoadTrue() | 42 .LoadTrue() |
44 .LoadFalse(); | 43 .LoadFalse(); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 iterator.Advance(); | 658 iterator.Advance(); |
660 } | 659 } |
661 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 660 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
662 iterator.Advance(); | 661 iterator.Advance(); |
663 CHECK(iterator.done()); | 662 CHECK(iterator.done()); |
664 } | 663 } |
665 | 664 |
666 } // namespace interpreter | 665 } // namespace interpreter |
667 } // namespace internal | 666 } // namespace internal |
668 } // namespace v8 | 667 } // namespace v8 |
OLD | NEW |