Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1176513004: [turbofan] Small cleanup in VisitTryCatchStatement. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 execution_control()->ReturnValue(result); 1201 execution_control()->ReturnValue(result);
1202 } 1202 }
1203 1203
1204 1204
1205 void AstGraphBuilder::VisitWithStatement(WithStatement* stmt) { 1205 void AstGraphBuilder::VisitWithStatement(WithStatement* stmt) {
1206 VisitForValue(stmt->expression()); 1206 VisitForValue(stmt->expression());
1207 Node* value = environment()->Pop(); 1207 Node* value = environment()->Pop();
1208 const Operator* op = javascript()->CreateWithContext(); 1208 const Operator* op = javascript()->CreateWithContext();
1209 Node* context = NewNode(op, value, GetFunctionClosureForContext()); 1209 Node* context = NewNode(op, value, GetFunctionClosureForContext());
1210 PrepareFrameState(context, stmt->EntryId()); 1210 PrepareFrameState(context, stmt->EntryId());
1211 ContextScope scope(this, stmt->scope(), context); 1211 VisitInScope(stmt->statement(), stmt->scope(), context);
1212 Visit(stmt->statement());
1213 } 1212 }
1214 1213
1215 1214
1216 void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { 1215 void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
1217 ZoneList<CaseClause*>* clauses = stmt->cases(); 1216 ZoneList<CaseClause*>* clauses = stmt->cases();
1218 SwitchBuilder compare_switch(this, clauses->length()); 1217 SwitchBuilder compare_switch(this, clauses->length());
1219 ControlScopeForBreakable scope(this, stmt, &compare_switch); 1218 ControlScopeForBreakable scope(this, stmt, &compare_switch);
1220 compare_switch.BeginSwitch(); 1219 compare_switch.BeginSwitch();
1221 int default_index = -1; 1220 int default_index = -1;
1222 1221
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 for_loop.BreakWhen(condition); 1393 for_loop.BreakWhen(condition);
1395 VisitForEffect(stmt->assign_each()); 1394 VisitForEffect(stmt->assign_each());
1396 VisitIterationBody(stmt, &for_loop); 1395 VisitIterationBody(stmt, &for_loop);
1397 for_loop.EndBody(); 1396 for_loop.EndBody();
1398 for_loop.EndLoop(); 1397 for_loop.EndLoop();
1399 } 1398 }
1400 1399
1401 1400
1402 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { 1401 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
1403 TryCatchBuilder try_control(this); 1402 TryCatchBuilder try_control(this);
1403 ExternalReference message_object =
1404 ExternalReference::address_of_pending_message_obj(isolate());
1404 1405
1405 // Evaluate the try-block inside a control scope. This simulates a handler 1406 // Evaluate the try-block inside a control scope. This simulates a handler
1406 // that is intercepting 'throw' control commands. 1407 // that is intercepting 'throw' control commands.
1407 try_control.BeginTry(); 1408 try_control.BeginTry();
1408 { 1409 {
1409 ControlScopeForCatch scope(this, &try_control); 1410 ControlScopeForCatch scope(this, &try_control);
1410 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); 1411 STATIC_ASSERT(TryBlockConstant::kElementCount == 1);
1411 environment()->Push(current_context()); 1412 environment()->Push(current_context());
1412 Visit(stmt->try_block()); 1413 Visit(stmt->try_block());
1413 environment()->Pop(); 1414 environment()->Pop();
1414 } 1415 }
1415 try_control.EndTry(); 1416 try_control.EndTry();
1416 1417
1417 // Clear message object as we enter the catch block.
1418 ExternalReference message_object =
1419 ExternalReference::address_of_pending_message_obj(isolate());
1420 Node* the_hole = jsgraph()->TheHoleConstant();
1421 BuildStoreExternal(message_object, kMachAnyTagged, the_hole);
1422
1423 // Create a catch scope that binds the exception. 1418 // Create a catch scope that binds the exception.
1424 Node* exception = try_control.GetExceptionNode(); 1419 Node* exception = try_control.GetExceptionNode();
1425 Unique<String> name = MakeUnique(stmt->variable()->name()); 1420 Unique<String> name = MakeUnique(stmt->variable()->name());
1426 const Operator* op = javascript()->CreateCatchContext(name); 1421 const Operator* op = javascript()->CreateCatchContext(name);
1427 Node* context = NewNode(op, exception, GetFunctionClosureForContext()); 1422 Node* context = NewNode(op, exception, GetFunctionClosureForContext());
1428 PrepareFrameState(context, BailoutId::None()); 1423
1429 { 1424 // Clear message object as we enter the catch block.
1430 ContextScope scope(this, stmt->scope(), context); 1425 Node* the_hole = jsgraph()->TheHoleConstant();
1431 DCHECK(stmt->scope()->declarations()->is_empty()); 1426 BuildStoreExternal(message_object, kMachAnyTagged, the_hole);
1432 // Evaluate the catch-block. 1427
1433 Visit(stmt->catch_block()); 1428 // Evaluate the catch-block.
1434 } 1429 VisitInScope(stmt->catch_block(), stmt->scope(), context);
1435 try_control.EndCatch(); 1430 try_control.EndCatch();
1436 1431
1437 // TODO(mstarzinger): Remove bailout once everything works. 1432 // TODO(mstarzinger): Remove bailout once everything works.
1438 if (!FLAG_turbo_try_catch) SetStackOverflow(); 1433 if (!FLAG_turbo_try_catch) SetStackOverflow();
1439 } 1434 }
1440 1435
1441 1436
1442 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 1437 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
1443 TryFinallyBuilder try_control(this); 1438 TryFinallyBuilder try_control(this);
1444
1445 ExternalReference message_object = 1439 ExternalReference message_object =
1446 ExternalReference::address_of_pending_message_obj(isolate()); 1440 ExternalReference::address_of_pending_message_obj(isolate());
1447 1441
1448 // We keep a record of all paths that enter the finally-block to be able to 1442 // We keep a record of all paths that enter the finally-block to be able to
1449 // dispatch to the correct continuation point after the statements in the 1443 // dispatch to the correct continuation point after the statements in the
1450 // finally-block have been evaluated. 1444 // finally-block have been evaluated.
1451 // 1445 //
1452 // The try-finally construct can enter the finally-block in three ways: 1446 // The try-finally construct can enter the finally-block in three ways:
1453 // 1. By exiting the try-block normally, falling through at the end. 1447 // 1. By exiting the try-block normally, falling through at the end.
1454 // 2. By exiting the try-block with a function-local control flow transfer 1448 // 2. By exiting the try-block with a function-local control flow transfer
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2843 globals()->clear(); 2837 globals()->clear();
2844 } 2838 }
2845 2839
2846 2840
2847 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) { 2841 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) {
2848 if (stmt == NULL) return; 2842 if (stmt == NULL) return;
2849 Visit(stmt); 2843 Visit(stmt);
2850 } 2844 }
2851 2845
2852 2846
2847 void AstGraphBuilder::VisitInScope(Statement* stmt, Scope* s, Node* context) {
2848 ContextScope scope(this, s, context);
2849 DCHECK(s->declarations()->is_empty());
2850 Visit(stmt);
2851 }
2852
2853
2853 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, 2854 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt,
2854 LoopBuilder* loop) { 2855 LoopBuilder* loop) {
2855 ControlScopeForIteration scope(this, stmt, loop); 2856 ControlScopeForIteration scope(this, stmt, loop);
2856 // TODO(mstarzinger): For now we only allow to interrupt non-asm.js code, 2857 // TODO(mstarzinger): For now we only allow to interrupt non-asm.js code,
2857 // which is a gigantic hack and should be extended to all code at some point. 2858 // which is a gigantic hack and should be extended to all code at some point.
2858 if (!info()->shared_info()->asm_function()) { 2859 if (!info()->shared_info()->asm_function()) {
2859 Node* node = NewNode(javascript()->StackCheck()); 2860 Node* node = NewNode(javascript()->StackCheck());
2860 PrepareFrameState(node, stmt->StackCheckId()); 2861 PrepareFrameState(node, stmt->StackCheckId());
2861 } 2862 }
2862 Visit(stmt->body()); 2863 Visit(stmt->body());
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4072 // Phi does not exist yet, introduce one. 4073 // Phi does not exist yet, introduce one.
4073 value = NewPhi(inputs, value, control); 4074 value = NewPhi(inputs, value, control);
4074 value->ReplaceInput(inputs - 1, other); 4075 value->ReplaceInput(inputs - 1, other);
4075 } 4076 }
4076 return value; 4077 return value;
4077 } 4078 }
4078 4079
4079 } // namespace compiler 4080 } // namespace compiler
4080 } // namespace internal 4081 } // namespace internal
4081 } // namespace v8 4082 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698