Ignore:
Timestamp:
Dec 16, 2015, 1:10:09 AM (9 years ago)
Author:
Yusuke Suzuki
Message:

[ES6] Handle new_generator_func / new_generator_func_exp in DFG / FTL
https://bugs.webkit.org/show_bug.cgi?id=152227

Reviewed by Saam Barati.

Source/JavaScriptCore:

This patch introduces new_generator_func / new_generator_func_exp into DFG and FTL.
We add a new DFG Node, NewGeneratorFunction. It will construct a function with GeneratorFunction's structure.
The structure of GeneratorFunction is different from one of Function because GeneratorFunction has the different proto.

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):

  • dfg/DFGClobberize.h:

(JSC::DFG::clobberize):

  • dfg/DFGClobbersExitState.cpp:

(JSC::DFG::clobbersExitState):

  • dfg/DFGDoesGC.cpp:

(JSC::DFG::doesGC):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):

  • dfg/DFGMayExit.cpp:

(JSC::DFG::mayExit):

  • dfg/DFGNode.h:

(JSC::DFG::Node::convertToPhantomNewFunction):
(JSC::DFG::Node::hasCellOperand):
(JSC::DFG::Node::isFunctionAllocation):

  • dfg/DFGNodeType.h:
  • dfg/DFGObjectAllocationSinkingPhase.cpp:
  • dfg/DFGPredictionPropagationPhase.cpp:

(JSC::DFG::PredictionPropagationPhase::propagate):

  • dfg/DFGSafeToExecute.h:

(JSC::DFG::safeToExecute):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileNewFunction):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGStoreBarrierInsertionPhase.cpp:
  • dfg/DFGStructureRegistrationPhase.cpp:

(JSC::DFG::StructureRegistrationPhase::run):

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
(JSC::FTL::DFG::LowerDFGToLLVM::compileNewFunction):

  • tests/stress/generator-function-create-optimized.js: Added.

(shouldBe):
(g):
(test.return.gen):
(test):
(test2.gen):
(test2):

  • tests/stress/generator-function-declaration-sinking-no-double-allocate.js: Added.

(shouldBe):
(GeneratorFunctionPrototype):
(call):
(f):
(sink):

  • tests/stress/generator-function-declaration-sinking-osrexit.js: Added.

(shouldBe):
(GeneratorFunctionPrototype):
(g):
(f):
(sink):

  • tests/stress/generator-function-declaration-sinking-put.js: Added.

(shouldBe):
(GeneratorFunctionPrototype):
(g):
(f):
(sink):

  • tests/stress/generator-function-expression-sinking-no-double-allocate.js: Added.

(shouldBe):
(GeneratorFunctionPrototype):
(call):
(f):
(sink):

  • tests/stress/generator-function-expression-sinking-osrexit.js: Added.

(shouldBe):
(GeneratorFunctionPrototype):
(g):
(sink):

  • tests/stress/generator-function-expression-sinking-put.js: Added.

(shouldBe):
(GeneratorFunctionPrototype):
(g):
(sink):

LayoutTests:

Make the test taking longer time.

  • js/regress/script-tests/generator-function-create.js:

(test):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp

    r193766 r194135  
    140140    // replace any use of those pointers by the corresponding
    141141    // materialization
    142     enum class Kind { Escaped, Object, Activation, Function, NewArrowFunction };
     142    enum class Kind { Escaped, Object, Activation, Function, ArrowFunction, GeneratorFunction };
    143143
    144144    explicit Allocation(Node* identifier = nullptr, Kind kind = Kind::Escaped)
     
    234234    bool isFunctionAllocation() const
    235235    {
    236         return m_kind == Kind::Function || m_kind == Kind::NewArrowFunction;
    237     }
    238    
    239     bool isArrowFunctionAllocation() const
    240     {
    241         return m_kind == Kind::NewArrowFunction;
     236        return m_kind == Kind::Function || m_kind == Kind::ArrowFunction || m_kind == Kind::GeneratorFunction;
    242237    }
    243238
     
    275270            break;
    276271               
    277         case Kind::NewArrowFunction:
    278             out.print("NewArrowFunction");
     272        case Kind::ArrowFunction:
     273            out.print("ArrowFunction");
     274            break;
     275
     276        case Kind::GeneratorFunction:
     277            out.print("GeneratorFunction");
    279278            break;
    280279
     
    838837
    839838        case NewFunction:
    840         case NewArrowFunction: {
     839        case NewArrowFunction:
     840        case NewGeneratorFunction: {
    841841            if (node->castOperand<FunctionExecutable*>()->singletonFunction()->isStillValid()) {
    842842                m_heap.escape(node->child1().node());
     
    844844            }
    845845           
    846             target = &m_heap.newAllocation(node, Allocation::Kind::Function);
     846            if (node->op() == NewGeneratorFunction)
     847                target = &m_heap.newAllocation(node, Allocation::Kind::GeneratorFunction);
     848            else if (node->op() == NewArrowFunction)
     849                target = &m_heap.newAllocation(node, Allocation::Kind::ArrowFunction);
     850            else
     851                target = &m_heap.newAllocation(node, Allocation::Kind::Function);
    847852            writes.add(FunctionExecutablePLoc, LazyNode(node->cellOperand()));
    848853            writes.add(FunctionActivationPLoc, LazyNode(node->child1().node()));
     
    14471452        }
    14481453
    1449         case Allocation::Kind::NewArrowFunction:
     1454        case Allocation::Kind::ArrowFunction:
     1455        case Allocation::Kind::GeneratorFunction:
    14501456        case Allocation::Kind::Function: {
    14511457            FrozenValue* executable = allocation.identifier()->cellOperand();
    14521458           
    1453             NodeType nodeType = allocation.kind() == Allocation::Kind::NewArrowFunction ? NewArrowFunction : NewFunction;
     1459            NodeType nodeType =
     1460                allocation.kind() == Allocation::Kind::ArrowFunction ? NewArrowFunction :
     1461                allocation.kind() == Allocation::Kind::GeneratorFunction ? NewGeneratorFunction : NewFunction;
    14541462           
    14551463            return m_graph.addNode(
     
    17831791                    case NewArrowFunction:
    17841792                    case NewFunction:
     1793                    case NewGeneratorFunction:
    17851794                        node->convertToPhantomNewFunction();
    17861795                        break;
     
    20342043       
    20352044        case NewFunction:
    2036         case NewArrowFunction: {
     2045        case NewArrowFunction:
     2046        case NewGeneratorFunction: {
    20372047            Vector<PromotedHeapLocation> locations = m_locationsForAllocation.get(escapee);
    20382048            ASSERT(locations.size() == 2);
Note: See TracChangeset for help on using the changeset viewer.