Commit 1853079a authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Small cleanup in VisitTryCatchStatement.

R=bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28899}
parent 0392d4f9
......@@ -1208,8 +1208,7 @@ void AstGraphBuilder::VisitWithStatement(WithStatement* stmt) {
const Operator* op = javascript()->CreateWithContext();
Node* context = NewNode(op, value, GetFunctionClosureForContext());
PrepareFrameState(context, stmt->EntryId());
ContextScope scope(this, stmt->scope(), context);
Visit(stmt->statement());
VisitInScope(stmt->statement(), stmt->scope(), context);
}
......@@ -1401,6 +1400,8 @@ void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) {
void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
TryCatchBuilder try_control(this);
ExternalReference message_object =
ExternalReference::address_of_pending_message_obj(isolate());
// Evaluate the try-block inside a control scope. This simulates a handler
// that is intercepting 'throw' control commands.
......@@ -1414,24 +1415,18 @@ void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
}
try_control.EndTry();
// Clear message object as we enter the catch block.
ExternalReference message_object =
ExternalReference::address_of_pending_message_obj(isolate());
Node* the_hole = jsgraph()->TheHoleConstant();
BuildStoreExternal(message_object, kMachAnyTagged, the_hole);
// Create a catch scope that binds the exception.
Node* exception = try_control.GetExceptionNode();
Unique<String> name = MakeUnique(stmt->variable()->name());
const Operator* op = javascript()->CreateCatchContext(name);
Node* context = NewNode(op, exception, GetFunctionClosureForContext());
PrepareFrameState(context, BailoutId::None());
{
ContextScope scope(this, stmt->scope(), context);
DCHECK(stmt->scope()->declarations()->is_empty());
// Evaluate the catch-block.
Visit(stmt->catch_block());
}
// Clear message object as we enter the catch block.
Node* the_hole = jsgraph()->TheHoleConstant();
BuildStoreExternal(message_object, kMachAnyTagged, the_hole);
// Evaluate the catch-block.
VisitInScope(stmt->catch_block(), stmt->scope(), context);
try_control.EndCatch();
// TODO(mstarzinger): Remove bailout once everything works.
......@@ -1441,7 +1436,6 @@ void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
TryFinallyBuilder try_control(this);
ExternalReference message_object =
ExternalReference::address_of_pending_message_obj(isolate());
......@@ -2853,6 +2847,13 @@ void AstGraphBuilder::VisitIfNotNull(Statement* stmt) {
}
void AstGraphBuilder::VisitInScope(Statement* stmt, Scope* s, Node* context) {
ContextScope scope(this, s, context);
DCHECK(s->declarations()->is_empty());
Visit(stmt);
}
void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt,
LoopBuilder* loop) {
ControlScopeForIteration scope(this, stmt, loop);
......
......@@ -357,6 +357,7 @@ class AstGraphBuilder : public AstVisitor {
// Visit statements.
void VisitIfNotNull(Statement* stmt);
void VisitInScope(Statement* stmt, Scope* scope, Node* context);
// Visit expressions.
void Visit(Expression* expr);
......
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