| OLD | NEW |
| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ASSERT(!m_firstUnsweptPage); | 119 ASSERT(!m_firstUnsweptPage); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void BaseArena::cleanupPages() | 122 void BaseArena::cleanupPages() |
| 123 { | 123 { |
| 124 clearFreeLists(); | 124 clearFreeLists(); |
| 125 | 125 |
| 126 ASSERT(!m_firstUnsweptPage); | 126 ASSERT(!m_firstUnsweptPage); |
| 127 // Add the BaseArena's pages to the orphanedPagePool. | 127 // Add the BaseArena's pages to the orphanedPagePool. |
| 128 for (BasePage* page = m_firstPage; page; page = page->next()) { | 128 for (BasePage* page = m_firstPage; page; page = page->next()) { |
| 129 Heap::decreaseAllocatedSpace(page->size()); | 129 Heap::heapStats().decreaseAllocatedSpace(page->size()); |
| 130 Heap::getOrphanedPagePool()->addOrphanedPage(arenaIndex(), page); | 130 Heap::getOrphanedPagePool()->addOrphanedPage(arenaIndex(), page); |
| 131 } | 131 } |
| 132 m_firstPage = nullptr; | 132 m_firstPage = nullptr; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void BaseArena::takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshot
Info& info) | 135 void BaseArena::takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshot
Info& info) |
| 136 { | 136 { |
| 137 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName" | 137 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName" |
| 138 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance(
)->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); | 138 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance(
)->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); |
| 139 size_t pageCount = 0; | 139 size_t pageCount = 0; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 pageMemory = memory; | 422 pageMemory = memory; |
| 423 } else { | 423 } else { |
| 424 Heap::getFreePagePool()->addFreePage(arenaIndex(), memory); | 424 Heap::getFreePagePool()->addFreePage(arenaIndex(), memory); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 | 428 |
| 429 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory,
this); | 429 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory,
this); |
| 430 page->link(&m_firstPage); | 430 page->link(&m_firstPage); |
| 431 | 431 |
| 432 Heap::increaseAllocatedSpace(page->size()); | 432 Heap::heapStats().increaseAllocatedSpace(page->size()); |
| 433 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | 433 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
| 434 // Allow the following addToFreeList() to add the newly allocated memory | 434 // Allow the following addToFreeList() to add the newly allocated memory |
| 435 // to the free list. | 435 // to the free list. |
| 436 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); | 436 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); |
| 437 Address address = page->payload(); | 437 Address address = page->payload(); |
| 438 for (size_t i = 0; i < page->payloadSize(); i++) | 438 for (size_t i = 0; i < page->payloadSize(); i++) |
| 439 address[i] = reuseAllowedZapValue; | 439 address[i] = reuseAllowedZapValue; |
| 440 ASAN_POISON_MEMORY_REGION(page->payload(), page->payloadSize()); | 440 ASAN_POISON_MEMORY_REGION(page->payload(), page->payloadSize()); |
| 441 #endif | 441 #endif |
| 442 addToFreeList(page->payload(), page->payloadSize()); | 442 addToFreeList(page->payload(), page->payloadSize()); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void NormalPageArena::freePage(NormalPage* page) | 445 void NormalPageArena::freePage(NormalPage* page) |
| 446 { | 446 { |
| 447 Heap::decreaseAllocatedSpace(page->size()); | 447 Heap::heapStats().decreaseAllocatedSpace(page->size()); |
| 448 | 448 |
| 449 if (page->terminating()) { | 449 if (page->terminating()) { |
| 450 // The thread is shutting down and this page is being removed as a part | 450 // The thread is shutting down and this page is being removed as a part |
| 451 // of the thread local GC. In that case the object could be traced in | 451 // of the thread local GC. In that case the object could be traced in |
| 452 // the next global GC if there is a dangling pointer from a live thread | 452 // the next global GC if there is a dangling pointer from a live thread |
| 453 // heap to this dead thread heap. To guard against this, we put the | 453 // heap to this dead thread heap. To guard against this, we put the |
| 454 // page into the orphaned page pool and zap the page memory. This | 454 // page into the orphaned page pool and zap the page memory. This |
| 455 // ensures that tracing the dangling pointer in the next global GC just | 455 // ensures that tracing the dangling pointer in the next global GC just |
| 456 // crashes instead of causing use-after-frees. After the next global | 456 // crashes instead of causing use-after-frees. After the next global |
| 457 // GC, the orphaned pages are removed. | 457 // GC, the orphaned pages are removed. |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); | 810 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); |
| 811 LargeObjectPage* largeObject = new (largeObjectAddress) LargeObjectPage(page
Memory, this, allocationSize); | 811 LargeObjectPage* largeObject = new (largeObjectAddress) LargeObjectPage(page
Memory, this, allocationSize); |
| 812 ASSERT(header->checkHeader()); | 812 ASSERT(header->checkHeader()); |
| 813 | 813 |
| 814 // Poison the object header and allocationGranularity bytes after the object | 814 // Poison the object header and allocationGranularity bytes after the object |
| 815 ASAN_POISON_MEMORY_REGION(header, sizeof(*header)); | 815 ASAN_POISON_MEMORY_REGION(header, sizeof(*header)); |
| 816 ASAN_POISON_MEMORY_REGION(largeObject->getAddress() + largeObject->size(), a
llocationGranularity); | 816 ASAN_POISON_MEMORY_REGION(largeObject->getAddress() + largeObject->size(), a
llocationGranularity); |
| 817 | 817 |
| 818 largeObject->link(&m_firstPage); | 818 largeObject->link(&m_firstPage); |
| 819 | 819 |
| 820 Heap::increaseAllocatedSpace(largeObject->size()); | 820 Heap::heapStats().increaseAllocatedSpace(largeObject->size()); |
| 821 getThreadState()->increaseAllocatedObjectSize(largeObject->size()); | 821 getThreadState()->increaseAllocatedObjectSize(largeObject->size()); |
| 822 return result; | 822 return result; |
| 823 } | 823 } |
| 824 | 824 |
| 825 void LargeObjectArena::freeLargeObjectPage(LargeObjectPage* object) | 825 void LargeObjectArena::freeLargeObjectPage(LargeObjectPage* object) |
| 826 { | 826 { |
| 827 ASAN_UNPOISON_MEMORY_REGION(object->payload(), object->payloadSize()); | 827 ASAN_UNPOISON_MEMORY_REGION(object->payload(), object->payloadSize()); |
| 828 object->heapObjectHeader()->finalize(object->payload(), object->payloadSize(
)); | 828 object->heapObjectHeader()->finalize(object->payload(), object->payloadSize(
)); |
| 829 Heap::decreaseAllocatedSpace(object->size()); | 829 Heap::heapStats().decreaseAllocatedSpace(object->size()); |
| 830 | 830 |
| 831 // Unpoison the object header and allocationGranularity bytes after the | 831 // Unpoison the object header and allocationGranularity bytes after the |
| 832 // object before freeing. | 832 // object before freeing. |
| 833 ASAN_UNPOISON_MEMORY_REGION(object->heapObjectHeader(), sizeof(HeapObjectHea
der)); | 833 ASAN_UNPOISON_MEMORY_REGION(object->heapObjectHeader(), sizeof(HeapObjectHea
der)); |
| 834 ASAN_UNPOISON_MEMORY_REGION(object->getAddress() + object->size(), allocatio
nGranularity); | 834 ASAN_UNPOISON_MEMORY_REGION(object->getAddress() + object->size(), allocatio
nGranularity); |
| 835 | 835 |
| 836 if (object->terminating()) { | 836 if (object->terminating()) { |
| 837 ASSERT(ThreadState::current()->isTerminating()); | 837 ASSERT(ThreadState::current()->isTerminating()); |
| 838 // The thread is shutting down and this page is being removed as a part | 838 // The thread is shutting down and this page is being removed as a part |
| 839 // of the thread local GC. In that case the object could be traced in | 839 // of the thread local GC. In that case the object could be traced in |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 | 1561 |
| 1562 m_hasEntries = true; | 1562 m_hasEntries = true; |
| 1563 size_t index = hash(address); | 1563 size_t index = hash(address); |
| 1564 ASSERT(!(index & 1)); | 1564 ASSERT(!(index & 1)); |
| 1565 Address cachePage = roundToBlinkPageStart(address); | 1565 Address cachePage = roundToBlinkPageStart(address); |
| 1566 m_entries[index + 1] = m_entries[index]; | 1566 m_entries[index + 1] = m_entries[index]; |
| 1567 m_entries[index] = cachePage; | 1567 m_entries[index] = cachePage; |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 } // namespace blink | 1570 } // namespace blink |
| OLD | NEW |