Changeset 43220 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
May 5, 2009, 4:34:23 AM (16 years ago)
Author:
[email protected]
Message:

Bug 25559: Improve native function call performance
<https://bugs.webkit.org/show_bug.cgi?id=25559>

Reviewed by Gavin Barraclough

In order to cache calls to native functions we now make the standard
prototype functions use a small assembly thunk that converts the JS
calling convention into the native calling convention. As this is
only beneficial in the JIT we use the NativeFunctionWrapper typedef
to alternate between PrototypeFunction and JSFunction to keep the
code sane. This change from PrototypeFunction to NativeFunctionWrapper
is the bulk of this patch.

Location:
trunk/JavaScriptCore/runtime
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/ArgList.h

    r43122 r43220  
    11/*
    22 *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    3  *  Copyright (C) 2003, 2007, 2008 Apple Computer, Inc.
     3 *  Copyright (C) 2003, 2007, 2008, 2009 Apple Computer, Inc.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    156156
    157157    class ArgList {
     158        friend class JIT;
    158159    public:
    159160        typedef JSValue* iterator;
  • trunk/JavaScriptCore/runtime/ArrayPrototype.cpp

    r43153 r43220  
    7373        return false;
    7474
    75     CodeBlock& codeBlock = callData.js.functionBody->bytecode(callData.js.scopeChain);
    7675#if ENABLE(JIT)
    7776    // If the JIT is enabled then we need to preserve the invariant that every
    7877    // function with a CodeBlock also has JIT code.
    79     if (!codeBlock.jitCode())
    80         JIT::compile(callData.js.scopeChain->globalData, &codeBlock);
     78    callData.js.functionBody->jitCode(callData.js.scopeChain);
     79    CodeBlock& codeBlock = callData.js.functionBody->generatedBytecode();
     80#else
     81    CodeBlock& codeBlock = callData.js.functionBody->bytecode(callData.js.scopeChain);
    8182#endif
    8283
  • trunk/JavaScriptCore/runtime/BooleanPrototype.cpp

    r43122 r43220  
    4242    setInternalValue(jsBoolean(false));
    4343
    44     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
    45     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
     44    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
     45    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
    4646}
    4747
  • trunk/JavaScriptCore/runtime/DateConstructor.cpp

    r43122 r43220  
    5757      putDirectWithoutTransition(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
    5858
    59       putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
    60       putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
    61       putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
     59      putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
     60      putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
     61      putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
    6262
    6363      putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 7), ReadOnly | DontEnum | DontDelete);
  • trunk/JavaScriptCore/runtime/ErrorPrototype.cpp

    r43122 r43220  
    4242    putDirectWithoutTransition(exec->propertyNames().message, jsNontrivialString(exec, "Unknown error"), DontEnum);
    4343
    44     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
     44    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
    4545}
    4646
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r43122 r43220  
    4444}
    4545
    46 void FunctionPrototype::addFunctionProperties(ExecState* exec, Structure* prototypeFunctionStructure, PrototypeFunction** callFunction, PrototypeFunction** applyFunction)
     46void FunctionPrototype::addFunctionProperties(ExecState* exec, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction)
    4747{
    48     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
    49     *applyFunction = new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
     48    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
     49    *applyFunction = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
    5050    putDirectFunctionWithoutTransition(exec, *applyFunction, DontEnum);
    51     *callFunction = new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
     51    *callFunction = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
    5252    putDirectFunctionWithoutTransition(exec, *callFunction, DontEnum);
    5353}
     
    8787    if (thisValue.isObject(&JSFunction::info)) {
    8888        JSFunction* function = asFunction(thisValue);
    89         UString functionBody = function->body()->toSourceString();
    90         insertSemicolonIfNeeded(functionBody);
    91         return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + function->body()->paramString() + ") " + functionBody);
     89        if (!function->isHostFunction()) {
     90            UString functionBody = function->body()->toSourceString();
     91            insertSemicolonIfNeeded(functionBody);
     92            return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + function->body()->paramString() + ") " + functionBody);
     93        }
    9294    }
    9395
  • trunk/JavaScriptCore/runtime/FunctionPrototype.h

    r43122 r43220  
    2323
    2424#include "InternalFunction.h"
     25#include "NativeFunctionWrapper.h"
    2526
    2627namespace JSC {
     
    3132    public:
    3233        FunctionPrototype(ExecState*, PassRefPtr<Structure>);
    33         void addFunctionProperties(ExecState*, Structure* prototypeFunctionStructure, PrototypeFunction** callFunction, PrototypeFunction** applyFunction);
     34        void addFunctionProperties(ExecState*, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction);
    3435
    3536        static PassRefPtr<Structure> createStructure(JSValue proto)
  • trunk/JavaScriptCore/runtime/JSFunction.cpp

    r43122 r43220  
    4646const ClassInfo JSFunction::info = { "Function", &InternalFunction::info, 0, 0 };
    4747
     48JSFunction::JSFunction(ExecState* exec, PassRefPtr<Structure> structure, int length, const Identifier& name, NativeFunction func)
     49    : Base(&exec->globalData(), structure, name)
     50#if ENABLE(JIT)
     51    , m_body(exec->globalData().nativeFunctionThunk())
     52#else
     53    , m_body(0)
     54#endif
     55{
     56#if ENABLE(JIT)
     57    setNativeFunction(func);
     58    putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
     59#else
     60    UNUSED_PARAM(length);
     61    UNUSED_PARAM(func);
     62    ASSERT_NOT_REACHED();
     63#endif
     64}
     65
    4866JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode)
    4967    : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), name)
    5068    , m_body(body)
    51     , m_scopeChain(scopeChainNode)
    52 {
     69{
     70    setScopeChain(scopeChainNode);
    5371}
    5472
     
    5977    // are based on a check for the this pointer value for this JSFunction - which will no longer be valid once
    6078    // this memory is freed and may be reused (potentially for another, different JSFunction).
    61     if (m_body && m_body->isGenerated())
    62         m_body->generatedBytecode().unlinkCallers();
     79    if (!isHostFunction()) {
     80        if (m_body && m_body->isGenerated())
     81            m_body->generatedBytecode().unlinkCallers();
     82        scopeChain().~ScopeChain();
     83    }
     84   
    6385#endif
    6486}
     
    6789{
    6890    Base::mark();
    69     m_body->mark();
    70     m_scopeChain.mark();
     91    if (!isHostFunction()) {
     92        m_body->mark();
     93        scopeChain().mark();
     94    }
    7195}
    7296
    7397CallType JSFunction::getCallData(CallData& callData)
    7498{
     99    if (isHostFunction()) {
     100        callData.native.function = nativeFunction();
     101        return CallTypeHost;
     102    }
    75103    callData.js.functionBody = m_body.get();
    76     callData.js.scopeChain = m_scopeChain.node();
     104    callData.js.scopeChain = scopeChain().node();
    77105    return CallTypeJS;
    78106}
     
    80108JSValue JSFunction::call(ExecState* exec, JSValue thisValue, const ArgList& args)
    81109{
    82     return exec->interpreter()->execute(m_body.get(), exec, this, thisValue.toThisObject(exec), args, m_scopeChain.node(), exec->exceptionSlot());
     110    ASSERT(!isHostFunction());
     111    return exec->interpreter()->execute(m_body.get(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());
    83112}
    84113
     
    86115{
    87116    JSFunction* thisObj = asFunction(slot.slotBase());
     117    ASSERT(!thisObj->isHostFunction());
    88118    return exec->interpreter()->retrieveArguments(exec, thisObj);
    89119}
     
    92122{
    93123    JSFunction* thisObj = asFunction(slot.slotBase());
     124    ASSERT(!thisObj->isHostFunction());
    94125    return exec->interpreter()->retrieveCaller(exec, thisObj);
    95126}
     
    98129{
    99130    JSFunction* thisObj = asFunction(slot.slotBase());
     131    ASSERT(!thisObj->isHostFunction());
    100132    return jsNumber(exec, thisObj->m_body->parameterCount());
    101133}
     
    103135bool JSFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    104136{
     137    if (isHostFunction())
     138        return Base::getOwnPropertySlot(exec, propertyName, slot);
     139
    105140    if (propertyName == exec->propertyNames().prototype) {
    106141        JSValue* location = getDirectLocation(propertyName);
    107142
    108143        if (!location) {
    109             JSObject* prototype = new (exec) JSObject(m_scopeChain.globalObject()->emptyObjectStructure());
     144            JSObject* prototype = new (exec) JSObject(scopeChain().globalObject()->emptyObjectStructure());
    110145            prototype->putDirect(exec->propertyNames().constructor, this, DontEnum);
    111146            putDirect(exec->propertyNames().prototype, prototype, DontDelete);
     
    136171void JSFunction::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
    137172{
     173    if (isHostFunction()) {
     174        Base::put(exec, propertyName, value, slot);
     175        return;
     176    }
    138177    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
    139178        return;
     
    143182bool JSFunction::deleteProperty(ExecState* exec, const Identifier& propertyName)
    144183{
     184    if (isHostFunction())
     185        return Base::deleteProperty(exec, propertyName);
    145186    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
    146187        return false;
     
    151192ConstructType JSFunction::getConstructData(ConstructData& constructData)
    152193{
     194    if (isHostFunction())
     195        return ConstructTypeNone;
    153196    constructData.js.functionBody = m_body.get();
    154     constructData.js.scopeChain = m_scopeChain.node();
     197    constructData.js.scopeChain = scopeChain().node();
    155198    return ConstructTypeJS;
    156199}
     
    158201JSObject* JSFunction::construct(ExecState* exec, const ArgList& args)
    159202{
     203    ASSERT(!isHostFunction());
    160204    Structure* structure;
    161205    JSValue prototype = get(exec, exec->propertyNames().prototype);
     
    166210    JSObject* thisObj = new (exec) JSObject(structure);
    167211
    168     JSValue result = exec->interpreter()->execute(m_body.get(), exec, this, thisObj, args, m_scopeChain.node(), exec->exceptionSlot());
     212    JSValue result = exec->interpreter()->execute(m_body.get(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot());
    169213    if (exec->hadException() || !result.isObject())
    170214        return thisObj;
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r43122 r43220  
    4747        JSFunction(PassRefPtr<Structure> structure)
    4848            : InternalFunction(structure)
    49             , m_scopeChain(NoScopeChain())
    5049        {
     50            clearScopeChain();
    5151        }
    5252
    5353    public:
     54        JSFunction(ExecState*, PassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
    5455        JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*);
    5556        ~JSFunction();
     
    6263        JSValue call(ExecState*, JSValue thisValue, const ArgList&);
    6364
    64         void setScope(const ScopeChain& scopeChain) { m_scopeChain = scopeChain; }
    65         ScopeChain& scope() { return m_scopeChain; }
     65        void setScope(const ScopeChain& scopeChain) { setScopeChain(scopeChain); }
     66        ScopeChain& scope() { return scopeChain(); }
    6667
    6768        void setBody(FunctionBodyNode* body) { m_body = body; }
     
    7879        }
    7980
     81#if ENABLE(JIT)
     82        bool isHostFunction() const { return m_body && m_body->isHostFunction(); }
     83#else
     84        bool isHostFunction() const { return false; }
     85#endif
    8086    private:
    8187        virtual const ClassInfo* classInfo() const { return &info; }
     
    8995
    9096        RefPtr<FunctionBodyNode> m_body;
    91         ScopeChain m_scopeChain;
     97        ScopeChain& scopeChain()
     98        {
     99            ASSERT(!isHostFunction());
     100            return *reinterpret_cast<ScopeChain*>(m_data);
     101        }
     102        void clearScopeChain()
     103        {
     104            ASSERT(!isHostFunction());
     105            new (m_data) ScopeChain(NoScopeChain());
     106        }
     107        void setScopeChain(ScopeChainNode* sc)
     108        {
     109            ASSERT(!isHostFunction());
     110            new (m_data) ScopeChain(sc);
     111        }
     112        void setScopeChain(const ScopeChain& sc)
     113        {
     114            ASSERT(!isHostFunction());
     115            *reinterpret_cast<ScopeChain*>(m_data) = sc;
     116        }
     117        NativeFunction nativeFunction()
     118        {
     119            return *reinterpret_cast<NativeFunction*>(m_data);
     120        }
     121        void setNativeFunction(NativeFunction func)
     122        {
     123            *reinterpret_cast<NativeFunction*>(m_data) = func;
     124        }
     125        unsigned char m_data[sizeof(void*)];
    92126    };
    93127
  • trunk/JavaScriptCore/runtime/JSGlobalData.cpp

    r43153 r43220  
    3939#include "JSByteArray.h"
    4040#include "JSClassRef.h"
     41#include "JSFunction.h"
    4142#include "JSLock.h"
    4243#include "JSNotAnObject.h"
     
    162163    regExpConstructorTable->deleteTable();
    163164    stringTable->deleteTable();
     165#if ENABLE(JIT)
     166    lazyNativeFunctionThunk.clear();
     167#endif
     168
    164169    delete arrayTable;
    165170    delete dateTable;
     
    227232}
    228233
     234void JSGlobalData::createNativeThunk()
     235{
     236#if ENABLE(JIT)
     237    lazyNativeFunctionThunk = FunctionBodyNode::createNativeThunk(this);
     238#endif
     239}
     240
    229241// FIXME: We can also detect forms like v1 < v2 ? -1 : 0, reverse comparison, etc.
    230242const Vector<Instruction>& JSGlobalData::numericCompareFunction(ExecState* exec)
     
    245257}
    246258
     259
    247260} // namespace JSC
  • trunk/JavaScriptCore/runtime/JSGlobalData.h

    r43122 r43220  
    4747    class ArgList;
    4848    class CommonIdentifiers;
     49    class FunctionBodyNode;
    4950    class Heap;
    5051    class IdentifierTable;
     
    120121#if ENABLE(JIT)
    121122        JITStubs jitStubs;
     123        FunctionBodyNode* nativeFunctionThunk() {
     124            if (!lazyNativeFunctionThunk)
     125                createNativeThunk();
     126            return lazyNativeFunctionThunk.get();
     127        }
     128        RefPtr<FunctionBodyNode> lazyNativeFunctionThunk;
    122129#endif
    123130        TimeoutChecker timeoutChecker;
     
    148155        JSGlobalData(bool isShared, const VPtrSet&);
    149156        static JSGlobalData*& sharedInstanceInternal();
     157        void createNativeThunk();
    150158    };
    151159} // namespace JSC
  • trunk/JavaScriptCore/runtime/JSGlobalObject.cpp

    r43122 r43220  
    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     PrototypeFunction* callFunction = 0;
    207     PrototypeFunction* applyFunction = 0;
     206    NativeFunctionWrapper* callFunction = 0;
     207    NativeFunctionWrapper* applyFunction = 0;
    208208    d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction);
    209209    d()->callFunction = callFunction;
     
    325325    d()->evalFunction = new (exec) GlobalEvalFunction(exec, GlobalEvalFunction::createStructure(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
    326326    putDirectFunctionWithoutTransition(exec, d()->evalFunction, DontEnum);
    327     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
    328     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
    329     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
    330     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
    331     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
    332     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
    333     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
    334     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
    335     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
    336     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
     327    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
     328    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
     329    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
     330    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
     331    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
     332    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
     333    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
     334    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
     335    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
     336    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
    337337#ifndef NDEBUG
    338     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
     338    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
    339339#endif
    340340
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r43122 r43220  
    2525#include "JSGlobalData.h"
    2626#include "JSVariableObject.h"
     27#include "NativeFunctionWrapper.h"
    2728#include "NumberPrototype.h"
    2829#include "StringPrototype.h"
     
    108109
    109110            GlobalEvalFunction* evalFunction;
    110             PrototypeFunction* callFunction;
    111             PrototypeFunction* applyFunction;
     111            NativeFunctionWrapper* callFunction;
     112            NativeFunctionWrapper* applyFunction;
    112113
    113114            ObjectPrototype* objectPrototype;
  • trunk/JavaScriptCore/runtime/Lookup.cpp

    r43122 r43220  
    7070
    7171    if (!location) {
    72         PrototypeFunction* function = new (exec) PrototypeFunction(exec, entry->functionLength(), propertyName, entry->function());
     72        InternalFunction* function = new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), entry->functionLength(), propertyName, entry->function());
    7373        thisObj->putDirect(propertyName, function, entry->attributes());
    7474        location = thisObj->getDirectLocation(propertyName);
  • trunk/JavaScriptCore/runtime/Lookup.h

    r43122 r43220  
    2424#include "CallFrame.h"
    2525#include "Identifier.h"
    26 #include "JSFunction.h"
    2726#include "JSGlobalObject.h"
    2827#include "JSObject.h"
  • trunk/JavaScriptCore/runtime/NumberPrototype.cpp

    r43122 r43220  
    5252    // The constructor will be added later, after NumberConstructor has been constructed
    5353
    54     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
    55     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
    56     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
    57     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
    58     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
    59     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
     54    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
     55    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
     57    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
     58    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
     59    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
    6060}
    6161
  • trunk/JavaScriptCore/runtime/ObjectPrototype.cpp

    r43122 r43220  
    4343    : JSObject(stucture)
    4444{
    45     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
    46     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
    47     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
    48     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
    49     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
    50     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
     45    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
     46    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
     47    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
     48    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
     49    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
     50    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
    5151
    5252    // Mozilla extensions
    53     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
    54     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
    55     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
    56     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
     53    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
     54    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
     55    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
    5757}
    5858
  • trunk/JavaScriptCore/runtime/RegExpPrototype.cpp

    r43122 r43220  
    4848    : JSObject(structure)
    4949{
    50     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
    51     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
    52     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
    53     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
     50    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
     51    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
     52    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
     53    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
    5454}
    5555
  • trunk/JavaScriptCore/runtime/StringConstructor.cpp

    r43122 r43220  
    5454
    5555    // ECMA 15.5.3.2 fromCharCode()
    56     putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
    5757
    5858    // no. of arguments for constructor
Note: See TracChangeset for help on using the changeset viewer.