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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 | 152 |
153 TEST_F(ConstantArrayBuilderTest, ToFixedArray) { | 153 TEST_F(ConstantArrayBuilderTest, ToFixedArray) { |
154 ConstantArrayBuilder builder(isolate(), zone()); | 154 ConstantArrayBuilder builder(isolate(), zone()); |
155 static const size_t kNumberOfElements = 37; | 155 static const size_t kNumberOfElements = 37; |
156 for (size_t i = 0; i < kNumberOfElements; i++) { | 156 for (size_t i = 0; i < kNumberOfElements; i++) { |
157 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); | 157 Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
158 builder.Insert(object); | 158 builder.Insert(object); |
159 CHECK(builder.At(i)->SameValue(*object)); | 159 CHECK(builder.At(i)->SameValue(*object)); |
160 } | 160 } |
161 Handle<FixedArray> constant_array = | 161 Handle<FixedArray> constant_array = builder.ToFixedArray(); |
162 builder.ToFixedArray(isolate()->factory()); | |
163 CHECK_EQ(constant_array->length(), kNumberOfElements); | 162 CHECK_EQ(constant_array->length(), kNumberOfElements); |
164 for (size_t i = 0; i < kNumberOfElements; i++) { | 163 for (size_t i = 0; i < kNumberOfElements; i++) { |
165 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); | 164 CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i))); |
166 } | 165 } |
167 } | 166 } |
168 | 167 |
169 | 168 |
170 TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { | 169 TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { |
171 ConstantArrayBuilder builder(isolate(), zone()); | 170 ConstantArrayBuilder builder(isolate(), zone()); |
172 for (size_t i = 0; i < kLowCapacity; i++) { | 171 for (size_t i = 0; i < kLowCapacity; i++) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 Handle<Object> original = builder.At(kLowCapacity + i); | 215 Handle<Object> original = builder.At(kLowCapacity + i); |
217 CHECK(original->SameValue(*reference)); | 216 CHECK(original->SameValue(*reference)); |
218 Handle<Object> duplicate = builder.At(i); | 217 Handle<Object> duplicate = builder.At(i); |
219 CHECK(duplicate->SameValue(*isolate()->factory()->the_hole_value())); | 218 CHECK(duplicate->SameValue(*isolate()->factory()->the_hole_value())); |
220 } | 219 } |
221 } | 220 } |
222 | 221 |
223 } // namespace interpreter | 222 } // namespace interpreter |
224 } // namespace internal | 223 } // namespace internal |
225 } // namespace v8 | 224 } // namespace v8 |
OLD | NEW |