comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2642:8932f1027050

Removed local value map.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 11 May 2011 14:15:14 +0200
parents d1c5a798b73c
children 3b807c0c5eeb
comparison
equal deleted inserted replaced
2641:d1c5a798b73c 2642:8932f1027050
80 80
81 private final IR ir; 81 private final IR ir;
82 private final C1XCompilation compilation; 82 private final C1XCompilation compilation;
83 private final CiStatistics stats; 83 private final CiStatistics stats;
84 84
85 /**
86 * Map used to implement local value numbering for the current block.
87 */
88 private final ValueMap localValueMap;
89
90 private final BytecodeStream stream; // the bytecode stream 85 private final BytecodeStream stream; // the bytecode stream
91 // bci-to-block mapping 86 // bci-to-block mapping
92 private BlockMap blockMap; 87 private BlockMap blockMap;
93 88
94 // the constant pool 89 // the constant pool
126 */ 121 */
127 public GraphBuilder(C1XCompilation compilation, IR ir, Graph graph) { 122 public GraphBuilder(C1XCompilation compilation, IR ir, Graph graph) {
128 this.compilation = compilation; 123 this.compilation = compilation;
129 this.ir = ir; 124 this.ir = ir;
130 this.stats = compilation.stats; 125 this.stats = compilation.stats;
131 this.localValueMap = C1XOptions.OptLocalValueNumbering ? new ValueMap() : null;
132 log = C1XOptions.TraceBytecodeParserLevel > 0 ? new LogStream(TTY.out()) : null; 126 log = C1XOptions.TraceBytecodeParserLevel > 0 ? new LogStream(TTY.out()) : null;
133 stream = new BytecodeStream(compilation.method.code()); 127 stream = new BytecodeStream(compilation.method.code());
134 constantPool = compilation.runtime.getConstantPool(compilation.method); 128 constantPool = compilation.runtime.getConstantPool(compilation.method);
135 this.graph = graph; 129 this.graph = graph;
136 this.frameState = new FrameStateBuilder(compilation.method, graph); 130 this.frameState = new FrameStateBuilder(compilation.method, graph);
963 appendWithoutOptimization(monitorEnter, bci); 957 appendWithoutOptimization(monitorEnter, bci);
964 frameState.lock(ir, x, lockNumber + 1); 958 frameState.lock(ir, x, lockNumber + 1);
965 if (bci == Instruction.SYNCHRONIZATION_ENTRY_BCI) { 959 if (bci == Instruction.SYNCHRONIZATION_ENTRY_BCI) {
966 monitorEnter.setStateAfter(frameState.create(0)); 960 monitorEnter.setStateAfter(frameState.create(0));
967 } 961 }
968 killMemoryMap(); // prevent any optimizations across synchronization
969 } 962 }
970 963
971 void genMonitorExit(Value x, int bci) { 964 void genMonitorExit(Value x, int bci) {
972 int lockNumber = frameState.locksSize() - 1; 965 int lockNumber = frameState.locksSize() - 1;
973 if (lockNumber < 0) { 966 if (lockNumber < 0) {
978 lockAddress = new MonitorAddress(lockNumber, graph); 971 lockAddress = new MonitorAddress(lockNumber, graph);
979 append(lockAddress); 972 append(lockAddress);
980 } 973 }
981 appendWithoutOptimization(new MonitorExit(x, lockAddress, lockNumber, graph), bci); 974 appendWithoutOptimization(new MonitorExit(x, lockAddress, lockNumber, graph), bci);
982 frameState.unlock(); 975 frameState.unlock();
983 killMemoryMap(); // prevent any optimizations across synchronization
984 } 976 }
985 977
986 void genJsr(int dest) { 978 void genJsr(int dest) {
987 throw new CiBailout("jsr/ret not supported"); 979 throw new CiBailout("jsr/ret not supported");
988 } 980 }
1073 private Value appendWithBCI(Instruction x, int bci) { 1065 private Value appendWithBCI(Instruction x, int bci) {
1074 if (x.isAppended()) { 1066 if (x.isAppended()) {
1075 // the instruction has already been added 1067 // the instruction has already been added
1076 return x; 1068 return x;
1077 } 1069 }
1078 if (localValueMap != null) {
1079 // look in the local value map
1080 Value r = localValueMap.findInsert(x);
1081 if (r != x) {
1082 C1XMetrics.LocalValueNumberHits++;
1083 if (r instanceof Instruction) {
1084 assert ((Instruction) r).isAppended() : "instruction " + r + "is not appended";
1085 }
1086 return r;
1087 }
1088 }
1089 1070
1090 assert x.next() == null : "instruction should not have been appended yet"; 1071 assert x.next() == null : "instruction should not have been appended yet";
1091 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")"; 1072 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")";
1092 1073
1093 if (lastInstr instanceof Base) { 1074 if (lastInstr instanceof Base) {
1173 BlockBegin b; 1154 BlockBegin b;
1174 while ((b = removeFromWorkList()) != null) { 1155 while ((b = removeFromWorkList()) != null) {
1175 if (!b.wasVisited()) { 1156 if (!b.wasVisited()) {
1176 b.setWasVisited(true); 1157 b.setWasVisited(true);
1177 // now parse the block 1158 // now parse the block
1178 killMemoryMap();
1179 curBlock = b; 1159 curBlock = b;
1180 frameState.initializeFrom(b.stateBefore()); 1160 frameState.initializeFrom(b.stateBefore());
1181 lastInstr = b; 1161 lastInstr = b;
1182 b.appendNext(null, -1); 1162 b.appendNext(null, -1);
1183 1163
1513 1493
1514 private void genArrayLength() { 1494 private void genArrayLength() {
1515 frameState.ipush(append(new ArrayLength(frameState.apop(), graph))); 1495 frameState.ipush(append(new ArrayLength(frameState.apop(), graph)));
1516 } 1496 }
1517 1497
1518 void killMemoryMap() {
1519 if (localValueMap != null) {
1520 localValueMap.killAll();
1521 }
1522 }
1523
1524 boolean assumeLeafClass(RiType type) { 1498 boolean assumeLeafClass(RiType type) {
1525 if (type.isResolved()) { 1499 if (type.isResolved()) {
1526 if (isFinal(type.accessFlags())) { 1500 if (isFinal(type.accessFlags())) {
1527 return true; 1501 return true;
1528 } 1502 }