OLD | NEW |
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/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 | 1327 |
1328 | 1328 |
1329 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1329 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { |
1330 TryCatchBuilder try_control(this); | 1330 TryCatchBuilder try_control(this); |
1331 | 1331 |
1332 // Evaluate the try-block inside a control scope. This simulates a handler | 1332 // Evaluate the try-block inside a control scope. This simulates a handler |
1333 // that is intercepting 'throw' control commands. | 1333 // that is intercepting 'throw' control commands. |
1334 try_control.BeginTry(); | 1334 try_control.BeginTry(); |
1335 { | 1335 { |
1336 ControlScopeForCatch scope(this, &try_control); | 1336 ControlScopeForCatch scope(this, &try_control); |
| 1337 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); |
| 1338 environment()->Push(current_context()); |
1337 Visit(stmt->try_block()); | 1339 Visit(stmt->try_block()); |
| 1340 environment()->Pop(); |
1338 } | 1341 } |
1339 try_control.EndTry(); | 1342 try_control.EndTry(); |
1340 | 1343 |
1341 // Create a catch scope that binds the exception. | 1344 // Create a catch scope that binds the exception. |
1342 Node* exception = try_control.GetExceptionNode(); | 1345 Node* exception = try_control.GetExceptionNode(); |
1343 Unique<String> name = MakeUnique(stmt->variable()->name()); | 1346 Unique<String> name = MakeUnique(stmt->variable()->name()); |
1344 const Operator* op = javascript()->CreateCatchContext(name); | 1347 const Operator* op = javascript()->CreateCatchContext(name); |
1345 Node* context = NewNode(op, exception, GetFunctionClosure()); | 1348 Node* context = NewNode(op, exception, GetFunctionClosure()); |
1346 PrepareFrameState(context, BailoutId::None()); | 1349 PrepareFrameState(context, BailoutId::None()); |
1347 { | 1350 { |
(...skipping 26 matching lines...) Expand all Loading... |
1374 // 3. By exiting the try-block with a thrown exception. | 1377 // 3. By exiting the try-block with a thrown exception. |
1375 Node* fallthrough_result = jsgraph()->TheHoleConstant(); | 1378 Node* fallthrough_result = jsgraph()->TheHoleConstant(); |
1376 ControlScope::DeferredCommands* commands = | 1379 ControlScope::DeferredCommands* commands = |
1377 new (zone()) ControlScope::DeferredCommands(this); | 1380 new (zone()) ControlScope::DeferredCommands(this); |
1378 | 1381 |
1379 // Evaluate the try-block inside a control scope. This simulates a handler | 1382 // Evaluate the try-block inside a control scope. This simulates a handler |
1380 // that is intercepting all control commands. | 1383 // that is intercepting all control commands. |
1381 try_control.BeginTry(); | 1384 try_control.BeginTry(); |
1382 { | 1385 { |
1383 ControlScopeForFinally scope(this, commands, &try_control); | 1386 ControlScopeForFinally scope(this, commands, &try_control); |
| 1387 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); |
| 1388 environment()->Push(current_context()); |
1384 Visit(stmt->try_block()); | 1389 Visit(stmt->try_block()); |
| 1390 environment()->Pop(); |
1385 } | 1391 } |
1386 try_control.EndTry(commands->GetFallThroughToken(), fallthrough_result); | 1392 try_control.EndTry(commands->GetFallThroughToken(), fallthrough_result); |
1387 | 1393 |
1388 // The result value semantics depend on how the block was entered: | 1394 // The result value semantics depend on how the block was entered: |
1389 // - ReturnStatement: It represents the return value being returned. | 1395 // - ReturnStatement: It represents the return value being returned. |
1390 // - ThrowStatement: It represents the exception being thrown. | 1396 // - ThrowStatement: It represents the exception being thrown. |
1391 // - BreakStatement/ContinueStatement: Filled with the hole. | 1397 // - BreakStatement/ContinueStatement: Filled with the hole. |
1392 // - Falling through into finally-block: Filled with the hole. | 1398 // - Falling through into finally-block: Filled with the hole. |
1393 Node* result = try_control.GetResultValueNode(); | 1399 Node* result = try_control.GetResultValueNode(); |
1394 Node* token = try_control.GetDispatchTokenNode(); | 1400 Node* token = try_control.GetDispatchTokenNode(); |
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3486 // Phi does not exist yet, introduce one. | 3492 // Phi does not exist yet, introduce one. |
3487 value = NewPhi(inputs, value, control); | 3493 value = NewPhi(inputs, value, control); |
3488 value->ReplaceInput(inputs - 1, other); | 3494 value->ReplaceInput(inputs - 1, other); |
3489 } | 3495 } |
3490 return value; | 3496 return value; |
3491 } | 3497 } |
3492 | 3498 |
3493 } // namespace compiler | 3499 } // namespace compiler |
3494 } // namespace internal | 3500 } // namespace internal |
3495 } // namespace v8 | 3501 } // namespace v8 |
OLD | NEW |