| 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 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 | 1229 |
| 1230 | 1230 |
| 1231 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1231 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| 1232 TryCatchBuilder try_control(this); | 1232 TryCatchBuilder try_control(this); |
| 1233 | 1233 |
| 1234 // Evaluate the try-block inside a control scope. This simulates a handler | 1234 // Evaluate the try-block inside a control scope. This simulates a handler |
| 1235 // that is intercepting 'throw' control commands. | 1235 // that is intercepting 'throw' control commands. |
| 1236 try_control.BeginTry(); | 1236 try_control.BeginTry(); |
| 1237 { | 1237 { |
| 1238 ControlScopeForCatch scope(this, &try_control); | 1238 ControlScopeForCatch scope(this, &try_control); |
| 1239 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); |
| 1240 environment()->Push(current_context()); |
| 1239 Visit(stmt->try_block()); | 1241 Visit(stmt->try_block()); |
| 1242 environment()->Pop(); |
| 1240 } | 1243 } |
| 1241 try_control.EndTry(); | 1244 try_control.EndTry(); |
| 1242 | 1245 |
| 1243 // Create a catch scope that binds the exception. | 1246 // Create a catch scope that binds the exception. |
| 1244 Node* exception = try_control.GetExceptionNode(); | 1247 Node* exception = try_control.GetExceptionNode(); |
| 1245 Unique<String> name = MakeUnique(stmt->variable()->name()); | 1248 Unique<String> name = MakeUnique(stmt->variable()->name()); |
| 1246 const Operator* op = javascript()->CreateCatchContext(name); | 1249 const Operator* op = javascript()->CreateCatchContext(name); |
| 1247 Node* context = NewNode(op, exception, GetFunctionClosure()); | 1250 Node* context = NewNode(op, exception, GetFunctionClosure()); |
| 1248 PrepareFrameState(context, BailoutId::None()); | 1251 PrepareFrameState(context, BailoutId::None()); |
| 1249 { | 1252 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1276 // 3. By exiting the try-block with a thrown exception. | 1279 // 3. By exiting the try-block with a thrown exception. |
| 1277 Node* fallthrough_result = jsgraph()->TheHoleConstant(); | 1280 Node* fallthrough_result = jsgraph()->TheHoleConstant(); |
| 1278 ControlScope::DeferredCommands* commands = | 1281 ControlScope::DeferredCommands* commands = |
| 1279 new (zone()) ControlScope::DeferredCommands(this); | 1282 new (zone()) ControlScope::DeferredCommands(this); |
| 1280 | 1283 |
| 1281 // Evaluate the try-block inside a control scope. This simulates a handler | 1284 // Evaluate the try-block inside a control scope. This simulates a handler |
| 1282 // that is intercepting all control commands. | 1285 // that is intercepting all control commands. |
| 1283 try_control.BeginTry(); | 1286 try_control.BeginTry(); |
| 1284 { | 1287 { |
| 1285 ControlScopeForFinally scope(this, commands, &try_control); | 1288 ControlScopeForFinally scope(this, commands, &try_control); |
| 1289 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); |
| 1290 environment()->Push(current_context()); |
| 1286 Visit(stmt->try_block()); | 1291 Visit(stmt->try_block()); |
| 1292 environment()->Pop(); |
| 1287 } | 1293 } |
| 1288 try_control.EndTry(commands->GetFallThroughToken(), fallthrough_result); | 1294 try_control.EndTry(commands->GetFallThroughToken(), fallthrough_result); |
| 1289 | 1295 |
| 1290 // The result value semantics depend on how the block was entered: | 1296 // The result value semantics depend on how the block was entered: |
| 1291 // - ReturnStatement: It represents the return value being returned. | 1297 // - ReturnStatement: It represents the return value being returned. |
| 1292 // - ThrowStatement: It represents the exception being thrown. | 1298 // - ThrowStatement: It represents the exception being thrown. |
| 1293 // - BreakStatement/ContinueStatement: Filled with the hole. | 1299 // - BreakStatement/ContinueStatement: Filled with the hole. |
| 1294 // - Falling through into finally-block: Filled with the hole. | 1300 // - Falling through into finally-block: Filled with the hole. |
| 1295 Node* result = try_control.GetResultValueNode(); | 1301 Node* result = try_control.GetResultValueNode(); |
| 1296 Node* token = try_control.GetDispatchTokenNode(); | 1302 Node* token = try_control.GetDispatchTokenNode(); |
| (...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3338 // Phi does not exist yet, introduce one. | 3344 // Phi does not exist yet, introduce one. |
| 3339 value = NewPhi(inputs, value, control); | 3345 value = NewPhi(inputs, value, control); |
| 3340 value->ReplaceInput(inputs - 1, other); | 3346 value->ReplaceInput(inputs - 1, other); |
| 3341 } | 3347 } |
| 3342 return value; | 3348 return value; |
| 3343 } | 3349 } |
| 3344 | 3350 |
| 3345 } // namespace compiler | 3351 } // namespace compiler |
| 3346 } // namespace internal | 3352 } // namespace internal |
| 3347 } // namespace v8 | 3353 } // namespace v8 |
| OLD | NEW |