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-register-allocator.h" | 8 #include "src/interpreter/bytecode-register-allocator.h" |
9 #include "test/unittests/test-utils.h" | 9 #include "test/unittests/test-utils.h" |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 CHECK_EQ(allocator()->maximum_register_count(), 6); | 84 CHECK_EQ(allocator()->maximum_register_count(), 6); |
85 CHECK_EQ(allocator()->next_register_index(), 3); | 85 CHECK_EQ(allocator()->next_register_index(), 3); |
86 | 86 |
87 RegisterList empty_reg_list = allocator()->NewRegisterList(0); | 87 RegisterList empty_reg_list = allocator()->NewRegisterList(0); |
88 CHECK_EQ(empty_reg_list.first_register().index(), 0); | 88 CHECK_EQ(empty_reg_list.first_register().index(), 0); |
89 CHECK_EQ(empty_reg_list.register_count(), 0); | 89 CHECK_EQ(empty_reg_list.register_count(), 0); |
90 CHECK_EQ(allocator()->maximum_register_count(), 6); | 90 CHECK_EQ(allocator()->maximum_register_count(), 6); |
91 CHECK_EQ(allocator()->next_register_index(), 3); | 91 CHECK_EQ(allocator()->next_register_index(), 3); |
92 } | 92 } |
93 | 93 |
| 94 TEST_F(BytecodeRegisterAllocatorTest, GrowableRegisterListAllocations) { |
| 95 CHECK_EQ(allocator()->maximum_register_count(), 0); |
| 96 Register reg = allocator()->NewRegister(); |
| 97 CHECK_EQ(reg.index(), 0); |
| 98 RegisterList reg_list = allocator()->NewGrowableRegisterList(); |
| 99 CHECK_EQ(reg_list.register_count(), 0); |
| 100 allocator()->GrowRegisterList(®_list); |
| 101 allocator()->GrowRegisterList(®_list); |
| 102 allocator()->GrowRegisterList(®_list); |
| 103 CHECK_EQ(reg_list.register_count(), 3); |
| 104 CHECK_EQ(reg_list[0].index(), 1); |
| 105 CHECK_EQ(reg_list[1].index(), 2); |
| 106 CHECK_EQ(reg_list[2].index(), 3); |
| 107 CHECK_EQ(allocator()->maximum_register_count(), 4); |
| 108 CHECK_EQ(allocator()->next_register_index(), 4); |
| 109 } |
| 110 |
94 } // namespace interpreter | 111 } // namespace interpreter |
95 } // namespace internal | 112 } // namespace internal |
96 } // namespace v8 | 113 } // namespace v8 |
OLD | NEW |