Chromium Code Reviews| 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-label.h" | 9 #include "src/interpreter/bytecode-label.h" |
| 10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
| 11 #include "test/unittests/test-utils.h" | 11 #include "test/unittests/test-utils.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 namespace interpreter { | 15 namespace interpreter { |
| 16 | 16 |
| 17 class BytecodeArrayBuilderTest : public TestWithIsolateAndZone { | 17 class BytecodeArrayBuilderTest : public TestWithIsolateAndZone { |
| 18 public: | 18 public: |
| 19 BytecodeArrayBuilderTest() {} | 19 BytecodeArrayBuilderTest() {} |
| 20 ~BytecodeArrayBuilderTest() override {} | 20 ~BytecodeArrayBuilderTest() override {} |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 | 23 |
| 24 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { | 24 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { |
| 25 BytecodeArrayBuilder builder(isolate(), zone(), 0, 1, 131); | 25 BytecodeArrayBuilder builder(isolate(), zone(), 0, 1, 131); |
|
Michael Starzinger
2016/08/05 09:19:06
nit: IIUC then we are just lucky here because no c
rmcilroy
2016/08/05 09:45:08
Added to all tests in this file.
| |
| 26 Factory* factory = isolate()->factory(); | 26 Factory* factory = isolate()->factory(); |
| 27 | 27 |
| 28 CHECK_EQ(builder.locals_count(), 131); | 28 CHECK_EQ(builder.locals_count(), 131); |
| 29 CHECK_EQ(builder.context_count(), 1); | 29 CHECK_EQ(builder.context_count(), 1); |
| 30 CHECK_EQ(builder.fixed_register_count(), 132); | 30 CHECK_EQ(builder.fixed_register_count(), 132); |
| 31 | 31 |
| 32 Register reg(0); | 32 Register reg(0); |
| 33 Register other(reg.index() + 1); | 33 Register other(reg.index() + 1); |
| 34 Register wide(128); | 34 Register wide(128); |
| 35 | 35 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 CHECK_EQ(builder.RegisterIsParameterOrLocal(param0), true); | 508 CHECK_EQ(builder.RegisterIsParameterOrLocal(param0), true); |
| 509 CHECK_EQ(builder.RegisterIsParameterOrLocal(param9), true); | 509 CHECK_EQ(builder.RegisterIsParameterOrLocal(param9), true); |
| 510 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg0), true); | 510 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg0), true); |
| 511 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg1), true); | 511 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg1), true); |
| 512 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg2), true); | 512 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg2), true); |
| 513 } | 513 } |
| 514 | 514 |
| 515 | 515 |
| 516 TEST_F(BytecodeArrayBuilderTest, Constants) { | 516 TEST_F(BytecodeArrayBuilderTest, Constants) { |
| 517 BytecodeArrayBuilder builder(isolate(), zone(), 0, 0, 0); | 517 BytecodeArrayBuilder builder(isolate(), zone(), 0, 0, 0); |
| 518 CanonicalHandleScope canonical(isolate()); | |
| 518 | 519 |
| 519 Factory* factory = isolate()->factory(); | 520 Factory* factory = isolate()->factory(); |
| 520 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(3.14); | 521 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(3.14); |
| 521 Handle<HeapObject> heap_num_2 = factory->NewHeapNumber(5.2); | 522 Handle<HeapObject> heap_num_2 = factory->NewHeapNumber(5.2); |
| 522 Handle<Object> large_smi(Smi::FromInt(0x12345678), isolate()); | 523 Handle<Object> large_smi(Smi::FromInt(0x12345678), isolate()); |
| 523 Handle<HeapObject> heap_num_2_copy(*heap_num_2); | 524 Handle<HeapObject> heap_num_2_copy(*heap_num_2); |
| 524 builder.LoadLiteral(heap_num_1) | 525 builder.LoadLiteral(heap_num_1) |
| 525 .LoadLiteral(heap_num_2) | 526 .LoadLiteral(heap_num_2) |
| 526 .LoadLiteral(large_smi) | 527 .LoadLiteral(large_smi) |
| 527 .LoadLiteral(heap_num_1) | 528 .LoadLiteral(heap_num_1) |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 iterator.Advance(); | 840 iterator.Advance(); |
| 840 } | 841 } |
| 841 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 842 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
| 842 iterator.Advance(); | 843 iterator.Advance(); |
| 843 CHECK(iterator.done()); | 844 CHECK(iterator.done()); |
| 844 } | 845 } |
| 845 | 846 |
| 846 } // namespace interpreter | 847 } // namespace interpreter |
| 847 } // namespace internal | 848 } // namespace internal |
| 848 } // namespace v8 | 849 } // namespace v8 |
| OLD | NEW |