summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap/WeakBlock.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/heap/WeakBlock.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/heap/WeakBlock.h')
-rw-r--r--Source/JavaScriptCore/heap/WeakBlock.h55
1 files changed, 28 insertions, 27 deletions
diff --git a/Source/JavaScriptCore/heap/WeakBlock.h b/Source/JavaScriptCore/heap/WeakBlock.h
index b6b631e27..6d4ff0709 100644
--- a/Source/JavaScriptCore/heap/WeakBlock.h
+++ b/Source/JavaScriptCore/heap/WeakBlock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,73 +23,71 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WeakBlock_h
-#define WeakBlock_h
+#pragma once
-#include "HeapBlock.h"
-#include "WeakHandleOwner.h"
+#include "CellContainer.h"
#include "WeakImpl.h"
#include <wtf/DoublyLinkedList.h>
#include <wtf/StdLibExtras.h>
namespace JSC {
-class DeadBlock;
-class HeapRootVisitor;
-class JSValue;
-class WeakHandleOwner;
+class Heap;
+class SlotVisitor;
-class WeakBlock : public HeapBlock<WeakBlock> {
+class WeakBlock : public DoublyLinkedListNode<WeakBlock> {
public:
friend class WTF::DoublyLinkedListNode<WeakBlock>;
- static const size_t blockSize = 4 * KB; // 5% of MarkedBlock size
+ static const size_t blockSize = 256; // 1/16 of MarkedBlock size
struct FreeCell {
FreeCell* next;
};
struct SweepResult {
- SweepResult();
bool isNull() const;
- bool blockIsFree;
- FreeCell* freeList;
+ bool blockIsFree { true };
+ bool blockIsLogicallyEmpty { true };
+ FreeCell* freeList { nullptr };
};
- static WeakBlock* create(DeadBlock*);
+ static WeakBlock* create(Heap&, CellContainer);
+ static void destroy(Heap&, WeakBlock*);
static WeakImpl* asWeakImpl(FreeCell*);
bool isEmpty();
+ bool isLogicallyEmptyButNotFree() const;
void sweep();
SweepResult takeSweepResult();
- void visit(HeapRootVisitor&);
+ void visit(SlotVisitor&);
+
void reap();
void lastChanceToFinalize();
+ void disconnectContainer() { m_container = CellContainer(); }
private:
static FreeCell* asFreeCell(WeakImpl*);
+
+ template<typename ContainerType>
+ void specializedVisit(ContainerType&, SlotVisitor&);
- WeakBlock(Region*);
- WeakImpl* firstWeakImpl();
+ explicit WeakBlock(CellContainer);
void finalize(WeakImpl*);
WeakImpl* weakImpls();
size_t weakImplCount();
void addToFreeList(FreeCell**, WeakImpl*);
+ CellContainer m_container;
+ WeakBlock* m_prev;
+ WeakBlock* m_next;
SweepResult m_sweepResult;
};
-inline WeakBlock::SweepResult::SweepResult()
- : blockIsFree(true)
- , freeList(0)
-{
- ASSERT(isNull());
-}
-
inline bool WeakBlock::SweepResult::isNull() const
{
return blockIsFree && !freeList; // This state is impossible, so we can use it to mean null.
@@ -138,6 +136,9 @@ inline bool WeakBlock::isEmpty()
return !m_sweepResult.isNull() && m_sweepResult.blockIsFree;
}
-} // namespace JSC
+inline bool WeakBlock::isLogicallyEmptyButNotFree() const
+{
+ return !m_sweepResult.isNull() && !m_sweepResult.blockIsFree && m_sweepResult.blockIsLogicallyEmpty;
+}
-#endif // WeakBlock_h
+} // namespace JSC