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 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 } | 1259 } |
1260 | 1260 |
1261 | 1261 |
1262 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { | 1262 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
1263 TryFinallyBuilder try_control(this); | 1263 TryFinallyBuilder try_control(this); |
1264 | 1264 |
1265 ExternalReference message_object = | 1265 ExternalReference message_object = |
1266 ExternalReference::address_of_pending_message_obj(isolate()); | 1266 ExternalReference::address_of_pending_message_obj(isolate()); |
1267 ExternalReference message_present = | 1267 ExternalReference message_present = |
1268 ExternalReference::address_of_has_pending_message(isolate()); | 1268 ExternalReference::address_of_has_pending_message(isolate()); |
1269 ExternalReference message_script = | |
1270 ExternalReference::address_of_pending_message_script(isolate()); | |
1271 | 1269 |
1272 // We keep a record of all paths that enter the finally-block to be able to | 1270 // We keep a record of all paths that enter the finally-block to be able to |
1273 // dispatch to the correct continuation point after the statements in the | 1271 // dispatch to the correct continuation point after the statements in the |
1274 // finally-block have been evaluated. | 1272 // finally-block have been evaluated. |
1275 // | 1273 // |
1276 // The try-finally construct can enter the finally-block in three ways: | 1274 // The try-finally construct can enter the finally-block in three ways: |
1277 // 1. By exiting the try-block normally, falling through at the end. | 1275 // 1. By exiting the try-block normally, falling through at the end. |
1278 // 2. By exiting the try-block with a function-local control flow transfer | 1276 // 2. By exiting the try-block with a function-local control flow transfer |
1279 // (i.e. through break/continue/return statements). | 1277 // (i.e. through break/continue/return statements). |
1280 // 3. By exiting the try-block with a thrown exception. | 1278 // 3. By exiting the try-block with a thrown exception. |
(...skipping 17 matching lines...) Expand all Loading... |
1298 // - Falling through into finally-block: Filled with the hole. | 1296 // - Falling through into finally-block: Filled with the hole. |
1299 Node* result = try_control.GetResultValueNode(); | 1297 Node* result = try_control.GetResultValueNode(); |
1300 Node* token = try_control.GetDispatchTokenNode(); | 1298 Node* token = try_control.GetDispatchTokenNode(); |
1301 | 1299 |
1302 // The result value, dispatch token and message is expected on the operand | 1300 // The result value, dispatch token and message is expected on the operand |
1303 // stack (this is in sync with FullCodeGenerator::EnterFinallyBlock). | 1301 // stack (this is in sync with FullCodeGenerator::EnterFinallyBlock). |
1304 environment()->Push(token); // TODO(mstarzinger): Cook token! | 1302 environment()->Push(token); // TODO(mstarzinger): Cook token! |
1305 environment()->Push(result); | 1303 environment()->Push(result); |
1306 environment()->Push(BuildLoadExternal(message_object, kMachAnyTagged)); | 1304 environment()->Push(BuildLoadExternal(message_object, kMachAnyTagged)); |
1307 environment()->Push(BuildLoadExternal(message_present, kMachBool)); | 1305 environment()->Push(BuildLoadExternal(message_present, kMachBool)); |
1308 environment()->Push(BuildLoadExternal(message_script, kMachAnyTagged)); | |
1309 | 1306 |
1310 // Evaluate the finally-block. | 1307 // Evaluate the finally-block. |
1311 Visit(stmt->finally_block()); | 1308 Visit(stmt->finally_block()); |
1312 try_control.EndFinally(); | 1309 try_control.EndFinally(); |
1313 | 1310 |
1314 // The result value, dispatch token and message is restored from the operand | 1311 // The result value, dispatch token and message is restored from the operand |
1315 // stack (this is in sync with FullCodeGenerator::ExitFinallyBlock). | 1312 // stack (this is in sync with FullCodeGenerator::ExitFinallyBlock). |
1316 BuildStoreExternal(message_script, kMachAnyTagged, environment()->Pop()); | |
1317 BuildStoreExternal(message_present, kMachBool, environment()->Pop()); | 1313 BuildStoreExternal(message_present, kMachBool, environment()->Pop()); |
1318 BuildStoreExternal(message_object, kMachAnyTagged, environment()->Pop()); | 1314 BuildStoreExternal(message_object, kMachAnyTagged, environment()->Pop()); |
1319 result = environment()->Pop(); | 1315 result = environment()->Pop(); |
1320 token = environment()->Pop(); // TODO(mstarzinger): Uncook token! | 1316 token = environment()->Pop(); // TODO(mstarzinger): Uncook token! |
1321 | 1317 |
1322 // Dynamic dispatch after the finally-block. | 1318 // Dynamic dispatch after the finally-block. |
1323 commands->ApplyDeferredCommands(token, result); | 1319 commands->ApplyDeferredCommands(token, result); |
1324 | 1320 |
1325 // TODO(mstarzinger): Remove bailout once everything works. | 1321 // TODO(mstarzinger): Remove bailout once everything works. |
1326 if (!FLAG_turbo_exceptions) SetStackOverflow(); | 1322 if (!FLAG_turbo_exceptions) SetStackOverflow(); |
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3337 // Phi does not exist yet, introduce one. | 3333 // Phi does not exist yet, introduce one. |
3338 value = NewPhi(inputs, value, control); | 3334 value = NewPhi(inputs, value, control); |
3339 value->ReplaceInput(inputs - 1, other); | 3335 value->ReplaceInput(inputs - 1, other); |
3340 } | 3336 } |
3341 return value; | 3337 return value; |
3342 } | 3338 } |
3343 | 3339 |
3344 } // namespace compiler | 3340 } // namespace compiler |
3345 } // namespace internal | 3341 } // namespace internal |
3346 } // namespace v8 | 3342 } // namespace v8 |
OLD | NEW |