| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 JoinEntryInstr* target) { | 1462 JoinEntryInstr* target) { |
| 1463 // Building a jump consists of the following actions: | 1463 // Building a jump consists of the following actions: |
| 1464 // * Record the current continuation result in a temporary. | 1464 // * Record the current continuation result in a temporary. |
| 1465 // * Restore the old context. | 1465 // * Restore the old context. |
| 1466 // * Overwrite the old context's continuation result with the temporary. | 1466 // * Overwrite the old context's continuation result with the temporary. |
| 1467 // * Append a Goto to the target's join. | 1467 // * Append a Goto to the target's join. |
| 1468 LocalVariable* old_ctx = lookup_scope->LookupVariable( | 1468 LocalVariable* old_ctx = lookup_scope->LookupVariable( |
| 1469 Symbols::AwaitContextVar(), false); | 1469 Symbols::AwaitContextVar(), false); |
| 1470 LocalVariable* continuation_result = lookup_scope->LookupVariable( | 1470 LocalVariable* continuation_result = lookup_scope->LookupVariable( |
| 1471 Symbols::AsyncOperationParam(), false); | 1471 Symbols::AsyncOperationParam(), false); |
| 1472 LocalVariable* continuation_error = lookup_scope->LookupVariable( |
| 1473 Symbols::AsyncOperationErrorParam(), false); |
| 1472 ASSERT((continuation_result != NULL) && continuation_result->is_captured()); | 1474 ASSERT((continuation_result != NULL) && continuation_result->is_captured()); |
| 1475 ASSERT((continuation_error != NULL) && continuation_error->is_captured()); |
| 1473 ASSERT((old_ctx != NULL) && old_ctx->is_captured()); | 1476 ASSERT((old_ctx != NULL) && old_ctx->is_captured()); |
| 1474 // Before restoring the continuation context we need to temporary save the | 1477 // Before restoring the continuation context we need to temporary save the |
| 1475 // current continuation result. | 1478 // result and error parameter. |
| 1476 Value* continuation_result_value = Bind(BuildLoadLocal(*continuation_result)); | 1479 LocalVariable* temp_result_var = EnterTempLocalScope( |
| 1477 Do(BuildStoreExprTemp(continuation_result_value)); | 1480 Bind(BuildLoadLocal(*continuation_result))); |
| 1478 | 1481 LocalVariable* temp_error_var = EnterTempLocalScope( |
| 1482 Bind(BuildLoadLocal(*continuation_error))); |
| 1479 // Restore the saved continuation context. | 1483 // Restore the saved continuation context. |
| 1480 BuildRestoreContext(*old_ctx); | 1484 BuildRestoreContext(*old_ctx); |
| 1481 | 1485 |
| 1482 // Pass over the continuation result. | 1486 // Pass over the continuation result. |
| 1483 Value* saved_continuation_result = Bind(BuildLoadExprTemp()); | 1487 |
| 1484 // FlowGraphBuilder is at top context level, but the await target has possibly | 1488 // FlowGraphBuilder is at top context level, but the await target has possibly |
| 1485 // been recorded in a nested context (old_ctx_level). We need to unroll | 1489 // been recorded in a nested context (old_ctx_level). We need to unroll |
| 1486 // manually here. | 1490 // manually here. |
| 1487 LocalVariable* tmp_var = EnterTempLocalScope(saved_continuation_result); | |
| 1488 intptr_t delta = old_ctx_level - | 1491 intptr_t delta = old_ctx_level - |
| 1489 continuation_result->owner()->context_level(); | 1492 continuation_result->owner()->context_level(); |
| 1490 ASSERT(delta >= 0); | 1493 ASSERT(delta >= 0); |
| 1491 Value* context = Bind(new(I) CurrentContextInstr()); | 1494 Value* context = Bind(new(I) CurrentContextInstr()); |
| 1492 while (delta-- > 0) { | 1495 while (delta-- > 0) { |
| 1493 context = Bind(new(I) LoadFieldInstr( | 1496 context = Bind(new(I) LoadFieldInstr( |
| 1494 context, Context::parent_offset(), Type::ZoneHandle(I, Type::null()), | 1497 context, Context::parent_offset(), Type::ZoneHandle(I, Type::null()), |
| 1495 Scanner::kNoSourcePos)); | 1498 Scanner::kNoSourcePos)); |
| 1496 } | 1499 } |
| 1497 Value* tmp_val = Bind(new(I) LoadLocalInstr(*tmp_var)); | 1500 LocalVariable* temp_context_var = EnterTempLocalScope(context); |
| 1501 |
| 1502 Value* context_val = Bind(new(I) LoadLocalInstr(*temp_context_var)); |
| 1503 Value* store_val = Bind(new(I) LoadLocalInstr(*temp_result_var)); |
| 1498 StoreInstanceFieldInstr* store = new(I) StoreInstanceFieldInstr( | 1504 StoreInstanceFieldInstr* store = new(I) StoreInstanceFieldInstr( |
| 1499 Context::variable_offset(continuation_result->index()), | 1505 Context::variable_offset(continuation_result->index()), |
| 1500 context, | 1506 context_val, |
| 1501 tmp_val, | 1507 store_val, |
| 1502 kEmitStoreBarrier, | 1508 kEmitStoreBarrier, |
| 1503 Scanner::kNoSourcePos); | 1509 Scanner::kNoSourcePos); |
| 1504 Do(store); | 1510 Do(store); |
| 1505 Do(ExitTempLocalScope(tmp_var)); | 1511 context_val = Bind(new(I) LoadLocalInstr(*temp_context_var)); |
| 1512 store_val = Bind(new(I) LoadLocalInstr(*temp_error_var)); |
| 1513 StoreInstanceFieldInstr* store2 = new(I) StoreInstanceFieldInstr( |
| 1514 Context::variable_offset(continuation_error->index()), |
| 1515 context_val, |
| 1516 store_val, |
| 1517 kEmitStoreBarrier, |
| 1518 Scanner::kNoSourcePos); |
| 1519 Do(store2); |
| 1520 |
| 1521 Do(ExitTempLocalScope(temp_context_var)); |
| 1522 Do(ExitTempLocalScope(temp_error_var)); |
| 1523 Do(ExitTempLocalScope(temp_result_var)); |
| 1506 | 1524 |
| 1507 // Goto saved join. | 1525 // Goto saved join. |
| 1508 Goto(target); | 1526 Goto(target); |
| 1509 } | 1527 } |
| 1510 | 1528 |
| 1511 | 1529 |
| 1512 // Used for type casts and to test assignments. | 1530 // Used for type casts and to test assignments. |
| 1513 Value* EffectGraphVisitor::BuildAssignableValue(intptr_t token_pos, | 1531 Value* EffectGraphVisitor::BuildAssignableValue(intptr_t token_pos, |
| 1514 Value* value, | 1532 Value* value, |
| 1515 const AbstractType& dst_type, | 1533 const AbstractType& dst_type, |
| (...skipping 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4207 Report::MessageF(Report::kBailout, | 4225 Report::MessageF(Report::kBailout, |
| 4208 Script::Handle(function.script()), | 4226 Script::Handle(function.script()), |
| 4209 function.token_pos(), | 4227 function.token_pos(), |
| 4210 "FlowGraphBuilder Bailout: %s %s", | 4228 "FlowGraphBuilder Bailout: %s %s", |
| 4211 String::Handle(function.name()).ToCString(), | 4229 String::Handle(function.name()).ToCString(), |
| 4212 reason); | 4230 reason); |
| 4213 UNREACHABLE(); | 4231 UNREACHABLE(); |
| 4214 } | 4232 } |
| 4215 | 4233 |
| 4216 } // namespace dart | 4234 } // namespace dart |
| OLD | NEW |