Changeset 146734 in webkit for trunk/Source/JavaScriptCore/heap/HandleSet.h
- Timestamp:
- Mar 24, 2013, 3:45:36 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/heap/HandleSet.h
r140584 r146734 27 27 #define HandleSet_h 28 28 29 #include <wtf/BlockStack.h>30 29 #include "Handle.h" 30 #include "HandleBlock.h" 31 #include <wtf/DoublyLinkedList.h> 31 32 #include <wtf/HashCountedSet.h> 32 33 #include <wtf/SentinelLinkedList.h> … … 35 36 namespace JSC { 36 37 38 class HandleBlock; 37 39 class HandleSet; 38 40 class HeapRootVisitor; … … 41 43 class SlotVisitor; 42 44 45 class HandleNode { 46 public: 47 HandleNode(WTF::SentinelTag); 48 HandleNode(); 49 50 HandleSlot slot(); 51 HandleSet* handleSet(); 52 53 void setPrev(HandleNode*); 54 HandleNode* prev(); 55 56 void setNext(HandleNode*); 57 HandleNode* next(); 58 59 private: 60 JSValue m_value; 61 HandleNode* m_prev; 62 HandleNode* m_next; 63 }; 64 43 65 class HandleSet { 66 friend class HandleBlock; 44 67 public: 45 68 static HandleSet* heapFor(HandleSlot); 46 69 47 70 HandleSet(JSGlobalData*); 48 71 ~HandleSet(); 72 49 73 JSGlobalData* globalData(); 50 74 … … 61 85 62 86 private: 63 class Node { 64 public: 65 Node(WTF::SentinelTag); 66 Node(HandleSet*); 67 68 HandleSlot slot(); 69 HandleSet* handleSet(); 70 71 void setPrev(Node*); 72 Node* prev(); 73 74 void setNext(Node*); 75 Node* next(); 76 77 private: 78 JSValue m_value; 79 HandleSet* m_handleSet; 80 Node* m_prev; 81 Node* m_next; 82 }; 83 87 typedef HandleNode Node; 84 88 static HandleSlot toHandle(Node*); 85 89 static Node* toNode(HandleSlot); … … 92 96 93 97 JSGlobalData* m_globalData; 94 BlockStack<Node> m_blockStack;98 DoublyLinkedList<HandleBlock> m_blockList; 95 99 96 100 SentinelLinkedList<Node> m_strongList; … … 110 114 } 111 115 112 inline HandleSlot HandleSet::toHandle( Node* node)116 inline HandleSlot HandleSet::toHandle(HandleSet::Node* node) 113 117 { 114 118 return reinterpret_cast<HandleSlot>(node); … … 117 121 inline HandleSet::Node* HandleSet::toNode(HandleSlot handle) 118 122 { 119 return reinterpret_cast< Node*>(handle);123 return reinterpret_cast<HandleSet::Node*>(handle); 120 124 } 121 125 … … 129 133 grow(); 130 134 131 Node* node = m_freeList.pop();132 new (NotNull, node) Node(this);135 HandleSet::Node* node = m_freeList.pop(); 136 new (NotNull, node) HandleSet::Node(); 133 137 m_immediateList.push(node); 134 138 return toHandle(node); … … 137 141 inline void HandleSet::deallocate(HandleSlot handle) 138 142 { 139 Node* node = toNode(handle);143 HandleSet::Node* node = toNode(handle); 140 144 if (node == m_nextToFinalize) { 141 145 ASSERT(m_nextToFinalize->next()); … … 143 147 } 144 148 145 SentinelLinkedList< Node>::remove(node);149 SentinelLinkedList<HandleSet::Node>::remove(node); 146 150 m_freeList.push(node); 147 151 } 148 152 149 inline HandleSet::Node::Node(HandleSet* handleSet) 150 : m_handleSet(handleSet) 151 , m_prev(0) 153 inline HandleNode::HandleNode() 154 : m_prev(0) 152 155 , m_next(0) 153 156 { 154 157 } 155 158 156 inline HandleSet::Node::Node(WTF::SentinelTag) 157 : m_handleSet(0) 158 , m_prev(0) 159 inline HandleNode::HandleNode(WTF::SentinelTag) 160 : m_prev(0) 159 161 , m_next(0) 160 162 { 161 163 } 162 164 163 inline HandleSlot Handle Set::Node::slot()165 inline HandleSlot HandleNode::slot() 164 166 { 165 167 return &m_value; 166 168 } 167 169 168 inline HandleSet* Handle Set::Node::handleSet()169 { 170 return m_handleSet;171 } 172 173 inline void Handle Set::Node::setPrev(Node* prev)170 inline HandleSet* HandleNode::handleSet() 171 { 172 return HandleBlock::blockFor(this)->handleSet(); 173 } 174 175 inline void HandleNode::setPrev(HandleNode* prev) 174 176 { 175 177 m_prev = prev; 176 178 } 177 179 178 inline Handle Set::Node* HandleSet::Node::prev()180 inline HandleNode* HandleNode::prev() 179 181 { 180 182 return m_prev; 181 183 } 182 184 183 inline void Handle Set::Node::setNext(Node* next)185 inline void HandleNode::setNext(HandleNode* next) 184 186 { 185 187 m_next = next; 186 188 } 187 189 188 inline Handle Set::Node* HandleSet::Node::next()190 inline HandleNode* HandleNode::next() 189 191 { 190 192 return m_next; … … 193 195 template<typename Functor> void HandleSet::forEachStrongHandle(Functor& functor, const HashCountedSet<JSCell*>& skipSet) 194 196 { 195 Node* end = m_strongList.end();196 for ( Node* node = m_strongList.begin(); node != end; node = node->next()) {197 HandleSet::Node* end = m_strongList.end(); 198 for (HandleSet::Node* node = m_strongList.begin(); node != end; node = node->next()) { 197 199 JSValue value = *node->slot(); 198 200 if (!value || !value.isCell())
Note:
See TracChangeset
for help on using the changeset viewer.