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

Unified Diff: Source/platform/heap/Heap.cpp

Issue 669323002: Oilpan: Clarify ownership of split-off heaps. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.cpp
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
index 714bc9a3959c2472b4ce6d5bb869801f143f87a5..9cab4f4292e0b661de55e96a7760265eec15e34d 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -2690,7 +2690,7 @@ void ThreadHeap<Header>::prepareHeapForTermination()
}
template<typename Header>
-BaseHeap* ThreadHeap<Header>::split(int numberOfNormalPages)
+PassOwnPtr<BaseHeap> ThreadHeap<Header>::split(int numberOfNormalPages)
{
// Create a new split off thread heap containing
// |numberOfNormalPages| of the pages of this ThreadHeap for
@@ -2698,7 +2698,7 @@ BaseHeap* ThreadHeap<Header>::split(int numberOfNormalPages)
// with this heap at the end of sweeping and the temporary
// ThreadHeap object will be deallocated after the merge.
ASSERT(numberOfNormalPages > 0);
- ThreadHeap<Header>* splitOff = new ThreadHeap(m_threadState, m_index);
+ OwnPtr<ThreadHeap<Header>> splitOff = adoptPtr(new ThreadHeap(m_threadState, m_index));
HeapPage<Header>* splitPoint = m_firstPage;
for (int i = 1; i < numberOfNormalPages; i++)
splitPoint = splitPoint->next();
@@ -2708,13 +2708,13 @@ BaseHeap* ThreadHeap<Header>::split(int numberOfNormalPages)
splitOff->m_numberOfNormalPages = numberOfNormalPages;
m_numberOfNormalPages -= numberOfNormalPages;
splitPoint->m_next = 0;
- return splitOff;
+ return splitOff.release();
}
template<typename Header>
-void ThreadHeap<Header>::merge(BaseHeap* splitOffBase)
+void ThreadHeap<Header>::merge(PassOwnPtr<BaseHeap> splitOffBase)
{
- ThreadHeap<Header>* splitOff = static_cast<ThreadHeap<Header>*>(splitOffBase);
+ ThreadHeap<Header>* splitOff = static_cast<ThreadHeap<Header>*>(splitOffBase.get());
// If the mergePoint is zero all split off pages became empty in
// this round and we don't have to merge. There are no pages and
// nothing on the freelists.
@@ -2735,7 +2735,6 @@ void ThreadHeap<Header>::merge(BaseHeap* splitOffBase)
}
}
}
- delete splitOffBase;
}
void Heap::getHeapSpaceSize(uint64_t* objectSpaceSize, uint64_t* allocatedSpaceSize)
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698