Changeset 2851 in webkit for trunk/JavaScriptCore/kjs/scope_chain.cpp
- Timestamp:
- Nov 24, 2002, 2:37:44 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/scope_chain.cpp
r2824 r2851 26 26 namespace KJS { 27 27 28 ScopeChainNode::ScopeChainNode(ScopeChainNode *n, ObjectImp *o)29 : next(n), object(o), nodeAndObjectRefCount(1), nodeOnlyRefCount(0)30 {31 o->ref();32 }33 34 28 inline void ScopeChain::ref() const 35 29 { 36 30 for (ScopeChainNode *n = _node; n; n = n->next) { 37 if (n-> nodeAndObjectRefCount++ != 0)31 if (n->refCount++ != 0) 38 32 break; 39 n->object->ref();40 33 } 41 }42 43 ScopeChain::ScopeChain(const NoRefScopeChain &c)44 : _node(c._node)45 {46 ref();47 34 } 48 35 … … 67 54 _node = newNode; 68 55 69 // Three cases: 70 // 1) This was not the last reference of the old node. 71 // In this case we move our ref from the old to the new node. 72 // 2) This was the last reference of the old node, but there are garbage collected references. 73 // In this case, the new node doesn't get any new ref, and the object is deref'd. 74 // 3) This was the last reference of the old node. 75 // In this case the object is deref'd and the entire node goes. 76 if (--oldNode->nodeAndObjectRefCount != 0) { 56 if (--oldNode->refCount != 0) { 77 57 if (newNode) 78 ++newNode-> nodeAndObjectRefCount;58 ++newNode->refCount; 79 59 } else { 80 oldNode->object->deref(); 81 if (oldNode->nodeOnlyRefCount == 0) 82 delete oldNode; 60 delete oldNode; 83 61 } 84 62 } … … 89 67 do { 90 68 ScopeChainNode *next = n->next; 91 n->object->deref(); 92 if (n->nodeOnlyRefCount == 0) 93 delete n; 69 delete n; 94 70 n = next; 95 } while (n && --n-> nodeAndObjectRefCount == 0);71 } while (n && --n->refCount == 0); 96 72 } 97 73 98 inline void NoRefScopeChain::ref() const 99 { 100 for (ScopeChainNode *n = _node; n; n = n->next) 101 if (n->nodeOnlyRefCount++ != 0) 102 break; 103 } 104 105 NoRefScopeChain &NoRefScopeChain::operator=(const ScopeChain &c) 106 { 107 c.ref(); 108 deref(); 109 _node = c._node; 110 return *this; 111 } 112 113 void NoRefScopeChain::mark() 74 void ScopeChain::mark() 114 75 { 115 76 for (ScopeChainNode *n = _node; n; n = n->next) { … … 120 81 } 121 82 122 void NoRefScopeChain::release()123 {124 ScopeChainNode *n = _node;125 do {126 ScopeChainNode *next = n->next;127 if (n->nodeAndObjectRefCount == 0)128 delete n;129 n = next;130 } while (n && --n->nodeOnlyRefCount == 0);131 }132 133 83 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.