Ignore:
Timestamp:
Apr 15, 2009, 12:13:25 AM (16 years ago)
Author:
[email protected]
Message:

Bug 25202: Improve performance of repeated callbacks into the VM

Reviewed by Cameron Zwarich

Add the concept of a CachedCall to native code for use in Array
prototype and similar functions where a single callback function
is called repeatedly with the same number of arguments.

Used Array.prototype.filter as the test function and got a 50% win
over a naive non-caching specialised version. This makes the native
implementation of Array.prototype.filter faster than the JS one once
more.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r41852 r42537  
    6868        friend class JIT;
    6969        friend class JITStubs;
    70 
     70        friend class CachedCall;
    7171    public:
    7272        Interpreter();
     
    110110    private:
    111111        enum ExecutionFlag { Normal, InitializeAndReturn };
     112       
     113        struct CallFrameClosure {
     114            CallFrame* oldCallFrame;
     115            CallFrame* newCallFrame;
     116            JSFunction* function;
     117            CodeBlock* codeBlock;
     118            JSGlobalData* globalData;
     119            Register* oldEnd;
     120            ScopeChainNode* scopeChain;
     121            int expectedParams;
     122            int providedParams;
     123
     124            void setArgument(int arg, JSValuePtr value)
     125            {
     126                if (arg < expectedParams)
     127                    newCallFrame[arg - RegisterFile::CallFrameHeaderSize - expectedParams] = value;
     128                else
     129                    newCallFrame[arg - RegisterFile::CallFrameHeaderSize - expectedParams - providedParams] = value;
     130            }
     131            void resetCallFrame()
     132            {
     133                newCallFrame->setScopeChain(scopeChain);
     134                newCallFrame->setCalleeArguments(0);
     135                for (int i = providedParams; i < expectedParams; ++i)
     136                    newCallFrame[i - RegisterFile::CallFrameHeaderSize - expectedParams] = jsUndefined();
     137            }
     138        };
     139        CallFrameClosure prepareForRepeatCall(FunctionBodyNode*, CallFrame*, JSFunction*, int argCount, ScopeChainNode*, JSValuePtr* exception);
     140        void endRepeatCall(CallFrameClosure&);
     141        JSValuePtr execute(CallFrameClosure&, JSValuePtr* exception);
    112142
    113143        NEVER_INLINE JSValuePtr callEval(CallFrame*, RegisterFile*, Register* argv, int argc, int registerOffset, JSValuePtr& exceptionValue);
     
    154184#endif
    155185    };
    156 
     186   
    157187} // namespace JSC
    158188
Note: See TracChangeset for help on using the changeset viewer.