Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapPage.cpp

Issue 1402103004: Oilpan: Factor out GC-related enum definitions to BlinkGC.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 { 307 {
308 ASSERT(threadState()->isInGC()); 308 ASSERT(threadState()->isInGC());
309 ASSERT(!m_firstUnsweptPage); 309 ASSERT(!m_firstUnsweptPage);
310 310
311 // Move all pages to a list of unswept pages. 311 // Move all pages to a list of unswept pages.
312 m_firstUnsweptPage = m_firstPage; 312 m_firstUnsweptPage = m_firstPage;
313 m_firstPage = nullptr; 313 m_firstPage = nullptr;
314 } 314 }
315 315
316 #if defined(ADDRESS_SANITIZER) 316 #if defined(ADDRESS_SANITIZER)
317 void BaseHeap::poisonHeap(ThreadState::ObjectsToPoison objectsToPoison, ThreadSt ate::Poisoning poisoning) 317 void BaseHeap::poisonHeap(BlinkGC::ObjectsToPoison objectsToPoison, BlinkGC::Poi soning poisoning)
318 { 318 {
319 // TODO(sof): support complete poisoning of all heaps. 319 // TODO(sof): support complete poisoning of all heaps.
320 ASSERT(objectsToPoison != ThreadState::MarkedAndUnmarked || heapIndex() == T hreadState::EagerSweepHeapIndex); 320 ASSERT(objectsToPoison != BlinkGC::MarkedAndUnmarked || heapIndex() == Blink GC::EagerSweepHeapIndex);
321 321
322 // This method may either be called to poison (SetPoison) heap 322 // This method may either be called to poison (SetPoison) heap
323 // object payloads prior to sweeping, or it may be called at 323 // object payloads prior to sweeping, or it may be called at
324 // the completion of a sweep to unpoison (ClearPoison) the 324 // the completion of a sweep to unpoison (ClearPoison) the
325 // objects remaining in the heap. Those will all be live and unmarked. 325 // objects remaining in the heap. Those will all be live and unmarked.
326 // 326 //
327 // Poisoning may be limited to unmarked objects only, or apply to all. 327 // Poisoning may be limited to unmarked objects only, or apply to all.
328 if (poisoning == ThreadState::SetPoison) { 328 if (poisoning == BlinkGC::SetPoison) {
329 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) 329 for (BasePage* page = m_firstUnsweptPage; page; page = page->next())
330 page->poisonObjects(objectsToPoison, poisoning); 330 page->poisonObjects(objectsToPoison, poisoning);
331 return; 331 return;
332 } 332 }
333 // Support clearing of poisoning after sweeping has completed, 333 // Support clearing of poisoning after sweeping has completed,
334 // in which case the pages of the live objects are reachable 334 // in which case the pages of the live objects are reachable
335 // via m_firstPage. 335 // via m_firstPage.
336 ASSERT(!m_firstUnsweptPage); 336 ASSERT(!m_firstUnsweptPage);
337 for (BasePage* page = m_firstPage; page; page = page->next()) 337 for (BasePage* page = m_firstPage; page; page = page->next())
338 page->poisonObjects(objectsToPoison, poisoning); 338 page->poisonObjects(objectsToPoison, poisoning);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 ASSERT(allocationSize > remainingAllocationSize()); 797 ASSERT(allocationSize > remainingAllocationSize());
798 ASSERT(allocationSize >= allocationGranularity); 798 ASSERT(allocationSize >= allocationGranularity);
799 799
800 #if ENABLE(GC_PROFILING) 800 #if ENABLE(GC_PROFILING)
801 threadState()->snapshotFreeListIfNecessary(); 801 threadState()->snapshotFreeListIfNecessary();
802 #endif 802 #endif
803 803
804 // 1. If this allocation is big enough, allocate a large object. 804 // 1. If this allocation is big enough, allocate a large object.
805 if (allocationSize >= largeObjectSizeThreshold) { 805 if (allocationSize >= largeObjectSizeThreshold) {
806 // TODO(sof): support eagerly finalized large objects, if ever needed. 806 // TODO(sof): support eagerly finalized large objects, if ever needed.
807 RELEASE_ASSERT(heapIndex() != ThreadState::EagerSweepHeapIndex); 807 RELEASE_ASSERT(heapIndex() != BlinkGC::EagerSweepHeapIndex);
808 LargeObjectHeap* largeObjectHeap = static_cast<LargeObjectHeap*>(threadS tate()->heap(ThreadState::LargeObjectHeapIndex)); 808 LargeObjectHeap* largeObjectHeap = static_cast<LargeObjectHeap*>(threadS tate()->heap(BlinkGC::LargeObjectHeapIndex));
809 Address largeObject = largeObjectHeap->allocateLargeObjectPage(allocatio nSize, gcInfoIndex); 809 Address largeObject = largeObjectHeap->allocateLargeObjectPage(allocatio nSize, gcInfoIndex);
810 ASAN_MARK_LARGE_VECTOR_CONTAINER(this, largeObject); 810 ASAN_MARK_LARGE_VECTOR_CONTAINER(this, largeObject);
811 return largeObject; 811 return largeObject;
812 } 812 }
813 813
814 // 2. Try to allocate from a free list. 814 // 2. Try to allocate from a free list.
815 updateRemainingAllocationSize(); 815 updateRemainingAllocationSize();
816 Address result = allocateFromFreeList(allocationSize, gcInfoIndex); 816 Address result = allocateFromFreeList(allocationSize, gcInfoIndex);
817 if (result) 817 if (result)
818 return result; 818 return result;
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 header->unmark(); 1330 header->unmark();
1331 headerAddress += size; 1331 headerAddress += size;
1332 startOfGap = headerAddress; 1332 startOfGap = headerAddress;
1333 ASSERT(headerAddress <= payloadEnd()); 1333 ASSERT(headerAddress <= payloadEnd());
1334 } 1334 }
1335 if (startOfGap != payloadEnd()) 1335 if (startOfGap != payloadEnd())
1336 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap ); 1336 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap );
1337 } 1337 }
1338 1338
1339 #if defined(ADDRESS_SANITIZER) 1339 #if defined(ADDRESS_SANITIZER)
1340 void NormalPage::poisonObjects(ThreadState::ObjectsToPoison objectsToPoison, Thr eadState::Poisoning poisoning) 1340 void NormalPage::poisonObjects(BlinkGC::ObjectsToPoison objectsToPoison, BlinkGC ::Poisoning poisoning)
1341 { 1341 {
1342 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { 1342 for (Address headerAddress = payload(); headerAddress < payloadEnd();) {
1343 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress); 1343 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress);
1344 ASSERT(header->size() < blinkPagePayloadSize()); 1344 ASSERT(header->size() < blinkPagePayloadSize());
1345 // Check if a free list entry first since we cannot call 1345 // Check if a free list entry first since we cannot call
1346 // isMarked on a free list entry. 1346 // isMarked on a free list entry.
1347 if (header->isFree()) { 1347 if (header->isFree()) {
1348 headerAddress += header->size(); 1348 headerAddress += header->size();
1349 continue; 1349 continue;
1350 } 1350 }
1351 ASSERT(header->checkHeader()); 1351 ASSERT(header->checkHeader());
1352 if (objectsToPoison == ThreadState::MarkedAndUnmarked || !header->isMark ed()) { 1352 if (objectsToPoison == BlinkGC::MarkedAndUnmarked || !header->isMarked() ) {
1353 if (poisoning == ThreadState::SetPoison) 1353 if (poisoning == BlinkGC::SetPoison)
1354 ASAN_POISON_MEMORY_REGION(header->payload(), header->payloadSize ()); 1354 ASAN_POISON_MEMORY_REGION(header->payload(), header->payloadSize ());
1355 else 1355 else
1356 ASAN_UNPOISON_MEMORY_REGION(header->payload(), header->payloadSi ze()); 1356 ASAN_UNPOISON_MEMORY_REGION(header->payload(), header->payloadSi ze());
1357 } 1357 }
1358 headerAddress += header->size(); 1358 headerAddress += header->size();
1359 } 1359 }
1360 } 1360 }
1361 #endif 1361 #endif
1362 1362
1363 void NormalPage::populateObjectStartBitMap() 1363 void NormalPage::populateObjectStartBitMap()
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 } 1670 }
1671 1671
1672 void LargeObjectPage::makeConsistentForMutator() 1672 void LargeObjectPage::makeConsistentForMutator()
1673 { 1673 {
1674 HeapObjectHeader* header = heapObjectHeader(); 1674 HeapObjectHeader* header = heapObjectHeader();
1675 if (header->isMarked()) 1675 if (header->isMarked())
1676 header->unmark(); 1676 header->unmark();
1677 } 1677 }
1678 1678
1679 #if defined(ADDRESS_SANITIZER) 1679 #if defined(ADDRESS_SANITIZER)
1680 void LargeObjectPage::poisonObjects(ThreadState::ObjectsToPoison objectsToPoison , ThreadState::Poisoning poisoning) 1680 void LargeObjectPage::poisonObjects(BlinkGC::ObjectsToPoison objectsToPoison, Bl inkGC::Poisoning poisoning)
1681 { 1681 {
1682 HeapObjectHeader* header = heapObjectHeader(); 1682 HeapObjectHeader* header = heapObjectHeader();
1683 if (objectsToPoison == ThreadState::MarkedAndUnmarked || !header->isMarked() ) { 1683 if (objectsToPoison == BlinkGC::MarkedAndUnmarked || !header->isMarked()) {
1684 if (poisoning == ThreadState::SetPoison) 1684 if (poisoning == BlinkGC::SetPoison)
1685 ASAN_POISON_MEMORY_REGION(header->payload(), header->payloadSize()); 1685 ASAN_POISON_MEMORY_REGION(header->payload(), header->payloadSize());
1686 else 1686 else
1687 ASAN_UNPOISON_MEMORY_REGION(header->payload(), header->payloadSize() ); 1687 ASAN_UNPOISON_MEMORY_REGION(header->payload(), header->payloadSize() );
1688 } 1688 }
1689 } 1689 }
1690 #endif 1690 #endif
1691 1691
1692 void LargeObjectPage::checkAndMarkPointer(Visitor* visitor, Address address) 1692 void LargeObjectPage::checkAndMarkPointer(Visitor* visitor, Address address)
1693 { 1693 {
1694 ASSERT(contains(address)); 1694 ASSERT(contains(address));
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1840
1841 m_hasEntries = true; 1841 m_hasEntries = true;
1842 size_t index = hash(address); 1842 size_t index = hash(address);
1843 ASSERT(!(index & 1)); 1843 ASSERT(!(index & 1));
1844 Address cachePage = roundToBlinkPageStart(address); 1844 Address cachePage = roundToBlinkPageStart(address);
1845 m_entries[index + 1] = m_entries[index]; 1845 m_entries[index + 1] = m_entries[index];
1846 m_entries[index] = cachePage; 1846 m_entries[index] = cachePage;
1847 } 1847 }
1848 1848
1849 } // namespace blink 1849 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.h ('k') | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698