Mercurial > hg > truffle
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 |
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 | |
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 | 35 |
36 /** | |
37 * AMD64 specific frame map. | |
14906 | 38 * |
10956 | 39 * This is the format of an AMD64 stack frame: |
14906 | 40 * |
10956 | 41 * <pre> |
42 * Base Contents | |
19507
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18463
diff
changeset
|
43 * |
10956 | 44 * : : ----- |
45 * caller | incoming overflow argument n | ^ | |
46 * frame : ... : | positive | |
47 * | incoming overflow argument 0 | | offsets | |
48 * ---------+--------------------------------+--------------------- | |
49 * | return address | | ^ | |
50 * current +--------------------------------+ | | ----- | |
51 * frame | | | | ^ | |
52 * : callee save area : | | | | |
53 * | | | | | | |
54 * +--------------------------------+ | | | | |
55 * | spill slot 0 | | negative | | | |
56 * : ... : v offsets | | | |
57 * | spill slot n | ----- total frame | |
58 * +--------------------------------+ frame size | |
59 * | alignment padding | size | | |
60 * +--------------------------------+ ----- | | | |
61 * | outgoing overflow argument n | ^ | | | |
62 * : ... : | positive | | | |
63 * | outgoing overflow argument 0 | | offsets v v | |
14906 | 64 * %sp--> +--------------------------------+--------------------------- |
65 * | |
10956 | 66 * </pre> |
14906 | 67 * |
10956 | 68 * The spill slot area also includes stack allocated memory blocks (ALLOCA blocks). The size of such |
69 * a block may be greater than the size of a normal spill slot or the word size. | |
70 * <p> | |
71 * A runtime can reserve space at the beginning of the overflow argument area. The calling | |
72 * convention can specify that the first overflow stack argument is not at offset 0, but at a | |
73 * specified offset. Use {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that | |
74 * call-free methods also have this space reserved. Then the VM can use the memory at offset 0 | |
75 * relative to the stack pointer. | |
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 | 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 | 101 } |
102 | |
103 @Override | |
104 public int offsetToCalleeSaveArea() { | |
105 return frameSize() - calleeSaveAreaSize(); | |
106 } | |
107 | |
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 | 110 return StackSlot.get(kind, -spillSize + additionalOffset, true); |
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 | 134 } |