use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class SPARCSaveRegistersOp method getMap.
@Override
public RegisterSaveLayout getMap(FrameMap frameMap) {
int total = 0;
for (int i = 0; i < savedRegisters.length; i++) {
if (savedRegisters[i] != null) {
total++;
}
}
Register[] keys = new Register[total];
int[] values = new int[total];
if (total != 0) {
int mapIndex = 0;
for (int i = 0; i < savedRegisters.length; i++) {
if (savedRegisters[i] != null) {
keys[mapIndex] = savedRegisters[i];
assert isStackSlot(slots[i]) : "not a StackSlot: " + slots[i];
StackSlot slot = asStackSlot(slots[i]);
values[mapIndex] = indexForStackSlot(frameMap, slot);
mapIndex++;
}
}
assert mapIndex == total;
}
return new RegisterSaveLayout(keys, values);
}
use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class SubstrateReferenceMapBuilder method addLiveValue.
@Override
public void addLiveValue(Value value) {
if (ValueUtil.isStackSlot(value)) {
StackSlot stackSlot = ValueUtil.asStackSlot(value);
int offset = stackSlot.getOffset(totalFrameSize);
assert referenceMap.debugMarkStackSlot(offset, stackSlot);
LIRKind kind = (LIRKind) value.getValueKind();
if (!kind.isValue()) {
if (kind.isUnknownReference()) {
throw JVMCIError.shouldNotReachHere("unknown reference alive across safepoint");
} else if (kind.isDerivedReference()) {
throw JVMCIError.shouldNotReachHere("derived references not supported yet on Substrate VM");
} else {
int bytes = bytesPerElement(kind);
int mapSlotSize = SubstrateReferenceMap.getSlotSizeInBytes();
assert bytes % mapSlotSize == 0;
assert offset % mapSlotSize == 0;
for (int i = 0; i < kind.getPlatformKind().getVectorLength(); i++) {
if (kind.isReference(i)) {
boolean compressed = kind.isCompressedReference(i);
referenceMap.markReferenceAtIndex((offset + i * bytes) / mapSlotSize, compressed);
}
}
}
}
} else if (ValueUtil.isRegister(value)) {
assert referenceMap.debugMarkRegister(ValueUtil.asRegister(value).number, value);
} else {
throw VMError.shouldNotReachHere(value.toString());
}
}
use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class FrameMap method allocateStackSlots.
/**
* Reserves a number of contiguous slots in the frame of the method being compiled. If the
* requested number of slots is 0, this method returns {@code null}.
*
* @param slots the number of slots to reserve
* @param objects specifies the indexes of the object pointer slots. The caller is responsible
* for guaranteeing that each such object pointer slot is initialized before any
* instruction that uses a reference map. Without this guarantee, the garbage
* collector could see garbage object values.
* @return the first reserved stack slot (i.e., at the lowest address)
*/
public StackSlot allocateStackSlots(int slots, BitSet objects) {
assert frameSize == -1 : "frame size must not yet be fixed";
if (slots == 0) {
return null;
}
spillSize += spillSlotRangeSize(slots);
if (!objects.isEmpty()) {
assert objects.length() <= slots;
StackSlot result = null;
for (int slotIndex = 0; slotIndex < slots; slotIndex++) {
StackSlot objectSlot = null;
if (objects.get(slotIndex)) {
objectSlot = allocateNewSpillSlot(LIRKind.reference(getTarget().arch.getWordKind()), slotIndex * getTarget().wordSize);
addObjectStackSlot(objectSlot);
}
if (slotIndex == 0) {
if (objectSlot != null) {
result = objectSlot;
} else {
result = allocateNewSpillSlot(LIRKind.value(getTarget().arch.getWordKind()), 0);
}
}
}
assert result != null;
return result;
} else {
return allocateNewSpillSlot(LIRKind.value(getTarget().arch.getWordKind()), 0);
}
}
use of jdk.vm.ci.code.StackSlot 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 jdk.vm.ci.code.StackSlot in project graal by oracle.
the class SimpleStackSlotAllocator method updateLIR.
@SuppressWarnings("try")
protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) {
DebugContext debug = res.getLIR().getDebug();
try (DebugContext.Scope scope = debug.scope("StackSlotMappingLIR")) {
ValueProcedure updateProc = (value, mode, flags) -> {
if (isVirtualStackSlot(value)) {
StackSlot stackSlot = mapping[asVirtualStackSlot(value).getId()];
debug.log("map %s -> %s", value, stackSlot);
return stackSlot;
}
return value;
};
for (AbstractBlockBase<?> block : res.getLIR().getControlFlowGraph().getBlocks()) {
try (Indent indent0 = debug.logAndIndent("block: %s", block)) {
for (LIRInstruction inst : res.getLIR().getLIRforBlock(block)) {
try (Indent indent1 = debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) {
inst.forEachAlive(updateProc);
inst.forEachInput(updateProc);
inst.forEachOutput(updateProc);
inst.forEachTemp(updateProc);
inst.forEachState(updateProc);
}
}
}
}
}
}
Aggregations