changeset 19089:5b61f60e458f

LSStackSlotAllocator: remove InstructionNumberer.
author Josef Eisl <josef.eisl@jku.at>
date Sat, 31 Jan 2015 14:48:27 +0100
parents fb4344ad6cd2
children d367ad9138f8
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/InstructionNumberer.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java
diffstat 2 files changed, 42 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/InstructionNumberer.java	Sat Jan 31 13:29:49 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.stackslotalloc;
-
-import java.util.*;
-
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.lir.*;
-
-public class InstructionNumberer {
-    private int maxOpId;
-
-    /**
-     * Numbers all instructions in all blocks.
-     */
-    protected void numberInstructions(LIR lir, List<? extends AbstractBlock<?>> sortedBlocks) {
-
-        int opId = 0;
-        int index = 0;
-        for (AbstractBlock<?> block : sortedBlocks) {
-
-            List<LIRInstruction> instructions = lir.getLIRforBlock(block);
-
-            int numInst = instructions.size();
-            for (int j = 0; j < numInst; j++) {
-                LIRInstruction op = instructions.get(j);
-                op.setId(opId);
-
-                index++;
-                opId += 2; // numbering of lirOps by two
-            }
-        }
-        assert (index << 1) == opId : "must match: " + (index << 1);
-        maxOpId = opId - 2;
-        assert maxOpId == maxOpId() : "must match";
-    }
-
-    /**
-     * Gets the highest instruction id allocated by this object.
-     */
-    public int maxOpId() {
-        return maxOpId;
-    }
-}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java	Sat Jan 31 13:29:49 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java	Sat Jan 31 14:48:27 2015 +0100
@@ -62,14 +62,14 @@
         new Allocator(res.getLIR(), builder).allocate();
     }
 
-    private static final class Allocator extends InstructionNumberer {
+    private static final class Allocator {
         private final LIR lir;
         private final FrameMapBuilderTool frameMapBuilder;
         private final StackInterval[] stackSlotMap;
         private final PriorityQueue<StackInterval> unhandled;
         private final PriorityQueue<StackInterval> active;
-
         private final List<? extends AbstractBlock<?>> sortedBlocks;
+        private final int maxOpId;
 
         private Allocator(LIR lir, FrameMapBuilderTool frameMapBuilder) {
             this.lir = lir;
@@ -81,14 +81,12 @@
             this.unhandled = new PriorityQueue<>((a, b) -> a.from() - b.from());
             // insert by to
             this.active = new PriorityQueue<>((a, b) -> a.to() - b.to());
+
+            // number instructions
+            this.maxOpId = numberInstructions(lir, sortedBlocks);
         }
 
         private void allocate() {
-            // create block ordering
-            List<? extends AbstractBlock<?>> blocks = lir.getControlFlowGraph().getBlocks();
-            assert blocks.size() > 0;
-
-            numberInstructions(lir, sortedBlocks);
             Debug.dump(lir, "After StackSlot numbering");
 
             long currentFrameSize = Debug.isMeterEnabled() ? frameMapBuilder.getFrameMap().currentFrameSize() : 0;
@@ -96,6 +94,7 @@
             try (Scope s = Debug.scope("StackSlotAllocationBuildIntervals"); Indent indent = Debug.logAndIndent("BuildIntervals")) {
                 buildIntervals();
             }
+            // verify intervals
             if (Debug.isEnabled()) {
                 verifyIntervals();
             }
@@ -111,7 +110,41 @@
             // assign stack slots
             assignStackSlots();
             Debug.dump(lir, "After StackSlot assignment");
-            StackSlotAllocator.allocatedFramesize.add(frameMapBuilder.getFrameMap().currentFrameSize() - currentFrameSize);
+            if (Debug.isMeterEnabled()) {
+                StackSlotAllocator.allocatedFramesize.add(frameMapBuilder.getFrameMap().currentFrameSize() - currentFrameSize);
+            }
+        }
+
+        /**
+         * Numbers all instructions in all blocks.
+         *
+         * @return The id of the last operation.
+         */
+        private static int numberInstructions(LIR lir, List<? extends AbstractBlock<?>> sortedBlocks) {
+            int opId = 0;
+            int index = 0;
+            for (AbstractBlock<?> block : sortedBlocks) {
+
+                List<LIRInstruction> instructions = lir.getLIRforBlock(block);
+
+                int numInst = instructions.size();
+                for (int j = 0; j < numInst; j++) {
+                    LIRInstruction op = instructions.get(j);
+                    op.setId(opId);
+
+                    index++;
+                    opId += 2; // numbering of lirOps by two
+                }
+            }
+            assert (index << 1) == opId : "must match: " + (index << 1);
+            return opId - 2;
+        }
+
+        /**
+         * Gets the highest instruction id allocated by this object.
+         */
+        private int maxOpId() {
+            return maxOpId;
         }
 
         private void buildIntervals() {
@@ -136,7 +169,7 @@
             }
         }
 
-        public void dumpIntervals(String label) {
+        private void dumpIntervals(String label) {
             Debug.dump(stackSlotMap, label);
         }