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

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

Issue 1962853002: [es8] Prepare explicit tail calls (STC) for staging with implicit tail calls (PTC). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@src-stage
Patch Set: Addressing comments Created 4 years, 7 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.cc » ('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 1cdcc3f66767c3af7c9ecd9107a18cdffb91e82f..1036ac942962ec93e2d37089f460bbf880366821 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -194,25 +194,36 @@ class ParserBase : public Traits {
class TailCallExpressionList {
public:
explicit TailCallExpressionList(Zone* zone)
- : zone_(zone), expressions_(0, zone) {}
+ : zone_(zone), expressions_(0, zone), has_explicit_tail_calls_(false) {}
const ZoneList<ExpressionT>& expressions() const { return expressions_; }
const Scanner::Location& location() const { return loc_; }
- bool is_empty() const { return expressions_.is_empty(); }
+ bool has_explicit_tail_calls() const { return has_explicit_tail_calls_; }
void Swap(TailCallExpressionList& other) {
expressions_.Swap(&other.expressions_);
std::swap(loc_, other.loc_);
+ std::swap(has_explicit_tail_calls_, other.has_explicit_tail_calls_);
}
- void Add(ExpressionT expr, const Scanner::Location& loc) {
- if (expressions_.is_empty()) loc_ = loc;
+ void AddImplicitTailCall(ExpressionT expr) {
+ expressions_.Add(expr, zone_);
+ }
+
+ void AddExplicitTailCall(ExpressionT expr, const Scanner::Location& loc) {
+ if (!has_explicit_tail_calls()) {
+ loc_ = loc;
+ has_explicit_tail_calls_ = true;
+ }
expressions_.Add(expr, zone_);
}
void Append(const TailCallExpressionList& other) {
- if (expressions_.is_empty()) loc_ = other.loc_;
+ if (!has_explicit_tail_calls()) {
+ loc_ = other.loc_;
+ has_explicit_tail_calls_ = other.has_explicit_tail_calls_;
+ }
expressions_.AddAll(other.expressions_, zone_);
}
@@ -220,6 +231,7 @@ class ParserBase : public Traits {
Zone* zone_;
ZoneList<ExpressionT> expressions_;
Scanner::Location loc_;
+ bool has_explicit_tail_calls_;
};
// Defines whether tail call expressions are allowed or not.
@@ -297,15 +309,18 @@ class ParserBase : public Traits {
TailCallExpressionList& tail_call_expressions() {
return tail_call_expressions_;
}
- void AddExpressionInTailPosition(ExpressionT expression,
- const Scanner::Location& loc) {
- // If only FLAG_harmony_explicit_tailcalls is enabled then expression
- // must be a Call expression.
- DCHECK(FLAG_harmony_tailcalls || !FLAG_harmony_explicit_tailcalls ||
- expression->IsCall());
+ void AddImplicitTailCallExpression(ExpressionT expression) {
+ if (return_expr_context() ==
+ ReturnExprContext::kInsideValidReturnStatement) {
+ tail_call_expressions_.AddImplicitTailCall(expression);
+ }
+ }
+ void AddExplicitTailCallExpression(ExpressionT expression,
+ const Scanner::Location& loc) {
+ DCHECK(expression->IsCall());
if (return_expr_context() ==
ReturnExprContext::kInsideValidReturnStatement) {
- tail_call_expressions_.Add(expression, loc);
+ tail_call_expressions_.AddExplicitTailCall(expression, loc);
}
}
@@ -2269,7 +2284,7 @@ ParserBase<Traits>::ParseTailCallExpression(ExpressionClassifier* classifier,
}
classifier->RecordTailCallExpressionError(
loc, MessageTemplate::kUnexpectedTailCall);
- function_state_->AddExpressionInTailPosition(expression, loc);
+ function_state_->AddExplicitTailCallExpression(expression, loc);
return expression;
}
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698