# HG changeset patch # User Josef Eisl # Date 1421167064 -3600 # Node ID 9236f6bd4aafbf2bcb9c5bd46a5eac40b8ebb66a # Parent 78532f14a3c9ec689de61b97eef0a1b185417c0d StackSlotAllocator: add debug meters diff -r 78532f14a3c9 -r 9236f6bd4aaf graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java Tue Jan 13 17:34:34 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java Tue Jan 13 17:37:44 2015 +0100 @@ -27,6 +27,8 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.lir.gen.*; /** @@ -90,7 +92,9 @@ } public FrameMap buildFrameMap(LIRGenerationResult res, StackSlotAllocator allocator) { - allocator.allocateStackSlots(this, res); + try (Scope s = Debug.scope("StackSlotAllocation")) { + allocator.allocateStackSlots(this, res); + } for (CallingConvention cc : calls) { frameMap.callsMethod(cc); } diff -r 78532f14a3c9 -r 9236f6bd4aaf graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/SimpleStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/SimpleStackSlotAllocator.java Tue Jan 13 17:34:34 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/SimpleStackSlotAllocator.java Tue Jan 13 17:37:44 2015 +0100 @@ -36,18 +36,24 @@ public void allocateStackSlots(FrameMapBuilderTool builder, LIRGenerationResult res) { StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()]; + long currentFrameSize = Debug.isMeterEnabled() ? 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.getLIRKind())); } else if (virtualSlot instanceof VirtualStackSlotRange) { - slot = mapVirtualStackSlotRange(builder, (VirtualStackSlotRange) virtualSlot); + VirtualStackSlotRange slotRange = (VirtualStackSlotRange) virtualSlot; + slot = mapVirtualStackSlotRange(builder, slotRange); + virtualFramesize.add(builder.getFrameMap().spillSlotRangeSize(slotRange.getSlots())); } else { throw GraalInternalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot); } + allocatedSlots.increment(); mapping[virtualSlot.getId()] = slot; } updateLIR(res, mapping); + allocatedFramesize.add(builder.getFrameMap().currentFrameSize() - currentFrameSize); } protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) { diff -r 78532f14a3c9 -r 9236f6bd4aaf graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/StackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/StackSlotAllocator.java Tue Jan 13 17:34:34 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/StackSlotAllocator.java Tue Jan 13 17:37:44 2015 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.lir.framemap; import com.oracle.graal.api.code.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.gen.*; /** @@ -31,5 +32,21 @@ * {@link VirtualStackSlot} in the {@link LIRGenerationResult#getLIR() LIR} to {@link StackSlot}. */ public interface StackSlotAllocator { + /** + * The number of allocated stack slots. + */ + static final DebugMetric allocatedSlots = Debug.metric("StackSlotAllocator[allocatedSlots]"); + /** + * The number of reused stack slots. + */ + static final DebugMetric reusedSlots = Debug.metric("StackSlotAllocator[reusedSlots]"); + /** + * The size (in bytes) required for all allocated stack slots. Note that this number + * corresponds to the actual frame size and might include alignment. + */ + static final DebugMetric allocatedFramesize = Debug.metric("StackSlotAllocator[AllocatedFramesize]"); + /** The size (in bytes) required for all virtual stack slots. */ + static final DebugMetric virtualFramesize = Debug.metric("StackSlotAllocator[VirtualFramesize]"); + void allocateStackSlots(FrameMapBuilderTool builder, LIRGenerationResult res); }