Chromium Code Reviews| Index: src/ast/ast-numbering.cc |
| diff --git a/src/ast/ast-numbering.cc b/src/ast/ast-numbering.cc |
| index 1c345c2f4133d52cf805d3e53b3a84634add7ff3..b34da82f8d3788afbb315e6c9a24043130a0274e 100644 |
| --- a/src/ast/ast-numbering.cc |
| +++ b/src/ast/ast-numbering.cc |
| @@ -17,6 +17,7 @@ class AstNumberingVisitor final : public AstVisitor { |
| isolate_(isolate), |
| zone_(zone), |
| next_id_(BailoutId::FirstUsable().ToInt()), |
| + yield_count_(0), |
| properties_(zone), |
| slot_cache_(zone), |
| dont_optimize_reason_(kNoReason) { |
| @@ -31,8 +32,6 @@ class AstNumberingVisitor final : public AstVisitor { |
| AST_NODE_LIST(DEFINE_VISIT) |
| #undef DEFINE_VISIT |
| - bool Finish(FunctionLiteral* node); |
| - |
| void VisitVariableProxyReference(VariableProxy* node); |
| void VisitPropertyReference(Property* node); |
| void VisitReference(Expression* expr); |
| @@ -73,9 +72,21 @@ class AstNumberingVisitor final : public AstVisitor { |
| BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } |
| + int GetAndResetYieldCount() { |
| + int old_yield_count = yield_count_; |
| + yield_count_ = 0; |
| + return old_yield_count; |
| + } |
| + |
| + void StoreAndUpdateYieldCount(IterationStatement* node, int old_yield_count) { |
| + node->set_yield_count(yield_count_); |
| + yield_count_ += old_yield_count; |
| + } |
| + |
| Isolate* isolate_; |
| Zone* zone_; |
| int next_id_; |
| + int yield_count_; |
| AstProperties properties_; |
| // The slot cache allows us to reuse certain feedback vector slots. |
| FeedbackVectorSlotCache slot_cache_; |
| @@ -217,6 +228,7 @@ void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { |
| void AstNumberingVisitor::VisitYield(Yield* node) { |
| + yield_count_++; |
| IncrementNodeCount(); |
| DisableOptimization(kYield); |
| ReserveFeedbackSlots(node); |
| @@ -284,8 +296,10 @@ void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { |
| IncrementNodeCount(); |
| DisableSelfOptimization(); |
| node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); |
| + int old_yield_count = GetAndResetYieldCount(); |
| Visit(node->body()); |
| Visit(node->cond()); |
| + StoreAndUpdateYieldCount(node, old_yield_count); |
| } |
| @@ -293,8 +307,10 @@ void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { |
| IncrementNodeCount(); |
| DisableSelfOptimization(); |
| node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); |
| + int old_yield_count = GetAndResetYieldCount(); |
| Visit(node->cond()); |
| Visit(node->body()); |
| + StoreAndUpdateYieldCount(node, old_yield_count); |
| } |
| @@ -377,9 +393,11 @@ void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { |
| IncrementNodeCount(); |
| DisableSelfOptimization(); |
| node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); |
| + Visit(node->enumerable()); // Not part of loop. |
|
neis
2016/04/13 09:54:27
Here I'm changing the order of visits, for conveni
|
| + int old_yield_count = GetAndResetYieldCount(); |
| Visit(node->each()); |
| - Visit(node->enumerable()); |
| Visit(node->body()); |
| + StoreAndUpdateYieldCount(node, old_yield_count); |
| ReserveFeedbackSlots(node); |
| } |
| @@ -388,11 +406,13 @@ void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { |
| IncrementNodeCount(); |
| DisableCrankshaft(kForOfStatement); |
| node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); |
| - Visit(node->assign_iterator()); |
| + Visit(node->assign_iterator()); // Not part of loop. |
| + int old_yield_count = GetAndResetYieldCount(); |
| Visit(node->next_result()); |
| Visit(node->result_done()); |
| Visit(node->assign_each()); |
| Visit(node->body()); |
| + StoreAndUpdateYieldCount(node, old_yield_count); |
| ReserveFeedbackSlots(node); |
| } |
| @@ -440,10 +460,12 @@ void AstNumberingVisitor::VisitForStatement(ForStatement* node) { |
| IncrementNodeCount(); |
| DisableSelfOptimization(); |
| node->set_base_id(ReserveIdRange(ForStatement::num_ids())); |
| - if (node->init() != NULL) Visit(node->init()); |
| + if (node->init() != NULL) Visit(node->init()); // Not part of loop. |
| + int old_yield_count = GetAndResetYieldCount(); |
| if (node->cond() != NULL) Visit(node->cond()); |
| if (node->next() != NULL) Visit(node->next()); |
| Visit(node->body()); |
| + StoreAndUpdateYieldCount(node, old_yield_count); |
| } |
| @@ -554,13 +576,6 @@ void AstNumberingVisitor::VisitRewritableExpression( |
| } |
| -bool AstNumberingVisitor::Finish(FunctionLiteral* node) { |
| - node->set_ast_properties(&properties_); |
| - node->set_dont_optimize_reason(dont_optimize_reason()); |
| - return !HasStackOverflow(); |
| -} |
| - |
| - |
| bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { |
| Scope* scope = node->scope(); |
| if (scope->new_target_var()) DisableCrankshaft(kSuperReference); |
| @@ -577,7 +592,10 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { |
| VisitDeclarations(scope->declarations()); |
| VisitStatements(node->body()); |
| - return Finish(node); |
| + node->set_ast_properties(&properties_); |
| + node->set_dont_optimize_reason(dont_optimize_reason()); |
| + node->set_yield_count(yield_count_); |
| + return !HasStackOverflow(); |
| } |