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

Unified Diff: src/parsing/parser-base.h

Issue 2685683002: [async-await] (simpler) fix for Return in try/finally in async functions (Closed)
Patch Set: also shrink the bitfield for ReturnStatement::Type Created 3 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.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index e1e3d3412281a274f2a3d03079735cc7c113a2de..777cad1ac79dfdcdceb8872bdc7bd316ffbb42ea 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -427,23 +427,12 @@ class ParserBase {
FunctionKind kind() const { return scope()->function_kind(); }
FunctionState* outer() const { return outer_function_state_; }
- void set_generator_object_variable(typename Types::Variable* variable) {
- DCHECK_NOT_NULL(variable);
- DCHECK(IsResumableFunction(kind()));
- DCHECK(scope()->has_forced_context_allocation());
- generator_object_variable_ = variable;
- }
typename Types::Variable* generator_object_variable() const {
- return generator_object_variable_;
+ return scope()->generator_object_var();
}
- void set_promise_variable(typename Types::Variable* variable) {
- DCHECK(variable != NULL);
- DCHECK(IsAsyncFunction(kind()));
- promise_variable_ = variable;
- }
typename Types::Variable* promise_variable() const {
- return promise_variable_;
+ return scope()->promise_var();
}
const ZoneList<DestructuringAssignment>&
@@ -1383,6 +1372,15 @@ class ParserBase {
return Call::NOT_EVAL;
}
+ // Convenience method which determines the type of return statement to emit
+ // depending on the current function type.
+ inline StatementT BuildReturnStatement(ExpressionT expr, int pos) {
+ if (V8_UNLIKELY(is_async_function())) {
+ return factory()->NewAsyncReturnStatement(expr, pos);
+ }
+ return factory()->NewReturnStatement(expr, pos);
+ }
+
// Validation per ES6 object literals.
class ObjectLiteralChecker {
public:
@@ -4276,9 +4274,8 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
} else {
ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
- body->Add(
- factory()->NewReturnStatement(expression, expression->position()),
- zone());
+ body->Add(BuildReturnStatement(expression, expression->position()),
+ zone());
if (allow_tailcalls() && !is_sloppy(language_mode())) {
// ES6 14.6.1 Static Semantics: IsInTailPosition
impl()->MarkTailPosition(expression);
@@ -5183,7 +5180,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseReturnStatement(
}
ExpectSemicolon(CHECK_OK);
return_value = impl()->RewriteReturn(return_value, loc.beg_pos);
- return factory()->NewReturnStatement(return_value, loc.beg_pos);
+ return BuildReturnStatement(return_value, loc.beg_pos);
}
template <typename Impl>
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698