AArch64FrameMap.java revision 12651:6ef01bd40ce2
1/* 2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23package org.graalvm.compiler.lir.aarch64; 24 25import org.graalvm.compiler.core.common.LIRKind; 26import org.graalvm.compiler.lir.framemap.FrameMap; 27 28import jdk.vm.ci.aarch64.AArch64Kind; 29import jdk.vm.ci.code.CodeCacheProvider; 30import jdk.vm.ci.code.RegisterConfig; 31import jdk.vm.ci.code.StackSlot; 32 33/** 34 * AArch64 specific frame map. 35 * <p/> 36 * This is the format of an AArch64 stack frame: 37 * <p/> 38 * 39 * <pre> 40 * Base Contents 41 * 42 * : : ----- 43 * caller | incoming overflow argument n | ^ 44 * frame : ... : | positive 45 * | incoming overflow argument 0 | | offsets 46 * ---------+--------------------------------+------------------------- 47 * | return address | | ^ 48 * | prev. frame pointer | | | 49 * +--------------------------------+ | | 50 * | spill slot 0 | | negative | ^ 51 * callee : ... : v offsets | | 52 * frame | spill slot n | ----- total frame 53 * +--------------------------------+ frame size 54 * | alignment padding | size | 55 * +--------------------------------+ ----- | | 56 * | outgoing overflow argument n | ^ | | 57 * : ... : | positive | | 58 * | outgoing overflow argument 0 | | offsets v v 59 * %sp--> +--------------------------------+--------------------------- 60 * 61 * </pre> 62 * 63 * The spill slot area also includes stack allocated memory blocks (ALLOCA blocks). The size of such 64 * a block may be greater than the size of a normal spill slot or the word size. 65 * <p/> 66 * A runtime can reserve space at the beginning of the overflow argument area. The calling 67 * convention can specify that the first overflow stack argument is not at offset 0, but at a 68 * specified offset. Use {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that 69 * call-free methods also have this space reserved. Then the VM can use the memory at offset 0 70 * relative to the stack pointer. 71 * <p/> 72 */ 73public class AArch64FrameMap extends FrameMap { 74 // Note: Spill size includes callee save area 75 76 /** 77 * Creates a new frame map for the specified method. 78 */ 79 public AArch64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig, ReferenceMapBuilderFactory referenceMapFactory) { 80 super(codeCache, registerConfig, referenceMapFactory); 81 initialSpillSize = frameSetupSize(); 82 spillSize = initialSpillSize; 83 } 84 85 @Override 86 public int totalFrameSize() { 87 // frameSize + return address + frame pointer 88 return frameSize() + frameSetupSize(); 89 } 90 91 private int frameSetupSize() { 92 // Size of return address and frame pointer that are saved in function prologue 93 return getTarget().arch.getWordSize() * 2; 94 } 95 96 @Override 97 public int currentFrameSize() { 98 return alignFrameSize(outgoingSize + spillSize); 99 } 100 101 public StackSlot allocateDeoptimizationRescueSlot() { 102 assert spillSize == initialSpillSize : "Deoptimization rescue slot must be the first stack slot"; 103 return allocateSpillSlot(LIRKind.value(AArch64Kind.QWORD)); 104 } 105} 106