Changeset 43037 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Apr 29, 2009, 6:21:52 PM (16 years ago)
Author:
[email protected]
Message:

Clean up ArgList to be a trivial type

Reviewed by Gavin Barraclough

Separate out old ArgList logic to handle buffering and marking arguments
into a distinct MarkedArgumentBuffer type. ArgList becomes a trivial
struct of a pointer and length.

Location:
trunk/JavaScriptCore
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r40501 r43037  
    123123    Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
    124124   
    125     ArgList args;
     125    MarkedArgumentBuffer args;
    126126    for (unsigned i = 0; i < parameterCount; i++)
    127127        args.append(jsString(exec, parameterNames[i]->ustring()));
     
    146146    JSObject* result;
    147147    if (argumentCount) {
    148         ArgList argList;
     148        MarkedArgumentBuffer argList;
    149149        for (size_t i = 0; i < argumentCount; ++i)
    150150            argList.append(toJS(arguments[i]));
     
    170170    JSLock lock(exec);
    171171
    172     ArgList argList;
     172    MarkedArgumentBuffer argList;
    173173    for (size_t i = 0; i < argumentCount; ++i)
    174174        argList.append(toJS(arguments[i]));
     
    191191    JSLock lock(exec);
    192192
    193     ArgList argList;
     193    MarkedArgumentBuffer argList;
    194194    for (size_t i = 0; i < argumentCount; ++i)
    195195        argList.append(toJS(arguments[i]));
     
    212212    JSLock lock(exec);
    213213
    214     ArgList argList;
     214    MarkedArgumentBuffer argList;
    215215    for (size_t i = 0; i < argumentCount; ++i)
    216216        argList.append(toJS(arguments[i]));
     
    390390        jsThisObject = exec->globalThisValue();
    391391
    392     ArgList argList;
     392    MarkedArgumentBuffer argList;
    393393    for (size_t i = 0; i < argumentCount; i++)
    394394        argList.append(toJS(arguments[i]));
     
    429429        return 0;
    430430
    431     ArgList argList;
     431    MarkedArgumentBuffer argList;
    432432    for (size_t i = 0; i < argumentCount; i++)
    433433        argList.append(toJS(arguments[i]));
  • trunk/JavaScriptCore/ChangeLog

    r43008 r43037  
     12009-04-29  Oliver Hunt  <[email protected]>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Clean up ArgList to be a trivial type
     6
     7        Separate out old ArgList logic to handle buffering and marking arguments
     8        into a distinct MarkedArgumentBuffer type.  ArgList becomes a trivial
     9        struct of a pointer and length.
     10
     11        * API/JSObjectRef.cpp:
     12        (JSObjectMakeFunction):
     13        (JSObjectMakeArray):
     14        (JSObjectMakeDate):
     15        (JSObjectMakeError):
     16        (JSObjectMakeRegExp):
     17        (JSObjectCallAsFunction):
     18        (JSObjectCallAsConstructor):
     19        * JavaScriptCore.exp:
     20        * interpreter/CallFrame.h:
     21        (JSC::ExecState::emptyList):
     22        * runtime/ArgList.cpp:
     23        (JSC::ArgList::getSlice):
     24        (JSC::MarkedArgumentBuffer::markLists):
     25        (JSC::MarkedArgumentBuffer::slowAppend):
     26        * runtime/ArgList.h:
     27        (JSC::MarkedArgumentBuffer::MarkedArgumentBuffer):
     28        (JSC::MarkedArgumentBuffer::~MarkedArgumentBuffer):
     29        (JSC::ArgList::ArgList):
     30        (JSC::ArgList::at):
     31        (JSC::ArgList::isEmpty):
     32        (JSC::ArgList::size):
     33        (JSC::ArgList::begin):
     34        (JSC::ArgList::end):
     35        * runtime/Arguments.cpp:
     36        (JSC::Arguments::fillArgList):
     37        * runtime/Arguments.h:
     38        * runtime/ArrayPrototype.cpp:
     39        (JSC::arrayProtoFuncConcat):
     40        (JSC::arrayProtoFuncPush):
     41        (JSC::arrayProtoFuncSort):
     42        (JSC::arrayProtoFuncFilter):
     43        (JSC::arrayProtoFuncMap):
     44        (JSC::arrayProtoFuncEvery):
     45        (JSC::arrayProtoFuncForEach):
     46        (JSC::arrayProtoFuncSome):
     47        (JSC::arrayProtoFuncReduce):
     48        (JSC::arrayProtoFuncReduceRight):
     49        * runtime/Collector.cpp:
     50        (JSC::Heap::collect):
     51        * runtime/Collector.h:
     52        (JSC::Heap::markListSet):
     53        * runtime/CommonIdentifiers.h:
     54        * runtime/Error.cpp:
     55        (JSC::Error::create):
     56        * runtime/FunctionPrototype.cpp:
     57        (JSC::functionProtoFuncApply):
     58        * runtime/JSArray.cpp:
     59        (JSC::JSArray::JSArray):
     60        (JSC::AVLTreeAbstractorForArrayCompare::compare_key_key):
     61        (JSC::JSArray::fillArgList):
     62        (JSC::constructArray):
     63        * runtime/JSArray.h:
     64        * runtime/JSGlobalData.cpp:
     65        (JSC::JSGlobalData::JSGlobalData):
     66        * runtime/JSGlobalData.h:
     67        * runtime/JSObject.cpp:
     68        (JSC::JSObject::put):
     69        * runtime/StringConstructor.cpp:
     70        (JSC::stringFromCharCodeSlowCase):
     71        * runtime/StringPrototype.cpp:
     72        (JSC::stringProtoFuncReplace):
     73        (JSC::stringProtoFuncConcat):
     74        (JSC::stringProtoFuncMatch):
     75
    1762009-04-29  Laszlo Gombos  <[email protected]>
    277
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r42808 r43037  
    162162__ZN3JSC19initializeThreadingEv
    163163__ZN3JSC20constructEmptyObjectEPNS_9ExecStateE
     164__ZN3JSC20MarkedArgumentBuffer10slowAppendENS_10JSValuePtrE
    164165__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE
    165166__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE
     
    204205__ZN3JSC6JSLockC1EPNS_9ExecStateE
    205206__ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE
    206 __ZN3JSC7ArgList10slowAppendENS_10JSValuePtrE
    207207__ZN3JSC7CStringD1Ev
    208208__ZN3JSC7CStringaSERKS0_
  • trunk/JavaScriptCore/interpreter/CallFrame.h

    r42537 r43037  
    8181
    8282        const CommonIdentifiers& propertyNames() const { return *globalData().propertyNames; }
    83         const ArgList& emptyList() const { return *globalData().emptyList; }
     83        const MarkedArgumentBuffer& emptyList() const { return *globalData().emptyList; }
    8484        Interpreter* interpreter() { return globalData().interpreter; }
    8585        Heap* heap() { return &globalData().heap; }
  • trunk/JavaScriptCore/runtime/ArgList.cpp

    r39670 r43037  
    3131void ArgList::getSlice(int startIndex, ArgList& result) const
    3232{
    33     ASSERT(!result.m_isReadOnly);
    34 
    35     const_iterator start = min(begin() + startIndex, end());
    36     result.m_vector.appendRange(start, end());
    37     result.m_size = result.m_vector.size();
    38     result.m_buffer = result.m_vector.data();
     33    if (startIndex <= 0 || static_cast<unsigned>(startIndex) >= m_argCount) {
     34        result = ArgList(m_args, 0);
     35        return;
     36    }
     37    result = ArgList(m_args + startIndex, m_argCount - startIndex);
    3938}
    4039
    41 void ArgList::markLists(ListSet& markSet)
     40void MarkedArgumentBuffer::markLists(ListSet& markSet)
    4241{
    4342    ListSet::iterator end = markSet.end();
    4443    for (ListSet::iterator it = markSet.begin(); it != end; ++it) {
    45         ArgList* list = *it;
     44        MarkedArgumentBuffer* list = *it;
    4645
    4746        iterator end2 = list->end();
     
    5251}
    5352
    54 void ArgList::slowAppend(JSValuePtr v)
     53void MarkedArgumentBuffer::slowAppend(JSValuePtr v)
    5554{
    5655    // As long as our size stays within our Vector's inline
  • trunk/JavaScriptCore/runtime/ArgList.h

    r42989 r43037  
    3232namespace JSC {
    3333   
    34     class ArgList : Noncopyable {
     34    class MarkedArgumentBuffer : Noncopyable {
    3535    private:
    3636        static const unsigned inlineCapacity = 8;
    3737        typedef Vector<Register, inlineCapacity> VectorType;
    38         typedef HashSet<ArgList*> ListSet;
     38        typedef HashSet<MarkedArgumentBuffer*> ListSet;
    3939
    4040    public:
     
    4444        // Constructor for a read-write list, to which you may append values.
    4545        // FIXME: Remove all clients of this API, then remove this API.
    46         ArgList()
     46        MarkedArgumentBuffer()
    4747            : m_markSet(0)
    4848#ifndef NDEBUG
     
    5555
    5656        // Constructor for a read-only list whose data has already been allocated elsewhere.
    57         ArgList(Register* buffer, size_t size)
     57        MarkedArgumentBuffer(Register* buffer, size_t size)
    5858            : m_buffer(buffer)
    5959            , m_size(size)
     
    7777        }
    7878
    79         ~ArgList()
     79        ~MarkedArgumentBuffer()
    8080        {
    8181            if (m_markSet)
     
    115115        }
    116116
    117         void getSlice(int startIndex, ArgList& result) const;
    118 
    119117        iterator begin() { return m_buffer; }
    120118        iterator end() { return m_buffer + m_size; }
     
    157155    };
    158156
     157    class ArgList {
     158    public:
     159        typedef JSValuePtr* iterator;
     160        typedef const JSValuePtr* const_iterator;
     161
     162        ArgList()
     163            : m_args(0)
     164            , m_argCount(0)
     165        {
     166        }
     167       
     168        ArgList(JSValuePtr* args, unsigned argCount)
     169            : m_args(args)
     170            , m_argCount(argCount)
     171        {
     172        }
     173       
     174        ArgList(Register* args, int argCount)
     175            : m_args(reinterpret_cast<JSValuePtr*>(args))
     176            , m_argCount(argCount)
     177        {
     178            ASSERT(argCount >= 0);
     179        }
     180
     181        ArgList(const MarkedArgumentBuffer& args)
     182            : m_args(reinterpret_cast<JSValuePtr*>(const_cast<Register*>(args.begin())))
     183            , m_argCount(args.size())
     184        {
     185        }
     186
     187        JSValuePtr at(size_t idx) const
     188        {
     189            if (idx < m_argCount)
     190                return m_args[idx];
     191            return jsUndefined();
     192        }
     193
     194        bool isEmpty() const { return !m_argCount; }
     195
     196        size_t size() const { return m_argCount; }
     197       
     198        iterator begin() { return m_args; }
     199        iterator end() { return m_args + m_argCount; }
     200       
     201        const_iterator begin() const { return m_args; }
     202        const_iterator end() const { return m_args + m_argCount; }
     203
     204        void getSlice(int startIndex, ArgList& result) const;
     205    private:
     206        JSValuePtr* m_args;
     207        size_t m_argCount;
     208    };
     209
    159210} // namespace JSC
    160211
  • trunk/JavaScriptCore/runtime/Arguments.cpp

    r42989 r43037  
    105105}
    106106
    107 void Arguments::fillArgList(ExecState* exec, ArgList& args)
     107void Arguments::fillArgList(ExecState* exec, MarkedArgumentBuffer& args)
    108108{
    109109    if (UNLIKELY(d->overrodeLength)) {
  • trunk/JavaScriptCore/runtime/Arguments.h

    r42337 r43037  
    6464        virtual void mark();
    6565
    66         void fillArgList(ExecState*, ArgList&);
     66        void fillArgList(ExecState*, MarkedArgumentBuffer&);
    6767
    6868        uint32_t numProvidedArguments(ExecState* exec) const
  • trunk/JavaScriptCore/runtime/ArrayPrototype.cpp

    r42989 r43037  
    306306        if (it == end)
    307307            break;
    308         curArg = (*it).jsValue();
     308        curArg = (*it);
    309309        ++it;
    310310    }
     
    336336    if (isJSArray(&exec->globalData(), thisValue) && args.size() == 1) {
    337337        JSArray* array = asArray(thisValue);
    338         array->push(exec, args.begin()->jsValue());
     338        array->push(exec, *args.begin());
    339339        return jsNumber(exec, array->length());
    340340    }
     
    478478                compareResult = -1;
    479479            else if (callType != CallTypeNone) {
    480                 ArgList l;
     480                MarkedArgumentBuffer l;
    481481                l.append(jObj);
    482482                l.append(minObj);
     
    620620        JSValuePtr v = slot.getValue(exec, k);
    621621
    622         ArgList eachArguments;
     622        MarkedArgumentBuffer eachArguments;
    623623
    624624        eachArguments.append(v);
     
    673673        JSValuePtr v = slot.getValue(exec, k);
    674674
    675         ArgList eachArguments;
     675        MarkedArgumentBuffer eachArguments;
    676676
    677677        eachArguments.append(v);
     
    730730            continue;
    731731
    732         ArgList eachArguments;
     732        MarkedArgumentBuffer eachArguments;
    733733
    734734        eachArguments.append(slot.getValue(exec, k));
     
    782782            continue;
    783783
    784         ArgList eachArguments;
     784        MarkedArgumentBuffer eachArguments;
    785785        eachArguments.append(slot.getValue(exec, k));
    786786        eachArguments.append(jsNumber(exec, k));
     
    830830            continue;
    831831
    832         ArgList eachArguments;
     832        MarkedArgumentBuffer eachArguments;
    833833        eachArguments.append(slot.getValue(exec, k));
    834834        eachArguments.append(jsNumber(exec, k));
     
    904904            continue;
    905905       
    906         ArgList eachArguments;
     906        MarkedArgumentBuffer eachArguments;
    907907        eachArguments.append(rv);
    908908        eachArguments.append(prop);
     
    973973            continue;
    974974       
    975         ArgList eachArguments;
     975        MarkedArgumentBuffer eachArguments;
    976976        eachArguments.append(rv);
    977977        eachArguments.append(prop);
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r42705 r43037  
    987987    markProtectedObjects();
    988988    if (m_markListSet && m_markListSet->size())
    989         ArgList::markLists(*m_markListSet);
     989        MarkedArgumentBuffer::markLists(*m_markListSet);
    990990    if (m_globalData->exception && !m_globalData->exception.marked())
    991991        m_globalData->exception.mark();
  • trunk/JavaScriptCore/runtime/Collector.h

    r39670 r43037  
    4040namespace JSC {
    4141
    42     class ArgList;
     42    class MarkedArgumentBuffer;
    4343    class CollectorBlock;
    4444    class JSCell;
     
    114114        void markConservatively(void* start, void* end);
    115115
    116         HashSet<ArgList*>& markListSet() { if (!m_markListSet) m_markListSet = new HashSet<ArgList*>; return *m_markListSet; }
     116        HashSet<MarkedArgumentBuffer*>& markListSet() { if (!m_markListSet) m_markListSet = new HashSet<MarkedArgumentBuffer*>; return *m_markListSet; }
    117117
    118118        JSGlobalData* globalData() const { return m_globalData; }
     
    148148        ProtectCountSet m_protectedValues;
    149149
    150         HashSet<ArgList*>* m_markListSet;
     150        HashSet<MarkedArgumentBuffer*>* m_markListSet;
    151151
    152152#if ENABLE(JSC_MULTIPLE_THREADS)
  • trunk/JavaScriptCore/runtime/CommonIdentifiers.h

    r42478 r43037  
    2525#include <wtf/Noncopyable.h>
    2626
    27 // ArgList of property names, passed to a macro so we can do set them up various
     27// MarkedArgumentBuffer of property names, passed to a macro so we can do set them up various
    2828// ways without repeating the list.
    2929#define JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
  • trunk/JavaScriptCore/runtime/Error.cpp

    r37938 r43037  
    7373    }
    7474
    75     ArgList args;
     75    MarkedArgumentBuffer args;
    7676    if (message.isEmpty())
    7777        args.append(jsString(exec, name));
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r42989 r43037  
    109109    JSValuePtr array = args.at(1);
    110110
    111     ArgList applyArgs;
     111    MarkedArgumentBuffer applyArgs;
    112112    if (!array.isUndefinedOrNull()) {
    113113        if (!array.isObject())
  • trunk/JavaScriptCore/runtime/JSArray.cpp

    r42989 r43037  
    174174    ArgList::const_iterator end = list.end();
    175175    for (ArgList::const_iterator it = list.begin(); it != end; ++it, ++i)
    176         storage->m_vector[i] = (*it).jsValue();
     176        storage->m_vector[i] = *it;
    177177
    178178    m_storage = storage;
     
    791791            compareResult = m_cachedCall->call().toNumber(m_cachedCall->newCallFrame());
    792792        } else {
    793             ArgList arguments;
     793            MarkedArgumentBuffer arguments;
    794794            arguments.append(va);
    795795            arguments.append(vb);
     
    915915}
    916916
    917 void JSArray::fillArgList(ExecState* exec, ArgList& args)
     917void JSArray::fillArgList(ExecState* exec, MarkedArgumentBuffer& args)
    918918{
    919919    unsigned fastAccessLength = min(m_storage->m_length, m_fastAccessCutoff);
     
    10611061JSArray* constructArray(ExecState* exec, JSValuePtr singleItemValue)
    10621062{
    1063     ArgList values;
     1063    MarkedArgumentBuffer values;
    10641064    values.append(singleItemValue);
    10651065    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values);
  • trunk/JavaScriptCore/runtime/JSArray.h

    r42989 r43037  
    7676        }
    7777
    78         void fillArgList(ExecState*, ArgList&);
     78        void fillArgList(ExecState*, MarkedArgumentBuffer&);
    7979        void copyToRegisters(ExecState*, Register*, uint32_t);
    8080
  • trunk/JavaScriptCore/runtime/JSGlobalData.cpp

    r41168 r43037  
    125125    , identifierTable(createIdentifierTable())
    126126    , propertyNames(new CommonIdentifiers(this))
    127     , emptyList(new ArgList)
     127    , emptyList(new MarkedArgumentBuffer)
    128128    , lexer(new Lexer(this))
    129129    , parser(new Parser)
  • trunk/JavaScriptCore/runtime/JSGlobalData.h

    r41168 r43037  
    108108        IdentifierTable* identifierTable;
    109109        CommonIdentifiers* propertyNames;
    110         const ArgList* emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark.
     110        const MarkedArgumentBuffer* emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark.
    111111        SmallStrings smallStrings;
    112112
  • trunk/JavaScriptCore/runtime/JSObject.cpp

    r40046 r43037  
    148148                CallData callData;
    149149                CallType callType = setterFunc->getCallData(callData);
    150                 ArgList args;
     150                MarkedArgumentBuffer args;
    151151                args.append(value);
    152152                call(exec, setterFunc, callType, callData, this, args);
  • trunk/JavaScriptCore/runtime/StringConstructor.cpp

    r42989 r43037  
    3434    ArgList::const_iterator end = args.end();
    3535    for (ArgList::const_iterator it = args.begin(); it != end; ++it)
    36         *p++ = static_cast<UChar>((*it).jsValue().toUInt32(exec));
     36        *p++ = static_cast<UChar>((*it).toUInt32(exec));
    3737    return jsString(exec, UString(buf, p - buf, false));
    3838}
  • trunk/JavaScriptCore/runtime/StringPrototype.cpp

    r42989 r43037  
    291291                if (callType != CallTypeNone) {
    292292                    int completeMatchStart = ovector[0];
    293                     ArgList args;
     293                    MarkedArgumentBuffer args;
    294294
    295295                    for (unsigned i = 0; i < reg->numSubpatterns() + 1; ++i) {
     
    343343
    344344    if (callType != CallTypeNone) {
    345         ArgList args;
     345        MarkedArgumentBuffer args;
    346346        args.append(jsSubstring(exec, source, matchPos, matchLen));
    347347        args.append(jsNumber(exec, matchPos));
     
    410410    ArgList::const_iterator end = args.end();
    411411    for (ArgList::const_iterator it = args.begin(); it != end; ++it)
    412         s += (*it).jsValue().toString(exec);
     412        s += (*it).toString(exec);
    413413    return jsString(exec, s);
    414414}
     
    487487
    488488    // return array of matches
    489     ArgList list;
     489    MarkedArgumentBuffer list;
    490490    int lastIndex = 0;
    491491    while (pos >= 0) {
Note: See TracChangeset for help on using the changeset viewer.