[JSC] Generator and AsyncGeneratorMethod's prototype is incorrect
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 18:49:22 +0000 (18:49 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 18:49:22 +0000 (18:49 +0000)
commit1bffe0f1b140f3786579729e1b6755e9ba1cab16
tree7d0700d51db6e512d2d348f599d5ce3ec0d4e1ac
parent4091ae3cbad7279b24fbc925b6e571757d144590
[JSC] Generator and AsyncGeneratorMethod's prototype is incorrect
https://bugs.webkit.org/show_bug.cgi?id=187585

Reviewed by Darin Adler.

JSTests:

* stress/default-proto-for-async-generator.js: Added.
(shouldBe):
(async.asyncGenerator):
* stress/default-proto-for-generator.js: Added.
(shouldBe):
(generator):
* stress/prototype-for-async-generator.js: Added.
(shouldBe):
(async.asyncGenerator):
(A.prototype.async.asyncGenerator):
(A):
* test262/expectations.yaml:

Source/JavaScriptCore:

This patch fixes Generator and AsyncGenerator's prototype issues.

1. Generator's default prototype is incorrect when `generator.prototype = null` is performed.
We fix this by changing JSFunction::prototypeForConstruction.

2. AsyncGeneratorMethod is not handled. We change the name isAsyncGeneratorFunctionParseMode
to isAsyncGeneratorWrapperParseMode since it is aligned to Generator's code. And use it well
to fix `prototype` issues for AsyncGeneratorMethod.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitPutAsyncGeneratorFields):
(JSC::BytecodeGenerator::emitNewFunction):
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionNode::emitBytecode):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionMetadata):
* parser/Parser.cpp:
(JSC::getAsynFunctionBodyParseMode):
(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseAsyncGeneratorFunctionSourceElements):
* parser/ParserModes.h:
(JSC::isAsyncGeneratorParseMode):
(JSC::isAsyncGeneratorWrapperParseMode):
(JSC::isAsyncGeneratorFunctionParseMode): Deleted.
* runtime/FunctionExecutable.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::prototypeForConstruction):
(JSC::JSFunction::getOwnPropertySlot):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233855 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
JSTests/ChangeLog
JSTests/stress/default-proto-for-async-generator.js [new file with mode: 0644]
JSTests/stress/default-proto-for-generator.js [new file with mode: 0644]
JSTests/stress/prototype-for-async-generator.js [new file with mode: 0644]
JSTests/test262/expectations.yaml
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/ParserModes.h
Source/JavaScriptCore/runtime/FunctionExecutable.h
Source/JavaScriptCore/runtime/JSFunction.cpp