X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..81345200c95645a1b0d2635520f96ad55dfde63f:/heap/HandleSet.cpp diff --git a/heap/HandleSet.cpp b/heap/HandleSet.cpp index a6ccf29..be667e8 100644 --- a/heap/HandleSet.cpp +++ b/heap/HandleSet.cpp @@ -26,24 +26,35 @@ #include "config.h" #include "HandleSet.h" +#include "HandleBlock.h" +#include "HandleBlockInlines.h" #include "HeapRootVisitor.h" #include "JSObject.h" +#include "JSCInlines.h" +#include namespace JSC { -HandleSet::HandleSet(JSGlobalData* globalData) - : m_globalData(globalData) - , m_nextToFinalize(0) +HandleSet::HandleSet(VM* vm) + : m_vm(vm) { grow(); } +HandleSet::~HandleSet() +{ + while (!m_blockList.isEmpty()) + m_vm->heap.blockAllocator().deallocate(HandleBlock::destroy(m_blockList.removeHead())); +} + void HandleSet::grow() { - Node* block = m_blockStack.grow(); - for (int i = m_blockStack.blockLength - 1; i >= 0; --i) { - Node* node = &block[i]; - new (NotNull, node) Node(this); + HandleBlock* newBlock = HandleBlock::create(m_vm->heap.blockAllocator().allocate(), this); + m_blockList.append(newBlock); + + for (int i = newBlock->nodeCapacity() - 1; i >= 0; --i) { + Node* node = newBlock->nodeAtIndex(i); + new (NotNull, node) Node; m_freeList.push(node); } } @@ -53,8 +64,7 @@ void HandleSet::visitStrongHandles(HeapRootVisitor& heapRootVisitor) Node* end = m_strongList.end(); for (Node* node = m_strongList.begin(); node != end; node = node->next()) { #if ENABLE(GC_VALIDATION) - if (!isLiveNode(node)) - CRASH(); + RELEASE_ASSERT(isLiveNode(node)); #endif heapRootVisitor.visit(node->slot()); } @@ -62,18 +72,12 @@ void HandleSet::visitStrongHandles(HeapRootVisitor& heapRootVisitor) void HandleSet::writeBarrier(HandleSlot slot, const JSValue& value) { - // Forbid assignment to handles during the finalization phase, since it would violate many GC invariants. - // File a bug with stack trace if you hit this. - if (m_nextToFinalize) - CRASH(); - if (!value == !*slot && slot->isCell() == value.isCell()) return; Node* node = toNode(slot); #if ENABLE(GC_VALIDATION) - if (!isLiveNode(node)) - CRASH(); + RELEASE_ASSERT(isLiveNode(node)); #endif SentinelLinkedList::remove(node); if (!value || !value.isCell()) { @@ -83,8 +87,7 @@ void HandleSet::writeBarrier(HandleSlot slot, const JSValue& value) m_strongList.push(node); #if ENABLE(GC_VALIDATION) - if (!isLiveNode(node)) - CRASH(); + RELEASE_ASSERT(isLiveNode(node)); #endif }