| 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.h" | 5 #include "vm/flow_graph.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 264 |
| 265 // Initialize start environment. | 265 // Initialize start environment. |
| 266 GrowableArray<Definition*> start_env(variable_count()); | 266 GrowableArray<Definition*> start_env(variable_count()); |
| 267 for (intptr_t i = 0; i < parameter_count(); ++i) { | 267 for (intptr_t i = 0; i < parameter_count(); ++i) { |
| 268 ParameterInstr* param = new ParameterInstr(i); | 268 ParameterInstr* param = new ParameterInstr(i); |
| 269 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. | 269 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
| 270 start_env.Add(param); | 270 start_env.Add(param); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // All locals are initialized with #null. | 273 // All locals are initialized with #null. |
| 274 Definition* null_defn = new BindInstr(BindInstr::kUsed, | 274 Definition* null_defn = |
| 275 new ConstantVal(Object::ZoneHandle())); | 275 new BindInstr(BindInstr::kUsed, |
| 276 new MaterializeComp(new ConstantVal(Object::ZoneHandle()))); |
| 276 // The null definition should not appear in input positions. | 277 // The null definition should not appear in input positions. |
| 277 ASSERT(null_defn->ssa_temp_index() == -1); | 278 ASSERT(null_defn->ssa_temp_index() == -1); |
| 278 while (start_env.length() < variable_count()) { | 279 while (start_env.length() < variable_count()) { |
| 279 start_env.Add(null_defn); | 280 start_env.Add(null_defn); |
| 280 } | 281 } |
| 281 graph_entry_->set_start_env( | 282 graph_entry_->set_start_env( |
| 282 new Environment(start_env, non_copied_parameter_count_)); | 283 new Environment(start_env, non_copied_parameter_count_)); |
| 283 | 284 |
| 284 BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0); | 285 BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0); |
| 285 ASSERT(normal_entry != NULL); // Must have entry. | 286 ASSERT(normal_entry != NULL); // Must have entry. |
| 286 GrowableArray<Definition*> env(variable_count()); | 287 GrowableArray<Definition*> env(variable_count()); |
| 287 env.AddArray(start_env); | 288 env.AddArray(start_env); |
| 288 RenameRecursive(normal_entry, &env, live_phis); | 289 RenameRecursive(normal_entry, &env, live_phis); |
| 289 } | 290 } |
| 290 | 291 |
| 291 | 292 |
| 292 // Helper to either use the constant value of a definition or the definition. | 293 // Helper to either use the constant value of a definition or the definition. |
| 293 static Value* UseDefinition(Definition* defn) { | 294 static Value* UseDefinition(Definition* defn) { |
| 294 if (defn->IsBind() && defn->AsBind()->computation()->IsConstant()) { | 295 if (defn->IsBind() && defn->AsBind()->computation()->IsMaterialize()) { |
| 295 return defn->AsBind()->computation()->AsConstant(); | 296 return defn->AsBind()->computation()->AsMaterialize()->constant_val(); |
| 296 } else { | 297 } else { |
| 297 return new UseVal(defn); | 298 return new UseVal(defn); |
| 298 } | 299 } |
| 299 } | 300 } |
| 300 | 301 |
| 301 | 302 |
| 302 void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, | 303 void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
| 303 GrowableArray<Definition*>* env, | 304 GrowableArray<Definition*>* env, |
| 304 GrowableArray<PhiInstr*>* live_phis) { | 305 GrowableArray<PhiInstr*>* live_phis) { |
| 305 // 1. Process phis first. | 306 // 1. Process phis first. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 464 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 464 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 465 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 465 OS::SNPrint(chars, len, kFormat, function_name, reason); | 466 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 466 const Error& error = Error::Handle( | 467 const Error& error = Error::Handle( |
| 467 LanguageError::New(String::Handle(String::New(chars)))); | 468 LanguageError::New(String::Handle(String::New(chars)))); |
| 468 Isolate::Current()->long_jump_base()->Jump(1, error); | 469 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 469 } | 470 } |
| 470 | 471 |
| 471 | 472 |
| 472 } // namespace dart | 473 } // namespace dart |
| OLD | NEW |