Changeset 194135 in webkit


Ignore:
Timestamp:
Dec 16, 2015 1:10:09 AM (8 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):

Location:
trunk
Files:
7 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r194134 r194135  
     12015-12-16  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [ES6] Handle new_generator_func / new_generator_func_exp in DFG / FTL
     4        https://bugs.webkit.org/show_bug.cgi?id=152227
     5
     6        Reviewed by Saam Barati.
     7
     8        Make the test taking longer time.
     9
     10        * js/regress/script-tests/generator-function-create.js:
     11        (test):
     12
    1132015-12-16  Tomas Popela  <tpopela@redhat.com>
    214
  • trunk/LayoutTests/js/regress/script-tests/generator-function-create.js

    r193907 r194135  
    88    return gen;
    99}
    10 noInline(createGeneratorFunction);
     10function test()
     11{
     12    for (var i = 0; i < 500; ++i)
     13        createGeneratorFunction();
     14}
     15noInline(test);
     16
    1117for (var i = 0; i < 1e4; ++i)
    12     createGeneratorFunction();
     18    test();
  • trunk/Source/JavaScriptCore/ChangeLog

    r194131 r194135  
     12015-12-16  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [ES6] Handle new_generator_func / new_generator_func_exp in DFG / FTL
     4        https://bugs.webkit.org/show_bug.cgi?id=152227
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch introduces new_generator_func / new_generator_func_exp into DFG and FTL.
     9        We add a new DFG Node, NewGeneratorFunction. It will construct a function with GeneratorFunction's structure.
     10        The structure of GeneratorFunction is different from one of Function because GeneratorFunction has the different __proto__.
     11
     12        * dfg/DFGAbstractInterpreterInlines.h:
     13        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     14        * dfg/DFGByteCodeParser.cpp:
     15        (JSC::DFG::ByteCodeParser::parseBlock):
     16        * dfg/DFGCapabilities.cpp:
     17        (JSC::DFG::capabilityLevel):
     18        * dfg/DFGClobberize.h:
     19        (JSC::DFG::clobberize):
     20        * dfg/DFGClobbersExitState.cpp:
     21        (JSC::DFG::clobbersExitState):
     22        * dfg/DFGDoesGC.cpp:
     23        (JSC::DFG::doesGC):
     24        * dfg/DFGFixupPhase.cpp:
     25        (JSC::DFG::FixupPhase::fixupNode):
     26        * dfg/DFGMayExit.cpp:
     27        (JSC::DFG::mayExit):
     28        * dfg/DFGNode.h:
     29        (JSC::DFG::Node::convertToPhantomNewFunction):
     30        (JSC::DFG::Node::hasCellOperand):
     31        (JSC::DFG::Node::isFunctionAllocation):
     32        * dfg/DFGNodeType.h:
     33        * dfg/DFGObjectAllocationSinkingPhase.cpp:
     34        * dfg/DFGPredictionPropagationPhase.cpp:
     35        (JSC::DFG::PredictionPropagationPhase::propagate):
     36        * dfg/DFGSafeToExecute.h:
     37        (JSC::DFG::safeToExecute):
     38        * dfg/DFGSpeculativeJIT.cpp:
     39        (JSC::DFG::SpeculativeJIT::compileNewFunction):
     40        * dfg/DFGSpeculativeJIT32_64.cpp:
     41        (JSC::DFG::SpeculativeJIT::compile):
     42        * dfg/DFGSpeculativeJIT64.cpp:
     43        (JSC::DFG::SpeculativeJIT::compile):
     44        * dfg/DFGStoreBarrierInsertionPhase.cpp:
     45        * dfg/DFGStructureRegistrationPhase.cpp:
     46        (JSC::DFG::StructureRegistrationPhase::run):
     47        * ftl/FTLCapabilities.cpp:
     48        (JSC::FTL::canCompile):
     49        * ftl/FTLLowerDFGToLLVM.cpp:
     50        (JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
     51        (JSC::FTL::DFG::LowerDFGToLLVM::compileNewFunction):
     52        * tests/stress/generator-function-create-optimized.js: Added.
     53        (shouldBe):
     54        (g):
     55        (test.return.gen):
     56        (test):
     57        (test2.gen):
     58        (test2):
     59        * tests/stress/generator-function-declaration-sinking-no-double-allocate.js: Added.
     60        (shouldBe):
     61        (GeneratorFunctionPrototype):
     62        (call):
     63        (f):
     64        (sink):
     65        * tests/stress/generator-function-declaration-sinking-osrexit.js: Added.
     66        (shouldBe):
     67        (GeneratorFunctionPrototype):
     68        (g):
     69        (f):
     70        (sink):
     71        * tests/stress/generator-function-declaration-sinking-put.js: Added.
     72        (shouldBe):
     73        (GeneratorFunctionPrototype):
     74        (g):
     75        (f):
     76        (sink):
     77        * tests/stress/generator-function-expression-sinking-no-double-allocate.js: Added.
     78        (shouldBe):
     79        (GeneratorFunctionPrototype):
     80        (call):
     81        (f):
     82        (sink):
     83        * tests/stress/generator-function-expression-sinking-osrexit.js: Added.
     84        (shouldBe):
     85        (GeneratorFunctionPrototype):
     86        (g):
     87        (sink):
     88        * tests/stress/generator-function-expression-sinking-put.js: Added.
     89        (shouldBe):
     90        (GeneratorFunctionPrototype):
     91        (g):
     92        (sink):
     93
    1942015-12-15  Mark Lam  <mark.lam@apple.com>
    295
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r194113 r194135  
    17611761            m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->arrowFunctionStructure());
    17621762        break;
    1763            
     1763
     1764    case NewGeneratorFunction:
     1765        forNode(node).set(
     1766            m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->generatorFunctionStructure());
     1767        break;
     1768
    17641769    case NewFunction:
    17651770        forNode(node).set(
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r194087 r194135  
    45584558        }
    45594559           
    4560         case op_new_func: {
     4560        case op_new_func:
     4561        case op_new_generator_func: {
    45614562            FunctionExecutable* decl = m_inlineStackTop->m_profiledBlock->functionDecl(currentInstruction[3].u.operand);
    45624563            FrozenValue* frozen = m_graph.freezeStrong(decl);
    4563             set(VirtualRegister(currentInstruction[1].u.operand),
    4564                 addToGraph(NewFunction, OpInfo(frozen), get(VirtualRegister(currentInstruction[2].u.operand))));
     4564            NodeType op = (opcodeID == op_new_generator_func) ? NewGeneratorFunction : NewFunction;
     4565            set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(op, OpInfo(frozen), get(VirtualRegister(currentInstruction[2].u.operand))));
     4566            static_assert(OPCODE_LENGTH(op_new_func) == OPCODE_LENGTH(op_new_generator_func), "The length of op_new_func should eqaual to one of op_new_generator_func");
    45654567            NEXT_OPCODE(op_new_func);
    45664568        }
    45674569
    45684570        case op_new_func_exp:
     4571        case op_new_generator_func_exp:
    45694572        case op_new_arrow_func_exp: {
    45704573            FunctionExecutable* expr = m_inlineStackTop->m_profiledBlock->functionExpr(currentInstruction[3].u.operand);
    45714574            FrozenValue* frozen = m_graph.freezeStrong(expr);
    4572             set(VirtualRegister(currentInstruction[1].u.operand),
    4573                 addToGraph(NewFunction, OpInfo(frozen), get(VirtualRegister(currentInstruction[2].u.operand))));
    4574            
    4575             if (opcodeID == op_new_func_exp) {
     4575            NodeType op = (opcodeID == op_new_generator_func_exp) ? NewGeneratorFunction : NewFunction;
     4576            set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(op, OpInfo(frozen), get(VirtualRegister(currentInstruction[2].u.operand))));
     4577           
     4578            if (opcodeID == op_new_func_exp || opcodeID == op_new_generator_func_exp) {
    45764579                // Curly braces are necessary
     4580                static_assert(OPCODE_LENGTH(op_new_func_exp) == OPCODE_LENGTH(op_new_generator_func_exp), "The length of op_new_func_exp should eqaual to one of op_new_generator_func_exp");
    45774581                NEXT_OPCODE(op_new_func_exp);
    45784582            } else {
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r194036 r194135  
    216216    case op_new_func:
    217217    case op_new_func_exp:
     218    case op_new_generator_func:
     219    case op_new_generator_func_exp:
    218220    case op_new_arrow_func_exp:
    219221    case op_create_lexical_environment:
  • trunk/Source/JavaScriptCore/dfg/DFGClobberize.h

    r194113 r194135  
    10341034    case NewArrowFunction:
    10351035    case NewFunction:
     1036    case NewGeneratorFunction:
    10361037        if (node->castOperand<FunctionExecutable*>()->singletonFunction()->isStillValid())
    10371038            write(Watchpoint_fire);
  • trunk/Source/JavaScriptCore/dfg/DFGClobbersExitState.cpp

    r190076 r194135  
    7878    case NewArrowFunction:
    7979    case NewFunction:
     80    case NewGeneratorFunction:
    8081        // Like above, but with the JSFunction allocation caveat.
    8182        return node->castOperand<FunctionExecutable*>()->singletonFunction()->isStillValid();
  • trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp

    r194087 r194135  
    248248    case NewArrowFunction:
    249249    case NewFunction:
     250    case NewGeneratorFunction:
    250251    case NewTypedArray:
    251252    case ThrowReferenceError:
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r194113 r194135  
    13881388        case CreateScopedArguments:
    13891389        case CreateActivation:
    1390         case NewFunction: {
     1390        case NewFunction:
     1391        case NewGeneratorFunction: {
    13911392            fixEdge<CellUse>(node->child1());
    13921393            break;
  • trunk/Source/JavaScriptCore/dfg/DFGMayExit.cpp

    r192814 r194135  
    144144    case NewFunction:
    145145    case NewArrowFunction:
     146    case NewGeneratorFunction:
    146147    case NewStringObject:
    147148    case CreateActivation:
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r194113 r194135  
    586586    void convertToPhantomNewFunction()
    587587    {
    588         ASSERT(m_op == NewFunction || m_op == NewArrowFunction);
     588        ASSERT(m_op == NewFunction || m_op == NewArrowFunction || m_op == NewGeneratorFunction);
    589589        m_op = PhantomNewFunction;
    590590        m_flags |= NodeMustGenerate;
     
    13571357        case NewFunction:
    13581358        case NewArrowFunction:
     1359        case NewGeneratorFunction:
    13591360        case CreateActivation:
    13601361        case MaterializeCreateActivation:
     
    15751576        case NewArrowFunction:
    15761577        case NewFunction:
     1578        case NewGeneratorFunction:
    15771579            return true;
    15781580        default:
  • trunk/Source/JavaScriptCore/dfg/DFGNodeType.h

    r194087 r194135  
    313313    \
    314314    macro(NewArrowFunction, NodeResultJS) \
     315    macro(NewGeneratorFunction, NodeResultJS) \
    315316    \
    316317    /* These aren't terminals but always exit */ \
  • 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);
  • trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

    r194087 r194135  
    210210        case GetCallee:
    211211        case NewArrowFunction:
    212         case NewFunction: {
     212        case NewFunction:
     213        case NewGeneratorFunction: {
    213214            changed |= setPrediction(SpecFunction);
    214215            break;
  • trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h

    r194087 r194135  
    269269    case NewArrowFunction:
    270270    case NewFunction:
     271    case NewGeneratorFunction:
    271272    case Jump:
    272273    case Branch:
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r194113 r194135  
    5151#include "JSCInlines.h"
    5252#include "JSEnvironmentRecord.h"
     53#include "JSGeneratorFunction.h"
    5354#include "JSLexicalEnvironment.h"
    5455#include "LinkBuffer.h"
     
    53735374{
    53745375    NodeType nodeType = node->op();
    5375     ASSERT(nodeType == NewFunction || nodeType == NewArrowFunction);
     5376    ASSERT(nodeType == NewFunction || nodeType == NewArrowFunction || nodeType == NewGeneratorFunction);
    53765377   
    53775378    SpeculateCellOperand scope(this, node->child1());
     
    54115412            callOperation(operationNewArrowFunction, resultGPR, scopeGPR, executable, thisValueTagGPR, thisValuePayloadGPR);
    54125413#endif
     5414        else if (nodeType == NewGeneratorFunction)
     5415            callOperation(operationNewGeneratorFunction, resultGPR, scopeGPR, executable);
    54135416        else
    54145417            callOperation(operationNewFunction, resultGPR, scopeGPR, executable);
     
    54185421    }
    54195422
    5420     Structure* structure = nodeType == NewArrowFunction
    5421         ? m_jit.graph().globalObjectFor(node->origin.semantic)->arrowFunctionStructure()
    5422         : m_jit.graph().globalObjectFor(node->origin.semantic)->functionStructure();
     5423    Structure* structure =
     5424        nodeType == NewArrowFunction ? m_jit.graph().globalObjectFor(node->origin.semantic)->arrowFunctionStructure() :
     5425        nodeType == NewGeneratorFunction ? m_jit.graph().globalObjectFor(node->origin.semantic)->generatorFunctionStructure() :
     5426        m_jit.graph().globalObjectFor(node->origin.semantic)->functionStructure();
    54235427   
    54245428    GPRTemporary result(this);
     
    54365440           
    54375441        addSlowPathGenerator(slowPathCall(slowPath, this, operationNewFunctionWithInvalidatedReallocationWatchpoint, resultGPR, scopeGPR, executable));
     5442    }
     5443
     5444    if (nodeType == NewGeneratorFunction) {
     5445        compileNewFunctionCommon<JSGeneratorFunction>(resultGPR, structure, scratch1GPR, scratch2GPR, scopeGPR, slowPath, JSGeneratorFunction::allocationSize(0), executable, JSGeneratorFunction::offsetOfScopeChain(), JSGeneratorFunction::offsetOfExecutable(), JSGeneratorFunction::offsetOfRareData());
     5446
     5447        addSlowPathGenerator(slowPathCall(slowPath, this, operationNewGeneratorFunctionWithInvalidatedReallocationWatchpoint, resultGPR, scopeGPR, executable));
    54385448    }
    54395449   
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r194087 r194135  
    44094409    case NewFunction:
    44104410    case NewArrowFunction:
     4411    case NewGeneratorFunction:
    44114412        compileNewFunction(node);
    44124413        break;
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r194087 r194135  
    43984398    case NewFunction:
    43994399    case NewArrowFunction:
     4400    case NewGeneratorFunction:
    44004401        compileNewFunction(node);
    44014402        break;
  • trunk/Source/JavaScriptCore/dfg/DFGStoreBarrierInsertionPhase.cpp

    r190076 r194135  
    307307            case NewArrowFunction:
    308308            case NewFunction:
     309            case NewGeneratorFunction:
    309310                // Nodes that allocate get to set their epoch because for those nodes we know
    310311                // that they will be the newest object in the heap.
  • trunk/Source/JavaScriptCore/dfg/DFGStructureRegistrationPhase.cpp

    r193653 r194135  
    147147                    registerStructure(m_graph.globalObjectFor(node->origin.semantic)->functionStructure());
    148148                    break;
     149                case NewGeneratorFunction:
     150                    registerStructure(m_graph.globalObjectFor(node->origin.semantic)->generatorFunctionStructure());
     151                    break;
    149152                   
    150153                default:
  • trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r194087 r194135  
    112112    case NewArrowFunction:
    113113    case NewFunction:
     114    case NewGeneratorFunction:
    114115    case GetClosureVar:
    115116    case PutClosureVar:
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

    r194126 r194135  
    5353#include "JSArrowFunction.h"
    5454#include "JSCInlines.h"
     55#include "JSGeneratorFunction.h"
    5556#include "JSLexicalEnvironment.h"
    5657#include "OperandsInlines.h"
     
    755756        case NewFunction:
    756757        case NewArrowFunction:
     758        case NewGeneratorFunction:
    757759            compileNewFunction();
    758760            break;
     
    35613563    void compileNewFunction()
    35623564    {
    3563         ASSERT(m_node->op() == NewFunction || m_node->op() == NewArrowFunction);
    3564        
     3565        ASSERT(m_node->op() == NewFunction || m_node->op() == NewArrowFunction || m_node->op() == NewGeneratorFunction);
    35653566        bool isArrowFunction = m_node->op() == NewArrowFunction;
     3567        bool isGeneratorFunction = m_node->op() == NewGeneratorFunction;
    35663568       
    35673569        LValue scope = lowCell(m_node->child1());
     
    35703572        FunctionExecutable* executable = m_node->castOperand<FunctionExecutable*>();
    35713573        if (executable->singletonFunction()->isStillValid()) {
    3572             LValue callResult = isArrowFunction
    3573                 ? vmCall(m_out.int64, m_out.operation(operationNewArrowFunction), m_callFrame, scope, weakPointer(executable), thisValue)
    3574                 : vmCall(m_out.int64, m_out.operation(operationNewFunction), m_callFrame, scope, weakPointer(executable));
     3574            LValue callResult =
     3575                isArrowFunction ? vmCall(m_out.int64, m_out.operation(operationNewArrowFunction), m_callFrame, scope, weakPointer(executable), thisValue) :
     3576                isGeneratorFunction ? vmCall(m_out.int64, m_out.operation(operationNewGeneratorFunction), m_callFrame, scope, weakPointer(executable)) :
     3577                vmCall(m_out.int64, m_out.operation(operationNewFunction), m_callFrame, scope, weakPointer(executable));
    35753578            setJSValue(callResult);
    35763579            return;
    35773580        }
    35783581       
    3579         Structure* structure = isArrowFunction
    3580             ? m_graph.globalObjectFor(m_node->origin.semantic)->arrowFunctionStructure()
    3581             : m_graph.globalObjectFor(m_node->origin.semantic)->functionStructure();
     3582        Structure* structure =
     3583            isArrowFunction ? m_graph.globalObjectFor(m_node->origin.semantic)->arrowFunctionStructure() :
     3584            isGeneratorFunction ? m_graph.globalObjectFor(m_node->origin.semantic)->generatorFunctionStructure() :
     3585            m_graph.globalObjectFor(m_node->origin.semantic)->functionStructure();
    35823586       
    35833587        LBasicBlock slowPath = FTL_NEW_BLOCK(m_out, ("NewFunction slow path"));
     
    35863590        LBasicBlock lastNext = m_out.insertNewBlocksBefore(slowPath);
    35873591       
    3588         LValue fastObject = isArrowFunction
    3589             ? allocateObject<JSArrowFunction>(structure, m_out.intPtrZero, slowPath)
    3590             : allocateObject<JSFunction>(structure, m_out.intPtrZero, slowPath);
     3592        LValue fastObject =
     3593            isArrowFunction ? allocateObject<JSArrowFunction>(structure, m_out.intPtrZero, slowPath) :
     3594            isGeneratorFunction ? allocateObject<JSGeneratorFunction>(structure, m_out.intPtrZero, slowPath) :
     3595            allocateObject<JSFunction>(structure, m_out.intPtrZero, slowPath);
    35913596       
    35923597       
     
    36173622                        locations[0].directGPR(), locations[1].directGPR(),
    36183623                        CCallHelpers::TrustedImmPtr(executable), locations[2].directGPR());
     3624                }
     3625                if (isGeneratorFunction) {
     3626                    return createLazyCallGenerator(
     3627                        operationNewGeneratorFunctionWithInvalidatedReallocationWatchpoint,
     3628                        locations[0].directGPR(), locations[1].directGPR(),
     3629                        CCallHelpers::TrustedImmPtr(executable));
    36193630                }
    36203631                return createLazyCallGenerator(
Note: See TracChangeset for help on using the changeset viewer.