Changeset 28937 in webkit for trunk/JavaScriptCore/wtf/RefPtr.h


Ignore:
Timestamp:
Dec 21, 2007, 1:54:51 PM (17 years ago)
Author:
Darin Adler
Message:

Reviewed by Eric.

1.022x as fast on SunSpider.

  • kjs/NodeInfo.h: Renamed SourceElementsStub to SourceElements, since that more accurately describes the role of this object, which is a reference-counted wrapper for a Vector.
  • kjs/Parser.cpp: (KJS::Parser::didFinishParsing): Changed parameter type to SourceElements, and use plain assignment instead of set.
  • kjs/Parser.h: Changed parameter type of didFinishParsing to a SourceElements. Also changed m_sourceElements; we now use a RefPtr instead of an OwnPtr as well.
  • kjs/grammar.y: Got rid of all the calls to release() on SourceElements. That's now handed inside the constructors for various node types, since we now use vector swapping instead.
  • kjs/nodes.cpp: (KJS::Node::rethrowException): Added NEVER_INLINE, because this was getting inlined and we want exception handling out of the normal code flow. (KJS::SourceElements::append): Moved here from the header. This now handles creating a BreakpointCheckStatement for each statement in the debugger case. That way we can get breakpoint handling without having it in every execute function. (KJS::BreakpointCheckStatement::BreakpointCheckStatement): Added. (KJS::BreakpointCheckStatement::execute): Added. Contains the code that was formerly in the StatementNode::hitStatement function and the KJS_BREAKPOINT macro. (KJS::BreakpointCheckStatement::streamTo): Added. (KJS::ArgumentListNode::evaluateList): Use KJS_CHECKEXCEPTIONVOID since the return type is void. (KJS::VarStatementNode::execute): Removed KJS_BREAKPOINT. (KJS::BlockNode::BlockNode): Changed parameter type to SourceElements. Changed code to use release since the class now contains a vector rather than a vector point. (KJS::BlockNode::optimizeVariableAccess): Updated since member is now a vector rather than a vector pointer. (KJS::BlockNode::execute): Ditto. (KJS::ExprStatementNode::execute): Removed KJS_BREAKPOINT. (KJS::IfNode::execute): Ditto. (KJS::IfElseNode::execute): Ditto. (KJS::DoWhileNode::execute): Ditto. (KJS::WhileNode::execute): Ditto. (KJS::ContinueNode::execute): Ditto. (KJS::BreakNode::execute): Ditto. (KJS::ReturnNode::execute): Ditto. (KJS::WithNode::execute): Ditto. (KJS::CaseClauseNode::optimizeVariableAccess): Updated since member is now a vector rather than a vector pointer. (KJS::CaseClauseNode::executeStatements): Ditto. (KJS::SwitchNode::execute): Removed KJS_BREAKPOINT. (KJS::ThrowNode::execute): Ditto. (KJS::TryNode::execute): Ditto. (KJS::ScopeNode::ScopeNode): Changed parameter type to SourceElements. (KJS::ProgramNode::ProgramNode): Ditto. (KJS::EvalNode::EvalNode): Ditto. (KJS::FunctionBodyNode::FunctionBodyNode): Ditto. (KJS::ScopeNode::optimizeVariableAccess): Updated since member is now a vector rather than a vector pointer.
  • kjs/nodes.h: Removed hitStatement. Renamed SourceElements to StatementVector. Renamed SourceElementsStub to SourceElements and made it derive from ParserRefCounted rather than from Node, hold a vector rather than a pointer to a vector, and changed the release function to swap with another vector rather than the pointer idiom. Updated BlockNode and CaseClauseNode to hold actual vectors instead of pointers to vectors. Added BreakpointCheckStatement.
  • kjs/nodes2string.cpp: (KJS::statementListStreamTo): Changed to work on a vector instead of a pointer to a vector. (KJS::BlockNode::streamTo): Ditto. (KJS::CaseClauseNode::streamTo): Ditto.
  • wtf/AlwaysInline.h: Added NEVER_INLINE.
  • wtf/PassRefPtr.h: Tweaked formatting. Added clear() function that matches the ones in OwnPtr and auto_ptr.
  • wtf/RefPtr.h: Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/RefPtr.h

    r27208 r28937  
    3535    public:
    3636        RefPtr() : m_ptr(0) {}
    37         RefPtr(T *ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }
    38         RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { if (T *ptr = m_ptr) ptr->ref(); }
     37        RefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }
     38        RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { if (T* ptr = m_ptr) ptr->ref(); }
    3939        // see comment in PassRefPtr.h for why this takes const reference
    4040        template <typename U> RefPtr(const PassRefPtr<U>&);
     
    4343        RefPtr(PlacementNewAdoptType) { }
    4444
    45         ~RefPtr() { if (T *ptr = m_ptr) ptr->deref(); }
     45        ~RefPtr() { if (T* ptr = m_ptr) ptr->deref(); }
    4646       
    47         template <typename U> RefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T *ptr = m_ptr) ptr->ref(); }
     47        template <typename U> RefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); }
    4848       
    49         T *get() const { return m_ptr; }
     49        T* get() const { return m_ptr; }
    5050       
     51        void clear() { if (T* ptr = m_ptr) ptr->deref(); m_ptr = 0; }
    5152        PassRefPtr<T> release() { PassRefPtr<T> tmp = adoptRef(m_ptr); m_ptr = 0; return tmp; }
    5253
     
    5758   
    5859        // This conversion operator allows implicit conversion to bool but not to other integer types.
    59         typedef T * (RefPtr::*UnspecifiedBoolType)() const;
     60        typedef T* (RefPtr::*UnspecifiedBoolType)() const;
    6061        operator UnspecifiedBoolType() const { return m_ptr ? &RefPtr::get : 0; }
    6162       
    6263        RefPtr& operator=(const RefPtr&);
    63         RefPtr& operator=(T *);
     64        RefPtr& operator=(T*);
    6465        RefPtr& operator=(const PassRefPtr<T>&);
    6566        template <typename U> RefPtr& operator=(const RefPtr<U>&);
     
    172173    template <typename T, typename U> inline RefPtr<T> static_pointer_cast(const RefPtr<U>& p)
    173174    {
    174         return RefPtr<T>(static_cast<T *>(p.get()));
     175        return RefPtr<T>(static_cast<T*>(p.get()));
    175176    }
    176177
    177178    template <typename T, typename U> inline RefPtr<T> const_pointer_cast(const RefPtr<U>& p)
    178179    {
    179         return RefPtr<T>(const_cast<T *>(p.get()));
     180        return RefPtr<T>(const_cast<T*>(p.get()));
    180181    }
    181182
Note: See TracChangeset for help on using the changeset viewer.