OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 | 2 |
3 // Test constant pool array code. | 3 // Test constant pool array code. |
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/objects.h" | 8 #include "src/objects.h" |
9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
10 | 10 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 Factory* factory = isolate->factory(); | 274 Factory* factory = isolate->factory(); |
275 v8::HandleScope scope(context->GetIsolate()); | 275 v8::HandleScope scope(context->GetIsolate()); |
276 | 276 |
277 ConstantPoolArray::NumberOfEntries small(0, 0, 1, 0); | 277 ConstantPoolArray::NumberOfEntries small(0, 0, 1, 0); |
278 ConstantPoolArray::NumberOfEntries extended(0, 0, 1, 0); | 278 ConstantPoolArray::NumberOfEntries extended(0, 0, 1, 0); |
279 Handle<ConstantPoolArray> array = | 279 Handle<ConstantPoolArray> array = |
280 factory->NewExtendedConstantPoolArray(small, extended); | 280 factory->NewExtendedConstantPoolArray(small, extended); |
281 | 281 |
282 // Start a second old-space page so that the heap pointer added to the | 282 // Start a second old-space page so that the heap pointer added to the |
283 // constant pool array ends up on the an evacuation candidate page. | 283 // constant pool array ends up on the an evacuation candidate page. |
284 Page* first_page = heap->old_data_space()->anchor()->next_page(); | 284 Page* first_page = heap->old_space()->anchor()->next_page(); |
285 { | 285 { |
286 HandleScope scope(isolate); | 286 HandleScope scope(isolate); |
287 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; | 287 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; |
288 Handle<HeapObject> temp = | 288 Handle<HeapObject> temp = |
289 factory->NewFixedDoubleArray(dummy_array_size / kDoubleSize, TENURED); | 289 factory->NewFixedDoubleArray(dummy_array_size / kDoubleSize, TENURED); |
290 CHECK(heap->InOldDataSpace(temp->address())); | 290 CHECK(heap->InOldSpace(temp->address())); |
291 Handle<HeapObject> heap_ptr = | 291 Handle<HeapObject> heap_ptr = |
292 factory->NewHeapNumber(5.0, IMMUTABLE, TENURED); | 292 factory->NewHeapNumber(5.0, IMMUTABLE, TENURED); |
293 CHECK(heap->InOldDataSpace(heap_ptr->address())); | 293 CHECK(heap->InOldSpace(heap_ptr->address())); |
294 CHECK(!first_page->Contains(heap_ptr->address())); | 294 CHECK(!first_page->Contains(heap_ptr->address())); |
295 array->set(0, *heap_ptr); | 295 array->set(0, *heap_ptr); |
296 array->set(1, *heap_ptr); | 296 array->set(1, *heap_ptr); |
297 } | 297 } |
298 | 298 |
299 // Check heap pointers are correctly updated on GC. | 299 // Check heap pointers are correctly updated on GC. |
300 Object* old_ptr = array->get_heap_ptr_entry(0); | 300 Object* old_ptr = array->get_heap_ptr_entry(0); |
301 Handle<Object> object(old_ptr, isolate); | 301 Handle<Object> object(old_ptr, isolate); |
302 CHECK_EQ(old_ptr, *object); | 302 CHECK_EQ(old_ptr, *object); |
303 CHECK_EQ(old_ptr, array->get_heap_ptr_entry(1)); | 303 CHECK_EQ(old_ptr, array->get_heap_ptr_entry(1)); |
304 | 304 |
305 // Force compacting garbage collection. | 305 // Force compacting garbage collection. |
306 CHECK(FLAG_always_compact); | 306 CHECK(FLAG_always_compact); |
307 heap->CollectAllGarbage(Heap::kNoGCFlags); | 307 heap->CollectAllGarbage(Heap::kNoGCFlags); |
308 | 308 |
309 CHECK_NE(old_ptr, *object); | 309 CHECK_NE(old_ptr, *object); |
310 CHECK_EQ(*object, array->get_heap_ptr_entry(0)); | 310 CHECK_EQ(*object, array->get_heap_ptr_entry(0)); |
311 CHECK_EQ(*object, array->get_heap_ptr_entry(1)); | 311 CHECK_EQ(*object, array->get_heap_ptr_entry(1)); |
312 } | 312 } |
OLD | NEW |