Changeset 210558 in webkit


Ignore:
Timestamp:
Jan 10, 2017 1:13:33 PM (7 years ago)
Author:
gskachkov@gmail.com
Message:

Calling async arrow function which is in a class's member function will cause error
https://bugs.webkit.org/show_bug.cgi?id=166879

Reviewed by Saam Barati.

JSTests:

  • stress/async-arrow-functions-lexical-binding-in-class.js: Added.

(shouldBe):
(shouldBeAsync):
(BaseClass.prototype.baseClassValue):
(BaseClass.prototype.get property):
(BaseClass):
(runSomething):
(ChildClass.prototype.classValue):
(ChildClass.prototype.get classProperty):
(ChildClass.prototype.asyncValueExp):
(ChildClass.prototype.asyncValueBody):
(ChildClass.prototype.asyncThisPropExp):
(ChildClass.prototype.asyncThisPropBody):
(ChildClass.prototype.asyncThisPropInEvalExp):
(ChildClass.prototype.asyncThisPropInEvalBody):
(ChildClass.prototype.asyncThisValueExp):
(ChildClass.prototype.asyncThisValueBody):
(ChildClass.prototype.asyncThisValueInEvalExp):
(ChildClass.prototype.asyncThisValueInEvalBody):
(ChildClass):
(ChildClass2):
(ChildClass2.prototype.classValue):
(ChildClass2.prototype.get classProperty):

  • stress/async-arrow-functions-lexical-super-binding.js:

Source/JavaScriptCore:

Current patch fixed loading 'super' in async arrow function. Errored appear becuase
super was loaded always nevertherless if it used in async arrow function or not, but bytecompiler
put to arrow function context only if it used within arrow function. So to fix this issue we need to
check if super was used in arrow function.

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::FunctionNode::emitBytecode):

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r210522 r210558  
     12017-01-10  Skachkov Oleksandr  <gskachkov@gmail.com>
     2
     3        Calling async arrow function which is in a class's member function will cause error
     4        https://bugs.webkit.org/show_bug.cgi?id=166879
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/async-arrow-functions-lexical-binding-in-class.js: Added.
     9        (shouldBe):
     10        (shouldBeAsync):
     11        (BaseClass.prototype.baseClassValue):
     12        (BaseClass.prototype.get property):
     13        (BaseClass):
     14        (runSomething):
     15        (ChildClass.prototype.classValue):
     16        (ChildClass.prototype.get classProperty):
     17        (ChildClass.prototype.asyncValueExp):
     18        (ChildClass.prototype.asyncValueBody):
     19        (ChildClass.prototype.asyncThisPropExp):
     20        (ChildClass.prototype.asyncThisPropBody):
     21        (ChildClass.prototype.asyncThisPropInEvalExp):
     22        (ChildClass.prototype.asyncThisPropInEvalBody):
     23        (ChildClass.prototype.asyncThisValueExp):
     24        (ChildClass.prototype.asyncThisValueBody):
     25        (ChildClass.prototype.asyncThisValueInEvalExp):
     26        (ChildClass.prototype.asyncThisValueInEvalBody):
     27        (ChildClass):
     28        (ChildClass2):
     29        (ChildClass2.prototype.classValue):
     30        (ChildClass2.prototype.get classProperty):
     31        * stress/async-arrow-functions-lexical-super-binding.js:
     32
    1332017-01-09  Yusuke Suzuki  <utatane.tea@gmail.com>
    234
  • trunk/JSTests/stress/async-arrow-functions-lexical-super-binding.js

    r208843 r210558  
    3939}
    4040
    41 // FIXME: super bindings in async arrow functions are broken
    4241shouldBeAsync("BaseClassValue", new ChildClass().asyncSuperProp());
    4342shouldBeAsync("BaseClassValue", new ChildClass().asyncSuperProp2());
  • trunk/Source/JavaScriptCore/ChangeLog

    r210557 r210558  
     12017-01-10  Skachkov Oleksandr  <gskachkov@gmail.com>
     2
     3        Calling async arrow function which is in a class's member function will cause error
     4        https://bugs.webkit.org/show_bug.cgi?id=166879
     5
     6        Reviewed by Saam Barati.
     7
     8        Current patch fixed loading 'super' in async arrow function. Errored appear becuase
     9        super was loaded always nevertherless if it used in async arrow function or not, but bytecompiler
     10        put to arrow function context only if it used within arrow function. So to fix this issue we need to
     11        check if super was used in arrow function.
     12
     13        * bytecompiler/BytecodeGenerator.h:
     14        * bytecompiler/NodesCodegen.cpp:
     15        (JSC::FunctionNode::emitBytecode):
     16
    1172017-01-10  Commit Queue  <commit-queue@webkit.org>
    218
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r210522 r210558  
    906906       
    907907        bool isNewTargetUsedInInnerArrowFunction();
     908        bool isArgumentsUsedInInnerArrowFunction();
     909
     910    public:
    908911        bool isSuperUsedInInnerArrowFunction();
    909         bool isArgumentsUsedInInnerArrowFunction();
    910 
    911     public:
    912912        bool isSuperCallUsedInInnerArrowFunction();
    913913        bool isThisUsedInInnerArrowFunction();
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r210522 r210558  
    35033503        generator.emitNode(next.get(), funcExpr);
    35043504
    3505         if (generator.superBinding() == SuperBinding::Needed || generator.parseMode() == SourceParseMode::AsyncArrowFunctionMode) {
    3506             // FIXME: Don't always load home object for async arrows
     3505        if (generator.superBinding() == SuperBinding::Needed || (generator.parseMode() == SourceParseMode::AsyncArrowFunctionMode && generator.isSuperUsedInInnerArrowFunction())) {
    35073506            RefPtr<RegisterID> homeObject = emitHomeObjectForCallee(generator);
    35083507            emitPutHomeObject(generator, next.get(), homeObject.get());
Note: See TracChangeset for help on using the changeset viewer.