| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 interface HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBitAnd(HBitAnd node); | 7 R visitBitAnd(HBitAnd node); |
| 8 R visitBitNot(HBitNot node); | 8 R visitBitNot(HBitNot node); |
| 9 R visitBitOr(HBitOr node); | 9 R visitBitOr(HBitOr node); |
| 10 R visitBitXor(HBitXor node); | 10 R visitBitXor(HBitXor node); |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 instruction.notifyAddedToBlock(this); | 498 instruction.notifyAddedToBlock(this); |
| 499 } | 499 } |
| 500 | 500 |
| 501 void addPhi(HPhi phi) { | 501 void addPhi(HPhi phi) { |
| 502 phis.addAfter(phis.last, phi); | 502 phis.addAfter(phis.last, phi); |
| 503 phi.notifyAddedToBlock(this); | 503 phi.notifyAddedToBlock(this); |
| 504 } | 504 } |
| 505 | 505 |
| 506 void removePhi(HPhi phi) { | 506 void removePhi(HPhi phi) { |
| 507 phis.remove(phi); | 507 phis.remove(phi); |
| 508 phi.notifyRemovedFromBlock(this); | 508 assert(phi.block == this); |
| 509 phi.notifyRemovedFromBlock(); |
| 509 } | 510 } |
| 510 | 511 |
| 511 void addAfter(HInstruction cursor, HInstruction instruction) { | 512 void addAfter(HInstruction cursor, HInstruction instruction) { |
| 512 assert(cursor is !HPhi); | 513 assert(cursor is !HPhi); |
| 513 assert(instruction is !HPhi); | 514 assert(instruction is !HPhi); |
| 514 assert(isOpen() || isClosed()); | 515 assert(isOpen() || isClosed()); |
| 515 super.addAfter(cursor, instruction); | 516 super.addAfter(cursor, instruction); |
| 516 instruction.notifyAddedToBlock(this); | 517 instruction.notifyAddedToBlock(this); |
| 517 } | 518 } |
| 518 | 519 |
| 519 void addBefore(HInstruction cursor, HInstruction instruction) { | 520 void addBefore(HInstruction cursor, HInstruction instruction) { |
| 520 assert(cursor is !HPhi); | 521 assert(cursor is !HPhi); |
| 521 assert(instruction is !HPhi); | 522 assert(instruction is !HPhi); |
| 522 assert(isOpen() || isClosed()); | 523 assert(isOpen() || isClosed()); |
| 523 super.addBefore(cursor, instruction); | 524 super.addBefore(cursor, instruction); |
| 524 instruction.notifyAddedToBlock(this); | 525 instruction.notifyAddedToBlock(this); |
| 525 } | 526 } |
| 526 | 527 |
| 527 void remove(HInstruction instruction) { | 528 void remove(HInstruction instruction) { |
| 528 assert(isOpen() || isClosed()); | 529 assert(isOpen() || isClosed()); |
| 529 assert(instruction is !HPhi); | 530 assert(instruction is !HPhi); |
| 530 super.remove(instruction); | 531 super.remove(instruction); |
| 531 instruction.notifyRemovedFromBlock(this); | 532 assert(instruction.block == this); |
| 533 instruction.notifyRemovedFromBlock(); |
| 532 } | 534 } |
| 533 | 535 |
| 534 void addSuccessor(HBasicBlock block) { | 536 void addSuccessor(HBasicBlock block) { |
| 535 // Forward branches are only allowed to new blocks. | 537 // Forward branches are only allowed to new blocks. |
| 536 assert(isClosed() && (block.isNew() || block.id < id)); | 538 assert(isClosed() && (block.isNew() || block.id < id)); |
| 537 if (successors.isEmpty()) { | 539 if (successors.isEmpty()) { |
| 538 successors = [block]; | 540 successors = [block]; |
| 539 } else { | 541 } else { |
| 540 successors.add(block); | 542 successors.add(block); |
| 541 } | 543 } |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 } | 936 } |
| 935 | 937 |
| 936 // These methods should be overwritten by instructions that | 938 // These methods should be overwritten by instructions that |
| 937 // participate in global value numbering. | 939 // participate in global value numbering. |
| 938 int typeCode() => -1; | 940 int typeCode() => -1; |
| 939 bool typeEquals(HInstruction other) => false; | 941 bool typeEquals(HInstruction other) => false; |
| 940 bool dataEquals(HInstruction other) => false; | 942 bool dataEquals(HInstruction other) => false; |
| 941 | 943 |
| 942 abstract accept(HVisitor visitor); | 944 abstract accept(HVisitor visitor); |
| 943 | 945 |
| 944 void notifyAddedToBlock(HBasicBlock block) { | 946 void notifyAddedToBlock(HBasicBlock targetBlock) { |
| 945 assert(!isInBasicBlock()); | 947 assert(!isInBasicBlock()); |
| 946 assert(this.block === null); | 948 assert(block === null); |
| 947 // Add [this] to the inputs' uses. | 949 // Add [this] to the inputs' uses. |
| 948 for (int i = 0; i < inputs.length; i++) { | 950 for (int i = 0; i < inputs.length; i++) { |
| 949 assert(inputs[i].isInBasicBlock()); | 951 assert(inputs[i].isInBasicBlock()); |
| 950 inputs[i].usedBy.add(this); | 952 inputs[i].usedBy.add(this); |
| 951 } | 953 } |
| 952 this.block = block; | 954 block = targetBlock; |
| 953 assert(isValid()); | 955 assert(isValid()); |
| 954 } | 956 } |
| 955 | 957 |
| 956 void notifyRemovedFromBlock(HBasicBlock block) { | 958 void notifyRemovedFromBlock() { |
| 957 assert(isInBasicBlock()); | 959 assert(isInBasicBlock()); |
| 958 assert(usedBy.isEmpty()); | 960 assert(usedBy.isEmpty()); |
| 959 assert(this.block === block); | |
| 960 | 961 |
| 961 // Remove [this] from the inputs' uses. | 962 // Remove [this] from the inputs' uses. |
| 962 for (int i = 0; i < inputs.length; i++) { | 963 for (int i = 0; i < inputs.length; i++) { |
| 963 List inputUsedBy = inputs[i].usedBy; | 964 List inputUsedBy = inputs[i].usedBy; |
| 964 for (int j = 0; j < inputUsedBy.length; j++) { | 965 for (int j = 0; j < inputUsedBy.length; j++) { |
| 965 if (inputUsedBy[j] === this) { | 966 if (inputUsedBy[j] === this) { |
| 966 inputUsedBy[j] = inputUsedBy[inputUsedBy.length - 1]; | 967 inputUsedBy[j] = inputUsedBy[inputUsedBy.length - 1]; |
| 967 inputUsedBy.removeLast(); | 968 inputUsedBy.removeLast(); |
| 968 break; | 969 break; |
| 969 } | 970 } |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 class HIfBlockInformation { | 2100 class HIfBlockInformation { |
| 2100 final HIf branch; | 2101 final HIf branch; |
| 2101 final SubGraph thenGraph; | 2102 final SubGraph thenGraph; |
| 2102 final SubGraph elseGraph; | 2103 final SubGraph elseGraph; |
| 2103 final HBasicBlock joinBlock; | 2104 final HBasicBlock joinBlock; |
| 2104 HIfBlockInformation(this.branch, | 2105 HIfBlockInformation(this.branch, |
| 2105 this.thenGraph, | 2106 this.thenGraph, |
| 2106 this.elseGraph, | 2107 this.elseGraph, |
| 2107 this.joinBlock); | 2108 this.joinBlock); |
| 2108 } | 2109 } |
| OLD | NEW |