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/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 try_control.BeginTry(); | 1408 try_control.BeginTry(); |
1409 { | 1409 { |
1410 ControlScopeForCatch scope(this, &try_control); | 1410 ControlScopeForCatch scope(this, &try_control); |
1411 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); | 1411 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); |
1412 environment()->Push(current_context()); | 1412 environment()->Push(current_context()); |
1413 Visit(stmt->try_block()); | 1413 Visit(stmt->try_block()); |
1414 environment()->Pop(); | 1414 environment()->Pop(); |
1415 } | 1415 } |
1416 try_control.EndTry(); | 1416 try_control.EndTry(); |
1417 | 1417 |
| 1418 // TODO(mstarzinger): We are only using a runtime call to get a lazy bailout |
| 1419 // point, there is no need to really emit an actual call. Optimize this! |
| 1420 Node* guard = NewNode(javascript()->CallRuntime(Runtime::kMaxSmi, 0)); |
| 1421 PrepareFrameState(guard, stmt->HandlerId()); |
| 1422 |
| 1423 // Clear message object as we enter the catch block. |
| 1424 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 1425 BuildStoreExternal(message_object, kMachAnyTagged, the_hole); |
| 1426 |
1418 // Create a catch scope that binds the exception. | 1427 // Create a catch scope that binds the exception. |
1419 Node* exception = try_control.GetExceptionNode(); | 1428 Node* exception = try_control.GetExceptionNode(); |
1420 Unique<String> name = MakeUnique(stmt->variable()->name()); | 1429 Unique<String> name = MakeUnique(stmt->variable()->name()); |
1421 const Operator* op = javascript()->CreateCatchContext(name); | 1430 const Operator* op = javascript()->CreateCatchContext(name); |
1422 Node* context = NewNode(op, exception, GetFunctionClosureForContext()); | 1431 Node* context = NewNode(op, exception, GetFunctionClosureForContext()); |
1423 | 1432 |
1424 // Clear message object as we enter the catch block. | |
1425 Node* the_hole = jsgraph()->TheHoleConstant(); | |
1426 BuildStoreExternal(message_object, kMachAnyTagged, the_hole); | |
1427 | |
1428 // Evaluate the catch-block. | 1433 // Evaluate the catch-block. |
1429 VisitInScope(stmt->catch_block(), stmt->scope(), context); | 1434 VisitInScope(stmt->catch_block(), stmt->scope(), context); |
1430 try_control.EndCatch(); | 1435 try_control.EndCatch(); |
1431 | 1436 |
1432 // TODO(mstarzinger): Remove bailout once everything works. | 1437 // TODO(mstarzinger): Remove bailout once everything works. |
1433 if (!FLAG_turbo_try_catch) SetStackOverflow(); | 1438 if (!FLAG_turbo_try_catch) SetStackOverflow(); |
1434 } | 1439 } |
1435 | 1440 |
1436 | 1441 |
1437 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { | 1442 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
(...skipping 19 matching lines...) Expand all Loading... |
1457 try_control.BeginTry(); | 1462 try_control.BeginTry(); |
1458 { | 1463 { |
1459 ControlScopeForFinally scope(this, commands, &try_control); | 1464 ControlScopeForFinally scope(this, commands, &try_control); |
1460 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); | 1465 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); |
1461 environment()->Push(current_context()); | 1466 environment()->Push(current_context()); |
1462 Visit(stmt->try_block()); | 1467 Visit(stmt->try_block()); |
1463 environment()->Pop(); | 1468 environment()->Pop(); |
1464 } | 1469 } |
1465 try_control.EndTry(commands->GetFallThroughToken(), fallthrough_result); | 1470 try_control.EndTry(commands->GetFallThroughToken(), fallthrough_result); |
1466 | 1471 |
| 1472 // TODO(mstarzinger): We are only using a runtime call to get a lazy bailout |
| 1473 // point, there is no need to really emit an actual call. Optimize this! |
| 1474 Node* guard = NewNode(javascript()->CallRuntime(Runtime::kMaxSmi, 0)); |
| 1475 PrepareFrameState(guard, stmt->HandlerId()); |
| 1476 |
1467 // The result value semantics depend on how the block was entered: | 1477 // The result value semantics depend on how the block was entered: |
1468 // - ReturnStatement: It represents the return value being returned. | 1478 // - ReturnStatement: It represents the return value being returned. |
1469 // - ThrowStatement: It represents the exception being thrown. | 1479 // - ThrowStatement: It represents the exception being thrown. |
1470 // - BreakStatement/ContinueStatement: Filled with the hole. | 1480 // - BreakStatement/ContinueStatement: Filled with the hole. |
1471 // - Falling through into finally-block: Filled with the hole. | 1481 // - Falling through into finally-block: Filled with the hole. |
1472 Node* result = try_control.GetResultValueNode(); | 1482 Node* result = try_control.GetResultValueNode(); |
1473 Node* token = try_control.GetDispatchTokenNode(); | 1483 Node* token = try_control.GetDispatchTokenNode(); |
1474 | 1484 |
1475 // The result value, dispatch token and message is expected on the operand | 1485 // The result value, dispatch token and message is expected on the operand |
1476 // stack (this is in sync with FullCodeGenerator::EnterFinallyBlock). | 1486 // stack (this is in sync with FullCodeGenerator::EnterFinallyBlock). |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 // Phi does not exist yet, introduce one. | 4071 // Phi does not exist yet, introduce one. |
4062 value = NewPhi(inputs, value, control); | 4072 value = NewPhi(inputs, value, control); |
4063 value->ReplaceInput(inputs - 1, other); | 4073 value->ReplaceInput(inputs - 1, other); |
4064 } | 4074 } |
4065 return value; | 4075 return value; |
4066 } | 4076 } |
4067 | 4077 |
4068 } // namespace compiler | 4078 } // namespace compiler |
4069 } // namespace internal | 4079 } // namespace internal |
4070 } // namespace v8 | 4080 } // namespace v8 |
OLD | NEW |