| Index: src/ia32/full-codegen-ia32.cc
|
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
|
| index b9e4d4bbb591b71efd37e7a05b312fc5258b94af..bafca92a33ceca273e9f35ceb7497f4ac132fe07 100644
|
| --- a/src/ia32/full-codegen-ia32.cc
|
| +++ b/src/ia32/full-codegen-ia32.cc
|
| @@ -1975,6 +1975,19 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
| EmitReturnSequence();
|
|
|
| __ bind(&resume);
|
| + Label init_value_check_done;
|
| + if (expr->yield_kind() == Yield::INITIAL) {
|
| + // When value is provided and it is not undefined, throw error.
|
| + __ CompareRoot(result_register(), Heap::kUndefinedValueRootIndex);
|
| + __ j(equal, &init_value_check_done);
|
| + // This error should be raised from the Generator.prototype.next side.
|
| + // So in this case, we return the hole value as a marker. The caller
|
| + // checks the result value and if it is the hole value, the caller
|
| + // throws error.
|
| + __ push(Immediate(isolate()->factory()->the_hole_value()));
|
| + __ jmp(&suspend);
|
| + }
|
| + __ bind(&init_value_check_done);
|
| context()->Plug(result_register());
|
| break;
|
| }
|
| @@ -2192,7 +2205,17 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| __ push(ebx);
|
| __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
|
|
|
| + // Throw error if we attempt to pass a value to an unborn generator.
|
| + Label wrong_start;
|
| + __ bind(&wrong_start);
|
| + __ CallRuntime(Runtime::kThrowGeneratorStartError, 0);
|
| +
|
| __ bind(&done);
|
| + // When a value is passed to an unborn generator, the result becomes the hole
|
| + // value. And we need to throw GeneratorStartError in the caller side.
|
| + // (Generator.prototype.next)
|
| + __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex);
|
| + __ j(equal, &wrong_start);
|
| context()->Plug(result_register());
|
| }
|
|
|
|
|