annotate graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java @ 21720:d915361cc3a1

moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Thu, 04 Jun 2015 13:35:47 +0200
parents 6df25b1418be
children
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
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
25 import com.oracle.jvmci.code.CodeCacheProvider;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
26 import com.oracle.jvmci.code.StackSlot;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
27 import com.oracle.jvmci.code.RegisterConfig;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
28 import com.oracle.jvmci.meta.Kind;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
29 import com.oracle.jvmci.meta.LIRKind;
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
30
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
31 import static com.oracle.jvmci.code.ValueUtil.*;
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
32
21720
d915361cc3a1 moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21708
diff changeset
33 import com.oracle.graal.asm.*;
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 18434
diff changeset
34 import com.oracle.graal.lir.framemap.*;
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
35
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
36 /**
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
37 * AMD64 specific frame map.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
38 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
39 * This is the format of an AMD64 stack frame:
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
40 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
41 * <pre>
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
42 * Base Contents
19507
1cde96b96673 Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents: 18463
diff changeset
43 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
44 * : : -----
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
45 * caller | incoming overflow argument n | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
46 * frame : ... : | positive
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
47 * | incoming overflow argument 0 | | offsets
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
48 * ---------+--------------------------------+---------------------
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
49 * | return address | | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
50 * current +--------------------------------+ | | -----
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
51 * frame | | | | ^
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
52 * : callee save area : | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
53 * | | | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
54 * +--------------------------------+ | | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
55 * | spill slot 0 | | negative | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
56 * : ... : v offsets | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
57 * | spill slot n | ----- total frame
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
58 * +--------------------------------+ frame size
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
59 * | alignment padding | size |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
60 * +--------------------------------+ ----- | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
61 * | outgoing overflow argument n | ^ | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
62 * : ... : | positive | |
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
63 * | outgoing overflow argument 0 | | offsets v v
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
64 * %sp--&gt; +--------------------------------+---------------------------
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
65 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
66 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14121
diff changeset
67 *
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
68 * 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
69 * 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
70 * <p>
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
71 * 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
72 * 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
73 * specified offset. Use {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
74 * 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
75 * relative to the stack pointer.
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
76 */
11594
3d358ea11300 allow backend to specify spill slot size
Mick Jordan <mick.jordan@oracle.com>
parents: 10958
diff changeset
77 public class AMD64FrameMap extends FrameMap {
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
78
18434
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
79 private StackSlot rbpSpillSlot;
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
80
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14906
diff changeset
81 public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14906
diff changeset
82 super(codeCache, registerConfig);
10958
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
83 // (negative) offset relative to sp + total frame size
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
84 initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
85 spillSize = initialSpillSize;
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
86 }
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 @Override
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
89 public int totalFrameSize() {
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
90 return frameSize() + returnAddressSize();
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
91 }
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 @Override
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
94 public int currentFrameSize() {
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
95 return alignFrameSize(outgoingSize + spillSize - returnAddressSize());
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
96 }
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
97
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
98 @Override
e2c63a0b799c moved move logic into architecture specific FrameMap
twisti
parents: 10956
diff changeset
99 protected int alignFrameSize(int size) {
18123
3c7e73362d6a Encapsulate FrameMap.registerConfig & FrameMap.target.
Josef Eisl <josef.eisl@jku.at>
parents: 16094
diff changeset
100 return NumUtil.roundUp(size + returnAddressSize(), getTarget().stackAlignment) - returnAddressSize();
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
101 }
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
102
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
103 @Override
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
104 public int offsetToCalleeSaveArea() {
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
105 return frameSize() - calleeSaveAreaSize();
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
106 }
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
107
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
108 @Override
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15124
diff changeset
109 protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
110 return StackSlot.get(kind, -spillSize + additionalOffset, true);
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
111 }
18434
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 /**
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
114 * 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
115 * 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
116 */
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
117 StackSlot allocateRBPSpillSlot() {
18463
eeed42f7e38c Assert assumptions about the deoptimization rescue slot.
Josef Eisl <josef.eisl@jku.at>
parents: 18449
diff changeset
118 assert spillSize == initialSpillSize : "RBP spill slot must be the first allocated stack slots";
18449
cdff1577017c FrameMapBuilder: use FrameMap.allocateSpillSlot();
Josef Eisl <josef.eisl@jku.at>
parents: 18443
diff changeset
119 rbpSpillSlot = allocateSpillSlot(LIRKind.value(Kind.Long));
18434
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
120 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
121 return rbpSpillSlot;
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
122 }
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
123
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
124 void freeRBPSpillSlot() {
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
125 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
126 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
127 spillSize = initialSpillSize;
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
128 }
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
129
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
130 public StackSlot allocateDeoptimizationRescueSlot() {
18463
eeed42f7e38c Assert assumptions about the deoptimization rescue slot.
Josef Eisl <josef.eisl@jku.at>
parents: 18449
diff changeset
131 assert spillSize == initialSpillSize || spillSize == initialSpillSize + spillSlotSize(LIRKind.value(Kind.Long)) : "Deoptimization rescue slot must be the first or second (if there is an RBP spill slot) stack slot";
18449
cdff1577017c FrameMapBuilder: use FrameMap.allocateSpillSlot();
Josef Eisl <josef.eisl@jku.at>
parents: 18443
diff changeset
132 return allocateSpillSlot(LIRKind.value(Kind.Long));
18434
06624c98ed8b Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
133 }
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents:
diff changeset
134 }