Mercurial > hg > truffle
changeset 18147:67a5f283487a
Introduce FrameMapBuilder.
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue Oct 21 14:56:52 2014 +0200 @@ -214,7 +214,7 @@ // - has no deoptimization points // - makes no foreign calls (which require an aligned stack) AMD64HotSpotLIRGenerationResult gen = (AMD64HotSpotLIRGenerationResult) lirGenRen; - FrameMap frameMap = gen.getFrameMap(); + FrameMap frameMap = (FrameMap) gen.getFrameMap(); LIR lir = gen.getLIR(); assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame"; boolean omitFrame = CanOmitFrame.getValue() && !frameMap.frameNeedsAllocating() && !lir.hasArgInCallerFrame() && !gen.hasForeignCall();
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Tue Oct 21 14:56:52 2014 +0200 @@ -468,7 +468,7 @@ @Override public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { - FrameMap frameMap = lirGenRes.getFrameMap(); + FrameMap frameMap = (FrameMap) lirGenRes.getFrameMap(); Assembler masm = createAssembler(frameMap); HotSpotFrameContext frameContext = new HotSpotFrameContext(); // save lirGen for later use by setHostGraph
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Tue Oct 21 14:56:52 2014 +0200 @@ -335,7 +335,7 @@ // - has no callee-saved registers // - has no incoming arguments passed on the stack // - has no instructions with debug info - FrameMap frameMap = lirGenRes.getFrameMap(); + FrameMap frameMap = (FrameMap) lirGenRes.getFrameMap(); Assembler masm = createAssembler(frameMap); PTXFrameContext frameContext = new PTXFrameContext(); CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Tue Oct 21 14:56:52 2014 +0200 @@ -181,7 +181,7 @@ @Override public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { SPARCHotSpotLIRGenerationResult gen = (SPARCHotSpotLIRGenerationResult) lirGenRes; - FrameMap frameMap = gen.getFrameMap(); + FrameMap frameMap = (FrameMap) gen.getFrameMap(); LIR lir = gen.getLIR(); assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLockStack.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLockStack.java Tue Oct 21 14:56:52 2014 +0200 @@ -35,11 +35,11 @@ public class HotSpotLockStack { private StackSlot[] locks; - private final FrameMap frameMap; + private final FrameMapBuilder frameMapBuilder; private final LIRKind slotKind; - public HotSpotLockStack(FrameMap frameMap, LIRKind slotKind) { - this.frameMap = frameMap; + public HotSpotLockStack(FrameMapBuilder frameMapBuilder, LIRKind slotKind) { + this.frameMapBuilder = frameMapBuilder; this.slotKind = slotKind; } @@ -53,7 +53,7 @@ locks = Arrays.copyOf(locks, lockDepth + 1); } if (locks[lockDepth] == null) { - locks[lockDepth] = frameMap.allocateSpillSlot(slotKind); + locks[lockDepth] = frameMapBuilder.allocateSpillSlot(slotKind); } return locks[lockDepth]; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Tue Oct 21 14:56:52 2014 +0200 @@ -38,7 +38,7 @@ * stack pointer, while spill slots are indexed from the beginning of the frame (and the total frame * size has to be added to get the actual offset from the stack pointer). */ -public abstract class FrameMap { +public abstract class FrameMap implements FrameMapBuilder { private final TargetDescription target; private final RegisterConfig registerConfig;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMapBuilder.java Tue Oct 21 14:56:52 2014 +0200 @@ -0,0 +1,79 @@ +/* + * 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; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; + +public interface FrameMapBuilder { + + /** + * Computes the final size of this frame. After this method has been called, methods that change + * the frame size cannot be called anymore, e.g., no more spill slots or outgoing arguments can + * be requested. + */ + void finish(); + + /** + * Reserves a spill slot in the frame of the method being compiled. The returned slot is aligned + * on its natural alignment, i.e., an 8-byte spill slot is aligned at an 8-byte boundary, unless + * overridden by a subclass. + * + * @param kind The kind of the spill slot to be reserved. + * @return A spill slot denoting the reserved memory area. + */ + StackSlot allocateSpillSlot(LIRKind kind); + + /** + * Reserves a number of contiguous slots in the frame of the method being compiled. If the + * requested number of slots is 0, this method returns {@code null}. + * + * @param slots the number of slots to reserve + * @param objects specifies the indexes of the object pointer slots. The caller is responsible + * for guaranteeing that each such object pointer slot is initialized before any + * instruction that uses a reference map. Without this guarantee, the garbage + * collector could see garbage object values. + * @param outObjectStackSlots if non-null, the object pointer slots allocated are added to this + * list + * @return the first reserved stack slot (i.e., at the lowest address) + */ + StackSlot allocateStackSlots(int slots, BitSet objects, List<StackSlot> outObjectStackSlots); + + RegisterConfig getRegisterConfig(); + + /** + * Frees a spill slot that was obtained via {@link #allocateSpillSlot(LIRKind)} such that it can + * be reused for the next allocation request for the same kind of slot. + */ + void freeSpillSlot(StackSlot slot); + + /** + * Informs the frame map that the compiled code calls a particular method, which may need stack + * space for outgoing arguments. + * + * @param cc The calling convention for the called method. + */ + void callsMethod(CallingConvention cc); +} \ No newline at end of file
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerationResult.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerationResult.java Tue Oct 21 14:56:52 2014 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.lir.*; public interface LIRGenerationResult { - FrameMap getFrameMap(); + FrameMapBuilder getFrameMap(); LIR getLIR();
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerationResultBase.java Wed Oct 22 14:50:09 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerationResultBase.java Tue Oct 21 14:56:52 2014 +0200 @@ -52,7 +52,7 @@ this.hasForeignCall = hasForeignCall; } - public final FrameMap getFrameMap() { + public final FrameMapBuilder getFrameMap() { return frameMap; }