| Index: runtime/vm/intermediate_language.cc
|
| diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
|
| index 80b0f870ee6f463ac03ef525ffd89fec6ad29878..ec9d0cdd5dbb3d60f07560763b5512a97d30cda7 100644
|
| --- a/runtime/vm/intermediate_language.cc
|
| +++ b/runtime/vm/intermediate_language.cc
|
| @@ -771,6 +771,34 @@ void BranchInstr::InheritDeoptTarget(Isolate* isolate, Instruction* other) {
|
| }
|
|
|
|
|
| +bool Instruction::IsDominatedBy(Instruction* dom) {
|
| + BlockEntryInstr* block = GetBlock();
|
| + BlockEntryInstr* dom_block = dom->GetBlock();
|
| +
|
| + if (dom->IsPhi()) {
|
| + dom = dom_block;
|
| + }
|
| +
|
| + if (block == dom_block) {
|
| + if ((block == dom) || (this == block->last_instruction())) {
|
| + return true;
|
| + }
|
| +
|
| + if (IsPhi()) {
|
| + return false;
|
| + }
|
| +
|
| + for (Instruction* curr = dom->next(); curr != NULL; curr = curr->next()) {
|
| + if (curr == this) return true;
|
| + }
|
| +
|
| + return false;
|
| + }
|
| +
|
| + return dom_block->Dominates(block);
|
| +}
|
| +
|
| +
|
| void Definition::ReplaceWith(Definition* other,
|
| ForwardInstructionIterator* iterator) {
|
| // Record other's input uses.
|
| @@ -963,6 +991,15 @@ bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const {
|
| }
|
|
|
|
|
| +BlockEntryInstr* BlockEntryInstr::ImmediateDominator() const {
|
| + Instruction* last = dominator()->last_instruction();
|
| + if ((last->SuccessorCount() == 1) && (last->SuccessorAt(0) == this)) {
|
| + return dominator();
|
| + }
|
| + return NULL;
|
| +}
|
| +
|
| +
|
| // Helper to mutate the graph during inlining. This block should be
|
| // replaced with new_block as a predecessor of all of this block's
|
| // successors. For each successor, the predecessors will be reordered
|
|
|