Chromium Code Reviews| 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 "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 // g) break-join (optional) | 1067 // g) break-join (optional) |
| 1068 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { | 1068 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { |
| 1069 TestGraphVisitor for_test(owner(), | 1069 TestGraphVisitor for_test(owner(), |
| 1070 temp_index(), | 1070 temp_index(), |
| 1071 node->condition()->token_index()); | 1071 node->condition()->token_index()); |
| 1072 node->condition()->Visit(&for_test); | 1072 node->condition()->Visit(&for_test); |
| 1073 ASSERT(!for_test.is_empty()); // Language spec. | 1073 ASSERT(!for_test.is_empty()); // Language spec. |
| 1074 | 1074 |
| 1075 EffectGraphVisitor for_body(owner(), temp_index()); | 1075 EffectGraphVisitor for_body(owner(), temp_index()); |
| 1076 node->body()->Visit(&for_body); | 1076 node->body()->Visit(&for_body); |
| 1077 if (for_body.is_open()) { | |
| 1078 CheckStackOverflowComp* comp = | |
| 1079 new CheckStackOverflowComp(node->token_index(), owner()->try_index()); | |
| 1080 for_body.AddInstruction(new DoInstr(comp)); | |
| 1081 } | |
|
Vyacheslav Egorov (Google)
2012/06/15 17:43:02
I am not sure that this is enough for the case lik
srdjan
2012/06/15 17:56:10
Done.
| |
| 1077 | 1082 |
| 1078 // Labels are set after body traversal. | 1083 // Labels are set after body traversal. |
| 1079 SourceLabel* lbl = node->label(); | 1084 SourceLabel* lbl = node->label(); |
| 1080 ASSERT(lbl != NULL); | 1085 ASSERT(lbl != NULL); |
| 1081 if (lbl->join_for_continue() != NULL) { | 1086 if (lbl->join_for_continue() != NULL) { |
| 1082 AddInstruction(lbl->join_for_continue()); | 1087 AddInstruction(lbl->join_for_continue()); |
| 1083 } | 1088 } |
| 1084 TieLoop(for_test, for_body); | 1089 TieLoop(for_test, for_body); |
| 1085 if (lbl->join_for_break() != NULL) { | 1090 if (lbl->join_for_break() != NULL) { |
| 1086 AddInstruction(lbl->join_for_break()); | 1091 AddInstruction(lbl->join_for_break()); |
| 1087 } | 1092 } |
| 1088 } | 1093 } |
| 1089 | 1094 |
| 1090 | 1095 |
| 1091 // The fragment is composed as follows: | 1096 // The fragment is composed as follows: |
| 1092 // a) body-entry-join | 1097 // a) body-entry-join |
| 1093 // b) [ body ] | 1098 // b) [ body ] |
| 1094 // c) test-entry (continue-join or body-exit-target) | 1099 // c) test-entry (continue-join or body-exit-target) |
| 1095 // d) [ test-entry ] -> (back-target, loop-exit-target) | 1100 // d) [ test-entry ] -> (back-target, loop-exit-target) |
| 1096 // e) back-target -> (body-entry-join) | 1101 // e) back-target -> (body-entry-join) |
| 1097 // f) loop-exit-target | 1102 // f) loop-exit-target |
| 1098 // g) break-join | 1103 // g) break-join |
| 1099 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { | 1104 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { |
| 1100 // Traverse body first in order to generate continue and break labels. | 1105 // Traverse body first in order to generate continue and break labels. |
| 1101 EffectGraphVisitor for_body(owner(), temp_index()); | 1106 EffectGraphVisitor for_body(owner(), temp_index()); |
| 1102 node->body()->Visit(&for_body); | 1107 node->body()->Visit(&for_body); |
| 1108 if (for_body.is_open()) { | |
| 1109 CheckStackOverflowComp* comp = | |
| 1110 new CheckStackOverflowComp(node->token_index(), owner()->try_index()); | |
| 1111 for_body.AddInstruction(new DoInstr(comp)); | |
| 1112 } | |
| 1103 | 1113 |
| 1104 TestGraphVisitor for_test(owner(), | 1114 TestGraphVisitor for_test(owner(), |
| 1105 temp_index(), | 1115 temp_index(), |
| 1106 node->condition()->token_index()); | 1116 node->condition()->token_index()); |
| 1107 node->condition()->Visit(&for_test); | 1117 node->condition()->Visit(&for_test); |
| 1108 ASSERT(is_open()); | 1118 ASSERT(is_open()); |
| 1109 | 1119 |
| 1110 // Tie do-while loop (test is after the body). | 1120 // Tie do-while loop (test is after the body). |
| 1111 JoinEntryInstr* body_entry_join = new JoinEntryInstr(); | 1121 JoinEntryInstr* body_entry_join = new JoinEntryInstr(); |
| 1112 AddInstruction(body_entry_join); | 1122 AddInstruction(body_entry_join); |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2552 char* chars = reinterpret_cast<char*>( | 2562 char* chars = reinterpret_cast<char*>( |
| 2553 Isolate::Current()->current_zone()->Allocate(len)); | 2563 Isolate::Current()->current_zone()->Allocate(len)); |
| 2554 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2564 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2555 const Error& error = Error::Handle( | 2565 const Error& error = Error::Handle( |
| 2556 LanguageError::New(String::Handle(String::New(chars)))); | 2566 LanguageError::New(String::Handle(String::New(chars)))); |
| 2557 Isolate::Current()->long_jump_base()->Jump(1, error); | 2567 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2558 } | 2568 } |
| 2559 | 2569 |
| 2560 | 2570 |
| 2561 } // namespace dart | 2571 } // namespace dart |
| OLD | NEW |