comparison graal/GraalCompiler/src/com/sun/c1x/opt/LivenessMarker.java @ 2531:eca17668badf

Remove dead code elimination 1
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 18:17:18 +0200
parents 16b9a8b5ad39
children fa3bda50cbfd
comparison
equal deleted inserted replaced
2530:7e7f817bdb28 2531:eca17668badf
22 */ 22 */
23 package com.sun.c1x.opt; 23 package com.sun.c1x.opt;
24 24
25 import static com.sun.c1x.ir.Value.Flag.*; 25 import static com.sun.c1x.ir.Value.Flag.*;
26 26
27 import com.sun.c1x.*;
28 import com.sun.c1x.graph.*; 27 import com.sun.c1x.graph.*;
29 import com.sun.c1x.ir.*; 28 import com.sun.c1x.ir.*;
30 import com.sun.c1x.value.*; 29 import com.sun.c1x.value.*;
31 30
32 /** 31 /**
75 deoptMarker.markAll(); 74 deoptMarker.markAll();
76 } 75 }
77 76
78 public int liveCount() { 77 public int liveCount() {
79 return count; 78 return count;
80 }
81
82 public void removeDeadCode() {
83 // second pass: remove dead instructions from blocks
84 ir.startBlock.iteratePreOrder(new BlockClosure() {
85 public void apply(BlockBegin block) {
86 Instruction prev = block;
87 Instruction i = block.next();
88 while (i != null) {
89 if (i.isLive()) {
90 prev.resetNext(i); // skip any previous dead instructions
91 prev = i;
92 } else {
93 C1XMetrics.DeadCodeEliminated++;
94 }
95 i = i.next();
96 }
97 }
98 });
99 // clear all marks on all instructions
100 valueMarker.clearAll();
101 deoptMarker.clearAll();
102 } 79 }
103 80
104 private static class Link { 81 private static class Link {
105 final Value value; 82 final Value value;
106 Link next; 83 Link next;