| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 235 | 235 | 
| 236   int expected_int64_indexs[] = { 0, 5, 6, 7, 8, 9 }; | 236   int expected_int64_indexs[] = { 0, 5, 6, 7, 8, 9 }; | 
| 237   CheckIterator(array, ConstantPoolArray::INT64, expected_int64_indexs, 6); | 237   CheckIterator(array, ConstantPoolArray::INT64, expected_int64_indexs, 6); | 
| 238   int expected_code_indexs[1]; | 238   int expected_code_indexs[1]; | 
| 239   CheckIterator(array, ConstantPoolArray::CODE_PTR, expected_code_indexs, 0); | 239   CheckIterator(array, ConstantPoolArray::CODE_PTR, expected_code_indexs, 0); | 
| 240   int expected_heap_indexs[] = { 10, 11, 12 }; | 240   int expected_heap_indexs[] = { 10, 11, 12 }; | 
| 241   CheckIterator(array, ConstantPoolArray::HEAP_PTR, expected_heap_indexs, 3); | 241   CheckIterator(array, ConstantPoolArray::HEAP_PTR, expected_heap_indexs, 3); | 
| 242   int expected_int32_indexs[] = { 1, 2, 3, 4 }; | 242   int expected_int32_indexs[] = { 1, 2, 3, 4 }; | 
| 243   CheckIterator(array, ConstantPoolArray::INT32, expected_int32_indexs, 4); | 243   CheckIterator(array, ConstantPoolArray::INT32, expected_int32_indexs, 4); | 
| 244 } | 244 } | 
| 245 |  | 
| 246 |  | 
| 247 TEST(ConstantPoolPreciseGC) { |  | 
| 248   LocalContext context; |  | 
| 249   Isolate* isolate = CcTest::i_isolate(); |  | 
| 250   Heap* heap = isolate->heap(); |  | 
| 251   Factory* factory = isolate->factory(); |  | 
| 252   v8::HandleScope scope(context->GetIsolate()); |  | 
| 253 |  | 
| 254   ConstantPoolArray::NumberOfEntries small(1, 0, 0, 1); |  | 
| 255   Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(small); |  | 
| 256 |  | 
| 257   // Check that the store buffer knows which entries are pointers and which are |  | 
| 258   // not.  To do this, make non-pointer entries which look like new space |  | 
| 259   // pointers but are actually invalid and ensure the GC doesn't try to move |  | 
| 260   // them. |  | 
| 261   Handle<HeapObject> object = factory->NewHeapNumber(4.0); |  | 
| 262   Object* raw_ptr = *object; |  | 
| 263   // If interpreted as a pointer, this should be right inside the heap number |  | 
| 264   // which will cause a crash when trying to lookup the 'map' pointer. |  | 
| 265   intptr_t invalid_ptr = reinterpret_cast<intptr_t>(raw_ptr) + kInt32Size; |  | 
| 266   int32_t invalid_ptr_int32 = static_cast<int32_t>(invalid_ptr); |  | 
| 267   int64_t invalid_ptr_int64 = static_cast<int64_t>(invalid_ptr); |  | 
| 268   array->set(0, invalid_ptr_int64); |  | 
| 269   array->set(1, invalid_ptr_int32); |  | 
| 270 |  | 
| 271   // Ensure we perform a scan on scavenge for the constant pool's page. |  | 
| 272   MemoryChunk::FromAddress(array->address())->set_scan_on_scavenge(true); |  | 
| 273   heap->CollectGarbage(NEW_SPACE); |  | 
| 274 |  | 
| 275   // Check the object was moved by GC. |  | 
| 276   CHECK_NE(*object, raw_ptr); |  | 
| 277 |  | 
| 278   // Check the non-pointer entries weren't changed. |  | 
| 279   CHECK_EQ(invalid_ptr_int64, array->get_int64_entry(0)); |  | 
| 280   CHECK_EQ(invalid_ptr_int32, array->get_int32_entry(1)); |  | 
| 281 } |  | 
| OLD | NEW | 
|---|