Reviewed by Oliver Hunt.
Rolled back in r77612 with ASSERT/crash fixed.
https://bugs.webkit.org/show_bug.cgi?id=53759
Don't shrink the heap to 0 unconditionally. Instead, shrink to 1 if
necessary. For now, the heap assumes that it always has at least one
block live.
* runtime/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::reset):
* runtime/Heap.h:
* runtime/MarkedSpace.cpp:
(JSC::MarkedSpace::allocate):
(JSC::MarkedSpace::shrinkBlocks):
(JSC::MarkedSpace::sweep):
(JSC::MarkedSpace::reset):
* runtime/MarkedSpace.h:
(JSC::MarkedSpace::highWaterMark):
(JSC::MarkedSpace::setHighWaterMark):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77699
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-04 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Rolled back in r77612 with ASSERT/crash fixed.
+ https://bugs.webkit.org/show_bug.cgi?id=53759
+
+ Don't shrink the heap to 0 unconditionally. Instead, shrink to 1 if
+ necessary. For now, the heap assumes that it always has at least one
+ block live.
+
+ * runtime/Heap.cpp:
+ (JSC::Heap::Heap):
+ (JSC::Heap::reset):
+ * runtime/Heap.h:
+ * runtime/MarkedSpace.cpp:
+ (JSC::MarkedSpace::allocate):
+ (JSC::MarkedSpace::shrinkBlocks):
+ (JSC::MarkedSpace::sweep):
+ (JSC::MarkedSpace::reset):
+ * runtime/MarkedSpace.h:
+ (JSC::MarkedSpace::highWaterMark):
+ (JSC::MarkedSpace::setHighWaterMark):
+
2011-02-04 David Kilzer <ddkilzer@apple.com>
BUILD FIX: REALLY remove the last vestiges of JSVALUE32!
#include "JSLock.h"
#include "JSONObject.h"
#include "Tracing.h"
+#include <algorithm>
#define COLLECT_ON_EVERY_ALLOCATION 0
+using namespace std;
+
namespace JSC {
+const size_t minBytesPerCycle = 512 * 1024;
+
Heap::Heap(JSGlobalData* globalData)
- : m_markedSpace(globalData)
- , m_operationInProgress(NoOperation)
+ : m_operationInProgress(NoOperation)
+ , m_markedSpace(globalData)
, m_markListSet(0)
, m_activityCallback(DefaultGCActivityCallback::create(this))
, m_globalData(globalData)
if (sweepToggle == DoSweep)
m_markedSpace.sweep();
+ size_t usedCellCount = m_markedSpace.markedCells();
+ size_t proportionalBytes = static_cast<size_t>(usedCellCount * 1.5 * HeapConstants::cellSize);
+ m_markedSpace.setHighWaterMark(max(proportionalBytes, minBytesPerCycle));
+
JAVASCRIPTCORE_GC_END();
(*m_activityCallback)();
RegisterFile& registerFile();
- MarkedSpace m_markedSpace;
OperationInProgress m_operationInProgress;
+ MarkedSpace m_markedSpace;
ProtectCountSet m_protectedValues;
Vector<PageAllocationAligned> m_weakGCHandlePools;
m_heap.nextCell = block->marked.nextPossiblyUnset(m_heap.nextCell);
} while (m_heap.nextCell != HeapConstants::cellsPerBlock);
m_heap.nextCell = 0;
+ m_heap.waterMark += BLOCK_SIZE;
} while (++m_heap.nextBlock != m_heap.usedBlocks);
-
+
+ if (m_heap.waterMark < m_heap.highWaterMark)
+ return &allocateBlock()->cells[m_heap.nextCell++];
+
return 0;
}
new (cell) JSCell(dummyMarkableCellStructure);
#endif
}
+
+ if (m_heap.usedBlocks > 1)
+ shrinkBlocks(1);
}
size_t MarkedSpace::objectCount() const
{
m_heap.nextCell = 0;
m_heap.nextBlock = 0;
+ m_heap.waterMark = 0;
#if ENABLE(JSC_ZOMBIES)
sweep();
#endif
- resizeBlocks();
}
LiveObjectIterator MarkedSpace::primaryHeapBegin()
size_t numBlocks;
size_t usedBlocks;
+
+ size_t waterMark;
+ size_t highWaterMark;
MarkedBlock* collectorBlock(size_t index) const
{
JSGlobalData* globalData() { return m_globalData; }
+ size_t highWaterMark() { return m_heap.highWaterMark; }
+ void setHighWaterMark(size_t highWaterMark) { m_heap.highWaterMark = highWaterMark; }
+
void* allocate(size_t);
void clearMarkBits();
void markRoots();
void reset();
void sweep();
+ size_t markedCells(size_t startBlock = 0, size_t startCell = 0) const;
size_t size() const;
size_t capacity() const;
void shrinkBlocks(size_t neededBlocks);
void clearMarkBits(MarkedBlock*);
- size_t markedCells(size_t startBlock = 0, size_t startCell = 0) const;
CollectorHeap m_heap;
JSGlobalData* m_globalData;