annotate graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java @ 15011:c8e575742f36

allow compilation with custom RegisterConfig
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 07 Apr 2014 19:21:22 +0200
parents f3a5036cc13c
children 76c90aa967b1
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 /*
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
25 import com.oracle.graal.api.code.*;
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
26 import com.oracle.graal.api.meta.*;
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
27 import com.oracle.graal.lir.*;
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
28
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
29 /**
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
30 * AMD64 specific frame map.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
31 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
32 * This is the format of an AMD64 stack frame:
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
33 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
34 * <pre>
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
35 * Base Contents
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 * : : -----
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
38 * caller | incoming overflow argument n | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
39 * frame : ... : | positive
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
40 * | incoming overflow argument 0 | | offsets
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
41 * ---------+--------------------------------+---------------------
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
42 * | return address | | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
43 * current +--------------------------------+ | | -----
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
44 * frame | | | | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
45 * : callee save area : | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
46 * | | | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
47 * +--------------------------------+ | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
48 * | spill slot 0 | | negative | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
49 * : ... : v offsets | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
50 * | spill slot n | ----- total frame
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
51 * +--------------------------------+ frame size
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
52 * | alignment padding | size |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
53 * +--------------------------------+ ----- | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
54 * | outgoing overflow argument n | ^ | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
55 * : ... : | positive | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
56 * | outgoing overflow argument 0 | | offsets v v
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
57 * %sp--&gt; +--------------------------------+---------------------------
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
58 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
59 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
60 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
61 * 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
62 * 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
63 * <p>
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
64 * 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
65 * 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
66 * specified offset. Use {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
67 * 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
68 * relative to the stack pointer.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
69 */
11594
3d358ea11300 allow backend to specify spill slot size
Mick Jordan <mick.jordan@oracle.com>
parents: 10958
diff changeset
70 public class AMD64FrameMap extends FrameMap {
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
71
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14906
diff changeset
72 public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14906
diff changeset
73 super(codeCache, registerConfig);
10958
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
74 // (negative) offset relative to sp + total frame size
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
75 initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
76 spillSize = initialSpillSize;
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
77 }
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
78
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
79 @Override
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
80 public int totalFrameSize() {
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
81 return frameSize() + returnAddressSize();
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 currentFrameSize() {
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
86 return alignFrameSize(outgoingSize + spillSize - 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 protected int alignFrameSize(int size) {
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
91 int x = size + returnAddressSize() + (target.stackAlignment - 1);
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
92 return (x / target.stackAlignment) * target.stackAlignment - returnAddressSize();
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
93 }
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
94
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
95 @Override
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
96 public int offsetToCalleeSaveArea() {
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
97 return frameSize() - calleeSaveAreaSize();
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
98 }
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
99
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
100 @Override
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
101 protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) {
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
102 return StackSlot.get(kind, -spillSize + additionalOffset, true);
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
103 }
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
104 }