Ignore:
Timestamp:
Apr 8, 2009, 4:08:28 PM (16 years ago)
Author:
[email protected]
Message:

Improve function.apply performance

Reviewed by Geoff Garen.

Jump through a few hoops to improve performance of function.apply in the general case.

In the case of zero or one arguments, or if there are only two arguments and the
second is an array literal we treat function.apply as function.call.

Otherwise we use the new opcodes op_load_varargs and op_call_varargs to do the .apply call
without re-entering the virtual machine.

File:
1 edited

Legend:

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

    r42065 r42337  
    205205    d()->prototypeFunctionStructure = PrototypeFunction::createStructure(d()->functionPrototype);
    206206    PrototypeFunction* callFunction = 0;
    207     d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get(), &callFunction);
     207    PrototypeFunction* applyFunction = 0;
     208    d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction);
    208209    d()->callFunction = callFunction;
     210    d()->applyFunction = applyFunction;
    209211    d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get());
    210212    d()->functionPrototype->structure()->setPrototypeWithoutTransition(d()->objectPrototype);
     
    374376    markIfNeeded(d()->evalFunction);
    375377    markIfNeeded(d()->callFunction);
     378    markIfNeeded(d()->applyFunction);
    376379
    377380    markIfNeeded(d()->objectPrototype);
Note: See TracChangeset for help on using the changeset viewer.