use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.
the class SimpleStackSlotAllocator method allocateStackSlots.
public void allocateStackSlots(FrameMapBuilderTool builder, LIRGenerationResult res) {
DebugContext debug = res.getLIR().getDebug();
StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()];
boolean allocatedFramesizeEnabled = allocatedFramesize.isEnabled(debug);
long currentFrameSize = allocatedFramesizeEnabled ? builder.getFrameMap().currentFrameSize() : 0;
for (VirtualStackSlot virtualSlot : builder.getStackSlots()) {
final StackSlot slot;
if (virtualSlot instanceof SimpleVirtualStackSlot) {
slot = mapSimpleVirtualStackSlot(builder, (SimpleVirtualStackSlot) virtualSlot);
virtualFramesize.add(debug, builder.getFrameMap().spillSlotSize(virtualSlot.getValueKind()));
} else if (virtualSlot instanceof VirtualStackSlotRange) {
VirtualStackSlotRange slotRange = (VirtualStackSlotRange) virtualSlot;
slot = mapVirtualStackSlotRange(builder, slotRange);
virtualFramesize.add(debug, builder.getFrameMap().spillSlotRangeSize(slotRange.getSlots()));
} else {
throw GraalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot);
}
allocatedSlots.increment(debug);
mapping[virtualSlot.getId()] = slot;
}
updateLIR(res, mapping);
if (allocatedFramesizeEnabled) {
allocatedFramesize.add(debug, builder.getFrameMap().currentFrameSize() - currentFrameSize);
}
}
use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.
the class AMD64MoveFactoryBase method createStackMove.
@Override
public final AMD64LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input) {
AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
switch(kind.getSizeInBytes()) {
case 2:
return new AMD64PushPopStackMove(WORD, result, input);
case 8:
return new AMD64PushPopStackMove(QWORD, result, input);
default:
RegisterBackupPair backup = backupSlotProvider.getScratchRegister(input.getPlatformKind());
Register scratchRegister = backup.register;
VirtualStackSlot backupSlot = backup.backupSlot;
return createStackMove(result, input, scratchRegister, backupSlot);
}
}
use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.
the class SSAMoveResolver method breakCycle.
@Override
protected void breakCycle(int spillCandidate) {
if (spillCandidate != -1) {
super.breakCycle(spillCandidate);
return;
}
assert mappingFromSize() > 1;
// Arbitrarily select the first entry for spilling.
int stackSpillCandidate = 0;
Interval fromInterval = getMappingFrom(stackSpillCandidate);
// allocate new stack slot
VirtualStackSlot spillSlot = getAllocator().getFrameMapBuilder().allocateSpillSlot(fromInterval.kind());
spillInterval(stackSpillCandidate, fromInterval, spillSlot);
}
use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.
the class StackValueNode method generate.
@Override
public void generate(NodeLIRBuilderTool gen) {
assert stackSlotHolder != null : "node not processed by StackValuePhase";
assert stackSlotHolder.gen == null || stackSlotHolder.gen == gen : "Same stack slot holder used during multiple compilations, therefore caching a wrong value";
stackSlotHolder.gen = gen;
if (size == 0) {
gen.setResult(this, new ConstantValue(gen.getLIRGeneratorTool().getLIRKind(FrameAccess.getWordStamp()), JavaConstant.forIntegerKind(FrameAccess.getWordKind(), 0)));
} else {
VirtualStackSlot slot = stackSlotHolder.slot;
if (slot == null) {
int wordSize = gen.getLIRGeneratorTool().target().wordSize;
int slots = roundUp(size, wordSize) / wordSize;
slot = gen.getLIRGeneratorTool().getResult().getFrameMapBuilder().allocateStackSlots(slots, new BitSet(0), null);
stackSlotHolder.slot = slot;
}
gen.setResult(this, gen.getLIRGeneratorTool().emitAddress(slot));
}
}
use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.
the class AllocaNode method generate.
@Override
public void generate(NodeLIRBuilderTool gen) {
VirtualStackSlot array = gen.getLIRGeneratorTool().getResult().getFrameMapBuilder().allocateStackSlots(slots, objects, null);
Value result = gen.getLIRGeneratorTool().emitAddress(array);
gen.setResult(this, result);
}
Aggregations