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/bytecompiler/BytecodeGenerator.h

    r42065 r42337  
    289289        RegisterID* emitCall(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    290290        RegisterID* emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
     291        RegisterID* emitCallVarargs(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, RegisterID* argCount, unsigned divot, unsigned startOffset, unsigned endOffset);
     292        RegisterID* emitLoadVarargs(RegisterID* argCountDst, RegisterID* args);
    291293
    292294        RegisterID* emitReturn(RegisterID* src);
     
    300302        PassRefPtr<Label> emitJumpIfFalse(RegisterID* cond, Label* target);
    301303        PassRefPtr<Label> emitJumpIfNotFunctionCall(RegisterID* cond, Label* target);
     304        PassRefPtr<Label> emitJumpIfNotFunctionApply(RegisterID* cond, Label* target);
    302305        PassRefPtr<Label> emitJumpScopes(Label* target, int targetScopeDepth);
    303306
     
    366369        typedef HashMap<double, JSValuePtr> NumberMap;
    367370        typedef HashMap<UString::Rep*, JSString*, IdentifierRepHash> IdentifierStringMap;
    368 
     371       
    369372        RegisterID* emitCall(OpcodeID, RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    370373       
Note: See TracChangeset for help on using the changeset viewer.