Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merged 7fe4d93
Browse files Browse the repository at this point in the history
[interpreter] Don't assume generator functions do an initial yield.

R=hablich@chromium.org
NOTRY=true
NOPRESUBMIT=true
BUG=chromium:638019

Review-Url: https://codereview.chromium.org/2251003003
Cr-Commit-Position: refs/branch-heads/5.3@{#50}
Cr-Branched-From: 820a23a-refs/heads/5.3.332@{#2}
Cr-Branched-From: 37538cb-refs/heads/master@{#37308}
  • Loading branch information
GeorgNeis authored and Commit bot committed Aug 18, 2016
1 parent a5fea2a commit 0f2210a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/interpreter/bytecode-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,10 @@ void BytecodeGenerator::VisitGeneratorPrologue() {
BuildIndexedJump(generator_state_, 0, generator_resume_points_.size(),
generator_resume_points_);

builder()->Bind(&regular_call);
builder()
->Bind(&regular_call)
.LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))
.StoreAccumulatorInRegister(generator_state_);
// This is a regular call. Fall through to the ordinary function prologue,
// after which we will run into the generator object creation and other extra
// code inserted by the parser.
Expand Down
30 changes: 18 additions & 12 deletions test/cctest/interpreter/bytecode_expectations/Generators.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ snippet: "
"
frame size: 11
parameter count: 1
bytecode array length: 200
bytecode array length: 204
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(20),
B(ResumeGenerator), R(new_target),
B(Star), R(1),
B(LdaZero),
B(TestEqualStrict), R(1),
B(JumpIfTrue), U8(56),
B(JumpIfTrue), U8(60),
B(LdaSmi), U8(76),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1),
B(LdaSmi), U8(-2),
B(Star), R(1),
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
B(Ldar), R(this),
Expand Down Expand Up @@ -109,7 +111,7 @@ bytecodes: [
constant pool: [
]
handlers: [
[38, 137, 143],
[42, 141, 147],
]

---
Expand All @@ -119,21 +121,23 @@ snippet: "
"
frame size: 11
parameter count: 1
bytecode array length: 293
bytecode array length: 297
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(26),
B(ResumeGenerator), R(new_target),
B(Star), R(1),
B(LdaZero),
B(TestEqualStrict), R(1),
B(JumpIfTrue), U8(62),
B(JumpIfTrue), U8(66),
B(LdaSmi), U8(1),
B(TestEqualStrict), R(1),
B(JumpIfTrueConstant), U8(0),
B(LdaSmi), U8(76),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1),
B(LdaSmi), U8(-2),
B(Star), R(1),
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
B(Ldar), R(this),
Expand Down Expand Up @@ -255,7 +259,7 @@ constant pool: [
kInstanceTypeDontCare,
]
handlers: [
[44, 221, 227],
[48, 225, 231],
]

---
Expand All @@ -265,21 +269,23 @@ snippet: "
"
frame size: 17
parameter count: 1
bytecode array length: 775
bytecode array length: 779
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(26),
B(ResumeGenerator), R(new_target),
B(Star), R(3),
B(LdaZero),
B(TestEqualStrict), R(3),
B(JumpIfTrue), U8(62),
B(JumpIfTrue), U8(66),
B(LdaSmi), U8(1),
B(TestEqualStrict), R(3),
B(JumpIfTrueConstant), U8(3),
B(LdaSmi), U8(76),
B(Star), R(4),
B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1),
B(LdaSmi), U8(-2),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
B(Ldar), R(this),
Expand Down Expand Up @@ -601,9 +607,9 @@ constant pool: [
kInstanceTypeDontCare,
]
handlers: [
[44, 694, 700],
[154, 448, 454],
[157, 402, 404],
[551, 563, 565],
[48, 698, 704],
[158, 452, 458],
[161, 406, 408],
[555, 567, 569],
]

7 changes: 7 additions & 0 deletions test/mjsunit/harmony/async-await-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,10 @@ assertEqualsAsync(
"20", () => (async(foo, { a = "0" }) => foo + a)("2", { a: undefined }));
assertThrows(() => eval("async({ foo = 1 })"), SyntaxError);
assertThrows(() => eval("async(a, { foo = 1 })"), SyntaxError);

// https://bugs.chromium.org/p/chromium/issues/detail?id=638019
async function gaga() {
let i = 1;
while (i-- > 0) { await 42 }
}
assertDoesNotThrow(gaga);

0 comments on commit 0f2210a

Please sign in to comment.