| 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/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 "test/unittests/test-utils.h" | 9 #include "test/unittests/test-utils.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace interpreter { | 13 namespace interpreter { |
| 14 | 14 |
| 15 class BytecodeArrayIteratorTest : public TestWithIsolateAndZone { | 15 class BytecodeArrayIteratorTest : public TestWithIsolateAndZone { |
| 16 public: | 16 public: |
| 17 BytecodeArrayIteratorTest() {} | 17 BytecodeArrayIteratorTest() {} |
| 18 ~BytecodeArrayIteratorTest() override {} | 18 ~BytecodeArrayIteratorTest() override {} |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 | 21 |
| 22 TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { | 22 TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { |
| 23 // Use a builder to create an array with containing multiple bytecodes | 23 // Use a builder to create an array with containing multiple bytecodes |
| 24 // with 0, 1 and 2 operands. | 24 // with 0, 1 and 2 operands. |
| 25 BytecodeArrayBuilder builder(isolate(), zone()); | 25 BytecodeArrayBuilder builder(isolate(), zone(), 3, 2, 0); |
| 26 builder.set_parameter_count(3); | |
| 27 builder.set_locals_count(2); | |
| 28 builder.set_context_count(0); | |
| 29 | |
| 30 Factory* factory = isolate()->factory(); | 26 Factory* factory = isolate()->factory(); |
| 31 Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); | 27 Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); |
| 32 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); | 28 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); |
| 33 Smi* zero = Smi::FromInt(0); | 29 Smi* zero = Smi::FromInt(0); |
| 34 Smi* smi_0 = Smi::FromInt(64); | 30 Smi* smi_0 = Smi::FromInt(64); |
| 35 Smi* smi_1 = Smi::FromInt(-65536); | 31 Smi* smi_1 = Smi::FromInt(-65536); |
| 36 Register reg_0(0); | 32 Register reg_0(0); |
| 37 Register reg_1(1); | 33 Register reg_1(1); |
| 38 Register reg_2 = Register::FromParameterIndex(2, builder.parameter_count()); | 34 Register reg_2 = Register::FromParameterIndex(2, builder.parameter_count()); |
| 39 Handle<String> name = factory->NewStringFromStaticChars("abc"); | 35 Handle<String> name = factory->NewStringFromStaticChars("abc"); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 100 |
| 105 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 101 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
| 106 CHECK(!iterator.done()); | 102 CHECK(!iterator.done()); |
| 107 iterator.Advance(); | 103 iterator.Advance(); |
| 108 CHECK(iterator.done()); | 104 CHECK(iterator.done()); |
| 109 } | 105 } |
| 110 | 106 |
| 111 } // namespace interpreter | 107 } // namespace interpreter |
| 112 } // namespace internal | 108 } // namespace internal |
| 113 } // namespace v8 | 109 } // namespace v8 |
| OLD | NEW |