Ignore:
Timestamp:
Jul 16, 2018, 11:49:22 AM (7 years ago)
Author:
Yusuke Suzuki
Message:

[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.

  1. 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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r233122 r233855  
    9191ALWAYS_INLINE static SourceParseMode getAsynFunctionBodyParseMode(SourceParseMode parseMode)
    9292{
    93     if (isAsyncGeneratorFunctionParseMode(parseMode))
     93    if (isAsyncGeneratorWrapperParseMode(parseMode))
    9494        return SourceParseMode::AsyncGeneratorBodyMode;
    9595
     
    238238        else if (isGeneratorWrapperParseMode(parseMode))
    239239            sourceElements = parseGeneratorFunctionSourceElements(context, calleeName, CheckForStrictMode);
    240         else if (isAsyncGeneratorFunctionParseMode(parseMode))
     240        else if (isAsyncGeneratorWrapperParseMode(parseMode))
    241241            sourceElements = parseAsyncGeneratorFunctionSourceElements(context, parseMode, isArrowFunctionBodyExpression, CheckForStrictMode);
    242242        else
     
    567567template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseAsyncGeneratorFunctionSourceElements(TreeBuilder& context, SourceParseMode parseMode, bool isArrowFunctionBodyExpression, SourceElementsMode mode)
    568568{
    569     ASSERT_UNUSED(parseMode, isAsyncGeneratorFunctionParseMode(parseMode));
     569    ASSERT_UNUSED(parseMode, isAsyncGeneratorWrapperParseMode(parseMode));
    570570    auto sourceElements = context.createSourceElements();
    571571       
Note: See TracChangeset for help on using the changeset viewer.