Mercurial > hg > graal-compiler
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 |
rev | line source |
---|---|
10956 | 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 | 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 */ | |
23 package com.oracle.graal.lir.amd64; | |
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 | 27 import com.oracle.graal.api.code.*; |
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 | 31 |
32 /** | |
33 * AMD64 specific frame map. | |
14906 | 34 * |
10956 | 35 * This is the format of an AMD64 stack frame: |
14906 | 36 * |
10956 | 37 * <pre> |
38 * Base Contents | |
18443
1c92d437179b
FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents:
18434
diff
changeset
|
39 * |
10956 | 40 * : : ----- |
41 * caller | incoming overflow argument n | ^ | |
42 * frame : ... : | positive | |
43 * | incoming overflow argument 0 | | offsets | |
44 * ---------+--------------------------------+--------------------- | |
45 * | return address | | ^ | |
46 * current +--------------------------------+ | | ----- | |
47 * frame | | | | ^ | |
48 * : callee save area : | | | | |
49 * | | | | | | |
50 * +--------------------------------+ | | | | |
51 * | spill slot 0 | | negative | | | |
52 * : ... : v offsets | | | |
53 * | spill slot n | ----- total frame | |
54 * +--------------------------------+ frame size | |
55 * | alignment padding | size | | |
56 * +--------------------------------+ ----- | | | |
57 * | outgoing overflow argument n | ^ | | | |
58 * : ... : | positive | | | |
59 * | outgoing overflow argument 0 | | offsets v v | |
14906 | 60 * %sp--> +--------------------------------+--------------------------- |
61 * | |
10956 | 62 * </pre> |
14906 | 63 * |
10956 | 64 * The spill slot area also includes stack allocated memory blocks (ALLOCA blocks). The size of such |
65 * a block may be greater than the size of a normal spill slot or the word size. | |
66 * <p> | |
67 * A runtime can reserve space at the beginning of the overflow argument area. The calling | |
68 * convention can specify that the first overflow stack argument is not at offset 0, but at a | |
69 * specified offset. Use {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that | |
70 * call-free methods also have this space reserved. Then the VM can use the memory at offset 0 | |
71 * relative to the stack pointer. | |
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 | 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 | 97 } |
98 | |
99 @Override | |
100 public int offsetToCalleeSaveArea() { | |
101 return frameSize() - calleeSaveAreaSize(); | |
102 } | |
103 | |
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 | 106 return StackSlot.get(kind, -spillSize + additionalOffset, true); |
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 | 133 } |