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

Unified Diff: Source/platform/heap/CallbackStack.h

Issue 1115993003: Try reducing and balance GC callback stack sizes. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: initialize stacks also before doing thread-terminating GCs Created 5 years, 8 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 | Source/platform/heap/CallbackStack.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/CallbackStack.h
diff --git a/Source/platform/heap/CallbackStack.h b/Source/platform/heap/CallbackStack.h
index e7e60ba8d337ee3effa4f57606fa7606f9fbf7e6..49b1f2949f89f98f602d8928e7db7e3e8f5ab13f 100644
--- a/Source/platform/heap/CallbackStack.h
+++ b/Source/platform/heap/CallbackStack.h
@@ -16,6 +16,20 @@ namespace blink {
// multiple chained CallbackStack object instances.
class CallbackStack {
public:
+
+ // Callback stacks are extensible, chaining blocks together. However,
+ // all but the first block are deleted when 'popped empty', so it
+ // is in our interest to not spill over into additional blocks too
+ // often. The block sizes used here tries to reflect that -- plentiful
+ // for 'typical' GCs, but not wasting too much slop either in the
+ // initial block.
+ enum BlockSizes {
+ MarkingStackBlockSize = 8192,
+ WeakCallbackStackBlockSize = 2048,
+ PostMarkingStackBlockSize = 1024,
+ EphemeronCallbackStackBlockSize = 1024,
+ };
+
class Item {
public:
Item() { }
@@ -33,7 +47,7 @@ public:
VisitorCallback m_callback;
};
- CallbackStack();
+ CallbackStack(unsigned blockSize);
~CallbackStack();
void clear();
@@ -49,22 +63,15 @@ public:
bool hasCallbackForObject(const void*);
#endif
- static const size_t blockSize = 8192;
-
private:
class Block {
public:
- explicit Block(Block* next)
- : m_limit(&(m_buffer[blockSize]))
- , m_current(&(m_buffer[0]))
- , m_next(next)
- {
- clearUnused();
- }
+ Block(Block* next, unsigned blockSize);
~Block()
{
clearUnused();
+ delete m_buffer;
}
void clear();
@@ -77,11 +84,6 @@ private:
return m_current == &(m_buffer[0]);
}
- size_t size() const
- {
- return blockSize - (m_limit - m_current);
- }
-
Item* allocateEntry()
{
if (LIKELY(m_current < m_limit))
@@ -104,20 +106,23 @@ private:
private:
void clearUnused();
- Item m_buffer[blockSize];
+ Item* m_buffer;
Item* m_limit;
Item* m_current;
Block* m_next;
+#if ENABLE(ASSERT)
+ unsigned m_blockSize;
+#endif
};
Item* popSlow();
Item* allocateEntrySlow();
void invokeOldestCallbacks(Block*, Block*, Visitor*);
bool hasJustOneBlock() const;
- void swap(CallbackStack* other);
Block* m_first;
Block* m_last;
+ unsigned m_blockSize;
};
ALWAYS_INLINE CallbackStack::Item* CallbackStack::allocateEntry()
« no previous file with comments | « no previous file | Source/platform/heap/CallbackStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698