| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 void InlineExitCollector::AddExit(ReturnInstr* exit) { | 93 void InlineExitCollector::AddExit(ReturnInstr* exit) { |
| 94 Data data = { NULL, exit }; | 94 Data data = { NULL, exit }; |
| 95 exits_.Add(data); | 95 exits_.Add(data); |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 void InlineExitCollector::Union(const InlineExitCollector* other) { |
| 100 // It doesn't make sense to combine different calls or calls from |
| 101 // different graphs. |
| 102 ASSERT(caller_graph_ == other->caller_graph_); |
| 103 ASSERT(call_ == other->call_); |
| 104 exits_.AddArray(other->exits_); |
| 105 } |
| 106 |
| 107 |
| 99 int InlineExitCollector::LowestBlockIdFirst(const Data* a, const Data* b) { | 108 int InlineExitCollector::LowestBlockIdFirst(const Data* a, const Data* b) { |
| 100 return (a->exit_block->block_id() - b->exit_block->block_id()); | 109 return (a->exit_block->block_id() - b->exit_block->block_id()); |
| 101 } | 110 } |
| 102 | 111 |
| 103 | 112 |
| 104 void InlineExitCollector::SortExits() { | 113 void InlineExitCollector::SortExits() { |
| 105 // Assign block entries here because we did not necessarily know them when | 114 // Assign block entries here because we did not necessarily know them when |
| 106 // the return exit was added to the array. | 115 // the return exit was added to the array. |
| 107 for (int i = 0; i < exits_.length(); ++i) { | 116 for (int i = 0; i < exits_.length(); ++i) { |
| 108 exits_[i].exit_block = exits_[i].exit_return->GetBlock(); | 117 exits_[i].exit_block = exits_[i].exit_return->GetBlock(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 125 ReturnAt(0)->UnuseAllInputs(); | 134 ReturnAt(0)->UnuseAllInputs(); |
| 126 *exit_block = ExitBlockAt(0); | 135 *exit_block = ExitBlockAt(0); |
| 127 *last_instruction = LastInstructionAt(0); | 136 *last_instruction = LastInstructionAt(0); |
| 128 return call_->HasUses() ? ValueAt(0)->definition() : NULL; | 137 return call_->HasUses() ? ValueAt(0)->definition() : NULL; |
| 129 } else { | 138 } else { |
| 130 // Create a join of the returns. | 139 // Create a join of the returns. |
| 131 intptr_t join_id = caller_graph_->max_block_id() + 1; | 140 intptr_t join_id = caller_graph_->max_block_id() + 1; |
| 132 caller_graph_->set_max_block_id(join_id); | 141 caller_graph_->set_max_block_id(join_id); |
| 133 JoinEntryInstr* join = | 142 JoinEntryInstr* join = |
| 134 new JoinEntryInstr(join_id, CatchClauseNode::kInvalidTryIndex); | 143 new JoinEntryInstr(join_id, CatchClauseNode::kInvalidTryIndex); |
| 135 join->InheritDeoptTarget(call_); | 144 join->InheritDeoptTargetAfter(call_); |
| 136 | 145 |
| 137 // The dominator set of the join is the intersection of the dominator | 146 // The dominator set of the join is the intersection of the dominator |
| 138 // sets of all the predecessors. If we keep the dominator sets ordered | 147 // sets of all the predecessors. If we keep the dominator sets ordered |
| 139 // by height in the dominator tree, we can also get the immediate | 148 // by height in the dominator tree, we can also get the immediate |
| 140 // dominator of the join node from the intersection. | 149 // dominator of the join node from the intersection. |
| 141 // | 150 // |
| 142 // block_dominators is the dominator set for each block, ordered from | 151 // block_dominators is the dominator set for each block, ordered from |
| 143 // the immediate dominator to the root of the dominator tree. This is | 152 // the immediate dominator to the root of the dominator tree. This is |
| 144 // the order we collect them in (adding at the end). | 153 // the order we collect them in (adding at the end). |
| 145 // | 154 // |
| (...skipping 26 matching lines...) Expand all Loading... |
| 172 } | 181 } |
| 173 } else { | 182 } else { |
| 174 // Intersect the block's dominators with the join's dominators so far. | 183 // Intersect the block's dominators with the join's dominators so far. |
| 175 intptr_t last = block_dominators.length() - 1; | 184 intptr_t last = block_dominators.length() - 1; |
| 176 for (intptr_t j = 0; j < join_dominators.length(); ++j) { | 185 for (intptr_t j = 0; j < join_dominators.length(); ++j) { |
| 177 intptr_t k = last - j; // Corresponding index in block_dominators. | 186 intptr_t k = last - j; // Corresponding index in block_dominators. |
| 178 if ((k < 0) || (join_dominators[j] != block_dominators[k])) { | 187 if ((k < 0) || (join_dominators[j] != block_dominators[k])) { |
| 179 // We either exhausted the dominators for this block before | 188 // We either exhausted the dominators for this block before |
| 180 // exhausting the current intersection, or else we found a block | 189 // exhausting the current intersection, or else we found a block |
| 181 // on the path from the root of the tree that is not in common. | 190 // on the path from the root of the tree that is not in common. |
| 182 ASSERT(j >= 2); | 191 // I.e., there cannot be an empty set of dominators. |
| 192 ASSERT(j > 0); |
| 183 join_dominators.TruncateTo(j); | 193 join_dominators.TruncateTo(j); |
| 184 break; | 194 break; |
| 185 } | 195 } |
| 186 } | 196 } |
| 187 } | 197 } |
| 188 } | 198 } |
| 189 // The immediate dominator of the join is the last one in the ordered | 199 // The immediate dominator of the join is the last one in the ordered |
| 190 // intersection. | 200 // intersection. |
| 191 join->set_dominator(join_dominators.Last()); | 201 join->set_dominator(join_dominators.Last()); |
| 192 join_dominators.Last()->AddDominatedBlock(join); | 202 join_dominators.Last()->AddDominatedBlock(join); |
| (...skipping 3180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3373 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3383 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3374 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3384 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3375 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3385 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3376 const Error& error = Error::Handle( | 3386 const Error& error = Error::Handle( |
| 3377 LanguageError::New(String::Handle(String::New(chars)))); | 3387 LanguageError::New(String::Handle(String::New(chars)))); |
| 3378 Isolate::Current()->long_jump_base()->Jump(1, error); | 3388 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3379 } | 3389 } |
| 3380 | 3390 |
| 3381 | 3391 |
| 3382 } // namespace dart | 3392 } // namespace dart |
| OLD | NEW |