Ignore:
Timestamp:
Dec 29, 2015, 3:49:35 AM (10 years ago)
Author:
Yusuke Suzuki
Message:

[ES6][ES7] Drop Constructability of generator function
https://bugs.webkit.org/show_bug.cgi?id=152383

Reviewed by Saam Barati.

We drop the constructability of generator functions.
This functionality is already landed in ES 2016 draft[1].
And this simplifies the existing JSC's generator implementation;
dropping GeneratorThisMode flag.

[1]: https://github.com/tc39/ecma262/releases/tag/es2016-draft-20151201

(JSC::createExecutableInternal):

  • bytecode/ExecutableInfo.h:

(JSC::ExecutableInfo::ExecutableInfo):
(JSC::ExecutableInfo::generatorThisMode): Deleted.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): Deleted.

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::generatorThisMode): Deleted.

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::generateUnlinkedFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

  • bytecode/UnlinkedFunctionExecutable.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator): Deleted.

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::makeFunction):
(JSC::BytecodeGenerator::generatorThisMode): Deleted.

  • bytecompiler/NodesCodegen.cpp:

(JSC::ThisNode::emitBytecode):

  • interpreter/Interpreter.cpp:

(JSC::eval): Deleted.

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/Executable.h:
  • runtime/GeneratorThisMode.h: Removed.
  • tests/stress/generator-eval-this.js:

(shouldThrow):

  • tests/stress/generator-is-not-constructible.js: Added.

(shouldThrow):
(A.staticGen):
(A.prototype.gen):
(A):
(TypeError):

  • tests/stress/generator-this.js:

(shouldBe.g.next):

  • tests/stress/generator-with-new-target.js:

(shouldThrow):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r193766 r194435  
    3232#include "ConstructAbility.h"
    3333#include "ExpressionRangeInfo.h"
    34 #include "GeneratorThisMode.h"
    3534#include "HandlerInfo.h"
    3635#include "Identifier.h"
     
    6766    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    6867
    69     static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, GeneratorThisMode generatorThisMode, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext, RefPtr<SourceProvider>&& sourceOverride = nullptr)
     68    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext, RefPtr<SourceProvider>&& sourceOverride = nullptr)
    7069    {
    7170        UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap))
    72             UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, generatorThisMode, parentScopeTDZVariables, isDerivedConstructorContext);
     71            UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, parentScopeTDZVariables, isDerivedConstructorContext);
    7372        instance->finishCreation(*vm);
    7473        return instance;
     
    8483    FunctionMode functionMode() const { return static_cast<FunctionMode>(m_functionMode); }
    8584    ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); }
    86     GeneratorThisMode generatorThisMode() const { return static_cast<GeneratorThisMode>(m_generatorThisMode); }
    8785    SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); }
    8886
     
    134132
    135133private:
    136     UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, GeneratorThisMode, VariableEnvironment&, bool isDerivedConstructorContext);
     134    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&, bool isDerivedConstructorContext);
    137135   
    138136    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall;
     
    165163    unsigned m_constructorKind : 2;
    166164    unsigned m_functionMode : 1; // FunctionMode
    167     unsigned m_generatorThisMode : 1;
    168165    unsigned m_superBinding : 1;
    169166    unsigned m_isDerivedConstructorContext : 1;
Note: See TracChangeset for help on using the changeset viewer.