summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-05-23 13:14:13 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-05-23 13:14:14 +0200
commita5b43f4f03d88d0fca8fb4531f49d1fecff582b7 (patch)
tree59c92f012966a40ee7087e8817726cadcb73d9ea /Source/JavaScriptCore/heap
parent276fb8ee82394b8fe414196677ce6af4028c5652 (diff)
parentd7fff220c897ab0eebcd6ca8087efd4b9477beb9 (diff)
downloadqtwebkit-a5b43f4f03d88d0fca8fb4531f49d1fecff582b7.tar.gz
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: Ibe8c6167bf9d9b6bd689b93ed7f5b94cdbd73ba7
Diffstat (limited to 'Source/JavaScriptCore/heap')
-rw-r--r--Source/JavaScriptCore/heap/MarkStack.cpp12
-rw-r--r--Source/JavaScriptCore/heap/MarkStack.h16
-rw-r--r--Source/JavaScriptCore/heap/MarkStackInlines.h10
-rw-r--r--Source/JavaScriptCore/heap/WeakSet.cpp2
4 files changed, 15 insertions, 25 deletions
diff --git a/Source/JavaScriptCore/heap/MarkStack.cpp b/Source/JavaScriptCore/heap/MarkStack.cpp
index 755a0ad50..39907c715 100644
--- a/Source/JavaScriptCore/heap/MarkStack.cpp
+++ b/Source/JavaScriptCore/heap/MarkStack.cpp
@@ -31,7 +31,6 @@
#include "CopiedSpace.h"
#include "CopiedSpaceInlines.h"
#include "Heap.h"
-#include "Options.h"
#include "JSArray.h"
#include "JSCell.h"
#include "JSObject.h"
@@ -45,13 +44,13 @@
namespace JSC {
+COMPILE_ASSERT(MarkStackSegment::blockSize == WeakBlock::blockSize, blockSizeMatch);
+
MarkStackArray::MarkStackArray(BlockAllocator& blockAllocator)
: m_blockAllocator(blockAllocator)
- , m_segmentCapacity(MarkStackSegment::capacityFromSize(Options::gcMarkStackSegmentSize()))
, m_top(0)
, m_numberOfSegments(0)
{
- ASSERT(MarkStackSegment::blockSize == WeakBlock::blockSize);
m_segments.push(MarkStackSegment::create(m_blockAllocator.allocate<MarkStackSegment>()));
m_numberOfSegments++;
}
@@ -64,7 +63,7 @@ MarkStackArray::~MarkStackArray()
void MarkStackArray::expand()
{
- ASSERT(m_segments.head()->m_top == m_segmentCapacity);
+ ASSERT(m_segments.head()->m_top == s_segmentCapacity);
MarkStackSegment* nextSegment = MarkStackSegment::create(m_blockAllocator.allocate<MarkStackSegment>());
m_numberOfSegments++;
@@ -97,8 +96,6 @@ void MarkStackArray::donateSomeCellsTo(MarkStackArray& other)
// we prefer donating whole segments over donating individual cells,
// even if this skews away from our 1 / 2 target.
- ASSERT(m_segmentCapacity == other.m_segmentCapacity);
-
size_t segmentsToDonate = m_numberOfSegments / 2; // If we only have one segment (our head) we don't donate any segments.
if (!segmentsToDonate) {
@@ -141,7 +138,6 @@ void MarkStackArray::stealSomeCellsFrom(MarkStackArray& other, size_t idleThread
// To reduce copying costs, we prefer stealing a whole segment over stealing
// individual cells, even if this skews away from our 1 / N target.
- ASSERT(m_segmentCapacity == other.m_segmentCapacity);
validatePrevious();
other.validatePrevious();
@@ -151,7 +147,7 @@ void MarkStackArray::stealSomeCellsFrom(MarkStackArray& other, size_t idleThread
MarkStackSegment* otherHead = other.m_segments.removeHead();
MarkStackSegment* myHead = m_segments.removeHead();
- ASSERT(other.m_segments.head()->m_top == m_segmentCapacity);
+ ASSERT(other.m_segments.head()->m_top == s_segmentCapacity);
m_segments.push(other.m_segments.removeHead());
diff --git a/Source/JavaScriptCore/heap/MarkStack.h b/Source/JavaScriptCore/heap/MarkStack.h
index 2a7f04450..c97b6a735 100644
--- a/Source/JavaScriptCore/heap/MarkStack.h
+++ b/Source/JavaScriptCore/heap/MarkStack.h
@@ -75,16 +75,6 @@ public:
{
return bitwise_cast<const JSCell**>(this + 1);
}
-
- static size_t capacityFromSize(size_t size)
- {
- return (size - sizeof(MarkStackSegment)) / sizeof(const JSCell*);
- }
-
- static size_t sizeFromCapacity(size_t capacity)
- {
- return sizeof(MarkStackSegment) + capacity * sizeof(const JSCell*);
- }
static const size_t blockSize = 4 * KB;
@@ -111,6 +101,10 @@ public:
bool isEmpty();
private:
+ template <size_t size> struct CapacityFromSize {
+ static const size_t value = (size - sizeof(MarkStackSegment)) / sizeof(const JSCell*);
+ };
+
JS_EXPORT_PRIVATE void expand();
size_t postIncTop();
@@ -124,7 +118,7 @@ private:
DoublyLinkedList<MarkStackSegment> m_segments;
BlockAllocator& m_blockAllocator;
- size_t m_segmentCapacity;
+ JS_EXPORT_PRIVATE static const size_t s_segmentCapacity = CapacityFromSize<MarkStackSegment::blockSize>::value;
size_t m_top;
size_t m_numberOfSegments;
diff --git a/Source/JavaScriptCore/heap/MarkStackInlines.h b/Source/JavaScriptCore/heap/MarkStackInlines.h
index 1595e843e..c577de602 100644
--- a/Source/JavaScriptCore/heap/MarkStackInlines.h
+++ b/Source/JavaScriptCore/heap/MarkStackInlines.h
@@ -52,8 +52,8 @@ inline size_t MarkStackArray::preDecTop()
inline void MarkStackArray::setTopForFullSegment()
{
- ASSERT(m_segments.head()->m_top == m_segmentCapacity);
- m_top = m_segmentCapacity;
+ ASSERT(m_segments.head()->m_top == s_segmentCapacity);
+ m_top = s_segmentCapacity;
}
inline void MarkStackArray::setTopForEmptySegment()
@@ -82,7 +82,7 @@ inline void MarkStackArray::validatePrevious()
inline void MarkStackArray::append(const JSCell* cell)
{
- if (m_top == m_segmentCapacity)
+ if (m_top == s_segmentCapacity)
expand();
m_segments.head()->data()[postIncTop()] = cell;
}
@@ -102,7 +102,7 @@ inline bool MarkStackArray::isEmpty()
if (m_top)
return false;
if (m_segments.head()->next()) {
- ASSERT(m_segments.head()->next()->m_top == m_segmentCapacity);
+ ASSERT(m_segments.head()->next()->m_top == s_segmentCapacity);
return false;
}
return true;
@@ -110,7 +110,7 @@ inline bool MarkStackArray::isEmpty()
inline size_t MarkStackArray::size()
{
- return m_top + m_segmentCapacity * (m_numberOfSegments - 1);
+ return m_top + s_segmentCapacity * (m_numberOfSegments - 1);
}
} // namespace JSC
diff --git a/Source/JavaScriptCore/heap/WeakSet.cpp b/Source/JavaScriptCore/heap/WeakSet.cpp
index 67b1d0613..7cedaee85 100644
--- a/Source/JavaScriptCore/heap/WeakSet.cpp
+++ b/Source/JavaScriptCore/heap/WeakSet.cpp
@@ -84,7 +84,7 @@ WeakBlock::FreeCell* WeakSet::addAllocator()
void WeakSet::removeAllocator(WeakBlock* block)
{
m_blocks.remove(block);
- WeakBlock::destroy(block);
+ heap()->blockAllocator().deallocate(WeakBlock::destroy(block));
}
} // namespace JSC