changeset 19027:9236f6bd4aaf

StackSlotAllocator: add debug meters
author Josef Eisl <josef.eisl@jku.at>
date Tue, 13 Jan 2015 17:37:44 +0100
parents 78532f14a3c9
children f59fc4850df5
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/SimpleStackSlotAllocator.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/StackSlotAllocator.java
diffstat 3 files changed, 29 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);
         }
--- 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) {
--- 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);
 }