annotate graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java @ 18443:1c92d437179b

FrameMapBuilder: move into package.
author Josef Eisl <josef.eisl@jku.at>
date Mon, 17 Nov 2014 16:41:44 +0100
parents 06624c98ed8b
children cdff1577017c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
1 /*
15124
76c90aa967b1 use NumUtil.roundUp in AMD64FrameMap.alignFrameSize(int)
twisti
parents: 15011
diff changeset
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
4 *
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
7 * published by the Free Software Foundation.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
8 *
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
13 * accompanied this code).
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
14 *
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
18 *
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
21 * questions.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
22 */
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
23 package com.oracle.graal.lir.amd64;
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
24
18434
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
25 import static com.oracle.graal.api.code.ValueUtil.*;
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
26
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
27 import com.oracle.graal.api.code.*;
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
28 import com.oracle.graal.api.meta.*;
15124
76c90aa967b1 use NumUtil.roundUp in AMD64FrameMap.alignFrameSize(int)
twisti
parents: 15011
diff changeset
29 import com.oracle.graal.asm.*;
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 18434
diff changeset
30 import com.oracle.graal.lir.framemap.*;
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
31
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
32 /**
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
33 * AMD64 specific frame map.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
34 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
35 * This is the format of an AMD64 stack frame:
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
36 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
37 * <pre>
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
38 * Base Contents
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 18434
diff changeset
39 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
40 * : : -----
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
41 * caller | incoming overflow argument n | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
42 * frame : ... : | positive
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
43 * | incoming overflow argument 0 | | offsets
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
44 * ---------+--------------------------------+---------------------
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
45 * | return address | | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
46 * current +--------------------------------+ | | -----
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
47 * frame | | | | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
48 * : callee save area : | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
49 * | | | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
50 * +--------------------------------+ | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
51 * | spill slot 0 | | negative | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
52 * : ... : v offsets | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
53 * | spill slot n | ----- total frame
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
54 * +--------------------------------+ frame size
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
55 * | alignment padding | size |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
56 * +--------------------------------+ ----- | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
57 * | outgoing overflow argument n | ^ | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
58 * : ... : | positive | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
59 * | outgoing overflow argument 0 | | offsets v v
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
60 * %sp--&gt; +--------------------------------+---------------------------
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
61 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
62 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
63 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
64 * The spill slot area also includes stack allocated memory blocks (ALLOCA blocks). The size of such
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
65 * a block may be greater than the size of a normal spill slot or the word size.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
66 * <p>
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
67 * A runtime can reserve space at the beginning of the overflow argument area. The calling
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
68 * convention can specify that the first overflow stack argument is not at offset 0, but at a
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
69 * specified offset. Use {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
70 * call-free methods also have this space reserved. Then the VM can use the memory at offset 0
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
71 * relative to the stack pointer.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
72 */
11594
3d358ea11300 allow backend to specify spill slot size
Mick Jordan <mick.jordan@oracle.com>
parents: 10958
diff changeset
73 public class AMD64FrameMap extends FrameMap {
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
74
18434
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
75 private StackSlot rbpSpillSlot;
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
76
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14906
diff changeset
77 public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14906
diff changeset
78 super(codeCache, registerConfig);
10958
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
79 // (negative) offset relative to sp + total frame size
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
80 initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
81 spillSize = initialSpillSize;
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
82 }
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
83
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
84 @Override
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
85 public int totalFrameSize() {
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
86 return frameSize() + returnAddressSize();
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
87 }
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
88
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
89 @Override
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
90 public int currentFrameSize() {
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
91 return alignFrameSize(outgoingSize + spillSize - returnAddressSize());
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
92 }
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
93
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
94 @Override
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
95 protected int alignFrameSize(int size) {
18123
3c7e73362d6a Encapsulate FrameMap.registerConfig & FrameMap.target.
Josef Eisl <josef.eisl@jku.at>
parents: 16094
diff changeset
96 return NumUtil.roundUp(size + returnAddressSize(), getTarget().stackAlignment) - returnAddressSize();
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
97 }
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
98
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
99 @Override
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
100 public int offsetToCalleeSaveArea() {
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
101 return frameSize() - calleeSaveAreaSize();
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
102 }
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
103
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
104 @Override
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15124
diff changeset
105 protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
106 return StackSlot.get(kind, -spillSize + additionalOffset, true);
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
107 }
18434
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
108
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
109 /**
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
110 * For non-leaf methods, RBP is preserved in the special stack slot required by the HotSpot
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
111 * runtime for walking/inspecting frames of such methods.
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
112 */
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
113 StackSlot allocateRBPSpillSlot() {
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
114 assert spillSize == initialSpillSize : "RBP spill slot can only be allocated before getting other stack slots";
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
115 int size = spillSlotSize(LIRKind.value(Kind.Long));
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
116 spillSize = NumUtil.roundUp(spillSize + size, size);
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
117 rbpSpillSlot = allocateNewSpillSlot(LIRKind.value(Kind.Long), 0);
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
118 assert asStackSlot(rbpSpillSlot).getRawOffset() == -16 : asStackSlot(rbpSpillSlot).getRawOffset();
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
119 return rbpSpillSlot;
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
120 }
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
121
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
122 void freeRBPSpillSlot() {
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
123 int size = spillSlotSize(LIRKind.value(Kind.Long));
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
124 assert spillSize == NumUtil.roundUp(initialSpillSize + size, size) : "RBP spill slot can not be freed after allocation other stack slots";
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
125 spillSize = initialSpillSize;
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
126 }
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
127
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
128 public StackSlot allocateDeoptimizationRescueSlot() {
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
129 int size = spillSlotSize(LIRKind.value(Kind.Long));
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
130 spillSize = NumUtil.roundUp(spillSize + size, size);
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
131 return allocateNewSpillSlot(LIRKind.value(Kind.Long), 0);
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
132 }
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
133 }