| 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/factory.h" | 7 #include "src/factory.h" |
| 8 #include "src/handles-inl.h" | 8 #include "src/handles-inl.h" |
| 9 #include "src/interpreter/constant-array-builder.h" | 9 #include "src/interpreter/constant-array-builder.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 Handle<Object> object = | 102 Handle<Object> object = |
| 103 isolate()->factory()->NewNumberFromSize(2 * k8BitCapacity + i); | 103 isolate()->factory()->NewNumberFromSize(2 * k8BitCapacity + i); |
| 104 size_t index = builder.CommitReservedEntry(OperandSize::kByte, object); | 104 size_t index = builder.CommitReservedEntry(OperandSize::kByte, object); |
| 105 CHECK_EQ(static_cast<int>(index), k8BitCapacity - reserved + i); | 105 CHECK_EQ(static_cast<int>(index), k8BitCapacity - reserved + i); |
| 106 CHECK(builder.At(static_cast<int>(index))->SameValue(*object)); | 106 CHECK(builder.At(static_cast<int>(index))->SameValue(*object)); |
| 107 } | 107 } |
| 108 CHECK_EQ(builder.size(), 2 * k8BitCapacity + reserved); | 108 CHECK_EQ(builder.size(), 2 * k8BitCapacity + reserved); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithWideReservations) { |
| 113 TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx16Reservations) { | |
| 114 for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { | 113 for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { |
| 115 ConstantArrayBuilder builder(isolate(), zone()); | 114 ConstantArrayBuilder builder(isolate(), zone()); |
| 116 for (size_t i = 0; i < k8BitCapacity; i++) { | 115 for (size_t i = 0; i < k8BitCapacity; i++) { |
| 117 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); | 116 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
| 118 builder.Insert(object); | 117 builder.Insert(object); |
| 119 CHECK(builder.At(i)->SameValue(*object)); | 118 CHECK(builder.At(i)->SameValue(*object)); |
| 120 CHECK_EQ(builder.size(), i + 1); | 119 CHECK_EQ(builder.size(), i + 1); |
| 121 } | 120 } |
| 122 for (size_t i = 0; i < reserved; i++) { | 121 for (size_t i = 0; i < reserved; i++) { |
| 123 OperandSize operand_size = builder.CreateReservedEntry(); | 122 OperandSize operand_size = builder.CreateReservedEntry(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 Handle<Object> original = builder.At(k8BitCapacity + i); | 210 Handle<Object> original = builder.At(k8BitCapacity + i); |
| 212 CHECK(original->SameValue(*reference)); | 211 CHECK(original->SameValue(*reference)); |
| 213 Handle<Object> duplicate = builder.At(i); | 212 Handle<Object> duplicate = builder.At(i); |
| 214 CHECK(duplicate->SameValue(*isolate()->factory()->the_hole_value())); | 213 CHECK(duplicate->SameValue(*isolate()->factory()->the_hole_value())); |
| 215 } | 214 } |
| 216 } | 215 } |
| 217 | 216 |
| 218 } // namespace interpreter | 217 } // namespace interpreter |
| 219 } // namespace internal | 218 } // namespace internal |
| 220 } // namespace v8 | 219 } // namespace v8 |
| OLD | NEW |