[ES7] yield star should not return if the inner iterator.throw returns { done: true }
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Apr 2016 07:35:48 +0000 (07:35 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Apr 2016 07:35:48 +0000 (07:35 +0000)
commit0558bd8e47a5d51456b2cf26f0992d020a505d11
tree91b8880dc523408101186b10f67fedc53ed7546a
parentbd73849b7eaa59695f9ee313c2a11c390a35fae0
[ES7] yield star should not return if the inner iterator.throw returns { done: true }
https://bugs.webkit.org/show_bug.cgi?id=156576

Reviewed by Saam Barati.

This is slight generator fix in ES7. When calling generator.throw(),
the yield-star should call the throw() of the inner generator. At that
time, when the result of throw() is { done: true}, the generator should
not stop itself.

    function * gen()
    {
        yield * (function * () {
            try {
                yield 42;
            } catch (error) { }
        }());
        // Continue executing.
        yield 42;
    }

    let g = gen();
    g.next();
    shouldBe(g.throw().value, 42);

* builtins/GeneratorPrototype.js:
(generatorResume):
(next):
(return):
(throw):
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitDelegateYield):
* runtime/JSGeneratorFunction.h:
* tests/stress/generator-yield-star.js:
(gen):
* tests/stress/yield-star-throw-continue.js: Added.
(shouldBe):
(generator):
(shouldThrow):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199652 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/builtins/GeneratorPrototype.js
Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp
Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/runtime/JSGeneratorFunction.h
Source/JavaScriptCore/tests/stress/generator-yield-star.js
Source/JavaScriptCore/tests/stress/yield-star-throw-continue.js [new file with mode: 0644]