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

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

Issue 1395493008: Revert of Oilpan: always shrink tail-allocated backing storage. (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
« 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
92 // prompt-free block.
93 // FIXME: Optimize the threshold size.
94 if (quantizedCurrentSize <= quantizedShrunkSize + sizeof(HeapObjectHeader) + sizeof(void*) * 32)
95 return true;
96
91 if (!address) 97 if (!address)
92 return true; 98 return true;
93 99
94 ThreadState* state = ThreadState::current(); 100 ThreadState* state = ThreadState::current();
95 if (state->sweepForbidden()) 101 if (state->sweepForbidden())
96 return false; 102 return false;
97 ASSERT(!state->isInGC()); 103 ASSERT(!state->isInGC());
98 ASSERT(state->isAllocationAllowed()); 104 ASSERT(state->isAllocationAllowed());
99 105
100 // FIXME: Support shrink for large objects. 106 // FIXME: Support shrink for large objects.
101 // Don't shrink backings allocated on other threads. 107 // Don't shrink backings allocated on other threads.
102 BasePage* page = pageFromObject(address); 108 BasePage* page = pageFromObject(address);
103 if (page->isLargeObjectPage() || page->heap()->threadState() != state) 109 if (page->isLargeObjectPage() || page->heap()->threadState() != state)
104 return false; 110 return false;
105 111
106 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address); 112 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address);
107 ASSERT(header->checkHeader()); 113 ASSERT(header->checkHeader());
108 NormalPageHeap* heap = static_cast<NormalPage*>(page)->heapForNormalPage(); 114 NormalPageHeap* heap = static_cast<NormalPage*>(page)->heapForNormalPage();
109 // We shrink the object only if the shrinking will make a non-small
110 // prompt-free block.
111 // FIXME: Optimize the threshold size.
112 if (quantizedCurrentSize <= quantizedShrunkSize + sizeof(HeapObjectHeader) + sizeof(void*) * 32 && !heap->isObjectAllocatedAtAllocationPoint(header))
113 return true;
114
115 bool succeededAtAllocationPoint = heap->shrinkObject(header, quantizedShrunk Size); 115 bool succeededAtAllocationPoint = heap->shrinkObject(header, quantizedShrunk Size);
116 if (succeededAtAllocationPoint) 116 if (succeededAtAllocationPoint)
117 state->allocationPointAdjusted(heap->heapIndex()); 117 state->allocationPointAdjusted(heap->heapIndex());
118 return true; 118 return true;
119 } 119 }
120 120
121 bool HeapAllocator::shrinkVectorBacking(void* address, size_t quantizedCurrentSi ze, size_t quantizedShrunkSize) 121 bool HeapAllocator::shrinkVectorBacking(void* address, size_t quantizedCurrentSi ze, size_t quantizedShrunkSize)
122 { 122 {
123 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); 123 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize);
124 } 124 }
125 125
126 bool HeapAllocator::shrinkInlineVectorBacking(void* address, size_t quantizedCur rentSize, size_t quantizedShrunkSize) 126 bool HeapAllocator::shrinkInlineVectorBacking(void* address, size_t quantizedCur rentSize, size_t quantizedShrunkSize)
127 { 127 {
128 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); 128 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize);
129 } 129 }
130 130
131 } // namespace blink 131 } // 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