summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap/WeakBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/heap/WeakBlock.cpp')
-rw-r--r--Source/JavaScriptCore/heap/WeakBlock.cpp49
1 files changed, 13 insertions, 36 deletions
diff --git a/Source/JavaScriptCore/heap/WeakBlock.cpp b/Source/JavaScriptCore/heap/WeakBlock.cpp
index ddbbc8c84..957090569 100644
--- a/Source/JavaScriptCore/heap/WeakBlock.cpp
+++ b/Source/JavaScriptCore/heap/WeakBlock.cpp
@@ -28,28 +28,20 @@
#include "Heap.h"
#include "HeapRootVisitor.h"
-#include "JSCInlines.h"
#include "JSObject.h"
-#include "WeakHandleOwner.h"
+#include "Operations.h"
+#include "Structure.h"
namespace JSC {
-WeakBlock* WeakBlock::create(Heap& heap, MarkedBlock& markedBlock)
+WeakBlock* WeakBlock::create(DeadBlock* block)
{
- heap.didAllocateBlock(WeakBlock::blockSize);
- return new (NotNull, fastMalloc(blockSize)) WeakBlock(markedBlock);
+ Region* region = block->region();
+ return new (NotNull, block) WeakBlock(region);
}
-void WeakBlock::destroy(Heap& heap, WeakBlock* block)
-{
- block->~WeakBlock();
- fastFree(block);
- heap.didFreeBlock(WeakBlock::blockSize);
-}
-
-WeakBlock::WeakBlock(MarkedBlock& markedBlock)
- : DoublyLinkedListNode<WeakBlock>()
- , m_markedBlock(&markedBlock)
+WeakBlock::WeakBlock(Region* region)
+ : HeapBlock<WeakBlock>(region)
{
for (size_t i = 0; i < weakImplCount(); ++i) {
WeakImpl* weakImpl = &weakImpls()[i];
@@ -84,11 +76,8 @@ void WeakBlock::sweep()
finalize(weakImpl);
if (weakImpl->state() == WeakImpl::Deallocated)
addToFreeList(&sweepResult.freeList, weakImpl);
- else {
+ else
sweepResult.blockIsFree = false;
- if (weakImpl->state() == WeakImpl::Live)
- sweepResult.blockIsLogicallyEmpty = false;
- }
}
m_sweepResult = sweepResult;
@@ -101,12 +90,6 @@ void WeakBlock::visit(HeapRootVisitor& heapRootVisitor)
if (isEmpty())
return;
- // If this WeakBlock doesn't belong to a MarkedBlock, we won't even be here.
- ASSERT(m_markedBlock);
-
- // We only visit after marking.
- ASSERT(m_markedBlock->isMarkedOrRetired());
-
SlotVisitor& visitor = heapRootVisitor.visitor();
for (size_t i = 0; i < weakImplCount(); ++i) {
@@ -114,12 +97,12 @@ void WeakBlock::visit(HeapRootVisitor& heapRootVisitor)
if (weakImpl->state() != WeakImpl::Live)
continue;
- WeakHandleOwner* weakHandleOwner = weakImpl->weakHandleOwner();
- if (!weakHandleOwner)
+ const JSValue& jsValue = weakImpl->jsValue();
+ if (Heap::isLive(jsValue.asCell()))
continue;
- const JSValue& jsValue = weakImpl->jsValue();
- if (m_markedBlock->isMarkedOrNewlyAllocated(jsValue.asCell()))
+ WeakHandleOwner* weakHandleOwner = weakImpl->weakHandleOwner();
+ if (!weakHandleOwner)
continue;
if (!weakHandleOwner->isReachableFromOpaqueRoots(Handle<Unknown>::wrapSlot(&const_cast<JSValue&>(jsValue)), weakImpl->context(), visitor))
@@ -135,18 +118,12 @@ void WeakBlock::reap()
if (isEmpty())
return;
- // If this WeakBlock doesn't belong to a MarkedBlock, we won't even be here.
- ASSERT(m_markedBlock);
-
- // We only reap after marking.
- ASSERT(m_markedBlock->isMarkedOrRetired());
-
for (size_t i = 0; i < weakImplCount(); ++i) {
WeakImpl* weakImpl = &weakImpls()[i];
if (weakImpl->state() > WeakImpl::Dead)
continue;
- if (m_markedBlock->isMarkedOrNewlyAllocated(weakImpl->jsValue().asCell())) {
+ if (Heap::isLive(weakImpl->jsValue().asCell())) {
ASSERT(weakImpl->state() == WeakImpl::Live);
continue;
}