Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 10696151: Skeleton of a linear scan register allocator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 // f) loop-exit-target 1065 // f) loop-exit-target
1066 // g) break-join (optional) 1066 // g) break-join (optional)
1067 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { 1067 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) {
1068 TestGraphVisitor for_test(owner(), 1068 TestGraphVisitor for_test(owner(),
1069 temp_index(), 1069 temp_index(),
1070 node->condition()->token_pos()); 1070 node->condition()->token_pos());
1071 node->condition()->Visit(&for_test); 1071 node->condition()->Visit(&for_test);
1072 ASSERT(!for_test.is_empty()); // Language spec. 1072 ASSERT(!for_test.is_empty()); // Language spec.
1073 1073
1074 EffectGraphVisitor for_body(owner(), temp_index()); 1074 EffectGraphVisitor for_body(owner(), temp_index());
1075 #if 0
srdjan 2012/07/11 17:22:32 Enable stack overflow check before submitting
1075 for_body.Do( 1076 for_body.Do(
1076 new CheckStackOverflowComp(node->token_pos(), owner()->try_index())); 1077 new CheckStackOverflowComp(node->token_pos(), owner()->try_index()));
1078 #endif
1077 node->body()->Visit(&for_body); 1079 node->body()->Visit(&for_body);
1078 1080
1079 // Labels are set after body traversal. 1081 // Labels are set after body traversal.
1080 SourceLabel* lbl = node->label(); 1082 SourceLabel* lbl = node->label();
1081 ASSERT(lbl != NULL); 1083 ASSERT(lbl != NULL);
1082 if (lbl->join_for_continue() != NULL) { 1084 if (lbl->join_for_continue() != NULL) {
1083 AddInstruction(lbl->join_for_continue()); 1085 AddInstruction(lbl->join_for_continue());
1084 } 1086 }
1085 TieLoop(for_test, for_body); 1087 TieLoop(for_test, for_body);
1086 if (lbl->join_for_break() != NULL) { 1088 if (lbl->join_for_break() != NULL) {
1087 AddInstruction(lbl->join_for_break()); 1089 AddInstruction(lbl->join_for_break());
1088 } 1090 }
1089 } 1091 }
1090 1092
1091 1093
1092 // The fragment is composed as follows: 1094 // The fragment is composed as follows:
1093 // a) body-entry-join 1095 // a) body-entry-join
1094 // b) [ body ] 1096 // b) [ body ]
1095 // c) test-entry (continue-join or body-exit-target) 1097 // c) test-entry (continue-join or body-exit-target)
1096 // d) [ test-entry ] -> (back-target, loop-exit-target) 1098 // d) [ test-entry ] -> (back-target, loop-exit-target)
1097 // e) back-target -> (body-entry-join) 1099 // e) back-target -> (body-entry-join)
1098 // f) loop-exit-target 1100 // f) loop-exit-target
1099 // g) break-join 1101 // g) break-join
1100 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { 1102 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) {
1101 // Traverse body first in order to generate continue and break labels. 1103 // Traverse body first in order to generate continue and break labels.
1102 EffectGraphVisitor for_body(owner(), temp_index()); 1104 EffectGraphVisitor for_body(owner(), temp_index());
1105 #if 0
1103 for_body.Do( 1106 for_body.Do(
1104 new CheckStackOverflowComp(node->token_pos(), owner()->try_index())); 1107 new CheckStackOverflowComp(node->token_pos(), owner()->try_index()));
1108 #endif
1105 node->body()->Visit(&for_body); 1109 node->body()->Visit(&for_body);
1106 1110
1107 TestGraphVisitor for_test(owner(), 1111 TestGraphVisitor for_test(owner(),
1108 temp_index(), 1112 temp_index(),
1109 node->condition()->token_pos()); 1113 node->condition()->token_pos());
1110 node->condition()->Visit(&for_test); 1114 node->condition()->Visit(&for_test);
1111 ASSERT(is_open()); 1115 ASSERT(is_open());
1112 1116
1113 // Tie do-while loop (test is after the body). 1117 // Tie do-while loop (test is after the body).
1114 JoinEntryInstr* body_entry_join = new JoinEntryInstr(); 1118 JoinEntryInstr* body_entry_join = new JoinEntryInstr();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 void EffectGraphVisitor::VisitForNode(ForNode* node) { 1161 void EffectGraphVisitor::VisitForNode(ForNode* node) {
1158 EffectGraphVisitor for_initializer(owner(), temp_index()); 1162 EffectGraphVisitor for_initializer(owner(), temp_index());
1159 node->initializer()->Visit(&for_initializer); 1163 node->initializer()->Visit(&for_initializer);
1160 Append(for_initializer); 1164 Append(for_initializer);
1161 ASSERT(is_open()); 1165 ASSERT(is_open());
1162 1166
1163 // Compose body to set any jump labels. 1167 // Compose body to set any jump labels.
1164 EffectGraphVisitor for_body(owner(), temp_index()); 1168 EffectGraphVisitor for_body(owner(), temp_index());
1165 TargetEntryInstr* body_entry = new TargetEntryInstr(); 1169 TargetEntryInstr* body_entry = new TargetEntryInstr();
1166 for_body.AddInstruction(body_entry); 1170 for_body.AddInstruction(body_entry);
1171 #if 0
1167 for_body.Do( 1172 for_body.Do(
1168 new CheckStackOverflowComp(node->token_pos(), owner()->try_index())); 1173 new CheckStackOverflowComp(node->token_pos(), owner()->try_index()));
1174 #endif
1169 node->body()->Visit(&for_body); 1175 node->body()->Visit(&for_body);
1170 1176
1171 // Join loop body, increment and compute their end instruction. 1177 // Join loop body, increment and compute their end instruction.
1172 ASSERT(!for_body.is_empty()); 1178 ASSERT(!for_body.is_empty());
1173 Instruction* loop_increment_end = NULL; 1179 Instruction* loop_increment_end = NULL;
1174 EffectGraphVisitor for_increment(owner(), temp_index()); 1180 EffectGraphVisitor for_increment(owner(), temp_index());
1175 if ((node->label()->join_for_continue() == NULL) && for_body.is_open()) { 1181 if ((node->label()->join_for_continue() == NULL) && for_body.is_open()) {
1176 // Do not insert an extra basic block. 1182 // Do not insert an extra basic block.
1177 node->increment()->Visit(&for_increment); 1183 node->increment()->Visit(&for_increment);
1178 for_body.Append(for_increment); 1184 for_body.Append(for_increment);
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 char* chars = reinterpret_cast<char*>( 2667 char* chars = reinterpret_cast<char*>(
2662 Isolate::Current()->current_zone()->Allocate(len)); 2668 Isolate::Current()->current_zone()->Allocate(len));
2663 OS::SNPrint(chars, len, kFormat, function_name, reason); 2669 OS::SNPrint(chars, len, kFormat, function_name, reason);
2664 const Error& error = Error::Handle( 2670 const Error& error = Error::Handle(
2665 LanguageError::New(String::Handle(String::New(chars)))); 2671 LanguageError::New(String::Handle(String::New(chars))));
2666 Isolate::Current()->long_jump_base()->Jump(1, error); 2672 Isolate::Current()->long_jump_base()->Jump(1, error);
2667 } 2673 }
2668 2674
2669 2675
2670 } // namespace dart 2676 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698