• barraclough@apple.com's avatar
    Implement Function.prototype.bind · 22215665
    barraclough@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=26382
    
    Reviewed by Sam Weinig.
    
    Source/JavaScriptCore: 
    
    This patch provides a basic functional implementation
    for Function.bind. It should (hopefully!) be fully
    functionally correct, and the bound functions can be
    called to quickly (since they are a subclass of
    JSFunction, not InternalFunction), but we'll probably
    want to follow up with some optimization work to keep
    bound calls in JIT code.
    
    * JavaScriptCore.JSVALUE32_64only.exp:
    * JavaScriptCore.JSVALUE64only.exp:
    * JavaScriptCore.exp:
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * jit/JITStubs.cpp:
    (JSC::JITThunks::hostFunctionStub):
    * jit/JITStubs.h:
    * jsc.cpp:
    (GlobalObject::addFunction):
    * runtime/CommonIdentifiers.h:
    * runtime/ConstructData.h:
    * runtime/Executable.h:
    (JSC::NativeExecutable::NativeExecutable):
    * runtime/FunctionPrototype.cpp:
    (JSC::FunctionPrototype::addFunctionProperties):
    (JSC::functionProtoFuncBind):
    * runtime/FunctionPrototype.h:
    * runtime/JSBoundFunction.cpp: Added.
    (JSC::boundFunctionCall):
    (JSC::boundFunctionConstruct):
    (JSC::JSBoundFunction::create):
    (JSC::JSBoundFunction::hasInstance):
    (JSC::JSBoundFunction::getOwnPropertySlot):
    (JSC::JSBoundFunction::getOwnPropertyDescriptor):
    (JSC::JSBoundFunction::JSBoundFunction):
    (JSC::JSBoundFunction::finishCreation):
    * runtime/JSBoundFunction.h: Added.
    (JSC::JSBoundFunction::targetFunction):
    (JSC::JSBoundFunction::boundThis):
    (JSC::JSBoundFunction::boundArgs):
    (JSC::JSBoundFunction::createStructure):
    * runtime/JSFunction.cpp:
    (JSC::JSFunction::create):
    (JSC::JSFunction::finishCreation):
    (JSC::createDescriptorForThrowingProperty):
    (JSC::JSFunction::getOwnPropertySlot):
    * runtime/JSFunction.h:
    * runtime/JSGlobalData.cpp:
    (JSC::JSGlobalData::getHostFunction):
    * runtime/JSGlobalData.h:
    * runtime/JSGlobalObject.cpp:
    (JSC::JSGlobalObject::reset):
    (JSC::JSGlobalObject::visitChildren):
    * runtime/JSGlobalObject.h:
    (JSC::JSGlobalObject::boundFunctionStructure):
    * runtime/Lookup.cpp:
    (JSC::setUpStaticFunctionSlot):
    
    Source/WebCore: 
    
    Test: fast/js/function-bind.html
    
    * bindings/js/JSDOMBinding.cpp:
    (WebCore::objectToStringFunctionGetter):
    * bindings/js/JSDOMWindowCustom.cpp:
    (WebCore::nonCachingStaticFunctionGetter):
    * bindings/js/JSHistoryCustom.cpp:
    (WebCore::nonCachingStaticBackFunctionGetter):
    (WebCore::nonCachingStaticForwardFunctionGetter):
    (WebCore::nonCachingStaticGoFunctionGetter):
    * bindings/js/JSLocationCustom.cpp:
    (WebCore::nonCachingStaticReplaceFunctionGetter):
    (WebCore::nonCachingStaticReloadFunctionGetter):
    (WebCore::nonCachingStaticAssignFunctionGetter):
        - Function::create no longer requires functionStructure() to be passed.
    
    LayoutTests: 
    
    We now pass Function.bind tests.
    
    * fast/js/Object-getOwnPropertyNames-expected.txt:
    * fast/js/basic-strict-mode-expected.txt:
    * fast/js/function-bind-expected.txt: Added.
    * fast/js/function-bind.html: Added.
    * fast/js/mozilla/strict/15.3.4.5-expected.txt:
    * fast/js/script-tests/function-bind.js: Added.
    * ietestcenter/Javascript/15.2.3.3-4-38-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-0-1-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-0-2-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-13.b-1-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-13.b-2-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-13.b-3-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-13.b-4-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-13.b-5-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-15-1-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-15-2-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-16-1-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-1-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-2-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-3-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-4-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-5-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-6-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-7-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-8-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-2-9-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-8-1-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-8-2-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-9-1-expected.txt:
    * ietestcenter/Javascript/15.3.4.5-9-2-expected.txt:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    22215665
CommonIdentifiers.h 4.03 KB