001/* 002 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.lir.framemap; 024 025import java.util.*; 026 027import jdk.internal.jvmci.code.*; 028import jdk.internal.jvmci.meta.*; 029 030import com.oracle.graal.lir.gen.*; 031import com.oracle.graal.lir.stackslotalloc.*; 032 033/** 034 * A {@link FrameMapBuilder} is used to collect all information necessary to 035 * {@linkplain #buildFrameMap create} a {@link FrameMap}. 036 */ 037public interface FrameMapBuilder { 038 039 /** 040 * Reserves a spill slot in the frame of the method being compiled. The returned slot is aligned 041 * on its natural alignment, i.e., an 8-byte spill slot is aligned at an 8-byte boundary, unless 042 * overridden by a subclass. 043 * 044 * @param kind The kind of the spill slot to be reserved. 045 * @return A spill slot denoting the reserved memory area. 046 */ 047 VirtualStackSlot allocateSpillSlot(LIRKind kind); 048 049 /** 050 * Reserves a number of contiguous slots in the frame of the method being compiled. If the 051 * requested number of slots is 0, this method returns {@code null}. 052 * 053 * @param slots the number of slots to reserve 054 * @param objects specifies the indexes of the object pointer slots. The caller is responsible 055 * for guaranteeing that each such object pointer slot is initialized before any 056 * instruction that uses a reference map. Without this guarantee, the garbage 057 * collector could see garbage object values. 058 * @param outObjectStackSlots if non-null, the object pointer slots allocated are added to this 059 * list 060 * @return the first reserved stack slot (i.e., at the lowest address) 061 */ 062 VirtualStackSlot allocateStackSlots(int slots, BitSet objects, List<VirtualStackSlot> outObjectStackSlots); 063 064 RegisterConfig getRegisterConfig(); 065 066 CodeCacheProvider getCodeCache(); 067 068 /** 069 * Informs the frame map that the compiled code calls a particular method, which may need stack 070 * space for outgoing arguments. 071 * 072 * @param cc The calling convention for the called method. 073 */ 074 void callsMethod(CallingConvention cc); 075 076 /** 077 * Creates a {@linkplain FrameMap} based on the information collected by this 078 * {@linkplain FrameMapBuilder}. 079 */ 080 FrameMap buildFrameMap(LIRGenerationResult result, StackSlotAllocator allocator); 081}