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

Unified Diff: third_party/WebKit/Source/platform/heap/Heap.h

Issue 2019273002: Make reallocation of large objects reliable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapPage.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/Heap.h
diff --git a/third_party/WebKit/Source/platform/heap/Heap.h b/third_party/WebKit/Source/platform/heap/Heap.h
index 509c3c8433425c715f4f4b742206b408f57c21e3..e3b7bf09c8f218d57ef52c633fa6a3bf5c0ded0e 100644
--- a/third_party/WebKit/Source/platform/heap/Heap.h
+++ b/third_party/WebKit/Source/platform/heap/Heap.h
@@ -574,18 +574,29 @@ Address ThreadHeap::reallocate(void* previous, size_t size)
HeapObjectHeader* previousHeader = HeapObjectHeader::fromPayload(previous);
BasePage* page = pageFromObject(previousHeader);
ASSERT(page);
- int arenaIndex = page->arena()->arenaIndex();
- // Recompute the effective heap index if previous allocation
- // was on the normal arenas or a large object.
- if (isNormalArenaIndex(arenaIndex) || arenaIndex == BlinkGC::LargeObjectArenaIndex)
- arenaIndex = arenaIndexForObjectSize(size);
+ // Determine arena index of new allocation.
+ int arenaIndex;
+ if (size >= largeObjectSizeThreshold) {
+ arenaIndex = BlinkGC::LargeObjectArenaIndex;
+ } else {
+ arenaIndex = page->arena()->arenaIndex();
+ if (isNormalArenaIndex(arenaIndex) || arenaIndex == BlinkGC::LargeObjectArenaIndex)
+ arenaIndex = arenaIndexForObjectSize(size);
+ }
+
+ size_t gcInfoIndex = GCInfoTrait<T>::index();
// TODO(haraken): We don't support reallocate() for finalizable objects.
ASSERT(!ThreadHeap::gcInfo(previousHeader->gcInfoIndex())->hasFinalizer());
- ASSERT(previousHeader->gcInfoIndex() == GCInfoTrait<T>::index());
- const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
+ ASSERT(previousHeader->gcInfoIndex() == gcInfoIndex);
HeapAllocHooks::freeHookIfEnabled(static_cast<Address>(previous));
- Address address = ThreadHeap::allocateOnArenaIndex(state, size, arenaIndex, GCInfoTrait<T>::index(), typeName);
+ Address address;
+ if (arenaIndex == BlinkGC::LargeObjectArenaIndex) {
+ address = page->arena()->allocateLargeObject(allocationSizeFromSize(size), gcInfoIndex);
+ } else {
+ const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
+ address = ThreadHeap::allocateOnArenaIndex(state, size, arenaIndex, gcInfoIndex, typeName);
+ }
size_t copySize = previousHeader->payloadSize();
if (copySize > size)
copySize = size;
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapPage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698