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/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 ASSERT(is_open()); | 1698 ASSERT(is_open()); |
1699 | 1699 |
1700 // Compose body to set any jump labels. | 1700 // Compose body to set any jump labels. |
1701 EffectGraphVisitor for_body(owner(), temp_index()); | 1701 EffectGraphVisitor for_body(owner(), temp_index()); |
1702 node->body()->Visit(&for_body); | 1702 node->body()->Visit(&for_body); |
1703 | 1703 |
1704 EffectGraphVisitor for_increment(owner(), temp_index()); | 1704 EffectGraphVisitor for_increment(owner(), temp_index()); |
1705 node->increment()->Visit(&for_increment); | 1705 node->increment()->Visit(&for_increment); |
1706 | 1706 |
1707 // Join the loop body and increment and then tie the loop. | 1707 // Join the loop body and increment and then tie the loop. |
1708 JoinEntryInstr* join = node->label()->join_for_continue(); | 1708 JoinEntryInstr* continue_join = node->label()->join_for_continue(); |
1709 if ((join != NULL) || for_body.is_open()) { | 1709 if ((continue_join != NULL) || for_body.is_open()) { |
1710 JoinEntryInstr* loop_start = | 1710 JoinEntryInstr* loop_entry = |
1711 new JoinEntryInstr(owner()->AllocateBlockId(), owner()->try_index()); | 1711 new JoinEntryInstr(owner()->AllocateBlockId(), owner()->try_index()); |
1712 if (join != NULL) { | 1712 if (continue_join != NULL) { |
1713 if (for_body.is_open()) for_body.Goto(join); | 1713 if (for_body.is_open()) for_body.Goto(continue_join); |
1714 AppendFragment(join, for_increment); | 1714 Instruction* current = AppendFragment(continue_join, for_increment); |
1715 for_increment.Goto(loop_start); | 1715 current->Goto(loop_entry); |
1716 } else { | 1716 } else { |
1717 for_body.Append(for_increment); | 1717 for_body.Append(for_increment); |
1718 for_body.Goto(loop_start); | 1718 for_body.Goto(loop_entry); |
1719 } | 1719 } |
1720 Goto(loop_start); | 1720 Goto(loop_entry); |
1721 exit_ = loop_start; | 1721 exit_ = loop_entry; |
1722 AddInstruction(new CheckStackOverflowInstr(node->token_pos(), true)); | 1722 AddInstruction(new CheckStackOverflowInstr(node->token_pos(), true)); |
1723 } | 1723 } |
1724 | 1724 |
1725 if (node->condition() == NULL) { | 1725 if (node->condition() == NULL) { |
1726 // Endless loop, no test. | 1726 // Endless loop, no test. |
1727 JoinEntryInstr* body_entry = | 1727 Append(for_body); |
1728 new JoinEntryInstr(owner()->AllocateBlockId(), owner()->try_index()); | 1728 exit_ = node->label()->join_for_break(); // May be NULL. |
1729 AppendFragment(body_entry, for_body); | |
1730 Goto(body_entry); | |
1731 if (node->label()->join_for_break() != NULL) { | |
1732 // Control flow of ForLoop continues into join_for_break. | |
1733 exit_ = node->label()->join_for_break(); | |
1734 } | |
1735 } else { | 1729 } else { |
1736 TestGraphVisitor for_test(owner(), | 1730 TestGraphVisitor for_test(owner(), |
1737 temp_index(), | 1731 temp_index(), |
1738 node->condition()->token_pos()); | 1732 node->condition()->token_pos()); |
1739 node->condition()->Visit(&for_test); | 1733 node->condition()->Visit(&for_test); |
1740 Append(for_test); | 1734 Append(for_test); |
1741 | 1735 |
1742 BlockEntryInstr* body_entry = for_test.CreateTrueSuccessor(); | 1736 BlockEntryInstr* body_entry = for_test.CreateTrueSuccessor(); |
1743 AppendFragment(body_entry, for_body); | 1737 AppendFragment(body_entry, for_body); |
1744 | 1738 |
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3503 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3497 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
3504 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3498 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
3505 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3499 OS::SNPrint(chars, len, kFormat, function_name, reason); |
3506 const Error& error = Error::Handle( | 3500 const Error& error = Error::Handle( |
3507 LanguageError::New(String::Handle(String::New(chars)))); | 3501 LanguageError::New(String::Handle(String::New(chars)))); |
3508 Isolate::Current()->long_jump_base()->Jump(1, error); | 3502 Isolate::Current()->long_jump_base()->Jump(1, error); |
3509 } | 3503 } |
3510 | 3504 |
3511 | 3505 |
3512 } // namespace dart | 3506 } // namespace dart |
OLD | NEW |