Changeset 196361 in webkit


Ignore:
Timestamp:
Feb 9, 2016 10:01:28 PM (8 years ago)
Author:
keith_miller@apple.com
Message:

calling methods off super in a class constructor should check for TDZ
https://bugs.webkit.org/show_bug.cgi?id=154060

Reviewed by Ryosuke Niwa.

In a class constructor we need to check for TDZ when calling a method
off the super class. This is because, for super method calls, we use
the derived class's newly constructed object as the super method's
this value.

  • bytecompiler/NodesCodegen.cpp:

(JSC::FunctionCallDotNode::emitBytecode):

  • tests/stress/super-method-calls-check-tdz.js: Added.

(Base):
(Derived):
(test):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r196337 r196361  
     12016-02-09  Keith Miller  <keith_miller@apple.com>
     2
     3        calling methods off super in a class constructor should check for TDZ
     4        https://bugs.webkit.org/show_bug.cgi?id=154060
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        In a class constructor we need to check for TDZ when calling a method
     9        off the super class. This is because, for super method calls, we use
     10        the derived class's newly constructed object as the super method's
     11        this value.
     12
     13        * bytecompiler/NodesCodegen.cpp:
     14        (JSC::FunctionCallDotNode::emitBytecode):
     15        * tests/stress/super-method-calls-check-tdz.js: Added.
     16        (Base):
     17        (Derived):
     18        (test):
     19
    1202016-02-09  Filip Pizlo  <fpizlo@apple.com>
    221
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r196323 r196361  
    919919    CallArguments callArguments(generator, m_args);
    920920    bool baseIsSuper = m_base->isSuperNode();
    921     if (baseIsSuper)
     921    if (baseIsSuper) {
     922        generator.emitTDZCheck(generator.thisRegister());
    922923        generator.emitMove(callArguments.thisRegister(), generator.thisRegister());
    923     else
     924    } else
    924925        generator.emitNode(callArguments.thisRegister(), m_base);
    925926    generator.emitExpressionInfo(subexpressionDivot(), subexpressionStart(), subexpressionEnd());
Note: See TracChangeset for help on using the changeset viewer.