Commit e5ac6509 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Make throwing expressions kill the environment.

This ensures that all expressions that throw actually mark the current
environment as dead in the AstGraphBuilder. This prevents live ranges
from being unnecessarily increased by paths that don't fall-through.
Note that we can do that because Runtime::kThrowFoo never returns.

R=svenpanne@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27546}
parent a373b089
......@@ -2737,13 +2737,8 @@ Node* AstGraphBuilder::BuildThrowIfStaticPrototype(Node* name,
Node* check = NewNode(javascript()->StrictEqual(), name, prototype_string);
prototype_check.If(check);
prototype_check.Then();
{
const Operator* op =
javascript()->CallRuntime(Runtime::kThrowStaticPrototypeError, 0);
Node* call = NewNode(op);
PrepareFrameState(call, bailout_id);
environment()->Push(call);
}
Node* error = BuildThrowStaticPrototypeError(bailout_id);
environment()->Push(error);
prototype_check.Else();
environment()->Push(name);
prototype_check.End();
......@@ -3102,7 +3097,9 @@ Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) {
const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1);
Node* call = NewNode(op, exception);
PrepareFrameState(call, bailout_id);
return call;
Node* control = NewNode(common()->Throw(), call);
UpdateControlDependencyToLeaveFunction(control);
return control;
}
......@@ -3113,7 +3110,9 @@ Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable,
javascript()->CallRuntime(Runtime::kThrowReferenceError, 1);
Node* call = NewNode(op, variable_name);
PrepareFrameState(call, bailout_id);
return call;
Node* control = NewNode(common()->Throw(), call);
UpdateControlDependencyToLeaveFunction(control);
return control;
}
......@@ -3122,7 +3121,20 @@ Node* AstGraphBuilder::BuildThrowConstAssignError(BailoutId bailout_id) {
javascript()->CallRuntime(Runtime::kThrowConstAssignError, 0);
Node* call = NewNode(op);
PrepareFrameState(call, bailout_id);
return call;
Node* control = NewNode(common()->Throw(), call);
UpdateControlDependencyToLeaveFunction(control);
return control;
}
Node* AstGraphBuilder::BuildThrowStaticPrototypeError(BailoutId bailout_id) {
const Operator* op =
javascript()->CallRuntime(Runtime::kThrowStaticPrototypeError, 0);
Node* call = NewNode(op);
PrepareFrameState(call, bailout_id);
Node* control = NewNode(common()->Throw(), call);
UpdateControlDependencyToLeaveFunction(control);
return control;
}
......
......@@ -300,6 +300,7 @@ class AstGraphBuilder : public AstVisitor {
Node* BuildThrowError(Node* exception, BailoutId bailout_id);
Node* BuildThrowReferenceError(Variable* var, BailoutId bailout_id);
Node* BuildThrowConstAssignError(BailoutId bailout_id);
Node* BuildThrowStaticPrototypeError(BailoutId bailout_id);
// Builders for dynamic hole-checks at runtime.
Node* BuildHoleCheckSilent(Node* value, Node* for_hole, Node* not_hole);
......
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