Changeset 42065 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Mar 27, 2009, 8:50:39 PM (16 years ago)
Author:
[email protected]
Message:

Improve performance of Function.prototype.call
<https://bugs.webkit.org/show_bug.cgi?id=24907>

Reviewed by Gavin Barraclough

Optimistically assume that expression.call(..) is going to be a call to
Function.prototype.call, and handle it specially to attempt to reduce the
degree of VM reentrancy.

When everything goes right this removes the vm reentry improving .call()
by around a factor of 10.

Location:
trunk/JavaScriptCore/runtime
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r41168 r42065  
    4444}
    4545
    46 void FunctionPrototype::addFunctionProperties(ExecState* exec, Structure* prototypeFunctionStructure)
     46void FunctionPrototype::addFunctionProperties(ExecState* exec, Structure* prototypeFunctionStructure, PrototypeFunction** callFunction)
    4747{
    4848    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
    4949    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
    50     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
     50    *callFunction = new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
     51    putDirectFunctionWithoutTransition(exec, *callFunction, DontEnum);
    5152}
    5253
  • trunk/JavaScriptCore/runtime/FunctionPrototype.h

    r39670 r42065  
    2626namespace JSC {
    2727
     28    class PrototypeFunction;
     29
    2830    class FunctionPrototype : public InternalFunction {
    2931    public:
    3032        FunctionPrototype(ExecState*, PassRefPtr<Structure>);
    31         void addFunctionProperties(ExecState*, Structure* prototypeFunctionStructure);
     33        void addFunctionProperties(ExecState*, Structure* prototypeFunctionStructure, PrototypeFunction** callFunction);
    3234
    3335        static PassRefPtr<Structure> createStructure(JSValuePtr proto)
  • trunk/JavaScriptCore/runtime/JSGlobalObject.cpp

    r41846 r42065  
    204204    d()->functionPrototype = new (exec) FunctionPrototype(exec, FunctionPrototype::createStructure(jsNull())); // The real prototype will be set once ObjectPrototype is created.
    205205    d()->prototypeFunctionStructure = PrototypeFunction::createStructure(d()->functionPrototype);
    206     d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get());
     206    PrototypeFunction* callFunction = 0;
     207    d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get(), &callFunction);
     208    d()->callFunction = callFunction;
    207209    d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get());
    208210    d()->functionPrototype->structure()->setPrototypeWithoutTransition(d()->objectPrototype);
     
    371373
    372374    markIfNeeded(d()->evalFunction);
     375    markIfNeeded(d()->callFunction);
    373376
    374377    markIfNeeded(d()->objectPrototype);
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r41232 r42065  
    4141    class NativeErrorConstructor;
    4242    class ProgramCodeBlock;
     43    class PrototypeFunction;
    4344    class RegExpConstructor;
    4445    class RegExpPrototype;
     
    105106
    106107            GlobalEvalFunction* evalFunction;
     108            PrototypeFunction* callFunction;
    107109
    108110            ObjectPrototype* objectPrototype;
Note: See TracChangeset for help on using the changeset viewer.