Ignore:
Timestamp:
Sep 23, 2008, 3:59:42 AM (17 years ago)
Author:
[email protected]
Message:

2008-09-23 Cameron Zwarich <[email protected]>

Reviewed by Oliver Hunt.

Bug 20989: Aguments constructor should put 'callee' and 'length' properties in a more efficient way
<https://bugs.webkit.org/show_bug.cgi?id=20989>

Make special cases for the 'callee' and 'length' properties in the
Arguments object.

This is somewhere between a 7.8% speedup and a 10% speedup on the V8
Raytrace benchmark, depending on whether it is run alone or with the
other V8 benchmarks.

  • kjs/Arguments.cpp: (JSC::ArgumentsData::ArgumentsData): (JSC::Arguments::Arguments): (JSC::Arguments::mark): (JSC::Arguments::getOwnPropertySlot): (JSC::Arguments::put): (JSC::Arguments::deleteProperty):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/Arguments.cpp

    r36793 r36804  
    3939
    4040struct ArgumentsData : Noncopyable {
    41     ArgumentsData(JSActivation* activation, unsigned numParameters, unsigned firstArgumentIndex, unsigned numArguments)
     41    ArgumentsData(JSActivation* activation, unsigned numParameters, unsigned firstArgumentIndex, unsigned numArguments, JSFunction* callee)
    4242        : activation(activation)
    4343        , numParameters(numParameters)
     
    4545        , numArguments(numArguments)
    4646        , extraArguments(0)
     47        , callee(callee)
     48        , overrodeLength(false)
     49        , overrodeCallee(false)
    4750    {
    4851    }
    4952
    5053    JSActivation* activation;
     54
    5155    unsigned numParameters;
    5256    unsigned firstArgumentIndex;
     
    5559    OwnArrayPtr<bool> deletedArguments;
    5660    Register extraArgumentsFixedBuffer[4];
     61
     62    JSFunction* callee;
     63    bool overrodeLength : 1;
     64    bool overrodeCallee : 1;
    5765};
    5866
     
    6068Arguments::Arguments(ExecState* exec, JSFunction* function, JSActivation* activation, int firstArgumentIndex, Register* argv, int argc)
    6169    : JSObject(exec->lexicalGlobalObject()->argumentsStructure())
    62     , d(new ArgumentsData(activation, function->numParameters(), firstArgumentIndex, argc))
     70    , d(new ArgumentsData(activation, function->numParameters(), firstArgumentIndex, argc, function))
    6371{
    6472    ASSERT(activation);
    65 
    66     putDirect(exec->propertyNames().callee, function, DontEnum);
    67     putDirect(exec->propertyNames().length, jsNumber(exec, argc), DontEnum);
    6873 
    6974    if (d->numArguments > d->numParameters) {
     
    98103    }
    99104
     105    if (!d->callee->marked())
     106        d->callee->mark();
     107
    100108    if (!d->activation->marked())
    101109        d->activation->mark();
     
    165173    }
    166174
     175    if (propertyName == exec->propertyNames().length && LIKELY(!d->overrodeLength)) {
     176        slot.setValue(jsNumber(exec, d->numArguments));
     177        return true;
     178    }
     179
     180    if (propertyName == exec->propertyNames().callee && LIKELY(!d->overrodeCallee)) {
     181        slot.setValue(d->callee);
     182        return true;
     183    }
     184
    167185    return JSObject::getOwnPropertySlot(exec, propertyName, slot);
    168186}
     
    190208        else
    191209            d->extraArguments[i - d->numParameters] = value;
     210        return;
     211    }
     212
     213    if (propertyName == exec->propertyNames().length && !d->overrodeLength) {
     214        d->overrodeLength = true;
     215        putDirect(propertyName, value, DontEnum);
     216        return;
     217    }
     218
     219    if (propertyName == exec->propertyNames().callee && !d->overrodeCallee) {
     220        d->overrodeCallee = true;
     221        putDirect(propertyName, value, DontEnum);
    192222        return;
    193223    }
     
    227257    }
    228258
     259    if (propertyName == exec->propertyNames().length && !d->overrodeLength) {
     260        d->overrodeLength = true;
     261        return true;
     262    }
     263
     264    if (propertyName == exec->propertyNames().callee && !d->overrodeCallee) {
     265        d->overrodeCallee = true;
     266        return true;
     267    }
     268
    229269    return JSObject::deleteProperty(exec, propertyName);
    230270}
Note: See TracChangeset for help on using the changeset viewer.