src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/SimpleStackSlotAllocator.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/SimpleStackSlotAllocator.java

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/SimpleStackSlotAllocator.java

Print this page

        

*** 27,40 **** import static org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedFramesize; import static org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedSlots; import static org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.virtualFramesize; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; ! import org.graalvm.compiler.debug.Debug; ! import org.graalvm.compiler.debug.Debug.Scope; ! import org.graalvm.compiler.debug.Indent; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.ValueProcedure; import org.graalvm.compiler.lir.VirtualStackSlot; import org.graalvm.compiler.lir.framemap.FrameMapBuilderTool; import org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot; --- 27,39 ---- import static org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedFramesize; import static org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedSlots; import static org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.virtualFramesize; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; ! import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.GraalError; + import org.graalvm.compiler.debug.Indent; import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.ValueProcedure; import org.graalvm.compiler.lir.VirtualStackSlot; import org.graalvm.compiler.lir.framemap.FrameMapBuilderTool; import org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot;
*** 52,99 **** allocateStackSlots((FrameMapBuilderTool) lirGenRes.getFrameMapBuilder(), lirGenRes); lirGenRes.buildFrameMap(); } public void allocateStackSlots(FrameMapBuilderTool builder, LIRGenerationResult res) { StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()]; ! long currentFrameSize = allocatedFramesize.isEnabled() ? builder.getFrameMap().currentFrameSize() : 0; for (VirtualStackSlot virtualSlot : builder.getStackSlots()) { final StackSlot slot; if (virtualSlot instanceof SimpleVirtualStackSlot) { slot = mapSimpleVirtualStackSlot(builder, (SimpleVirtualStackSlot) virtualSlot); ! virtualFramesize.add(builder.getFrameMap().spillSlotSize(virtualSlot.getValueKind())); } else if (virtualSlot instanceof VirtualStackSlotRange) { VirtualStackSlotRange slotRange = (VirtualStackSlotRange) virtualSlot; slot = mapVirtualStackSlotRange(builder, slotRange); ! virtualFramesize.add(builder.getFrameMap().spillSlotRangeSize(slotRange.getSlots())); } else { throw GraalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot); } ! allocatedSlots.increment(); mapping[virtualSlot.getId()] = slot; } updateLIR(res, mapping); ! if (allocatedFramesize.isEnabled()) { ! allocatedFramesize.add(builder.getFrameMap().currentFrameSize() - currentFrameSize); } } @SuppressWarnings("try") protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) { ! try (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); --- 51,101 ---- allocateStackSlots((FrameMapBuilderTool) lirGenRes.getFrameMapBuilder(), lirGenRes); lirGenRes.buildFrameMap(); } 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); } } @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);
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/SimpleStackSlotAllocator.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File