annotate src/share/vm/c1/c1_FrameMap.cpp @ 4710:41406797186b

7113012: G1: rename not-fully-young GCs as "mixed" Summary: Renamed partially-young GCs as mixed and fully-young GCs as young. Change all external output that includes those terms (GC log and GC ergo log) as well as any comments, fields, methods, etc. The changeset also includes very minor code tidying up (added some curly brackets). Reviewed-by: johnc, brutisso
author tonyp
date Fri, 16 Dec 2011 02:14:27 -0500
parents 1d1603768966
children 1d7922586cf6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2192
diff changeset
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
26 #include "c1/c1_FrameMap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
27 #include "c1/c1_LIR.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
28 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
29 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
30 # include "vmreg_x86.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
31 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
32 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
33 # include "vmreg_sparc.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
34 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
35 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
36 # include "vmreg_zero.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
37 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2093
diff changeset
38 #ifdef TARGET_ARCH_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2093
diff changeset
39 # include "vmreg_arm.inline.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2093
diff changeset
40 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2093
diff changeset
41 #ifdef TARGET_ARCH_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2093
diff changeset
42 # include "vmreg_ppc.inline.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2093
diff changeset
43 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 //-----------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Convert method signature into an array of BasicTypes for the arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
50 BasicTypeArray* FrameMap::signature_type_array_for(const ciMethod* method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 ciSignature* sig = method->signature();
a61af66fc99e Initial load
duke
parents:
diff changeset
52 BasicTypeList* sta = new BasicTypeList(method->arg_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // add receiver, if any
a61af66fc99e Initial load
duke
parents:
diff changeset
54 if (!method->is_static()) sta->append(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // add remaining arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
56 for (int i = 0; i < sig->count(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 ciType* type = sig->type_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 BasicType t = type->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 if (t == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 t = T_OBJECT;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 sta->append(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // done
a61af66fc99e Initial load
duke
parents:
diff changeset
65 return sta;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 CallingConvention* FrameMap::java_calling_convention(const BasicTypeArray* signature, bool outgoing) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // compute the size of the arguments first. The signature array
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // that java_calling_convention takes includes a T_VOID after double
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // work items but our signatures do not.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 int sizeargs = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 for (i = 0; i < signature->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 sizeargs += type2size[signature->at(i)];
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 int sig_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 for (i = 0; i < sizeargs; i++, sig_index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 sig_bt[i] = signature->at(sig_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 sig_bt[i + 1] = T_VOID;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 intptr_t out_preserve = SharedRuntime::java_calling_convention(sig_bt, regs, sizeargs, outgoing);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 LIR_OprList* args = new LIR_OprList(signature->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
92 for (i = 0; i < sizeargs;) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 BasicType t = sig_bt[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
94 assert(t != T_VOID, "should be skipping these");
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 LIR_Opr opr = map_to_opr(t, regs + i, outgoing);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 args->append(opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 if (opr->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 LIR_Address* addr = opr->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
100 assert(addr->disp() == (int)addr->disp(), "out of range value");
2093
7514897db238 7009849: C1: Incorrect frame size computation
iveresov
parents: 1972
diff changeset
101 out_preserve = MAX2(out_preserve, (intptr_t)(addr->disp() - STACK_BIAS) / 4);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 i += type2size[t];
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 assert(args->length() == signature->length(), "size mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
106 out_preserve += SharedRuntime::out_preserve_stack_slots();
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (outgoing) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // update the space reserved for arguments.
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
110 update_reserved_argument_area_size(out_preserve * BytesPerWord);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return new CallingConvention(args, out_preserve);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 CallingConvention* FrameMap::c_calling_convention(const BasicTypeArray* signature) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // compute the size of the arguments first. The signature array
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // that java_calling_convention takes includes a T_VOID after double
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // work items but our signatures do not.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int sizeargs = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 for (i = 0; i < signature->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 sizeargs += type2size[signature->at(i)];
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 int sig_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 for (i = 0; i < sizeargs; i++, sig_index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 sig_bt[i] = signature->at(sig_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 sig_bt[i + 1] = T_VOID;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 intptr_t out_preserve = SharedRuntime::c_calling_convention(sig_bt, regs, sizeargs);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 LIR_OprList* args = new LIR_OprList(signature->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
139 for (i = 0; i < sizeargs;) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 BasicType t = sig_bt[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
141 assert(t != T_VOID, "should be skipping these");
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // C calls are always outgoing
a61af66fc99e Initial load
duke
parents:
diff changeset
144 bool outgoing = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 LIR_Opr opr = map_to_opr(t, regs + i, outgoing);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // they might be of different types if for instance floating point
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // values are passed in cpu registers, but the sizes must match.
a61af66fc99e Initial load
duke
parents:
diff changeset
148 assert(type2size[opr->type()] == type2size[t], "type mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
149 args->append(opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 if (opr->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 LIR_Address* addr = opr->as_address_ptr();
2093
7514897db238 7009849: C1: Incorrect frame size computation
iveresov
parents: 1972
diff changeset
152 out_preserve = MAX2(out_preserve, (intptr_t)(addr->disp() - STACK_BIAS) / 4);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 i += type2size[t];
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 assert(args->length() == signature->length(), "size mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
157 out_preserve += SharedRuntime::out_preserve_stack_slots();
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
158 update_reserved_argument_area_size(out_preserve * BytesPerWord);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return new CallingConvention(args, out_preserve);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 //--------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // FrameMap
a61af66fc99e Initial load
duke
parents:
diff changeset
165 //--------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 bool FrameMap::_init_done = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 Register FrameMap::_cpu_rnr2reg [FrameMap::nof_cpu_regs];
a61af66fc99e Initial load
duke
parents:
diff changeset
169 int FrameMap::_cpu_reg2rnr [FrameMap::nof_cpu_regs];
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 FrameMap::FrameMap(ciMethod* method, int monitors, int reserved_argument_area_size) {
1584
b812ff5abc73 6958292: C1: Enable parallel compilation
iveresov
parents: 1552
diff changeset
173 assert(_init_done, "should already be completed");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 _framesize = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 _num_spills = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 assert(monitors >= 0, "not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
179 _num_monitors = monitors;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 assert(reserved_argument_area_size >= 0, "not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
181 _reserved_argument_area_size = MAX2(4, reserved_argument_area_size) * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 _argcount = method->arg_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 _argument_locations = new intArray(_argcount, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 _incoming_arguments = java_calling_convention(signature_type_array_for(method), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 _oop_map_arg_count = _incoming_arguments->reserved_stack_slots();
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 int java_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 for (int i = 0; i < _incoming_arguments->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 LIR_Opr opr = _incoming_arguments->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 if (opr->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 LIR_Address* address = opr->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
193 _argument_locations->at_put(java_index, address->disp() - STACK_BIAS);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 _incoming_arguments->args()->at_put(i, LIR_OprFact::stack(java_index, as_BasicType(as_ValueType(address->type()))));
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 java_index += type2size[opr->type()];
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 bool FrameMap::finalize_frame(int nof_slots) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 assert(nof_slots >= 0, "must be positive");
a61af66fc99e Initial load
duke
parents:
diff changeset
204 assert(_num_spills == -1, "can only be set once");
a61af66fc99e Initial load
duke
parents:
diff changeset
205 _num_spills = nof_slots;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(_framesize == -1, "should only be calculated once");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 _framesize = round_to(in_bytes(sp_offset_for_monitor_base(0)) +
a61af66fc99e Initial load
duke
parents:
diff changeset
208 _num_monitors * sizeof(BasicObjectLock) +
a61af66fc99e Initial load
duke
parents:
diff changeset
209 sizeof(intptr_t) + // offset of deopt orig pc
a61af66fc99e Initial load
duke
parents:
diff changeset
210 frame_pad_in_bytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
211 StackAlignmentInBytes) / 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 int java_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 for (int i = 0; i < _incoming_arguments->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 LIR_Opr opr = _incoming_arguments->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (opr->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 _argument_locations->at_put(java_index, in_bytes(framesize_in_bytes()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
217 _argument_locations->at(java_index));
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 java_index += type2size[opr->type()];
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // make sure it's expressible on the platform
a61af66fc99e Initial load
duke
parents:
diff changeset
222 return validate_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 VMReg FrameMap::sp_offset2vmreg(ByteSize offset) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 int offset_in_bytes = in_bytes(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 assert(offset_in_bytes % 4 == 0, "must be multiple of 4 bytes");
a61af66fc99e Initial load
duke
parents:
diff changeset
228 assert(offset_in_bytes / 4 < framesize() + oop_map_arg_count(), "out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return VMRegImpl::stack2reg(offset_in_bytes / 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 bool FrameMap::location_for_sp_offset(ByteSize byte_offset_from_sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
234 Location::Type loc_type,
a61af66fc99e Initial load
duke
parents:
diff changeset
235 Location* loc) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 int offset = in_bytes(byte_offset_from_sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 assert(offset >= 0, "incorrect offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (!Location::legal_offset_in_bytes(offset)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 Location tmp_loc = Location::new_stk_loc(loc_type, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 *loc = tmp_loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 bool FrameMap::locations_for_slot (int index, Location::Type loc_type,
a61af66fc99e Initial load
duke
parents:
diff changeset
248 Location* loc, Location* second) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 ByteSize offset_from_sp = sp_offset_for_slot(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if (!location_for_sp_offset(offset_from_sp, loc_type, loc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 if (second != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // two word item
a61af66fc99e Initial load
duke
parents:
diff changeset
255 offset_from_sp = offset_from_sp + in_ByteSize(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return location_for_sp_offset(offset_from_sp, loc_type, second);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 //////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Public accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
263 //////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 ByteSize FrameMap::sp_offset_for_slot(const int index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 if (index < argcount()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 int offset = _argument_locations->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 assert(offset != -1, "not a memory argument");
a61af66fc99e Initial load
duke
parents:
diff changeset
270 assert(offset >= framesize() * 4, "argument inside of frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return in_ByteSize(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 ByteSize offset = sp_offset_for_spill(index - argcount());
a61af66fc99e Initial load
duke
parents:
diff changeset
274 assert(in_bytes(offset) < framesize() * 4, "spill outside of frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 ByteSize FrameMap::sp_offset_for_double_slot(const int index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 ByteSize offset = sp_offset_for_slot(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 if (index >= argcount()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 assert(in_bytes(offset) + 4 < framesize() * 4, "spill outside of frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 ByteSize FrameMap::sp_offset_for_spill(const int index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 assert(index >= 0 && index < _num_spills, "out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
290 int offset = round_to(first_available_sp_in_frame + _reserved_argument_area_size, sizeof(double)) +
a61af66fc99e Initial load
duke
parents:
diff changeset
291 index * spill_slot_size_in_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 return in_ByteSize(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 ByteSize FrameMap::sp_offset_for_monitor_base(const int index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 int end_of_spills = round_to(first_available_sp_in_frame + _reserved_argument_area_size, sizeof(double)) +
a61af66fc99e Initial load
duke
parents:
diff changeset
297 _num_spills * spill_slot_size_in_bytes;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
298 int offset = (int) round_to(end_of_spills, HeapWordSize) + index * sizeof(BasicObjectLock);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return in_ByteSize(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 ByteSize FrameMap::sp_offset_for_monitor_lock(int index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 check_monitor_index(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 return sp_offset_for_monitor_base(index) + in_ByteSize(BasicObjectLock::lock_offset_in_bytes());;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 ByteSize FrameMap::sp_offset_for_monitor_object(int index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 check_monitor_index(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 return sp_offset_for_monitor_base(index) + in_ByteSize(BasicObjectLock::obj_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 void FrameMap::print_frame_layout() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 int svar;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 tty->print_cr("#####################################");
a61af66fc99e Initial load
duke
parents:
diff changeset
315 tty->print_cr("Frame size in words %d", framesize());
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 if( _num_monitors > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 tty->print_cr("monitor [0]:%d | [%2d]:%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
319 in_bytes(sp_offset_for_monitor_base(0)),
a61af66fc99e Initial load
duke
parents:
diff changeset
320 in_bytes(sp_offset_for_monitor_base(_num_monitors)));
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 if( _num_spills > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 svar = _num_spills - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 if(svar == 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
325 tty->print_cr("spill [0]:%d", in_bytes(sp_offset_for_spill(0)));
a61af66fc99e Initial load
duke
parents:
diff changeset
326 else
a61af66fc99e Initial load
duke
parents:
diff changeset
327 tty->print_cr("spill [0]:%d | [%2d]:%d", in_bytes(sp_offset_for_spill(0)),
a61af66fc99e Initial load
duke
parents:
diff changeset
328 svar,
a61af66fc99e Initial load
duke
parents:
diff changeset
329 in_bytes(sp_offset_for_spill(svar)));
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // For OopMaps, map a local variable or spill index to an VMReg.
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // This is the offset from sp() in the frame of the slot for the index,
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // skewed by SharedInfo::stack0 to indicate a stack location (vs.a register.)
a61af66fc99e Initial load
duke
parents:
diff changeset
337 //
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // C ABI size +
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // framesize + framesize +
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // stack0 stack0 stack0 0 <- VMReg->value()
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // | | | <registers> |
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // ..........|..............|..............|.............|
a61af66fc99e Initial load
duke
parents:
diff changeset
343 // 0 1 2 3 | <C ABI area> | 4 5 6 ...... | <- local indices
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // ^ ^ sp()
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // | |
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // arguments non-argument locals
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 VMReg FrameMap::regname(LIR_Opr opr) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 if (opr->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 assert(!opr->is_virtual(), "should not see virtual registers here");
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return opr->as_register()->as_VMReg();
a61af66fc99e Initial load
duke
parents:
diff changeset
353 } else if (opr->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 return sp_offset2vmreg(sp_offset_for_slot(opr->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
355 } else if (opr->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 LIR_Address* addr = opr->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
357 assert(addr->base() == stack_pointer(), "sp based addressing only");
a61af66fc99e Initial load
duke
parents:
diff changeset
358 return sp_offset2vmreg(in_ByteSize(addr->index()->as_jint()));
a61af66fc99e Initial load
duke
parents:
diff changeset
359 }
a61af66fc99e Initial load
duke
parents:
diff changeset
360 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
361 return VMRegImpl::Bad();
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // ------------ extra spill slots ---------------