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

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

Issue 1393863004: Oilpan: always shrink tail-allocated backing storage (reland.) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle no-op shrink attempts 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapPage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/heap/HeapAllocator.h" 6 #include "platform/heap/HeapAllocator.h"
7 7
8 namespace blink { 8 namespace blink {
9 9
10 void HeapAllocator::backingFree(void* address) 10 void HeapAllocator::backingFree(void* address)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return backingExpand(address, newSize); 81 return backingExpand(address, newSize);
82 } 82 }
83 83
84 bool HeapAllocator::expandHashTableBacking(void* address, size_t newSize) 84 bool HeapAllocator::expandHashTableBacking(void* address, size_t newSize)
85 { 85 {
86 return backingExpand(address, newSize); 86 return backingExpand(address, newSize);
87 } 87 }
88 88
89 bool HeapAllocator::backingShrink(void* address, size_t quantizedCurrentSize, si ze_t quantizedShrunkSize) 89 bool HeapAllocator::backingShrink(void* address, size_t quantizedCurrentSize, si ze_t quantizedShrunkSize)
90 { 90 {
91 // We shrink the object only if the shrinking will make a non-small 91 if (!address || quantizedShrunkSize == quantizedCurrentSize)
92 // prompt-free block.
93 // FIXME: Optimize the threshold size.
94 if (quantizedCurrentSize <= quantizedShrunkSize + sizeof(HeapObjectHeader) + sizeof(void*) * 32)
95 return true; 92 return true;
96 93
97 if (!address) 94 ASSERT(quantizedShrunkSize < quantizedCurrentSize);
98 return true;
99 95
100 ThreadState* state = ThreadState::current(); 96 ThreadState* state = ThreadState::current();
101 if (state->sweepForbidden()) 97 if (state->sweepForbidden())
102 return false; 98 return false;
103 ASSERT(!state->isInGC()); 99 ASSERT(!state->isInGC());
104 ASSERT(state->isAllocationAllowed()); 100 ASSERT(state->isAllocationAllowed());
105 101
106 // FIXME: Support shrink for large objects. 102 // FIXME: Support shrink for large objects.
107 // Don't shrink backings allocated on other threads. 103 // Don't shrink backings allocated on other threads.
108 BasePage* page = pageFromObject(address); 104 BasePage* page = pageFromObject(address);
109 if (page->isLargeObjectPage() || page->heap()->threadState() != state) 105 if (page->isLargeObjectPage() || page->heap()->threadState() != state)
110 return false; 106 return false;
111 107
112 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address); 108 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address);
113 ASSERT(header->checkHeader()); 109 ASSERT(header->checkHeader());
114 NormalPageHeap* heap = static_cast<NormalPage*>(page)->heapForNormalPage(); 110 NormalPageHeap* heap = static_cast<NormalPage*>(page)->heapForNormalPage();
111 // We shrink the object only if the shrinking will make a non-small
112 // prompt-free block.
113 // FIXME: Optimize the threshold size.
114 if (quantizedCurrentSize <= quantizedShrunkSize + sizeof(HeapObjectHeader) + sizeof(void*) * 32 && !heap->isObjectAllocatedAtAllocationPoint(header))
115 return true;
116
115 bool succeededAtAllocationPoint = heap->shrinkObject(header, quantizedShrunk Size); 117 bool succeededAtAllocationPoint = heap->shrinkObject(header, quantizedShrunk Size);
116 if (succeededAtAllocationPoint) 118 if (succeededAtAllocationPoint)
117 state->allocationPointAdjusted(heap->heapIndex()); 119 state->allocationPointAdjusted(heap->heapIndex());
118 return true; 120 return true;
119 } 121 }
120 122
121 bool HeapAllocator::shrinkVectorBacking(void* address, size_t quantizedCurrentSi ze, size_t quantizedShrunkSize) 123 bool HeapAllocator::shrinkVectorBacking(void* address, size_t quantizedCurrentSi ze, size_t quantizedShrunkSize)
122 { 124 {
123 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); 125 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize);
124 } 126 }
125 127
126 bool HeapAllocator::shrinkInlineVectorBacking(void* address, size_t quantizedCur rentSize, size_t quantizedShrunkSize) 128 bool HeapAllocator::shrinkInlineVectorBacking(void* address, size_t quantizedCur rentSize, size_t quantizedShrunkSize)
127 { 129 {
128 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); 130 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize);
129 } 131 }
130 132
131 } // namespace blink 133 } // namespace blink
OLDNEW
« 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