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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 Handle<Object> expected; | 276 Handle<Object> expected; |
277 if (i == 0 || i == 256 || i == 65536) { | 277 if (i == 0 || i == 256 || i == 65536) { |
278 expected = isolate()->factory()->NewNumber(count++); | 278 expected = isolate()->factory()->NewNumber(count++); |
279 } else { | 279 } else { |
280 expected = isolate()->factory()->the_hole_value(); | 280 expected = isolate()->factory()->the_hole_value(); |
281 } | 281 } |
282 CHECK(constant_array->get(i)->SameValue(*expected)); | 282 CHECK(constant_array->get(i)->SameValue(*expected)); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
| 286 TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithFixedReservations) { |
| 287 ConstantArrayBuilder builder(isolate(), zone()); |
| 288 for (size_t i = 0; i < k16BitCapacity; i++) { |
| 289 if ((i % 2) == 0) { |
| 290 CHECK_EQ(i, builder.AllocateEntry()); |
| 291 } else { |
| 292 builder.Insert(handle(Smi::FromInt(static_cast<int>(i)), isolate())); |
| 293 } |
| 294 } |
| 295 CHECK_EQ(builder.size(), k16BitCapacity); |
| 296 |
| 297 // Check values before reserved entries are inserted. |
| 298 for (size_t i = 0; i < k16BitCapacity; i++) { |
| 299 if ((i % 2) == 0) { |
| 300 // Check reserved values are the hole. |
| 301 Handle<Object> empty = builder.At(i); |
| 302 CHECK(empty->SameValue(isolate()->heap()->the_hole_value())); |
| 303 } else { |
| 304 CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), i); |
| 305 } |
| 306 } |
| 307 |
| 308 // Insert reserved entries. |
| 309 for (size_t i = 0; i < k16BitCapacity; i += 2) { |
| 310 builder.InsertAllocatedEntry( |
| 311 i, handle(Smi::FromInt(static_cast<int>(i)), isolate())); |
| 312 } |
| 313 |
| 314 // Check values after reserved entries are inserted. |
| 315 for (size_t i = 0; i < k16BitCapacity; i++) { |
| 316 CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), i); |
| 317 } |
| 318 } |
| 319 |
286 } // namespace interpreter | 320 } // namespace interpreter |
287 } // namespace internal | 321 } // namespace internal |
288 } // namespace v8 | 322 } // namespace v8 |
OLD | NEW |