Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java @ 2546:e1b3db8031ee
Removed liveness marking.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 21:54:31 +0200 |
parents | bb050fe2901d |
children | 274360f98f97 |
comparison
equal
deleted
inserted
replaced
2545:bb050fe2901d | 2546:e1b3db8031ee |
---|---|
203 variablesForConstants = new ArrayList<CiVariable>(); | 203 variablesForConstants = new ArrayList<CiVariable>(); |
204 | 204 |
205 this.operands = new OperandPool(compilation.target); | 205 this.operands = new OperandPool(compilation.target); |
206 | 206 |
207 new PhiSimplifier(ir); | 207 new PhiSimplifier(ir); |
208 | |
209 // mark the liveness of all instructions if it hasn't already been done by the optimizer | |
210 LivenessMarker livenessMarker = new LivenessMarker(ir); | |
211 C1XMetrics.LiveHIRInstructions += livenessMarker.liveCount(); | |
212 } | 208 } |
213 | 209 |
214 public ArrayList<DeoptimizationStub> deoptimizationStubs() { | 210 public ArrayList<DeoptimizationStub> deoptimizationStubs() { |
215 return deoptimizationStubs; | 211 return deoptimizationStubs; |
216 } | 212 } |
227 public void doBlock(BlockBegin block) { | 223 public void doBlock(BlockBegin block) { |
228 blockDoProlog(block); | 224 blockDoProlog(block); |
229 this.currentBlock = block; | 225 this.currentBlock = block; |
230 | 226 |
231 for (Instruction instr = block; instr != null; instr = instr.next()) { | 227 for (Instruction instr = block; instr != null; instr = instr.next()) { |
232 if (instr.isLive()) { | 228 if (!(instr instanceof BlockBegin)) { |
233 walkState(instr, instr.stateBefore()); | 229 walkState(instr, instr.stateBefore()); |
234 doRoot(instr); | 230 doRoot(instr); |
235 } | 231 } |
236 } | 232 } |
237 | 233 |
275 // Assign new location to Local instruction for this local | 271 // Assign new location to Local instruction for this local |
276 Value instr = state.localAt(javaIndex); | 272 Value instr = state.localAt(javaIndex); |
277 Local local = ((Local) instr); | 273 Local local = ((Local) instr); |
278 CiKind kind = src.kind.stackKind(); | 274 CiKind kind = src.kind.stackKind(); |
279 assert kind == local.kind.stackKind() : "local type check failed"; | 275 assert kind == local.kind.stackKind() : "local type check failed"; |
280 if (local.isLive()) { | 276 setResult(local, dest); |
281 setResult(local, dest); | |
282 } | |
283 javaIndex += kind.jvmSlots; | 277 javaIndex += kind.jvmSlots; |
284 } | 278 } |
285 } | 279 } |
286 | 280 |
287 @Override | 281 @Override |
363 emitXir(snippet, x, stateFor(x), null, true); | 357 emitXir(snippet, x, stateFor(x), null, true); |
364 } | 358 } |
365 | 359 |
366 @Override | 360 @Override |
367 public void visitConstant(Constant x) { | 361 public void visitConstant(Constant x) { |
368 if (canInlineAsConstant(x)) { | 362 if (!canInlineAsConstant(x)) { |
369 //setResult(x, loadConstant(x)); | |
370 } else { | |
371 CiValue res = x.operand(); | 363 CiValue res = x.operand(); |
372 if (!(res.isLegal())) { | 364 if (!(res.isLegal())) { |
373 res = x.asConstant(); | 365 res = x.asConstant(); |
374 } | 366 } |
375 if (res.isConstant()) { | 367 if (res.isConstant()) { |
376 if (isUsedForValue(x)) { | 368 CiVariable reg = createResultVariable(x); |
377 CiVariable reg = createResultVariable(x); | 369 lir.move(res, reg); |
378 lir.move(res, reg); | |
379 } else { | |
380 assert x.checkFlag(Value.Flag.LiveDeopt); | |
381 x.setOperand(res); | |
382 } | |
383 } else { | 370 } else { |
384 setResult(x, (CiVariable) res); | 371 setResult(x, (CiVariable) res); |
385 } | 372 } |
386 } | 373 } |
387 } | 374 } |
1218 return res.toArray(new SwitchRange[res.size()]); | 1205 return res.toArray(new SwitchRange[res.size()]); |
1219 } | 1206 } |
1220 | 1207 |
1221 void doRoot(Instruction instr) { | 1208 void doRoot(Instruction instr) { |
1222 currentInstruction = instr; | 1209 currentInstruction = instr; |
1223 assert instr.isLive() : "use only with roots"; | |
1224 assert !instr.hasSubst() : "shouldn't have missed substitution"; | 1210 assert !instr.hasSubst() : "shouldn't have missed substitution"; |
1225 | 1211 |
1226 if (C1XOptions.TraceLIRVisit) { | 1212 if (C1XOptions.TraceLIRVisit) { |
1227 TTY.println("Visiting " + instr); | 1213 TTY.println("Visiting " + instr); |
1228 } | 1214 } |
1229 instr.accept(this); | 1215 instr.accept(this); |
1230 if (C1XOptions.TraceLIRVisit) { | 1216 if (C1XOptions.TraceLIRVisit) { |
1231 TTY.println("Operand for " + instr + " = " + instr.operand()); | 1217 TTY.println("Operand for " + instr + " = " + instr.operand()); |
1232 } | 1218 } |
1233 | |
1234 assert (instr.operand().isLegal()) || !isUsedForValue(instr) || instr.isConstant() : "operand was not set for live instruction"; | |
1235 } | |
1236 | |
1237 private boolean isUsedForValue(Instruction instr) { | |
1238 return instr.checkFlag(Value.Flag.LiveValue); | |
1239 } | 1219 } |
1240 | 1220 |
1241 protected void logicOp(int code, CiValue resultOp, CiValue leftOp, CiValue rightOp) { | 1221 protected void logicOp(int code, CiValue resultOp, CiValue leftOp, CiValue rightOp) { |
1242 if (isTwoOperand && leftOp != resultOp) { | 1222 if (isTwoOperand && leftOp != resultOp) { |
1243 assert rightOp != resultOp : "malformed"; | 1223 assert rightOp != resultOp : "malformed"; |
1269 void moveToPhi(PhiResolver resolver, Value curVal, Value suxVal) { | 1249 void moveToPhi(PhiResolver resolver, Value curVal, Value suxVal) { |
1270 // move current value to referenced phi function | 1250 // move current value to referenced phi function |
1271 if (suxVal instanceof Phi) { | 1251 if (suxVal instanceof Phi) { |
1272 Phi phi = (Phi) suxVal; | 1252 Phi phi = (Phi) suxVal; |
1273 // curVal can be null without phi being null in conjunction with inlining | 1253 // curVal can be null without phi being null in conjunction with inlining |
1274 if (phi.isLive() && !phi.isDeadPhi() && curVal != null && curVal != phi) { | 1254 if (!phi.isDeadPhi() && curVal != null && curVal != phi) { |
1275 assert curVal.isLive() : "value not live: " + curVal + ", suxVal=" + suxVal; | |
1276 assert !phi.isIllegal() : "illegal phi cannot be marked as live"; | 1255 assert !phi.isIllegal() : "illegal phi cannot be marked as live"; |
1277 if (curVal instanceof Phi) { | 1256 if (curVal instanceof Phi) { |
1278 operandForPhi((Phi) curVal); | 1257 operandForPhi((Phi) curVal); |
1279 } | 1258 } |
1280 CiValue operand = curVal.operand(); | 1259 CiValue operand = curVal.operand(); |
1363 | 1342 |
1364 protected void preGCWriteBarrier(CiValue addrOpr, boolean patch, LIRDebugInfo info) { | 1343 protected void preGCWriteBarrier(CiValue addrOpr, boolean patch, LIRDebugInfo info) { |
1365 } | 1344 } |
1366 | 1345 |
1367 protected void setNoResult(Instruction x) { | 1346 protected void setNoResult(Instruction x) { |
1368 assert !isUsedForValue(x) : "can't have use"; | |
1369 x.clearOperand(); | 1347 x.clearOperand(); |
1370 } | 1348 } |
1371 | 1349 |
1372 protected CiValue setResult(Value x, CiVariable operand) { | 1350 protected CiValue setResult(Value x, CiVariable operand) { |
1373 x.setOperand(operand); | 1351 x.setOperand(operand); |
1417 IRScope scope = s.scope(); | 1395 IRScope scope = s.scope(); |
1418 if (bci == Instruction.SYNCHRONIZATION_ENTRY_BCI) { | 1396 if (bci == Instruction.SYNCHRONIZATION_ENTRY_BCI) { |
1419 assert x instanceof ExceptionObject || | 1397 assert x instanceof ExceptionObject || |
1420 x instanceof Throw || | 1398 x instanceof Throw || |
1421 x instanceof MonitorEnter || | 1399 x instanceof MonitorEnter || |
1422 x instanceof MonitorExit; | 1400 x instanceof MonitorExit : x + ", " + x.getClass(); |
1423 } | 1401 } |
1424 | 1402 |
1425 for (int index = 0; index < s.localsSize(); index++) { | 1403 for (int index = 0; index < s.localsSize(); index++) { |
1426 final Value value = s.localAt(index); | 1404 final Value value = s.localAt(index); |
1427 if (value != null) { | 1405 if (value != null) { |
1436 } | 1414 } |
1437 | 1415 |
1438 private void walkStateValue(Value value) { | 1416 private void walkStateValue(Value value) { |
1439 if (value != null) { | 1417 if (value != null) { |
1440 assert !value.hasSubst() : "missed substitution"; | 1418 assert !value.hasSubst() : "missed substitution"; |
1441 assert value.isLive() : "value must be marked live in frame state"; | |
1442 if (value instanceof Phi && !value.isIllegal()) { | 1419 if (value instanceof Phi && !value.isIllegal()) { |
1443 // phi's are special | 1420 // phi's are special |
1444 operandForPhi((Phi) value); | 1421 operandForPhi((Phi) value); |
1445 } else if (value.operand().isIllegal()) { | 1422 } else if (value.operand().isIllegal()) { |
1446 // instruction doesn't have an operand yet | 1423 // instruction doesn't have an operand yet |
1511 */ | 1488 */ |
1512 protected CiValue makeOperand(Value instruction) { | 1489 protected CiValue makeOperand(Value instruction) { |
1513 if (instruction == null) { | 1490 if (instruction == null) { |
1514 return CiValue.IllegalValue; | 1491 return CiValue.IllegalValue; |
1515 } | 1492 } |
1516 assert instruction.isLive(); | |
1517 CiValue operand = instruction.operand(); | 1493 CiValue operand = instruction.operand(); |
1518 if (operand.isIllegal()) { | 1494 if (operand.isIllegal()) { |
1519 if (instruction instanceof Phi) { | 1495 if (instruction instanceof Phi) { |
1520 // a phi may not have an operand yet if it is for an exception block | 1496 // a phi may not have an operand yet if it is for an exception block |
1521 operand = operandForPhi((Phi) instruction); | 1497 operand = operandForPhi((Phi) instruction); |