Ignore:
Timestamp:
Mar 8, 2012, 10:49:55 PM (13 years ago)
Author:
[email protected]
Message:

Allocate the RegExpObject's data with the Cell
https://bugs.webkit.org/show_bug.cgi?id=80654

Patch by Benjamin Poulain <[email protected]> on 2012-03-08
Reviewed by Gavin Barraclough.

This patch removes the creation of RegExpObject's data to avoid the overhead
create by the allocation and destruction.

We RegExp are created repeatedly, this provides some performance improvment.
The PeaceKeeper test stringDetectBrowser improves by 10%.

  • runtime/RegExpObject.cpp:

(JSC::RegExpObject::RegExpObject):
(JSC::RegExpObject::visitChildren):
(JSC::RegExpObject::getOwnPropertyDescriptor):
(JSC::RegExpObject::defineOwnProperty):
(JSC::RegExpObject::match):

  • runtime/RegExpObject.h:

(JSC::RegExpObject::setRegExp):
(JSC::RegExpObject::regExp):
(JSC::RegExpObject::setLastIndex):
(JSC::RegExpObject::getLastIndex):
(RegExpObject):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/RegExpObject.h

    r109008 r110266  
    11/*
    22 *  Copyright (C) 1999-2000 Harri Porten ([email protected])
    3  *  Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved.
     3 *  Copyright (C) 2003, 2007, 2008, 2012 Apple Inc. All Rights Reserved.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    4545        }
    4646
    47         void setRegExp(JSGlobalData& globalData, RegExp* r) { d->regExp.set(globalData, this, r); }
    48         RegExp* regExp() const { return d->regExp.get(); }
     47        void setRegExp(JSGlobalData& globalData, RegExp* r) { m_regExp.set(globalData, this, r); }
     48        RegExp* regExp() const { return m_regExp.get(); }
    4949
    5050        void setLastIndex(ExecState* exec, size_t lastIndex)
    5151        {
    52             d->lastIndex.setWithoutWriteBarrier(jsNumber(lastIndex));
    53             if (LIKELY(d->lastIndexIsWritable))
    54                 d->lastIndex.setWithoutWriteBarrier(jsNumber(lastIndex));
     52            m_lastIndex.setWithoutWriteBarrier(jsNumber(lastIndex));
     53            if (LIKELY(m_lastIndexIsWritable))
     54                m_lastIndex.setWithoutWriteBarrier(jsNumber(lastIndex));
    5555            else
    5656                throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     
    5858        void setLastIndex(ExecState* exec, JSValue lastIndex, bool shouldThrow)
    5959        {
    60             if (LIKELY(d->lastIndexIsWritable))
    61                 d->lastIndex.set(exec->globalData(), this, lastIndex);
     60            if (LIKELY(m_lastIndexIsWritable))
     61                m_lastIndex.set(exec->globalData(), this, lastIndex);
    6262            else if (shouldThrow)
    6363                throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     
    6565        JSValue getLastIndex() const
    6666        {
    67             return d->lastIndex.get();
     67            return m_lastIndex.get();
    6868        }
    6969
     
    8585        JS_EXPORT_PRIVATE RegExpObject(JSGlobalObject*, Structure*, RegExp*);
    8686        JS_EXPORT_PRIVATE void finishCreation(JSGlobalObject*);
    87         static void destroy(JSCell*);
    8887
    8988        static const unsigned StructureFlags = OverridesVisitChildren | OverridesGetOwnPropertySlot | Base::StructureFlags;
     
    9998        bool match(ExecState*);
    10099
    101         struct RegExpObjectData {
    102             WTF_MAKE_FAST_ALLOCATED;
    103         public:
    104             RegExpObjectData(JSGlobalData& globalData, RegExpObject* owner, RegExp* regExp)
    105                 : regExp(globalData, owner, regExp)
    106                 , lastIndexIsWritable(true)
    107             {
    108                 lastIndex.setWithoutWriteBarrier(jsNumber(0));
    109             }
    110 
    111             WriteBarrier<RegExp> regExp;
    112             WriteBarrier<Unknown> lastIndex;
    113             bool lastIndexIsWritable;
    114         };
    115100#if COMPILER(MSVC)
    116101        friend void WTF::deleteOwnedPtr<RegExpObjectData>(RegExpObjectData*);
    117102#endif
    118         OwnPtr<RegExpObjectData> d;
     103        WriteBarrier<RegExp> m_regExp;
     104        WriteBarrier<Unknown> m_lastIndex;
     105        bool m_lastIndexIsWritable;
    119106    };
    120107
Note: See TracChangeset for help on using the changeset viewer.