# HG changeset patch # User Josef Eisl # Date 1417635297 -3600 # Node ID 252067cb86ad237d88f1d12826a06b81d20d0639 # Parent 312cf5a0376e59ade297763d703c776a26c2b77f Remove FrameMappingTool. diff -r 312cf5a0376e -r 252067cb86ad 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 Wed Dec 03 20:21:24 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java Wed Dec 03 20:34:57 2014 +0100 @@ -22,17 +22,11 @@ */ 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.*; /** @@ -96,35 +90,10 @@ } public FrameMap buildFrameMap(LIRGenerationResult res) { - FrameMappingTool mapper = new SimpleStackSlotAllocator().allocateStackSlots(this); + new SimpleStackSlotAllocator().allocateStackSlots(this, res); for (CallingConvention cc : calls) { frameMap.callsMethod(cc); } - // 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; } diff -r 312cf5a0376e -r 252067cb86ad graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMappingTool.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMappingTool.java Wed Dec 03 20:21:24 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +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; - -import com.oracle.graal.api.code.*; - -/** - * A tool to get the real stack slot from a virtual stack slot. - */ -@FunctionalInterface -public interface FrameMappingTool { - StackSlot getStackSlot(VirtualStackSlot slot); -} diff -r 312cf5a0376e -r 252067cb86ad 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 Wed Dec 03 20:21:24 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/SimpleStackSlotAllocator.java Wed Dec 03 20:34:57 2014 +0100 @@ -22,12 +22,19 @@ */ package com.oracle.graal.lir.framemap; +import static com.oracle.graal.api.code.ValueUtil.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.gen.*; public class SimpleStackSlotAllocator implements StackSlotAllocator { - public FrameMappingTool allocateStackSlots(FrameMapBuilderImpl builder) { + public void allocateStackSlots(FrameMapBuilderImpl builder, LIRGenerationResult res) { StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()]; for (VirtualStackSlot virtualSlot : builder.getStackSlots()) { final StackSlot slot; @@ -40,7 +47,33 @@ } mapping[virtualSlot.getId()] = slot; } - return v -> mapping[v.getId()]; + updateLIR(res, mapping); + } + + 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 (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); + } + } + } + } + } } protected StackSlot mapSimpleVirtualStackSlot(FrameMapBuilderImpl builder, SimpleVirtualStackSlot virtualStackSlot) { diff -r 312cf5a0376e -r 252067cb86ad 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 Wed Dec 03 20:21:24 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/StackSlotAllocator.java Wed Dec 03 20:34:57 2014 +0100 @@ -23,11 +23,13 @@ package com.oracle.graal.lir.framemap; import com.oracle.graal.api.code.*; +import com.oracle.graal.lir.gen.*; /** * A {@link StackSlotAllocator} is responsible for translating {@link VirtualStackSlot virtual} - * stack slots into {@link StackSlot real} stack slots. + * stack slots into {@link StackSlot real} stack slots. This includes changing all occurrences of + * {@link VirtualStackSlot} in the {@link LIRGenerationResult#getLIR() LIR} to {@link StackSlot}. */ public interface StackSlotAllocator { - FrameMappingTool allocateStackSlots(FrameMapBuilderImpl builder); + void allocateStackSlots(FrameMapBuilderImpl builder, LIRGenerationResult res); }