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/JSArray.cpp

    r40993 r42337  
    911911}
    912912
     913void JSArray::copyToRegisters(ExecState* exec, Register* buffer, uint32_t maxSize)
     914{
     915    ASSERT(m_storage->m_length == maxSize);
     916    UNUSED_PARAM(maxSize);
     917    unsigned fastAccessLength = min(m_storage->m_length, m_fastAccessCutoff);
     918    unsigned i = 0;
     919    for (; i < fastAccessLength; ++i)
     920        buffer[i] = getIndex(i);
     921    uint32_t size = m_storage->m_length;
     922    for (; i < size; ++i)
     923        buffer[i] = get(exec, i);
     924}
     925
    913926unsigned JSArray::compactForSorting()
    914927{
Note: See TracChangeset for help on using the changeset viewer.