Changeset 43259 in webkit for trunk/JavaScriptCore/parser/Nodes.h


Ignore:
Timestamp:
May 5, 2009, 4:09:52 PM (16 years ago)
Author:
Darin Adler
Message:

2009-05-05 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

Bug 25569: make ParserRefCounted use conventional reference counting
https://bugs.webkit.org/show_bug.cgi?id=25569

SunSpider speedup of about 1.6%.

  • parser/Nodes.cpp: (JSC::NodeReleaser::releaseAllNodes): ALWAYS_INLINE. (JSC::NodeReleaser::adopt): Ditto. (JSC::ParserRefCounted::ParserRefCounted): Removed most of the code. Add the object to a Vector<RefPtr> that gets cleared after parsing. (JSC::ParserRefCounted::~ParserRefCounted): Removed most of the code.
  • parser/Nodes.h: Made ParserRefCounted inherit from RefCounted and made inline versions of the constructor and destructor. Made the Node constructor inline.
  • parser/Parser.cpp: (JSC::Parser::parse): Call globalData->parserObjects.shrink(0) after parsing, where it used to call ParserRefCounted::deleteNewObjects.
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): Eliminated code to manage the newParserObjects and parserObjectExtraRefCounts. (JSC::JSGlobalData::~JSGlobalData): Ditto.
  • runtime/JSGlobalData.h: Replaced the HashSet and HashCountedSet with a Vector.
  • wtf/PassRefPtr.h: (WTF::PassRefPtr::~PassRefPtr): The most common thing to do with a PassRefPtr in hot code is to pass it and then destroy it once it's set to zero. Help the optimizer by telling it that's true.
File:
1 edited

Legend:

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

    r43230 r43259  
    2929#include "Error.h"
    3030#include "JITCode.h"
     31#include "Lexer.h"
    3132#include "Opcode.h"
    3233#include "ResultType.h"
     
    3536#include <wtf/MathExtras.h>
    3637#include <wtf/OwnPtr.h>
    37 #include <wtf/Vector.h>
    3838
    3939#if PLATFORM(X86) && COMPILER(GCC)
     
    103103    };
    104104
    105     class ParserRefCounted : Noncopyable {
     105    class ParserRefCounted : public RefCounted<ParserRefCounted> {
    106106    protected:
    107107        ParserRefCounted(JSGlobalData*) JSC_FAST_CALL;
     
    112112        // Nonrecursive destruction.
    113113        virtual void releaseNodes(NodeReleaser&);
    114 
    115         void ref() JSC_FAST_CALL;
    116         void deref() JSC_FAST_CALL;
    117         bool hasOneRef() JSC_FAST_CALL;
    118 
    119         static void deleteNewObjects(JSGlobalData*) JSC_FAST_CALL;
    120 
    121     private:
    122         JSGlobalData* m_globalData;
    123     };
     114    };
     115
     116#ifdef NDEBUG
     117    inline ParserRefCounted::ParserRefCounted(JSGlobalData* globalData)
     118    {
     119        globalData->parserObjects.append(adoptRef(this));
     120    }
     121
     122    inline ParserRefCounted::~ParserRefCounted()
     123    {
     124    }
     125#endif
    124126
    125127    class Node : public ParserRefCounted {
    126128    public:
    127         Node(JSGlobalData*) JSC_FAST_CALL;
     129        Node(JSGlobalData* globalData) JSC_FAST_CALL
     130            : ParserRefCounted(globalData)
     131            , m_line(globalData->lexer->lineNumber())
     132        {
     133        }
    128134
    129135        /*
Note: See TracChangeset for help on using the changeset viewer.