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/runtime/FunctionExecutable.h

    r233039 r233855  
    137137    bool isSetter() const { return parseMode() == SourceParseMode::SetterMode; }
    138138    bool isGenerator() const { return isGeneratorParseMode(parseMode()); }
    139     bool isAsyncGenerator() const { return SourceParseModeSet(SourceParseMode::AsyncGeneratorWrapperFunctionMode, SourceParseMode::AsyncGeneratorBodyMode).contains(parseMode()); }
     139    bool isAsyncGenerator() const { return isAsyncGeneratorParseMode(parseMode()); }
    140140    bool isMethod() const { return parseMode() == SourceParseMode::MethodMode; }
    141141    bool hasCallerAndArgumentsProperties() const
     
    153153            SourceParseMode::GeneratorWrapperMethodMode,
    154154            SourceParseMode::AsyncGeneratorWrapperFunctionMode,
     155            SourceParseMode::AsyncGeneratorWrapperMethodMode,
    155156            SourceParseMode::AsyncGeneratorBodyMode
    156157        ).contains(parseMode()) || isClass();
Note: See TracChangeset for help on using the changeset viewer.