Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: src/parsing/parser.cc

Issue 1667503004: Fix embarrassing bug in last-minute-change to yield* CL. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 81e0a5eb5a04bec1355e41c157088c3bf2cd4431..dfac2c994fb991771c9f01271653405bb97405af 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -5809,7 +5809,7 @@ void ParserTraits::SetFunctionNameFromIdentifierRef(Expression* value,
// if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output);
// break;
// case kReturn:
-// IteratorClose(iterator, input); // See below.
+// IteratorClose(iterator, input, output); // See below.
// break;
// case kThrow:
// let iteratorThrow = iterator.throw;
@@ -5846,15 +5846,15 @@ void ParserTraits::SetFunctionNameFromIdentifierRef(Expression* value,
//
// let iteratorReturn = iterator.return;
// if (IS_NULL_OR_UNDEFINED(iteratorReturn)) return;
-// let result = %_Call(iteratorReturn, iterator);
-// if (!IS_RECEIVER(result)) %ThrowIterResultNotAnObject(result);
+// let output = %_Call(iteratorReturn, iterator);
+// if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output);
//
-// IteratorClose(iterator, input) expands to the following:
+// IteratorClose(iterator, input, output) expands to the following:
//
// let iteratorReturn = iterator.return;
// if (IS_NULL_OR_UNDEFINED(iteratorReturn)) return input;
-// let result = %_Call(iteratorReturn, iterator, input);
-// if (!IS_RECEIVER(result)) %ThrowIterResultNotAnObject(result);
+// output = %_Call(iteratorReturn, iterator, input);
+// if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output);
Expression* ParserTraits::RewriteYieldStar(
@@ -6023,7 +6023,8 @@ Expression* ParserTraits::RewriteYieldStar(
Statement* throw_call = factory->NewExpressionStatement(call, nopos);
Block* then = factory->NewBlock(nullptr, 4+1, false, nopos);
- BuildIteratorClose(then->statements(), var_iterator, Nothing<Variable*>());
+ BuildIteratorClose(then->statements(), var_iterator, Nothing<Variable*>(),
+ Nothing<Variable*>());
then->statements()->Add(throw_call, zone);
check_throw =
factory->NewIfStatement(condition, then, skip, nopos);
@@ -6195,7 +6196,8 @@ Expression* ParserTraits::RewriteYieldStar(
case_next->Add(factory->NewBreakStatement(switch_mode, nopos), zone);
auto case_return = new (zone) ZoneList<Statement*>(5, zone);
- BuildIteratorClose(case_return, var_iterator, Just(var_input));
+ BuildIteratorClose(
+ case_return, var_iterator, Just(var_input), Just(var_output));
case_return->Add(factory->NewBreakStatement(switch_mode, nopos), zone);
auto case_throw = new (zone) ZoneList<Statement*>(5, zone);
@@ -6259,7 +6261,8 @@ Expression* ParserTraits::RewriteYieldStar(
void ParserTraits::BuildIteratorClose(ZoneList<Statement*>* statements,
Variable* iterator,
- Maybe<Variable*> input) {
+ Maybe<Variable*> input,
+ Maybe<Variable*> output) {
const int nopos = RelocInfo::kNoPosition;
auto factory = parser_->factory();
auto avfactory = parser_->ast_value_factory();
@@ -6300,8 +6303,8 @@ void ParserTraits::BuildIteratorClose(ZoneList<Statement*>* statements,
factory->NewIfStatement(condition, return_undefined, skip, nopos);
}
- // let result = %_Call(iteratorReturn, iterator); OR
- // let result = %_Call(iteratorReturn, iterator, input);
+ // let output = %_Call(iteratorReturn, iterator); OR
+ // output = %_Call(iteratorReturn, iterator, input);
Statement* call_return;
{
auto args = new (zone) ZoneList<Expression*>(3, zone);
@@ -6313,13 +6316,15 @@ void ParserTraits::BuildIteratorClose(ZoneList<Statement*>* statements,
Expression* call =
factory->NewCallRuntime(Runtime::kInlineCall, args, nopos);
+ Expression* output_proxy = factory->NewVariableProxy(
+ output.IsJust() ? output.FromJust() : var);
Expression* assignment = factory->NewAssignment(
- Token::ASSIGN, factory->NewVariableProxy(var), call, nopos);
+ Token::ASSIGN, output_proxy, call, nopos);
call_return = factory->NewExpressionStatement(assignment, nopos);
}
- // if (!IS_RECEIVER(result)) %ThrowIterResultNotAnObject(result);
- Statement* validate_result;
+ // if (!IS_RECEIVER(output)) %ThrowIterResultNotAnObject(output);
+ Statement* validate_output;
{
Expression* is_receiver_call;
{
@@ -6338,14 +6343,14 @@ void ParserTraits::BuildIteratorClose(ZoneList<Statement*>* statements,
throw_call = factory->NewExpressionStatement(call, nopos);
}
- validate_result =
+ validate_output =
factory->NewIfStatement(is_receiver_call, skip, throw_call, nopos);
}
statements->Add(get_return, zone);
statements->Add(check_return, zone);
statements->Add(call_return, zone);
- statements->Add(validate_result, zone);
+ statements->Add(validate_output, zone);
}
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698