| 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/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 caller_graph->set_max_block_id(join_id); | 190 caller_graph->set_max_block_id(join_id); |
| 191 JoinEntryInstr* join = | 191 JoinEntryInstr* join = |
| 192 new JoinEntryInstr(join_id, CatchClauseNode::kInvalidTryIndex); | 192 new JoinEntryInstr(join_id, CatchClauseNode::kInvalidTryIndex); |
| 193 for (intptr_t i = 0; i < num_exits; ++i) { | 193 for (intptr_t i = 0; i < num_exits; ++i) { |
| 194 LastInstructionAt(i)->Goto(join); | 194 LastInstructionAt(i)->Goto(join); |
| 195 // Directly add the predecessors of the join in ascending block id order. | 195 // Directly add the predecessors of the join in ascending block id order. |
| 196 join->predecessors_.Add(ExitBlockAt(i)); | 196 join->predecessors_.Add(ExitBlockAt(i)); |
| 197 } | 197 } |
| 198 // If the call has uses, create a phi of the returns. | 198 // If the call has uses, create a phi of the returns. |
| 199 if (call->HasUses()) { | 199 if (call->HasUses()) { |
| 200 // Environment count: length before call - argument count (+ return) | |
| 201 intptr_t env_count = call->env()->Length() - call->ArgumentCount(); | |
| 202 // Add a phi of the return values. | 200 // Add a phi of the return values. |
| 203 join->InsertPhi(env_count, env_count + 1); | 201 PhiInstr* phi = new PhiInstr(join, num_exits); |
| 204 PhiInstr* phi = join->phis()->Last(); | |
| 205 phi->set_ssa_temp_index(caller_graph->alloc_ssa_temp_index()); | 202 phi->set_ssa_temp_index(caller_graph->alloc_ssa_temp_index()); |
| 206 phi->mark_alive(); | 203 phi->mark_alive(); |
| 207 for (intptr_t i = 0; i < num_exits; ++i) { | 204 for (intptr_t i = 0; i < num_exits; ++i) { |
| 208 phi->SetInputAt(i, ValueAt(i)); | 205 phi->SetInputAt(i, ValueAt(i)); |
| 209 } | 206 } |
| 207 join->InsertPhi(phi); |
| 210 // Replace uses of the call with the phi. | 208 // Replace uses of the call with the phi. |
| 211 call->ReplaceUsesWith(phi); | 209 call->ReplaceUsesWith(phi); |
| 212 } else { | 210 } else { |
| 213 // In the case that the result is unused, remove the return value uses | 211 // In the case that the result is unused, remove the return value uses |
| 214 // from their definition's use list. | 212 // from their definition's use list. |
| 215 for (intptr_t i = 0; i < num_exits; ++i) { | 213 for (intptr_t i = 0; i < num_exits; ++i) { |
| 216 ValueAt(i)->RemoveFromUseList(); | 214 ValueAt(i)->RemoveFromUseList(); |
| 217 } | 215 } |
| 218 } | 216 } |
| 219 // Remove the call from the graph. | 217 // Remove the call from the graph. |
| (...skipping 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3262 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3265 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3263 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3266 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3264 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3267 const Error& error = Error::Handle( | 3265 const Error& error = Error::Handle( |
| 3268 LanguageError::New(String::Handle(String::New(chars)))); | 3266 LanguageError::New(String::Handle(String::New(chars)))); |
| 3269 Isolate::Current()->long_jump_base()->Jump(1, error); | 3267 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3270 } | 3268 } |
| 3271 | 3269 |
| 3272 | 3270 |
| 3273 } // namespace dart | 3271 } // namespace dart |
| OLD | NEW |