Ignore:
Timestamp:
Sep 22, 2011, 2:22:17 PM (14 years ago)
Author:
[email protected]
Message:

Implement Function.prototype.bind
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.

(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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95742 r95751  
     12011-09-22  Gavin Barraclough  <[email protected]>
     2
     3        Implement Function.prototype.bind
     4        https://bugs.webkit.org/show_bug.cgi?id=26382
     5
     6        Reviewed by Sam Weinig.
     7
     8        This patch provides a basic functional implementation
     9        for Function.bind. It should (hopefully!) be fully
     10        functionally correct, and the bound functions can be
     11        called to quickly (since they are a subclass of
     12        JSFunction, not InternalFunction), but we'll probably
     13        want to follow up with some optimization work to keep
     14        bound calls in JIT code.
     15
     16        * JavaScriptCore.JSVALUE32_64only.exp:
     17        * JavaScriptCore.JSVALUE64only.exp:
     18        * JavaScriptCore.exp:
     19        * JavaScriptCore.xcodeproj/project.pbxproj:
     20        * jit/JITStubs.cpp:
     21        (JSC::JITThunks::hostFunctionStub):
     22        * jit/JITStubs.h:
     23        * jsc.cpp:
     24        (GlobalObject::addFunction):
     25        * runtime/CommonIdentifiers.h:
     26        * runtime/ConstructData.h:
     27        * runtime/Executable.h:
     28        (JSC::NativeExecutable::NativeExecutable):
     29        * runtime/FunctionPrototype.cpp:
     30        (JSC::FunctionPrototype::addFunctionProperties):
     31        (JSC::functionProtoFuncBind):
     32        * runtime/FunctionPrototype.h:
     33        * runtime/JSBoundFunction.cpp: Added.
     34        (JSC::boundFunctionCall):
     35        (JSC::boundFunctionConstruct):
     36        (JSC::JSBoundFunction::create):
     37        (JSC::JSBoundFunction::hasInstance):
     38        (JSC::JSBoundFunction::getOwnPropertySlot):
     39        (JSC::JSBoundFunction::getOwnPropertyDescriptor):
     40        (JSC::JSBoundFunction::JSBoundFunction):
     41        (JSC::JSBoundFunction::finishCreation):
     42        * runtime/JSBoundFunction.h: Added.
     43        (JSC::JSBoundFunction::targetFunction):
     44        (JSC::JSBoundFunction::boundThis):
     45        (JSC::JSBoundFunction::boundArgs):
     46        (JSC::JSBoundFunction::createStructure):
     47        * runtime/JSFunction.cpp:
     48        (JSC::JSFunction::create):
     49        (JSC::JSFunction::finishCreation):
     50        (JSC::createDescriptorForThrowingProperty):
     51        (JSC::JSFunction::getOwnPropertySlot):
     52        * runtime/JSFunction.h:
     53        * runtime/JSGlobalData.cpp:
     54        (JSC::JSGlobalData::getHostFunction):
     55        * runtime/JSGlobalData.h:
     56        * runtime/JSGlobalObject.cpp:
     57        (JSC::JSGlobalObject::reset):
     58        (JSC::JSGlobalObject::visitChildren):
     59        * runtime/JSGlobalObject.h:
     60        (JSC::JSGlobalObject::boundFunctionStructure):
     61        * runtime/Lookup.cpp:
     62        (JSC::setUpStaticFunctionSlot):
     63
    1642011-09-22  Oliver Hunt  <[email protected]>
    265
Note: See TracChangeset for help on using the changeset viewer.