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

Unified Diff: third_party/WebKit/Source/platform/heap/CallbackStack.cpp

Issue 1686943002: Oilpan: Decommit backing storage of CallbackStacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
Index: third_party/WebKit/Source/platform/heap/CallbackStack.cpp
diff --git a/third_party/WebKit/Source/platform/heap/CallbackStack.cpp b/third_party/WebKit/Source/platform/heap/CallbackStack.cpp
index 48823846abdabb8d8e30471327d1629f12560ac8..c76db50e0f336cdee4f18dd7155fc457cfe21f0a 100644
--- a/third_party/WebKit/Source/platform/heap/CallbackStack.cpp
+++ b/third_party/WebKit/Source/platform/heap/CallbackStack.cpp
@@ -3,14 +3,46 @@
// found in the LICENSE file.
#include "platform/heap/CallbackStack.h"
+#include "wtf/PageAllocator.h"
namespace blink {
-void CallbackStack::Block::clear()
+CallbackStack::Block::Block(Block* next)
{
+ static_assert((blockSize * sizeof(Item)) % WTF::kPageAllocationGranularity == 0, "CallbackStack::blockSize * sizeof(Item) must be a multiple of WTF::kPageAllocationGranularity");
+ m_buffer = static_cast<Item*>(WTF::allocPages(nullptr, blockSize * sizeof(Item), WTF::kPageAllocationGranularity, WTF::PageAccessible));
+ RELEASE_ASSERT(m_buffer);
+
+#if ENABLE(ASSERT)
+ for (size_t i = 0; i < blockSize; i++)
+ m_buffer[i] = Item(0, 0);
+#endif
+
+ m_limit = &(m_buffer[blockSize]);
+ m_current = &(m_buffer[0]);
+ m_next = next;
+}
+
+CallbackStack::Block::~Block()
+{
+ WTF::freePages(m_buffer, blockSize * sizeof(Item));
+ m_buffer = nullptr;
+ m_limit = nullptr;
+ m_current = nullptr;
+ m_next = nullptr;
+}
+
+void CallbackStack::Block::decommit()
+{
+#if ENABLE(ASSERT)
+ for (size_t i = 0; i < blockSize; i++)
+ m_buffer[i] = Item(0, 0);
+#endif
+
+ WTF::discardSystemPages(m_buffer, blockSize * sizeof(Item));
+
m_current = &m_buffer[0];
m_next = nullptr;
- clearUnused();
}
void CallbackStack::Block::invokeEphemeronCallbacks(Visitor* visitor)
@@ -35,34 +67,28 @@ bool CallbackStack::Block::hasCallbackForObject(const void* object)
}
#endif
-void CallbackStack::Block::clearUnused()
-{
-#if ENABLE(ASSERT)
- for (size_t i = 0; i < blockSize; i++)
- m_buffer[i] = Item(0, 0);
-#endif
-}
-
-CallbackStack::CallbackStack() : m_first(new Block(0)), m_last(m_first)
+CallbackStack::CallbackStack()
+ : m_first(new Block(0))
+ , m_last(m_first)
{
}
CallbackStack::~CallbackStack()
{
- clear();
+ RELEASE_ASSERT(isEmpty());
delete m_first;
m_first = nullptr;
m_last = nullptr;
}
-void CallbackStack::clear()
+void CallbackStack::decommit()
{
Block* next;
for (Block* current = m_first->next(); current; current = next) {
next = current->next();
delete current;
}
- m_first->clear();
+ m_first->decommit();
m_last = m_first;
}
@@ -86,7 +112,7 @@ CallbackStack::Item* CallbackStack::popSlow()
Block* next = m_first->next();
if (!next) {
#if ENABLE(ASSERT)
- m_first->clear();
+ m_first->decommit();
sof 2016/02/24 09:50:05 Isn't this call redundant/unwanted if the stack it
haraken 2016/02/24 10:06:19 This decommit is only enabled in assert builds whe
sof 2016/02/24 10:07:39 Shouldn't it just do the clearing then?
haraken 2016/02/24 10:21:44 Done.
sof 2016/02/24 10:32:23 Not yet uploaded?
#endif
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698