Chromium Code Reviews| Index: src/compiler/ast-graph-builder.cc |
| diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc |
| index 8591c956ff9435707d4ddb29dae8325381415562..bd9bf166e76daac379bc3e1fcb03f56504e01ae1 100644 |
| --- a/src/compiler/ast-graph-builder.cc |
| +++ b/src/compiler/ast-graph-builder.cc |
| @@ -139,10 +139,10 @@ class AstGraphBuilder::ContextScope BASE_EMBEDDED { |
| // - TryFinallyStatement: Intercepts 'break', 'continue', 'throw' and 'return'. |
| class AstGraphBuilder::ControlScope BASE_EMBEDDED { |
| public: |
| - ControlScope(AstGraphBuilder* builder, int stack_delta) |
| + explicit ControlScope(AstGraphBuilder* builder) |
| : builder_(builder), |
| outer_(builder->execution_control()), |
| - stack_delta_(stack_delta) { |
| + stack_height_(builder->environment()->stack_height()) { |
| builder_->set_execution_control(this); // Push. |
| } |
| @@ -189,12 +189,12 @@ class AstGraphBuilder::ControlScope BASE_EMBEDDED { |
| Environment* environment() { return builder_->environment(); } |
| AstGraphBuilder* builder() const { return builder_; } |
| - int stack_delta() const { return stack_delta_; } |
| + int stack_height() const { return stack_height_; } |
| private: |
| AstGraphBuilder* builder_; |
| ControlScope* outer_; |
| - int stack_delta_; |
| + int stack_height_; |
| }; |
| @@ -270,7 +270,7 @@ class AstGraphBuilder::ControlScopeForBreakable : public ControlScope { |
| public: |
| ControlScopeForBreakable(AstGraphBuilder* owner, BreakableStatement* target, |
| ControlBuilder* control) |
| - : ControlScope(owner, 0), target_(target), control_(control) {} |
| + : ControlScope(owner), target_(target), control_(control) {} |
| protected: |
| virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE { |
| @@ -297,8 +297,8 @@ class AstGraphBuilder::ControlScopeForBreakable : public ControlScope { |
| class AstGraphBuilder::ControlScopeForIteration : public ControlScope { |
| public: |
| ControlScopeForIteration(AstGraphBuilder* owner, IterationStatement* target, |
| - LoopBuilder* control, int stack_delta) |
| - : ControlScope(owner, stack_delta), target_(target), control_(control) {} |
| + LoopBuilder* control) |
| + : ControlScope(owner), target_(target), control_(control) {} |
| protected: |
| virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE { |
| @@ -327,7 +327,7 @@ class AstGraphBuilder::ControlScopeForIteration : public ControlScope { |
| class AstGraphBuilder::ControlScopeForCatch : public ControlScope { |
| public: |
| ControlScopeForCatch(AstGraphBuilder* owner, TryCatchBuilder* control) |
| - : ControlScope(owner, 0), control_(control) { |
| + : ControlScope(owner), control_(control) { |
| builder()->try_nesting_level_++; // Increment nesting. |
| } |
| ~ControlScopeForCatch() { |
| @@ -358,7 +358,7 @@ class AstGraphBuilder::ControlScopeForFinally : public ControlScope { |
| public: |
| ControlScopeForFinally(AstGraphBuilder* owner, DeferredCommands* commands, |
| TryFinallyBuilder* control) |
| - : ControlScope(owner, 0), commands_(commands), control_(control) { |
| + : ControlScope(owner), commands_(commands), control_(control) { |
| builder()->try_nesting_level_++; // Increment nesting. |
| } |
| ~ControlScopeForFinally() { |
| @@ -427,13 +427,13 @@ bool AstGraphBuilder::CreateGraph() { |
| int parameter_count = info()->num_parameters(); |
| graph()->SetStart(graph()->NewNode(common()->Start(parameter_count))); |
| - // Initialize control scope. |
| - ControlScope control(this, 0); |
| - |
| // Initialize the top-level environment. |
| Environment env(this, scope, graph()->start()); |
| set_environment(&env); |
| + // Initialize control scope. |
| + ControlScope control(this); |
| + |
| if (info()->is_osr()) { |
| // Use OSR normal entry as the start of the top-level environment. |
| // It will be replaced with {Dead} after typing and optimizations. |
| @@ -680,8 +680,9 @@ void AstGraphBuilder::ControlScope::PerformCommand(Command command, |
| Environment* env = environment()->CopyAsUnreachable(); |
| ControlScope* current = this; |
| while (current != NULL) { |
| + int stack_delta = environment()->stack_height() - current->stack_height(); |
| + if (stack_delta > 0) environment()->Drop(stack_delta); |
|
titzer
2015/02/19 12:33:00
environment()->TrimStack() ?
Michael Starzinger
2015/02/19 12:58:21
Done. Called it just "Trim" as per offline discuss
|
| if (current->Execute(command, target, value)) break; |
| - environment()->Drop(current->stack_delta()); |
| current = current->outer_; |
| } |
| builder()->set_environment(env); |
| @@ -995,7 +996,7 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { |
| void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| LoopBuilder while_loop(this); |
| while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
| - VisitIterationBody(stmt, &while_loop, 0); |
| + VisitIterationBody(stmt, &while_loop); |
| while_loop.EndBody(); |
| VisitForTest(stmt->cond()); |
| Node* condition = environment()->Pop(); |
| @@ -1010,7 +1011,7 @@ void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
| VisitForTest(stmt->cond()); |
| Node* condition = environment()->Pop(); |
| while_loop.BreakUnless(condition); |
| - VisitIterationBody(stmt, &while_loop, 0); |
| + VisitIterationBody(stmt, &while_loop); |
| while_loop.EndBody(); |
| while_loop.EndLoop(); |
| } |
| @@ -1027,7 +1028,7 @@ void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { |
| } else { |
| for_loop.BreakUnless(jsgraph()->TrueConstant()); |
| } |
| - VisitIterationBody(stmt, &for_loop, 0); |
| + VisitIterationBody(stmt, &for_loop); |
| for_loop.EndBody(); |
| VisitIfNotNull(stmt->next()); |
| for_loop.EndLoop(); |
| @@ -1166,7 +1167,7 @@ void AstGraphBuilder::VisitForInBody(ForInStatement* stmt) { |
| value = environment()->Pop(); |
| // Bind value and do loop body. |
| VisitForInAssignment(stmt->each(), value, stmt->AssignmentId()); |
| - VisitIterationBody(stmt, &for_loop, 5); |
| + VisitIterationBody(stmt, &for_loop); |
| for_loop.EndBody(); |
| // Inc counter and continue. |
| Node* index_inc = |
| @@ -1189,7 +1190,7 @@ void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { |
| Node* condition = environment()->Pop(); |
| for_loop.BreakWhen(condition); |
| VisitForEffect(stmt->assign_each()); |
| - VisitIterationBody(stmt, &for_loop, 0); |
| + VisitIterationBody(stmt, &for_loop); |
| for_loop.EndBody(); |
| for_loop.EndLoop(); |
| } |
| @@ -2279,8 +2280,8 @@ void AstGraphBuilder::VisitIfNotNull(Statement* stmt) { |
| void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, |
| - LoopBuilder* loop, int stack_delta) { |
| - ControlScopeForIteration scope(this, stmt, loop, stack_delta); |
| + LoopBuilder* loop) { |
| + ControlScopeForIteration scope(this, stmt, loop); |
| Visit(stmt->body()); |
| } |
| @@ -3001,9 +3002,7 @@ Node* AstGraphBuilder::MakeNode(const Operator* op, int value_input_count, |
| if (!result->op()->HasProperty(Operator::kNoThrow) && inside_try_scope) { |
| Node* on_exception = graph()->NewNode(common()->IfException(), result); |
| environment_->UpdateControlDependency(on_exception); |
| - if (FLAG_turbo_exceptions) { |
| - execution_control()->ThrowValue(jsgraph()->UndefinedConstant()); |
| - } |
| + execution_control()->ThrowValue(jsgraph()->UndefinedConstant()); |
| } |
| // Add implicit success continuation for throwing nodes. |
| if (!result->op()->HasProperty(Operator::kNoThrow)) { |