Ignore:
Timestamp:
May 10, 2009, 9:30:14 PM (16 years ago)
Author:
Darin Adler
Message:

2009-05-10 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

Bug 25674: syntax tree nodes should use arena allocation
https://bugs.webkit.org/show_bug.cgi?id=25674

Part two: Remove reference counting from most nodes.

  • JavaScriptCore.xcodeproj/project.pbxproj: Added ParserArena.h and .cpp.
  • parser/Grammar.y: Replaced uses of ParserRefCountedData with uses of ParserArenaData. Took out now-nonfunctional code that tries to manually release declaration list. Changed the new calls that create FuncDeclNode and FuncExprNode so that they use the proper version of operator new for the reference-counted idiom, not the deletion idiom.
  • parser/NodeConstructors.h: (JSC::ParserArenaDeletable::operator new): Added. (JSC::ParserArenaRefCounted::ParserArenaRefCounted): Added. (JSC::Node::Node): Removed ParserRefCounted initializer. (JSC::ElementNode::ElementNode): Ditto. (JSC::PropertyNode::PropertyNode): Ditto. (JSC::ArgumentsNode::ArgumentsNode): Ditto. (JSC::SourceElements::SourceElements): Ditto. (JSC::ParameterNode::ParameterNode): Ditto. (JSC::FuncExprNode::FuncExprNode): Added ParserArenaRefCounted initializer. (JSC::FuncDeclNode::FuncDeclNode): Ditto. (JSC::CaseClauseNode::CaseClauseNode): Removed ParserRefCounted initializer. (JSC::ClauseListNode::ClauseListNode): Ditto. (JSC::CaseBlockNode::CaseBlockNode): Ditto.
  • parser/NodeInfo.h: Replaced uses of ParserRefCountedData with uses of ParserArenaData.
  • parser/Nodes.cpp: (JSC::ScopeNode::ScopeNode): Added ParserArenaRefCounted initializer. (JSC::ProgramNode::create): Use the proper version of operator new for the reference-counted idiom, not the deletion idiom. Use the arena contains function instead of the vecctor find function. (JSC::EvalNode::create): Use the proper version of operator new for the reference-counted idiom, not the deletion idiom. Use the arena reset function instead of the vector shrink function. (JSC::FunctionBodyNode::createNativeThunk): Use the proper version of operator new for the reference-counted idiom, not the deletion idiom. (JSC::FunctionBodyNode::create): More of the same.
  • parser/Nodes.h: Added ParserArenaDeletable and ParserArenaRefCounted to replace ParserRefCounted. Fixed inheritance so only the classes that need reference counting inherit from ParserArenaRefCounted.
  • parser/Parser.cpp: (JSC::Parser::parse): Set m_sourceElements to 0 since it now starts uninitialized. Just set it to 0 again in the failure case, since it's now just a raw pointer, not an owning one. (JSC::Parser::reparseInPlace): Removed now-unneeded get() function. (JSC::Parser::didFinishParsing): Replaced uses of ParserRefCountedData with uses of ParserArenaData.
  • parser/Parser.h: Less RefPtr, more arena.
  • parser/ParserArena.cpp: Added.
  • parser/ParserArena.h: Added.
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::~JSGlobalData): Removed arena-related code, since it's now in the Parser. (JSC::JSGlobalData::createLeaked): Removed unneeded #ifndef. (JSC::JSGlobalData::createNativeThunk): Tweaked #if a bit.
  • runtime/JSGlobalData.h: Removed parserArena, which is now in Parser.
  • wtf/RefCounted.h: Added deletionHasBegun function, for use in assertions to catch deletion not done by the deref function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/Nodes.cpp

    r43475 r43479  
    5151
    5252static void substitute(UString& string, const UString& substring) JSC_FAST_CALL;
    53 
    54 // ------------------------------ ParserRefCounted -----------------------------------------
    55 
    56 #ifndef NDEBUG
    57 
    58 static RefCountedLeakCounter parserRefCountedCounter("JSC::Node");
    59 
    60 ALWAYS_INLINE ParserRefCounted::ParserRefCounted(JSGlobalData* globalData)
    61 {
    62     globalData->parserArena.append(adoptRef(this));
    63     parserRefCountedCounter.increment();
    64 }
    65 
    66 ALWAYS_INLINE ParserRefCounted::~ParserRefCounted()
    67 {
    68     parserRefCountedCounter.decrement();
    69 }
    70 
    71 #endif
    7253
    7354// ------------------------------ ThrowableExpressionData --------------------------------
     
    18401821ScopeNode::ScopeNode(JSGlobalData* globalData)
    18411822    : StatementNode(globalData)
     1823    , ParserArenaRefCounted(globalData)
    18421824    , m_features(NoFeatures)
    18431825{
     
    18491831ScopeNode::ScopeNode(JSGlobalData* globalData, const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, CodeFeatures features, int numConstants)
    18501832    : StatementNode(globalData)
    1851     , m_data(new ScopeNodeData(globalData->parserArena, children, varStack, funcStack, numConstants))
     1833    , ParserArenaRefCounted(globalData)
     1834    , m_data(new ScopeNodeData(globalData->parser->arena(), children, varStack, funcStack, numConstants))
    18521835    , m_features(features)
    18531836    , m_source(source)
     
    18671850PassRefPtr<ProgramNode> ProgramNode::create(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, const SourceCode& source, CodeFeatures features, int numConstants)
    18681851{
    1869     RefPtr<ProgramNode> node = new (globalData) ProgramNode(globalData, children, varStack, funcStack, source, features, numConstants);
     1852    RefPtr<ProgramNode> node = new ProgramNode(globalData, children, varStack, funcStack, source, features, numConstants);
    18701853
    18711854    ASSERT(node->data()->m_arena.last() == node);
    18721855    node->data()->m_arena.removeLast();
    1873     ASSERT(node->data()->m_arena.find(node.get()) == notFound);
     1856    ASSERT(!node->data()->m_arena.contains(node.get()));
    18741857
    18751858    return node.release();
     
    19111894PassRefPtr<EvalNode> EvalNode::create(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, const SourceCode& source, CodeFeatures features, int numConstants)
    19121895{
    1913     RefPtr<EvalNode> node = new (globalData) EvalNode(globalData, children, varStack, funcStack, source, features, numConstants);
     1896    RefPtr<EvalNode> node = new EvalNode(globalData, children, varStack, funcStack, source, features, numConstants);
    19141897
    19151898    ASSERT(node->data()->m_arena.last() == node);
    19161899    node->data()->m_arena.removeLast();
    1917     ASSERT(node->data()->m_arena.find(node.get()) == notFound);
     1900    ASSERT(!node->data()->m_arena.contains(node.get()));
    19181901
    19191902    return node.release();
     
    20262009PassRefPtr<FunctionBodyNode> FunctionBodyNode::createNativeThunk(JSGlobalData* globalData)
    20272010{
    2028     RefPtr<FunctionBodyNode> body = new (globalData) FunctionBodyNode(globalData);
    2029     globalData->parserArena.shrink(0);
     2011    RefPtr<FunctionBodyNode> body = new FunctionBodyNode(globalData);
     2012    globalData->parser->arena().reset();
    20302013    body->m_jitCode = globalData->jitStubs.ctiNativeCallThunk();
    20312014    return body.release();
     
    20352018FunctionBodyNode* FunctionBodyNode::create(JSGlobalData* globalData)
    20362019{
    2037     return new (globalData) FunctionBodyNode(globalData);
     2020    return new FunctionBodyNode(globalData);
    20382021}
    20392022
    20402023PassRefPtr<FunctionBodyNode> FunctionBodyNode::create(JSGlobalData* globalData, SourceElements* children, VarStack* varStack, FunctionStack* funcStack, const SourceCode& sourceCode, CodeFeatures features, int numConstants)
    20412024{
    2042     RefPtr<FunctionBodyNode> node = new (globalData) FunctionBodyNode(globalData, children, varStack, funcStack, sourceCode, features, numConstants);
     2025    RefPtr<FunctionBodyNode> node = new FunctionBodyNode(globalData, children, varStack, funcStack, sourceCode, features, numConstants);
    20432026
    20442027    ASSERT(node->data()->m_arena.last() == node);
    20452028    node->data()->m_arena.removeLast();
    2046     ASSERT(node->data()->m_arena.find(node.get()) == notFound);
     2029    ASSERT(!node->data()->m_arena.contains(node.get()));
    20472030
    20482031    return node.release();
Note: See TracChangeset for help on using the changeset viewer.