Ignore:
Timestamp:
Oct 11, 2015, 11:46:52 AM (10 years ago)
Author:
Yusuke Suzuki
Message:

ES6 classes: When a class extends B, super() invokes B.prototype.constructor() instead of B()
https://bugs.webkit.org/show_bug.cgi?id=149001

Reviewed by Saam Barati.

Source/JavaScriptCore:

This patch matches the super() call in the constructor to the latest spec.
Before this patch, when calling super(), it loads callee.[[HomeObject]].__proto__.constructor
as a super constructor. But after this patch, it loads callee.__proto__ as a super constructor.
This behavior corresponds to the section 12.3.5.2[1].

[1]: http://www.ecma-international.org/ecma-262/6.0/#sec-getsuperconstructor

  • bytecompiler/NodesCodegen.cpp:

(JSC::SuperNode::emitBytecode):

  • tests/stress/super-call-does-not-look-up-constructor.js: Added.

(shouldBe):
(B):
(C):
(B.prototype):

LayoutTests:

An error message becomes changed.

  • js/class-syntax-call-expected.txt:
  • js/class-syntax-extends-expected.txt:
  • js/class-syntax-super-expected.txt:
  • js/script-tests/class-syntax-call.js:
  • js/script-tests/class-syntax-extends.js:
  • js/script-tests/class-syntax-super.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r190014 r190847  
    168168    callee.setIndex(JSStack::Callee);
    169169
    170     RefPtr<RegisterID> homeObject = generator.emitGetById(generator.newTemporary(), &callee, generator.propertyNames().homeObjectPrivateName);
    171     RefPtr<RegisterID> protoParent = generator.emitGetById(generator.newTemporary(), homeObject.get(), generator.propertyNames().underscoreProto);
    172     return generator.emitGetById(generator.finalDestination(dst), protoParent.get(), generator.propertyNames().constructor);
     170    return generator.emitGetById(generator.finalDestination(dst), &callee, generator.propertyNames().underscoreProto);
    173171}
    174172
Note: See TracChangeset for help on using the changeset viewer.