Commit 3c71bd18 authored by ishell's avatar ishell Committed by Commit bot

[es6] Fix tail Call nodes marking.

TBR=rossberg@chromium.org

Review URL: https://codereview.chromium.org/1666183002

Cr-Commit-Position: refs/heads/master@{#33761}
parent c357a87a
......@@ -473,7 +473,10 @@ class Block final : public BreakableStatement {
}
void MarkTail() override {
if (!statements_.is_empty()) statements_.last()->MarkTail();
for (int i = 0; i < statements_.length(); i++) {
Statement* stmt = statements_.at(i);
stmt->MarkTail();
}
}
Scope* scope() const { return scope_; }
......@@ -962,7 +965,6 @@ class ExpressionStatement final : public Statement {
void set_expression(Expression* e) { expression_ = e; }
Expression* expression() const { return expression_; }
bool IsJump() const override { return expression_->IsThrow(); }
void MarkTail() override { expression_->MarkTail(); }
protected:
ExpressionStatement(Zone* zone, Expression* expression, int pos)
......@@ -1020,6 +1022,8 @@ class ReturnStatement final : public JumpStatement {
void set_expression(Expression* e) { expression_ = e; }
void MarkTail() override { expression_->MarkTail(); }
protected:
explicit ReturnStatement(Zone* zone, Expression* expression, int pos)
: JumpStatement(zone, pos), expression_(expression) { }
......@@ -1089,7 +1093,10 @@ class CaseClause final : public Expression {
TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); }
void MarkTail() override {
if (!statements_->is_empty()) statements_->last()->MarkTail();
for (int i = 0; i < statements_->length(); i++) {
Statement* stmt = statements_->at(i);
stmt->MarkTail();
}
}
Type* compare_type() { return compare_type_; }
......@@ -1125,7 +1132,10 @@ class SwitchStatement final : public BreakableStatement {
void set_tag(Expression* t) { tag_ = t; }
void MarkTail() override {
if (!cases_->is_empty()) cases_->last()->MarkTail();
for (int i = 0; i < cases_->length(); i++) {
CaseClause* clause = cases_->at(i);
clause->MarkTail();
}
}
protected:
......
......@@ -1608,7 +1608,9 @@ void AstPrinter::VisitProperty(Property* node) {
void AstPrinter::VisitCall(Call* node) {
EmbeddedVector<char, 128> buf;
FormatSlotNode(&buf, node, "CALL", node->CallFeedbackICSlot());
const char* name =
node->tail_call_mode() == TailCallMode::kAllow ? "TAIL CALL" : "CALL";
FormatSlotNode(&buf, node, name, node->CallFeedbackICSlot());
IndentedScope indent(this, buf.start());
Visit(node->expression());
......
......@@ -2792,11 +2792,6 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
is_undefined, ThisExpression(scope_, factory(), pos),
is_object_conditional, pos);
}
// ES6 14.6.1 Static Semantics: IsInTailPosition
if (FLAG_harmony_tailcalls && !is_sloppy(language_mode())) {
return_value->MarkTail();
}
}
ExpectSemicolon(CHECK_OK);
......@@ -4750,6 +4745,13 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
RelocInfo::kNoPosition));
}
// ES6 14.6.1 Static Semantics: IsInTailPosition
if (FLAG_harmony_tailcalls && !is_sloppy(language_mode())) {
for (int i = 0; i < body->length(); i++) {
Statement* stmt = body->at(i);
stmt->MarkTail();
}
}
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment