Mercurial > hg > truffle
comparison graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java @ 21338:5010ea46630a
LinearScan: move changeSpillState to LinearScanWalker.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 12 May 2015 14:04:40 +0200 |
parents | 5661a921e123 |
children | 1c56b7be2731 |
comparison
equal
deleted
inserted
replaced
21337:583a64c48dda | 21338:5010ea46630a |
---|---|
37 import com.oracle.graal.debug.*; | 37 import com.oracle.graal.debug.*; |
38 import com.oracle.graal.lir.*; | 38 import com.oracle.graal.lir.*; |
39 import com.oracle.graal.lir.LIRInstruction.OperandFlag; | 39 import com.oracle.graal.lir.LIRInstruction.OperandFlag; |
40 import com.oracle.graal.lir.LIRInstruction.OperandMode; | 40 import com.oracle.graal.lir.LIRInstruction.OperandMode; |
41 import com.oracle.graal.lir.alloc.lsra.Interval.RegisterBinding; | 41 import com.oracle.graal.lir.alloc.lsra.Interval.RegisterBinding; |
42 import com.oracle.graal.lir.alloc.lsra.Interval.SpillState; | |
43 import com.oracle.graal.lir.framemap.*; | 42 import com.oracle.graal.lir.framemap.*; |
44 import com.oracle.graal.lir.gen.*; | 43 import com.oracle.graal.lir.gen.*; |
45 import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; | 44 import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; |
46 import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext; | 45 import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext; |
47 import com.oracle.graal.options.*; | 46 import com.oracle.graal.options.*; |
440 * registers. | 439 * registers. |
441 */ | 440 */ |
442 boolean hasCall(int opId) { | 441 boolean hasCall(int opId) { |
443 assert isEven(opId) : "opId not even"; | 442 assert isEven(opId) : "opId not even"; |
444 return instructionForId(opId).destroysCallerSavedRegisters(); | 443 return instructionForId(opId).destroysCallerSavedRegisters(); |
445 } | |
446 | |
447 // called during register allocation | |
448 void changeSpillState(Interval interval, int spillPos) { | |
449 switch (interval.spillState()) { | |
450 case NoSpillStore: { | |
451 int defLoopDepth = blockForId(interval.spillDefinitionPos()).getLoopDepth(); | |
452 int spillLoopDepth = blockForId(spillPos).getLoopDepth(); | |
453 | |
454 if (defLoopDepth < spillLoopDepth) { | |
455 /* | |
456 * The loop depth of the spilling position is higher then the loop depth at the | |
457 * definition of the interval. Move write to memory out of loop. | |
458 */ | |
459 if (LinearScan.Options.LSRAOptimizeSpillPosition.getValue()) { | |
460 // find best spill position in dominator the tree | |
461 interval.setSpillState(SpillState.SpillInDominator); | |
462 } else { | |
463 // store at definition of the interval | |
464 interval.setSpillState(SpillState.StoreAtDefinition); | |
465 } | |
466 } else { | |
467 /* | |
468 * The interval is currently spilled only once, so for now there is no reason to | |
469 * store the interval at the definition. | |
470 */ | |
471 interval.setSpillState(SpillState.OneSpillStore); | |
472 } | |
473 break; | |
474 } | |
475 | |
476 case OneSpillStore: { | |
477 if (LinearScan.Options.LSRAOptimizeSpillPosition.getValue()) { | |
478 // the interval is spilled more then once | |
479 interval.setSpillState(SpillState.SpillInDominator); | |
480 } else { | |
481 // It is better to store it to memory at the definition. | |
482 interval.setSpillState(SpillState.StoreAtDefinition); | |
483 } | |
484 break; | |
485 } | |
486 | |
487 case SpillInDominator: | |
488 case StoreAtDefinition: | |
489 case StartInMemory: | |
490 case NoOptimization: | |
491 case NoDefinitionFound: | |
492 // nothing to do | |
493 break; | |
494 | |
495 default: | |
496 throw new BailoutException("other states not allowed at this time"); | |
497 } | |
498 } | 444 } |
499 | 445 |
500 abstract static class IntervalPredicate { | 446 abstract static class IntervalPredicate { |
501 | 447 |
502 abstract boolean apply(Interval i); | 448 abstract boolean apply(Interval i); |