Changeset 34791 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- Jun 25, 2008, 12:07:38 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r34784 r34791 107 107 #endif 108 108 109 static HashSet<ParserRefCounted*>* newTrackedObjects; 110 static HashCountedSet<ParserRefCounted*>* trackedObjectExtraRefCounts; 111 112 ParserRefCounted::ParserRefCounted() 109 ParserRefCounted::ParserRefCounted(JSGlobalData* globalData) 110 : m_globalData(globalData) 113 111 { 114 112 #ifndef NDEBUG 115 113 ParserRefCountedCounter::increment(); 116 114 #endif 117 if (! newTrackedObjects)118 newTrackedObjects = new HashSet<ParserRefCounted*>;119 newTrackedObjects->add(this);120 ASSERT( newTrackedObjects->contains(this));115 if (!m_globalData->newTrackedObjects) 116 m_globalData->newTrackedObjects = new HashSet<ParserRefCounted*>; 117 m_globalData->newTrackedObjects->add(this); 118 ASSERT(m_globalData->newTrackedObjects->contains(this)); 121 119 } 122 120 … … 131 129 { 132 130 // bumping from 0 to 1 is just removing from the new nodes set 133 if ( newTrackedObjects) {134 HashSet<ParserRefCounted*>::iterator it = newTrackedObjects->find(this);135 if (it != newTrackedObjects->end()) {136 newTrackedObjects->remove(it);137 ASSERT(! trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(this));131 if (m_globalData->newTrackedObjects) { 132 HashSet<ParserRefCounted*>::iterator it = m_globalData->newTrackedObjects->find(this); 133 if (it != m_globalData->newTrackedObjects->end()) { 134 m_globalData->newTrackedObjects->remove(it); 135 ASSERT(!m_globalData->trackedObjectExtraRefCounts || !m_globalData->trackedObjectExtraRefCounts->contains(this)); 138 136 return; 139 137 } 140 138 } 141 139 142 ASSERT(! newTrackedObjects || !newTrackedObjects->contains(this));143 144 if (! trackedObjectExtraRefCounts)145 trackedObjectExtraRefCounts = new HashCountedSet<ParserRefCounted*>;146 trackedObjectExtraRefCounts->add(this);140 ASSERT(!m_globalData->newTrackedObjects || !m_globalData->newTrackedObjects->contains(this)); 141 142 if (!m_globalData->trackedObjectExtraRefCounts) 143 m_globalData->trackedObjectExtraRefCounts = new HashCountedSet<ParserRefCounted*>; 144 m_globalData->trackedObjectExtraRefCounts->add(this); 147 145 } 148 146 149 147 void ParserRefCounted::deref() 150 148 { 151 ASSERT(! newTrackedObjects || !newTrackedObjects->contains(this));152 153 if (! trackedObjectExtraRefCounts) {149 ASSERT(!m_globalData->newTrackedObjects || !m_globalData->newTrackedObjects->contains(this)); 150 151 if (!m_globalData->trackedObjectExtraRefCounts) { 154 152 delete this; 155 153 return; 156 154 } 157 155 158 HashCountedSet<ParserRefCounted*>::iterator it = trackedObjectExtraRefCounts->find(this);159 if (it == trackedObjectExtraRefCounts->end())156 HashCountedSet<ParserRefCounted*>::iterator it = m_globalData->trackedObjectExtraRefCounts->find(this); 157 if (it == m_globalData->trackedObjectExtraRefCounts->end()) 160 158 delete this; 161 159 else 162 trackedObjectExtraRefCounts->remove(it);160 m_globalData->trackedObjectExtraRefCounts->remove(it); 163 161 } 164 162 165 163 bool ParserRefCounted::hasOneRef() 166 164 { 167 if ( newTrackedObjects &&newTrackedObjects->contains(this)) {168 ASSERT(! trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(this));165 if (m_globalData->newTrackedObjects && m_globalData->newTrackedObjects->contains(this)) { 166 ASSERT(!m_globalData->trackedObjectExtraRefCounts || !m_globalData->trackedObjectExtraRefCounts->contains(this)); 169 167 return false; 170 168 } 171 169 172 ASSERT(! newTrackedObjects || !newTrackedObjects->contains(this));173 174 if (! trackedObjectExtraRefCounts)170 ASSERT(!m_globalData->newTrackedObjects || !m_globalData->newTrackedObjects->contains(this)); 171 172 if (!m_globalData->trackedObjectExtraRefCounts) 175 173 return true; 176 174 177 return ! trackedObjectExtraRefCounts->contains(this);178 } 179 180 void ParserRefCounted::deleteNewObjects( )181 { 182 if (! newTrackedObjects)175 return !m_globalData->trackedObjectExtraRefCounts->contains(this); 176 } 177 178 void ParserRefCounted::deleteNewObjects(JSGlobalData* globalData) 179 { 180 if (!globalData->newTrackedObjects) 183 181 return; 184 182 185 183 #ifndef NDEBUG 186 HashSet<ParserRefCounted*>::iterator end = newTrackedObjects->end();187 for (HashSet<ParserRefCounted*>::iterator it = newTrackedObjects->begin(); it != end; ++it)188 ASSERT(! trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(*it));184 HashSet<ParserRefCounted*>::iterator end = globalData->newTrackedObjects->end(); 185 for (HashSet<ParserRefCounted*>::iterator it = globalData->newTrackedObjects->begin(); it != end; ++it) 186 ASSERT(!globalData->trackedObjectExtraRefCounts || !globalData->trackedObjectExtraRefCounts->contains(*it)); 189 187 #endif 190 deleteAllValues(*newTrackedObjects); 191 delete newTrackedObjects; 192 newTrackedObjects = 0; 193 } 194 195 Node::Node() 196 : m_expectedReturnType(ObjectType) 197 { 198 m_line = JSGlobalData::threadInstance().lexer->lineNo(); 199 } 200 201 Node::Node(JSType expectedReturn) 202 : m_expectedReturnType(expectedReturn) 203 { 204 m_line = JSGlobalData::threadInstance().lexer->lineNo(); 188 deleteAllValues(*globalData->newTrackedObjects); 189 delete globalData->newTrackedObjects; 190 globalData->newTrackedObjects = 0; 191 } 192 193 Node::Node(JSGlobalData* globalData) 194 : ParserRefCounted(globalData) 195 , m_expectedReturnType(ObjectType) 196 { 197 m_line = globalData->lexer->lineNo(); 198 } 199 200 Node::Node(JSGlobalData* globalData, JSType expectedReturn) 201 : ParserRefCounted(globalData) 202 , m_expectedReturnType(expectedReturn) 203 { 204 m_line = globalData->lexer->lineNo(); 205 205 } 206 206 … … 248 248 // ------------------------------ StatementNode -------------------------------- 249 249 250 StatementNode::StatementNode() 251 : m_lastLine(-1) 250 StatementNode::StatementNode(JSGlobalData* globalData) 251 : Node(globalData) 252 , m_lastLine(-1) 252 253 { 253 254 m_line = -1; … … 272 273 // ------------------------------ BreakpointCheckStatement -------------------------------- 273 274 274 BreakpointCheckStatement::BreakpointCheckStatement(PassRefPtr<StatementNode> statement) 275 : m_statement(statement) 275 BreakpointCheckStatement::BreakpointCheckStatement(JSGlobalData* globalData, PassRefPtr<StatementNode> statement) 276 : StatementNode(globalData) 277 , m_statement(statement) 276 278 { 277 279 ASSERT(m_statement); … … 1023 1025 // ------------------------------ ConstDeclNode ---------------------------------- 1024 1026 1025 ConstDeclNode::ConstDeclNode(const Identifier& ident, ExpressionNode* init) 1026 : m_ident(ident) 1027 ConstDeclNode::ConstDeclNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* init) 1028 : ExpressionNode(globalData) 1029 , m_ident(ident) 1027 1030 , m_init(init) 1028 1031 { … … 1107 1110 // ------------------------------ BlockNode ------------------------------------ 1108 1111 1109 BlockNode::BlockNode(SourceElements* children) 1112 BlockNode::BlockNode(JSGlobalData* globalData, SourceElements* children) 1113 : StatementNode(globalData) 1110 1114 { 1111 1115 if (children) … … 1265 1269 // ------------------------------ ForInNode ------------------------------------ 1266 1270 1267 ForInNode::ForInNode(ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) 1268 : m_init(0L) 1271 ForInNode::ForInNode(JSGlobalData* globalData, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) 1272 : StatementNode(globalData) 1273 , m_init(0L) 1269 1274 , m_lexpr(l) 1270 1275 , m_expr(expr) … … 1274 1279 } 1275 1280 1276 ForInNode::ForInNode(const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement) 1277 : m_ident(ident) 1278 , m_lexpr(new ResolveNode(ident)) 1281 ForInNode::ForInNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement) 1282 : StatementNode(globalData) 1283 , m_ident(ident) 1284 , m_lexpr(new ResolveNode(globalData, ident)) 1279 1285 , m_expr(expr) 1280 1286 , m_statement(statement) … … 1282 1288 { 1283 1289 if (in) 1284 m_init = new AssignResolveNode( ident, in, true);1290 m_init = new AssignResolveNode(globalData,ident, in, true); 1285 1291 // for( var foo = bar in baz ) 1286 1292 } … … 1566 1572 // ------------------------------ FunctionBodyNode ----------------------------- 1567 1573 1568 ScopeNode::ScopeNode( SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)1569 : BlockNode( children)1570 , m_sourceURL( JSGlobalData::threadInstance().parser->sourceURL())1571 , m_sourceId( JSGlobalData::threadInstance().parser->sourceId())1574 ScopeNode::ScopeNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1575 : BlockNode(globalData, children) 1576 , m_sourceURL(globalData->parser->sourceURL()) 1577 , m_sourceId(globalData->parser->sourceId()) 1572 1578 , m_usesEval(usesEval) 1573 1579 , m_needsClosure(needsClosure) … … 1581 1587 // ------------------------------ ProgramNode ----------------------------- 1582 1588 1583 ProgramNode::ProgramNode( SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)1584 : ScopeNode( children, varStack, funcStack, usesEval, needsClosure)1585 { 1586 } 1587 1588 ProgramNode* ProgramNode::create( SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)1589 { 1590 return new ProgramNode( children, varStack, funcStack, usesEval, needsClosure);1589 ProgramNode::ProgramNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1590 : ScopeNode(globalData, children, varStack, funcStack, usesEval, needsClosure) 1591 { 1592 } 1593 1594 ProgramNode* ProgramNode::create(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1595 { 1596 return new ProgramNode(globalData, children, varStack, funcStack, usesEval, needsClosure); 1591 1597 } 1592 1598 1593 1599 // ------------------------------ EvalNode ----------------------------- 1594 1600 1595 EvalNode::EvalNode( SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)1596 : ScopeNode( children, varStack, funcStack, usesEval, needsClosure)1601 EvalNode::EvalNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1602 : ScopeNode(globalData, children, varStack, funcStack, usesEval, needsClosure) 1597 1603 { 1598 1604 } … … 1624 1630 } 1625 1631 1626 EvalNode* EvalNode::create( SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)1627 { 1628 return new EvalNode( children, varStack, funcStack, usesEval, needsClosure);1632 EvalNode* EvalNode::create(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1633 { 1634 return new EvalNode(globalData, children, varStack, funcStack, usesEval, needsClosure); 1629 1635 } 1630 1636 1631 1637 // ------------------------------ FunctionBodyNode ----------------------------- 1632 1638 1633 FunctionBodyNode::FunctionBodyNode( SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)1634 : ScopeNode( children, varStack, funcStack, usesEval, needsClosure)1639 FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1640 : ScopeNode(globalData, children, varStack, funcStack, usesEval, needsClosure) 1635 1641 { 1636 1642 } … … 1642 1648 } 1643 1649 1644 FunctionBodyNode* FunctionBodyNode::create( SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)1645 { 1646 return new FunctionBodyNode( children, varStack, funcStack, usesEval, needsClosure);1650 FunctionBodyNode* FunctionBodyNode::create(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure) 1651 { 1652 return new FunctionBodyNode(globalData, children, varStack, funcStack, usesEval, needsClosure); 1647 1653 } 1648 1654
Note:
See TracChangeset
for help on using the changeset viewer.