| Index: frog/leg/ssa/types.dart
|
| ===================================================================
|
| --- frog/leg/ssa/types.dart (revision 5925)
|
| +++ frog/leg/ssa/types.dart (working copy)
|
| @@ -1,66 +0,0 @@
|
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| -// for details. All rights reserved. Use of this source code is governed by a
|
| -// BSD-style license that can be found in the LICENSE file.
|
| -
|
| -class SsaTypePropagator extends HGraphVisitor implements OptimizationPhase {
|
| -
|
| - final Map<int, HInstruction> workmap;
|
| - final List<int> worklist;
|
| - final Compiler compiler;
|
| - final String name = 'type propagator';
|
| -
|
| - SsaTypePropagator(Compiler this.compiler)
|
| - : workmap = new Map<int, HInstruction>(),
|
| - worklist = new List<int>();
|
| -
|
| - void visitGraph(HGraph graph) {
|
| - visitDominatorTree(graph);
|
| - processWorklist();
|
| - }
|
| -
|
| - visitBasicBlock(HBasicBlock block) {
|
| - if (block.isLoopHeader()) {
|
| - block.forEachPhi((HPhi phi) {
|
| - phi.setInitialTypeForLoopPhi();
|
| - addToWorkList(phi);
|
| - });
|
| - } else {
|
| - block.forEachPhi((HPhi phi) {
|
| - if (phi.updateType()) addUsersAndInputsToWorklist(phi);
|
| - });
|
| - }
|
| -
|
| - HInstruction instruction = block.first;
|
| - while (instruction !== null) {
|
| - if (instruction.updateType()) addUsersAndInputsToWorklist(instruction);
|
| - instruction = instruction.next;
|
| - }
|
| - }
|
| -
|
| - void processWorklist() {
|
| - while (!worklist.isEmpty()) {
|
| - int id = worklist.removeLast();
|
| - HInstruction instruction = workmap[id];
|
| - assert(instruction !== null);
|
| - workmap.remove(id);
|
| - if (instruction.updateType()) addUsersAndInputsToWorklist(instruction);
|
| - }
|
| - }
|
| -
|
| - void addUsersAndInputsToWorklist(HInstruction instruction) {
|
| - for (int i = 0, length = instruction.usedBy.length; i < length; i++) {
|
| - addToWorkList(instruction.usedBy[i]);
|
| - }
|
| - for (int i = 0, length = instruction.inputs.length; i < length; i++) {
|
| - addToWorkList(instruction.inputs[i]);
|
| - }
|
| - }
|
| -
|
| - void addToWorkList(HInstruction instruction) {
|
| - final int id = instruction.id;
|
| - if (!workmap.containsKey(id)) {
|
| - worklist.add(id);
|
| - workmap[id] = instruction;
|
| - }
|
| - }
|
| -}
|
|
|