Changeset 34791 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Jun 25, 2008, 12:07:38 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoff.

Remove more threadInstance() calls.

  • kjs/JSFunction.cpp: (KJS::JSFunction::getParameterName): (KJS::IndexToNameMap::unMap): (KJS::Arguments::deleteProperty):
  • kjs/JSFunction.h: Access nullIdentifier without going to thread specific storage.
  • JavaScriptCore.exp:
  • kjs/JSGlobalData.cpp: (KJS::JSGlobalData::JSGlobalData):
  • kjs/JSGlobalData.h:
  • kjs/Parser.cpp: (KJS::Parser::parse):
  • kjs/Parser.h: (KJS::ParserRefCountedData::ParserRefCountedData): (KJS::Parser::parse):
  • kjs/grammar.y:
  • kjs/nodes.cpp: (KJS::ParserRefCounted::ParserRefCounted): (KJS::ParserRefCounted::ref): (KJS::ParserRefCounted::deref): (KJS::ParserRefCounted::hasOneRef): (KJS::ParserRefCounted::deleteNewObjects): (KJS::Node::Node): (KJS::StatementNode::StatementNode): (KJS::BreakpointCheckStatement::BreakpointCheckStatement): (KJS::ConstDeclNode::ConstDeclNode): (KJS::BlockNode::BlockNode): (KJS::ForInNode::ForInNode): (KJS::ScopeNode::ScopeNode): (KJS::ProgramNode::ProgramNode): (KJS::ProgramNode::create): (KJS::EvalNode::EvalNode): (KJS::EvalNode::create): (KJS::FunctionBodyNode::FunctionBodyNode): (KJS::FunctionBodyNode::create):
  • kjs/nodes.h: (KJS::ExpressionNode::): (KJS::NullNode::): (KJS::BooleanNode::): (KJS::NumberNode::): (KJS::ImmediateNumberNode::): (KJS::StringNode::): (KJS::RegExpNode::): (KJS::ThisNode::): (KJS::ResolveNode::): (KJS::ElementNode::): (KJS::ArrayNode::): (KJS::PropertyNode::): (KJS::PropertyListNode::): (KJS::ObjectLiteralNode::): (KJS::BracketAccessorNode::): (KJS::DotAccessorNode::): (KJS::ArgumentListNode::): (KJS::ArgumentsNode::): (KJS::NewExprNode::): (KJS::EvalFunctionCallNode::): (KJS::FunctionCallValueNode::): (KJS::FunctionCallResolveNode::): (KJS::FunctionCallBracketNode::): (KJS::FunctionCallDotNode::): (KJS::PrePostResolveNode::): (KJS::PostIncResolveNode::): (KJS::PostDecResolveNode::): (KJS::PostfixBracketNode::): (KJS::PostIncBracketNode::): (KJS::PostDecBracketNode::): (KJS::PostfixDotNode::): (KJS::PostIncDotNode::): (KJS::PostDecDotNode::): (KJS::PostfixErrorNode::): (KJS::DeleteResolveNode::): (KJS::DeleteBracketNode::): (KJS::DeleteDotNode::): (KJS::DeleteValueNode::): (KJS::VoidNode::): (KJS::TypeOfResolveNode::): (KJS::TypeOfValueNode::): (KJS::PreIncResolveNode::): (KJS::PreDecResolveNode::): (KJS::PrefixBracketNode::): (KJS::PreIncBracketNode::): (KJS::PreDecBracketNode::): (KJS::PrefixDotNode::): (KJS::PreIncDotNode::): (KJS::PreDecDotNode::): (KJS::PrefixErrorNode::): (KJS::UnaryOpNode::UnaryOpNode): (KJS::UnaryPlusNode::): (KJS::NegateNode::): (KJS::BitwiseNotNode::): (KJS::LogicalNotNode::): (KJS::BinaryOpNode::BinaryOpNode): (KJS::ReverseBinaryOpNode::ReverseBinaryOpNode): (KJS::MultNode::): (KJS::DivNode::): (KJS::ModNode::): (KJS::AddNode::): (KJS::SubNode::): (KJS::LeftShiftNode::): (KJS::RightShiftNode::): (KJS::UnsignedRightShiftNode::): (KJS::LessNode::): (KJS::GreaterNode::): (KJS::LessEqNode::): (KJS::GreaterEqNode::): (KJS::InstanceOfNode::): (KJS::InNode::): (KJS::EqualNode::): (KJS::NotEqualNode::): (KJS::StrictEqualNode::): (KJS::NotStrictEqualNode::): (KJS::BitAndNode::): (KJS::BitOrNode::): (KJS::BitXOrNode::): (KJS::LogicalAndNode::): (KJS::LogicalOrNode::): (KJS::ConditionalNode::): (KJS::ReadModifyResolveNode::): (KJS::AssignResolveNode::): (KJS::ReadModifyBracketNode::): (KJS::AssignBracketNode::): (KJS::AssignDotNode::): (KJS::ReadModifyDotNode::): (KJS::AssignErrorNode::): (KJS::CommaNode::): (KJS::VarDeclCommaNode::): (KJS::ConstStatementNode::): (KJS::SourceElements::SourceElements): (KJS::EmptyStatementNode::): (KJS::DebuggerStatementNode::): (KJS::ExprStatementNode::): (KJS::VarStatementNode::): (KJS::IfNode::): (KJS::IfElseNode::): (KJS::DoWhileNode::): (KJS::WhileNode::): (KJS::ForNode::): (KJS::ContinueNode::): (KJS::BreakNode::): (KJS::ReturnNode::): (KJS::WithNode::): (KJS::LabelNode::): (KJS::ThrowNode::): (KJS::TryNode::): (KJS::ParameterNode::): (KJS::FuncExprNode::): (KJS::FuncDeclNode::): (KJS::CaseClauseNode::): (KJS::ClauseListNode::): (KJS::CaseBlockNode::): (KJS::SwitchNode::): Changed ParserRefCounted to hold a JSGlobalData pointer, and used it to replace threadInstance calls.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r34784 r34791  
    107107#endif
    108108
    109 static HashSet<ParserRefCounted*>* newTrackedObjects;
    110 static HashCountedSet<ParserRefCounted*>* trackedObjectExtraRefCounts;
    111 
    112 ParserRefCounted::ParserRefCounted()
     109ParserRefCounted::ParserRefCounted(JSGlobalData* globalData)
     110    : m_globalData(globalData)
    113111{
    114112#ifndef NDEBUG
    115113    ParserRefCountedCounter::increment();
    116114#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));
    121119}
    122120
     
    131129{
    132130    // 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));
    138136            return;
    139137        }
    140138    }
    141139
    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);
    147145}
    148146
    149147void ParserRefCounted::deref()
    150148{
    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) {
    154152        delete this;
    155153        return;
    156154    }
    157155
    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())
    160158        delete this;
    161159    else
    162         trackedObjectExtraRefCounts->remove(it);
     160        m_globalData->trackedObjectExtraRefCounts->remove(it);
    163161}
    164162
    165163bool ParserRefCounted::hasOneRef()
    166164{
    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));
    169167        return false;
    170168    }
    171169
    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)
    175173        return true;
    176174
    177     return !trackedObjectExtraRefCounts->contains(this);
    178 }
    179 
    180 void ParserRefCounted::deleteNewObjects()
    181 {
    182     if (!newTrackedObjects)
     175    return !m_globalData->trackedObjectExtraRefCounts->contains(this);
     176}
     177
     178void ParserRefCounted::deleteNewObjects(JSGlobalData* globalData)
     179{
     180    if (!globalData->newTrackedObjects)
    183181        return;
    184182
    185183#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));
    189187#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
     193Node::Node(JSGlobalData* globalData)
     194    : ParserRefCounted(globalData)
     195    , m_expectedReturnType(ObjectType)
     196{
     197    m_line = globalData->lexer->lineNo();
     198}
     199
     200Node::Node(JSGlobalData* globalData, JSType expectedReturn)
     201    : ParserRefCounted(globalData)
     202    , m_expectedReturnType(expectedReturn)
     203{
     204    m_line = globalData->lexer->lineNo();
    205205}
    206206
     
    248248// ------------------------------ StatementNode --------------------------------
    249249
    250 StatementNode::StatementNode()
    251     : m_lastLine(-1)
     250StatementNode::StatementNode(JSGlobalData* globalData)
     251    : Node(globalData)
     252    , m_lastLine(-1)
    252253{
    253254    m_line = -1;
     
    272273// ------------------------------ BreakpointCheckStatement --------------------------------
    273274
    274 BreakpointCheckStatement::BreakpointCheckStatement(PassRefPtr<StatementNode> statement)
    275     : m_statement(statement)
     275BreakpointCheckStatement::BreakpointCheckStatement(JSGlobalData* globalData, PassRefPtr<StatementNode> statement)
     276    : StatementNode(globalData)
     277    , m_statement(statement)
    276278{
    277279    ASSERT(m_statement);
     
    10231025// ------------------------------ ConstDeclNode ----------------------------------
    10241026
    1025 ConstDeclNode::ConstDeclNode(const Identifier& ident, ExpressionNode* init)
    1026     : m_ident(ident)
     1027ConstDeclNode::ConstDeclNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* init)
     1028    : ExpressionNode(globalData)
     1029    , m_ident(ident)
    10271030    , m_init(init)
    10281031{
     
    11071110// ------------------------------ BlockNode ------------------------------------
    11081111
    1109 BlockNode::BlockNode(SourceElements* children)
     1112BlockNode::BlockNode(JSGlobalData* globalData, SourceElements* children)
     1113    : StatementNode(globalData)
    11101114{
    11111115    if (children)
     
    12651269// ------------------------------ ForInNode ------------------------------------
    12661270
    1267 ForInNode::ForInNode(ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
    1268     : m_init(0L)
     1271ForInNode::ForInNode(JSGlobalData* globalData, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
     1272    : StatementNode(globalData)
     1273    , m_init(0L)
    12691274    , m_lexpr(l)
    12701275    , m_expr(expr)
     
    12741279}
    12751280
    1276 ForInNode::ForInNode(const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement)
    1277     : m_ident(ident)
    1278     , m_lexpr(new ResolveNode(ident))
     1281ForInNode::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))
    12791285    , m_expr(expr)
    12801286    , m_statement(statement)
     
    12821288{
    12831289    if (in)
    1284         m_init = new AssignResolveNode(ident, in, true);
     1290        m_init = new AssignResolveNode(globalData,ident, in, true);
    12851291    // for( var foo = bar in baz )
    12861292}
     
    15661572// ------------------------------ FunctionBodyNode -----------------------------
    15671573
    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())
     1574ScopeNode::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())
    15721578    , m_usesEval(usesEval)
    15731579    , m_needsClosure(needsClosure)
     
    15811587// ------------------------------ ProgramNode -----------------------------
    15821588
    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);
     1589ProgramNode::ProgramNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     1590    : ScopeNode(globalData, children, varStack, funcStack, usesEval, needsClosure)
     1591{
     1592}
     1593
     1594ProgramNode* 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);
    15911597}
    15921598
    15931599// ------------------------------ EvalNode -----------------------------
    15941600
    1595 EvalNode::EvalNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
    1596     : ScopeNode(children, varStack, funcStack, usesEval, needsClosure)
     1601EvalNode::EvalNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     1602    : ScopeNode(globalData, children, varStack, funcStack, usesEval, needsClosure)
    15971603{
    15981604}
     
    16241630}
    16251631
    1626 EvalNode* EvalNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
    1627 {
    1628     return new EvalNode(children, varStack, funcStack, usesEval, needsClosure);
     1632EvalNode* 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);
    16291635}
    16301636
    16311637// ------------------------------ FunctionBodyNode -----------------------------
    16321638
    1633 FunctionBodyNode::FunctionBodyNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
    1634     : ScopeNode(children, varStack, funcStack, usesEval, needsClosure)
     1639FunctionBodyNode::FunctionBodyNode(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     1640    : ScopeNode(globalData, children, varStack, funcStack, usesEval, needsClosure)
    16351641{
    16361642}
     
    16421648}
    16431649
    1644 FunctionBodyNode* FunctionBodyNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
    1645 {
    1646     return new FunctionBodyNode(children, varStack, funcStack, usesEval, needsClosure);
     1650FunctionBodyNode* 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);
    16471653}
    16481654
Note: See TracChangeset for help on using the changeset viewer.