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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 TEST_F(ConstantArrayBuilderTest, ToFixedArray) { | 43 TEST_F(ConstantArrayBuilderTest, ToFixedArray) { |
44 CanonicalHandleScope canonical(isolate()); | 44 CanonicalHandleScope canonical(isolate()); |
45 ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); | 45 ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); |
46 static const size_t kNumberOfElements = 37; | 46 static const size_t kNumberOfElements = 37; |
47 for (size_t i = 0; i < kNumberOfElements; i++) { | 47 for (size_t i = 0; i < kNumberOfElements; i++) { |
48 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); | 48 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
49 builder.Insert(object); | 49 builder.Insert(object); |
50 CHECK(builder.At(i)->SameValue(*object)); | 50 CHECK(builder.At(i)->SameValue(*object)); |
51 } | 51 } |
52 Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); | 52 Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); |
53 CHECK_EQ(constant_array->length(), kNumberOfElements); | 53 CHECK_EQ(constant_array->length(), static_cast<int>(kNumberOfElements)); |
54 for (size_t i = 0; i < kNumberOfElements; i++) { | 54 for (size_t i = 0; i < kNumberOfElements; i++) { |
55 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); | 55 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 TEST_F(ConstantArrayBuilderTest, ToLargeFixedArray) { | 59 TEST_F(ConstantArrayBuilderTest, ToLargeFixedArray) { |
60 CanonicalHandleScope canonical(isolate()); | 60 CanonicalHandleScope canonical(isolate()); |
61 ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); | 61 ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); |
62 static const size_t kNumberOfElements = 37373; | 62 static const size_t kNumberOfElements = 37373; |
63 for (size_t i = 0; i < kNumberOfElements; i++) { | 63 for (size_t i = 0; i < kNumberOfElements; i++) { |
64 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); | 64 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
65 builder.Insert(object); | 65 builder.Insert(object); |
66 CHECK(builder.At(i)->SameValue(*object)); | 66 CHECK(builder.At(i)->SameValue(*object)); |
67 } | 67 } |
68 Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); | 68 Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); |
69 CHECK_EQ(constant_array->length(), kNumberOfElements); | 69 CHECK_EQ(constant_array->length(), static_cast<int>(kNumberOfElements)); |
70 for (size_t i = 0; i < kNumberOfElements; i++) { | 70 for (size_t i = 0; i < kNumberOfElements; i++) { |
71 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); | 71 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 TEST_F(ConstantArrayBuilderTest, ToLargeFixedArrayWithReservations) { | 75 TEST_F(ConstantArrayBuilderTest, ToLargeFixedArrayWithReservations) { |
76 CanonicalHandleScope canonical(isolate()); | 76 CanonicalHandleScope canonical(isolate()); |
77 ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); | 77 ConstantArrayBuilder builder(zone(), isolate()->factory()->the_hole_value()); |
78 static const size_t kNumberOfElements = 37373; | 78 static const size_t kNumberOfElements = 37373; |
79 for (size_t i = 0; i < kNumberOfElements; i++) { | 79 for (size_t i = 0; i < kNumberOfElements; i++) { |
80 builder.CommitReservedEntry(builder.CreateReservedEntry(), | 80 builder.CommitReservedEntry(builder.CreateReservedEntry(), |
81 Smi::FromInt(static_cast<int>(i))); | 81 Smi::FromInt(static_cast<int>(i))); |
82 } | 82 } |
83 Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); | 83 Handle<FixedArray> constant_array = builder.ToFixedArray(isolate()); |
84 CHECK_EQ(constant_array->length(), kNumberOfElements); | 84 CHECK_EQ(constant_array->length(), static_cast<int>(kNumberOfElements)); |
85 for (size_t i = 0; i < kNumberOfElements; i++) { | 85 for (size_t i = 0; i < kNumberOfElements; i++) { |
86 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); | 86 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { | 90 TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { |
91 CanonicalHandleScope canonical(isolate()); | 91 CanonicalHandleScope canonical(isolate()); |
92 for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { | 92 for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { |
93 ConstantArrayBuilder builder(zone(), | 93 ConstantArrayBuilder builder(zone(), |
94 isolate()->factory()->the_hole_value()); | 94 isolate()->factory()->the_hole_value()); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 // Check values after reserved entries are inserted. | 342 // Check values after reserved entries are inserted. |
343 for (size_t i = 0; i < k16BitCapacity; i++) { | 343 for (size_t i = 0; i < k16BitCapacity; i++) { |
344 CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), static_cast<int>(i)); | 344 CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), static_cast<int>(i)); |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 } // namespace interpreter | 348 } // namespace interpreter |
349 } // namespace internal | 349 } // namespace internal |
350 } // namespace v8 | 350 } // namespace v8 |
OLD | NEW |