Changeset 189522 in webkit


Ignore:
Timestamp:
Sep 8, 2015 6:01:06 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Function.prototype.bind: Bound functions must use the Prototype? of their target function instead of Function.prototype
https://bugs.webkit.org/show_bug.cgi?id=145605

Patch by Matthew Hill <matthew.jh@outlook.com> on 2015-09-08
Reviewed by Geoffrey Garen.

  • runtime/JSBoundFunction.cpp:

(JSC::JSBoundFunction::create):

  • tests/es6.yaml:
Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r189520 r189522  
     12015-09-08  Matthew Hill  <matthew.jh@outlook.com>
     2
     3        Function.prototype.bind: Bound functions must use the [[Prototype]] of their target function instead of Function.prototype
     4        https://bugs.webkit.org/show_bug.cgi?id=145605
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * runtime/JSBoundFunction.cpp:
     9        (JSC::JSBoundFunction::create):
     10        * tests/es6.yaml:
     11
    1122015-09-08  Mark Lam  <mark.lam@apple.com>
    213
  • trunk/Source/JavaScriptCore/runtime/JSBoundFunction.cpp

    r182899 r189522  
    3636
    3737EncodedJSValue JSC_HOST_CALL boundFunctionCall(ExecState* exec)
    38 {
     38{   
    3939    JSBoundFunction* boundFunction = jsCast<JSBoundFunction*>(exec->callee());
    4040
     
    8181    bool canConstruct = constructType != ConstructTypeNone;
    8282    NativeExecutable* executable = vm.getHostFunction(boundFunctionCall, canConstruct ? boundFunctionConstruct : callHostFunctionAsConstructor);
    83     JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(vm, globalObject, globalObject->boundFunctionStructure(), targetFunction, boundThis, boundArgs);
    84 
     83    JSValue targetPrototype = targetFunction->prototype();
     84    Structure* structure = JSBoundFunction::createStructure(vm, globalObject, targetPrototype);
     85    JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(vm, globalObject, structure, targetFunction, boundThis, boundArgs);
     86   
    8587    function->finishCreation(vm, executable, length, name);
    8688    return function;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r189429 r189522  
    272272    m_functionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get()));
    273273    m_arrowFunctionStructure.set(vm, this, JSArrowFunction::createStructure(vm, this, m_functionPrototype.get()));
    274     m_boundFunctionStructure.set(vm, this, JSBoundFunction::createStructure(vm, this, m_functionPrototype.get()));
    275274    m_nativeStdFunctionStructure.set(vm, this, JSNativeStdFunction::createStructure(vm, this, m_functionPrototype.get()));
    276275    m_namedFunctionStructure.set(vm, this, Structure::addPropertyTransition(vm, m_functionStructure.get(), vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, m_functionNameOffset));
     
    819818    visitor.append(&thisObject->m_calleeStructure);
    820819    visitor.append(&thisObject->m_functionStructure);
    821     visitor.append(&thisObject->m_boundFunctionStructure);
    822820    visitor.append(&thisObject->m_arrowFunctionStructure);
    823821    visitor.append(&thisObject->m_nativeStdFunctionStructure);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r189429 r189522  
    256256    WriteBarrier<Structure> m_calleeStructure;
    257257    WriteBarrier<Structure> m_functionStructure;
    258     WriteBarrier<Structure> m_boundFunctionStructure;
    259258    WriteBarrier<Structure> m_arrowFunctionStructure;
    260259    WriteBarrier<Structure> m_nativeStdFunctionStructure;
     
    491490    Structure* calleeStructure() const { return m_calleeStructure.get(); }
    492491    Structure* functionStructure() const { return m_functionStructure.get(); }
    493     Structure* boundFunctionStructure() const { return m_boundFunctionStructure.get(); }
    494492    Structure* arrowFunctionStructure() const { return m_arrowFunctionStructure.get(); }
    495493    Structure* nativeStdFunctionStructure() const { return m_nativeStdFunctionStructure.get(); }
  • trunk/Source/JavaScriptCore/tests/es6.yaml

    r189504 r189522  
    882882  cmd: runES6 :fail
    883883- path: es6/prototype_of_bound_functions_arrow_functions.js
    884   cmd: runES6 :fail
     884  cmd: runES6 :normal
    885885- path: es6/prototype_of_bound_functions_basic_functions.js
    886   cmd: runES6 :fail
     886  cmd: runES6 :normal
    887887- path: es6/prototype_of_bound_functions_classes.js
    888   cmd: runES6 :fail
     888  cmd: runES6 :normal
    889889- path: es6/prototype_of_bound_functions_generator_functions.js
    890890  cmd: runES6 :fail
    891891- path: es6/prototype_of_bound_functions_subclasses.js
    892   cmd: runES6 :fail
     892  cmd: runES6 :normal
    893893- path: es6/Proxy_apply_handler.js
    894894  cmd: runES6 :fail
Note: See TracChangeset for help on using the changeset viewer.