changeset 19020:312cf5a0376e

Remove FrameMapBuilder.requireMapping() (only LIR needs to be updated).
author Josef Eisl <josef.eisl@jku.at>
date Wed, 03 Dec 2014 20:21:24 +0100
parents 56e6b5756886
children 252067cb86ad
files graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilder.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMappable.java
diffstat 7 files changed, 31 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Wed Dec 03 21:39:15 2014 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Wed Dec 03 20:21:24 2014 +0100
@@ -129,7 +129,6 @@
 
             RegisterConfig registerConfig = null;
             FrameMapBuilder frameMapBuilder = backend.newFrameMapBuilder(registerConfig);
-            frameMapBuilder.requireMapping(lir);
             TargetDescription target = backend.getTarget();
             CallingConvention cc = CodeUtil.getCallingConvention(backend.getProviders().getCodeCache(), CallingConvention.Type.JavaCallee, method, false);
             this.lirGenRes = backend.newLIRGenerationResult(lir, frameMapBuilder, method, null);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Dec 03 21:39:15 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Dec 03 20:21:24 2014 +0100
@@ -323,7 +323,6 @@
         }
         try (Scope ds = Debug.scope("BackEnd", lir)) {
             FrameMapBuilder frameMapBuilder = backend.newFrameMapBuilder(registerConfig);
-            frameMapBuilder.requireMapping(lir);
             LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, frameMapBuilder, graph.method(), stub);
             LIRGeneratorTool lirGen = backend.newLIRGenerator(cc, lirGenRes);
             NodeLIRBuilderTool nodeLirGen = backend.newNodeLIRBuilder(graph, lirGen);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Wed Dec 03 21:39:15 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Wed Dec 03 20:21:24 2014 +0100
@@ -1749,31 +1749,6 @@
         }
     }
 
-    private class Mapper implements FrameMappable {
-
-        public void map(FrameMappingTool tool) {
-            try (Scope scope = Debug.scope("StackSlotMappingLSRA")) {
-                for (Interval current : intervals) {
-                    if (current != null) {
-                        if (isVirtualStackSlot(current.location())) {
-                            VirtualStackSlot value = asVirtualStackSlot(current.location());
-                            StackSlot stackSlot = tool.getStackSlot(value);
-                            Debug.log("map %s -> %s", value, stackSlot);
-                            current.assignLocation(stackSlot);
-                        }
-                        if (current.isSplitParent() && current.spillSlot() != null && isVirtualStackSlot(current.spillSlot())) {
-                            VirtualStackSlot value = asVirtualStackSlot(current.spillSlot());
-                            StackSlot stackSlot = tool.getStackSlot(value);
-                            Debug.log("map %s -> %s", value, stackSlot);
-                            current.setSpillSlot(stackSlot);
-                        }
-                    }
-                }
-            }
-        }
-
-    }
-
     public static void allocate(TargetDescription target, LIRGenerationResult res) {
         new LinearScan(target, res).allocate();
     }
@@ -1821,9 +1796,6 @@
                 printIntervals("After register allocation");
                 printLir("After register allocation", true);
 
-                // register interval mapper
-                frameMapBuilder.requireMapping(new Mapper());
-
                 sortIntervalsAfterAllocation();
 
                 if (DetailedAsserts.getValue()) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java	Wed Dec 03 21:39:15 2014 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java	Wed Dec 03 20:21:24 2014 +0100
@@ -22,24 +22,18 @@
  */
 package com.oracle.graal.lir;
 
-import static com.oracle.graal.api.code.ValueUtil.*;
-
 import java.util.*;
 
-import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.lir.StandardOp.BlockEndOp;
 import com.oracle.graal.lir.StandardOp.LabelOp;
-import com.oracle.graal.lir.framemap.*;
 
 /**
  * This class implements the overall container for the LIR graph and directs its construction,
  * optimization, and finalization.
  */
-public class LIR implements FrameMappable {
+public class LIR {
 
     private final AbstractControlFlowGraph<?> cfg;
 
@@ -226,30 +220,4 @@
         }
     }
 
-    public void map(FrameMappingTool tool) {
-        try (Scope scope = Debug.scope("StackSlotMappingLIR")) {
-            ValueProcedure updateProc = (value, mode, flags) -> {
-                if (isVirtualStackSlot(value)) {
-                    StackSlot stackSlot = tool.getStackSlot(asVirtualStackSlot(value));
-                    Debug.log("map %s -> %s", value, stackSlot);
-                    return stackSlot;
-                }
-                return value;
-            };
-            for (AbstractBlock<?> block : getControlFlowGraph().getBlocks()) {
-                try (Indent indent0 = Debug.logAndIndent("block: %s", block)) {
-                    for (LIRInstruction inst : 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);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilder.java	Wed Dec 03 21:39:15 2014 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilder.java	Wed Dec 03 20:21:24 2014 +0100
@@ -72,12 +72,6 @@
     void callsMethod(CallingConvention cc);
 
     /**
-     * Registers a FrameMappable class so that virtual stack slots can be changed to real stack
-     * slots.
-     */
-    void requireMapping(FrameMappable mappable);
-
-    /**
      * Creates a {@linkplain FrameMap} based on the information collected by this
      * {@linkplain FrameMapBuilder}.
      */
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java	Wed Dec 03 21:39:15 2014 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java	Wed Dec 03 20:21:24 2014 +0100
@@ -22,11 +22,17 @@
  */
 package com.oracle.graal.lir.framemap;
 
+import static com.oracle.graal.api.code.ValueUtil.*;
+
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.*;
+import com.oracle.graal.compiler.common.cfg.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.Debug.Scope;
+import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.gen.*;
 
 /**
@@ -48,12 +54,9 @@
         this.frameMap = frameMap;
         this.stackSlots = new ArrayList<>();
         this.calls = new ArrayList<>();
-        this.mappables = new ArrayList<>();
         this.numStackSlots = 0;
     }
 
-    private final List<FrameMappable> mappables;
-
     public VirtualStackSlot allocateSpillSlot(LIRKind kind) {
         SimpleVirtualStackSlot slot = new SimpleVirtualStackSlot(numStackSlots++, kind);
         stackSlots.add(slot);
@@ -97,17 +100,35 @@
         for (CallingConvention cc : calls) {
             frameMap.callsMethod(cc);
         }
-        // rewrite
-        mappables.forEach(m -> m.map(mapper));
+        // update LIR
+        try (Scope scope = Debug.scope("StackSlotMappingLIR")) {
+            ValueProcedure updateProc = (value, mode, flags) -> {
+                if (isVirtualStackSlot(value)) {
+                    StackSlot stackSlot = mapper.getStackSlot(asVirtualStackSlot(value));
+                    Debug.log("map %s -> %s", value, stackSlot);
+                    return stackSlot;
+                }
+                return value;
+            };
+            for (AbstractBlock<?> 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);
+                        }
+                    }
+                }
+            }
+        }
 
         frameMap.finish();
         return frameMap;
     }
 
-    public void requireMapping(FrameMappable mappable) {
-        this.mappables.add(mappable);
-    }
-
     List<VirtualStackSlot> getStackSlots() {
         return stackSlots;
     }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMappable.java	Wed Dec 03 21:39:15 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2014, 2014, 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.framemap;
-
-/**
- * This interface should be implemented by all classes that store virtual stack slots to convert
- * them into real stack slots when {@link FrameMapBuilder#buildFrameMap} is called. Implementors
- * should register themselves using {@link FrameMapBuilder#requireMapping(FrameMappable)}.
- */
-public interface FrameMappable {
-    void map(FrameMappingTool tool);
-}