Changeset 43259 in webkit for trunk/JavaScriptCore/parser/Nodes.cpp
- Timestamp:
- May 5, 2009, 4:09:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/Nodes.cpp
r43230 r43259 29 29 #include "BytecodeGenerator.h" 30 30 #include "CallFrame.h" 31 #include "Debugger.h" 31 32 #include "JIT.h" 32 33 #include "JSFunction.h" … … 34 35 #include "JSStaticScopeObject.h" 35 36 #include "LabelScope.h" 37 #include "Operations.h" 36 38 #include "Parser.h" 37 39 #include "PropertyNameArray.h" 38 40 #include "RegExpObject.h" 39 41 #include "SamplingTool.h" 40 #include "Debugger.h"41 #include "Lexer.h"42 #include "Operations.h"43 #include <math.h>44 42 #include <wtf/Assertions.h> 45 #include <wtf/HashCountedSet.h>46 #include <wtf/HashSet.h>47 #include <wtf/MathExtras.h>48 43 #include <wtf/RefCountedLeakCounter.h> 49 44 #include <wtf/Threading.h> … … 81 76 }; 82 77 83 void NodeReleaser::releaseAllNodes(ParserRefCounted* root)78 ALWAYS_INLINE void NodeReleaser::releaseAllNodes(ParserRefCounted* root) 84 79 { 85 80 ASSERT(root); … … 97 92 } 98 93 99 void NodeReleaser::adopt(PassRefPtr<ParserRefCounted> node)94 ALWAYS_INLINE void NodeReleaser::adopt(PassRefPtr<ParserRefCounted> node) 100 95 { 101 96 ASSERT(node); … … 122 117 123 118 #ifndef NDEBUG 119 124 120 static RefCountedLeakCounter parserRefCountedCounter("JSC::Node"); 121 122 ALWAYS_INLINE ParserRefCounted::ParserRefCounted(JSGlobalData* globalData) 123 { 124 globalData->parserObjects.append(adoptRef(this)); 125 parserRefCountedCounter.increment(); 126 } 127 128 ALWAYS_INLINE ParserRefCounted::~ParserRefCounted() 129 { 130 parserRefCountedCounter.decrement(); 131 } 132 125 133 #endif 126 134 127 ParserRefCounted::ParserRefCounted(JSGlobalData* globalData)128 : m_globalData(globalData)129 {130 #ifndef NDEBUG131 parserRefCountedCounter.increment();132 #endif133 if (!m_globalData->newParserObjects)134 m_globalData->newParserObjects = new HashSet<ParserRefCounted*>;135 m_globalData->newParserObjects->add(this);136 ASSERT(m_globalData->newParserObjects->contains(this));137 }138 139 ParserRefCounted::~ParserRefCounted()140 {141 #ifndef NDEBUG142 parserRefCountedCounter.decrement();143 #endif144 }145 146 135 void ParserRefCounted::releaseNodes(NodeReleaser&) 147 136 { 148 }149 150 void ParserRefCounted::ref()151 {152 // bumping from 0 to 1 is just removing from the new nodes set153 if (m_globalData->newParserObjects) {154 HashSet<ParserRefCounted*>::iterator it = m_globalData->newParserObjects->find(this);155 if (it != m_globalData->newParserObjects->end()) {156 m_globalData->newParserObjects->remove(it);157 ASSERT(!m_globalData->parserObjectExtraRefCounts || !m_globalData->parserObjectExtraRefCounts->contains(this));158 return;159 }160 }161 162 ASSERT(!m_globalData->newParserObjects || !m_globalData->newParserObjects->contains(this));163 164 if (!m_globalData->parserObjectExtraRefCounts)165 m_globalData->parserObjectExtraRefCounts = new HashCountedSet<ParserRefCounted*>;166 m_globalData->parserObjectExtraRefCounts->add(this);167 }168 169 void ParserRefCounted::deref()170 {171 ASSERT(!m_globalData->newParserObjects || !m_globalData->newParserObjects->contains(this));172 173 if (!m_globalData->parserObjectExtraRefCounts) {174 delete this;175 return;176 }177 178 HashCountedSet<ParserRefCounted*>::iterator it = m_globalData->parserObjectExtraRefCounts->find(this);179 if (it == m_globalData->parserObjectExtraRefCounts->end())180 delete this;181 else182 m_globalData->parserObjectExtraRefCounts->remove(it);183 }184 185 bool ParserRefCounted::hasOneRef()186 {187 if (m_globalData->newParserObjects && m_globalData->newParserObjects->contains(this)) {188 ASSERT(!m_globalData->parserObjectExtraRefCounts || !m_globalData->parserObjectExtraRefCounts->contains(this));189 return false;190 }191 192 ASSERT(!m_globalData->newParserObjects || !m_globalData->newParserObjects->contains(this));193 194 if (!m_globalData->parserObjectExtraRefCounts)195 return true;196 197 return !m_globalData->parserObjectExtraRefCounts->contains(this);198 }199 200 void ParserRefCounted::deleteNewObjects(JSGlobalData* globalData)201 {202 if (!globalData->newParserObjects)203 return;204 205 #ifndef NDEBUG206 HashSet<ParserRefCounted*>::iterator end = globalData->newParserObjects->end();207 for (HashSet<ParserRefCounted*>::iterator it = globalData->newParserObjects->begin(); it != end; ++it)208 ASSERT(!globalData->parserObjectExtraRefCounts || !globalData->parserObjectExtraRefCounts->contains(*it));209 #endif210 deleteAllValues(*globalData->newParserObjects);211 delete globalData->newParserObjects;212 globalData->newParserObjects = 0;213 }214 215 // ------------------------------ Node --------------------------------216 217 Node::Node(JSGlobalData* globalData)218 : ParserRefCounted(globalData)219 {220 m_line = globalData->lexer->lineNumber();221 137 } 222 138
Note:
See TracChangeset
for help on using the changeset viewer.