Mercurial > hg > truffle
annotate src/share/vm/c1/c1_FrameMap.hpp @ 6862:8a5ea0a9ccc4
7127708: G1: change task num types from int to uint in concurrent mark
Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich.
Reviewed-by: johnc
Contributed-by: Kaushik Srenevasan <kaushik@twitter.com>
author | johnc |
---|---|
date | Sat, 06 Oct 2012 01:17:44 -0700 |
parents | 8a02ca5e5576 |
children | b9a9ed0f8eeb |
rev | line source |
---|---|
0 | 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 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
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:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_C1_C1_FRAMEMAP_HPP |
26 #define SHARE_VM_C1_C1_FRAMEMAP_HPP | |
27 | |
28 #include "asm/assembler.hpp" | |
29 #include "c1/c1_Defs.hpp" | |
30 #include "c1/c1_LIR.hpp" | |
31 #include "code/vmreg.hpp" | |
32 #include "memory/allocation.hpp" | |
33 #include "runtime/frame.hpp" | |
34 #include "runtime/synchronizer.hpp" | |
35 #include "utilities/globalDefinitions.hpp" | |
36 | |
0 | 37 class ciMethod; |
38 class CallingConvention; | |
39 class BasicTypeArray; | |
40 class BasicTypeList; | |
41 | |
42 //-------------------------------------------------------- | |
43 // FrameMap | |
44 //-------------------------------------------------------- | |
45 | |
46 // This class is responsible of mapping items (locals, monitors, spill | |
47 // slots and registers to their frame location | |
48 // | |
49 // The monitors are specified by a consecutive index, although each monitor entry | |
50 // occupies two words. The monitor_index is 0.._num_monitors | |
51 // The spill index is similar to local index; it is in range 0..(open) | |
52 // | |
53 // The CPU registers are mapped using a fixed table; register with number 0 | |
54 // is the most used one. | |
55 | |
56 | |
57 // stack grow direction --> SP | |
58 // +----------+---+----------+-------+------------------------+-----+ | |
59 // |arguments | x | monitors | spill | reserved argument area | ABI | | |
60 // +----------+---+----------+-------+------------------------+-----+ | |
61 // | |
62 // x = ABI area (SPARC) or return adress and link (i486) | |
63 // ABI = ABI area (SPARC) or nothing (i486) | |
64 | |
65 | |
66 class LIR_OprDesc; | |
67 typedef LIR_OprDesc* LIR_Opr; | |
68 | |
69 | |
70 class FrameMap : public CompilationResourceObj { | |
71 public: | |
72 enum { | |
73 nof_cpu_regs = pd_nof_cpu_regs_frame_map, | |
74 nof_fpu_regs = pd_nof_fpu_regs_frame_map, | |
75 | |
76 nof_cpu_regs_reg_alloc = pd_nof_cpu_regs_reg_alloc, | |
77 nof_fpu_regs_reg_alloc = pd_nof_fpu_regs_reg_alloc, | |
78 | |
2002 | 79 max_nof_caller_save_cpu_regs = pd_nof_caller_save_cpu_regs_frame_map, |
80 nof_caller_save_fpu_regs = pd_nof_caller_save_fpu_regs_frame_map, | |
0 | 81 |
82 spill_slot_size_in_bytes = 4 | |
83 }; | |
84 | |
1972 | 85 #ifdef TARGET_ARCH_x86 |
86 # include "c1_FrameMap_x86.hpp" | |
87 #endif | |
88 #ifdef TARGET_ARCH_sparc | |
89 # include "c1_FrameMap_sparc.hpp" | |
90 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2002
diff
changeset
|
91 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2002
diff
changeset
|
92 # include "c1_FrameMap_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2002
diff
changeset
|
93 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2002
diff
changeset
|
94 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2002
diff
changeset
|
95 # include "c1_FrameMap_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2002
diff
changeset
|
96 #endif |
1972 | 97 |
0 | 98 |
99 friend class LIR_OprDesc; | |
100 | |
101 private: | |
102 static bool _init_done; | |
103 static Register _cpu_rnr2reg [nof_cpu_regs]; | |
104 static int _cpu_reg2rnr [nof_cpu_regs]; | |
105 | |
2002 | 106 static LIR_Opr _caller_save_cpu_regs [max_nof_caller_save_cpu_regs]; |
0 | 107 static LIR_Opr _caller_save_fpu_regs [nof_caller_save_fpu_regs]; |
108 | |
109 int _framesize; | |
110 int _argcount; | |
111 int _num_monitors; | |
112 int _num_spills; | |
113 int _reserved_argument_area_size; | |
114 int _oop_map_arg_count; | |
115 | |
116 CallingConvention* _incoming_arguments; | |
117 intArray* _argument_locations; | |
118 | |
119 void check_spill_index (int spill_index) const { assert(spill_index >= 0, "bad index"); } | |
120 void check_monitor_index (int monitor_index) const { assert(monitor_index >= 0 && | |
121 monitor_index < _num_monitors, "bad index"); } | |
122 | |
123 static Register cpu_rnr2reg (int rnr) { | |
124 assert(_init_done, "tables not initialized"); | |
125 debug_only(cpu_range_check(rnr);) | |
126 return _cpu_rnr2reg[rnr]; | |
127 } | |
128 | |
129 static int cpu_reg2rnr (Register reg) { | |
130 assert(_init_done, "tables not initialized"); | |
131 debug_only(cpu_range_check(reg->encoding());) | |
132 return _cpu_reg2rnr[reg->encoding()]; | |
133 } | |
134 | |
135 static void map_register(int rnr, Register reg) { | |
136 debug_only(cpu_range_check(rnr);) | |
137 debug_only(cpu_range_check(reg->encoding());) | |
138 _cpu_rnr2reg[rnr] = reg; | |
139 _cpu_reg2rnr[reg->encoding()] = rnr; | |
140 } | |
141 | |
142 void update_reserved_argument_area_size (int size) { | |
143 assert(size >= 0, "check"); | |
144 _reserved_argument_area_size = MAX2(_reserved_argument_area_size, size); | |
145 } | |
146 | |
147 protected: | |
148 #ifndef PRODUCT | |
149 static void cpu_range_check (int rnr) { assert(0 <= rnr && rnr < nof_cpu_regs, "cpu register number is too big"); } | |
150 static void fpu_range_check (int rnr) { assert(0 <= rnr && rnr < nof_fpu_regs, "fpu register number is too big"); } | |
151 #endif | |
152 | |
153 | |
154 ByteSize sp_offset_for_monitor_base(const int idx) const; | |
155 | |
156 Address make_new_address(ByteSize sp_offset) const; | |
157 | |
158 ByteSize sp_offset_for_slot(const int idx) const; | |
159 ByteSize sp_offset_for_double_slot(const int idx) const; | |
160 ByteSize sp_offset_for_spill(const int idx) const; | |
161 ByteSize sp_offset_for_monitor_lock(int monitor_index) const; | |
162 ByteSize sp_offset_for_monitor_object(int monitor_index) const; | |
163 | |
164 VMReg sp_offset2vmreg(ByteSize offset) const; | |
165 | |
166 // platform dependent hook used to check that frame is properly | |
167 // addressable on the platform. Used by sparc to verify that all | |
168 // stack addresses are expressable in a simm13. | |
169 bool validate_frame(); | |
170 | |
171 static LIR_Opr map_to_opr(BasicType type, VMRegPair* reg, bool incoming); | |
172 | |
173 public: | |
174 // Opr representing the stack_pointer on this platform | |
175 static LIR_Opr stack_pointer(); | |
176 | |
1564 | 177 // JSR 292 |
178 static LIR_Opr method_handle_invoke_SP_save_opr(); | |
179 | |
0 | 180 static BasicTypeArray* signature_type_array_for(const ciMethod* method); |
181 | |
182 // for outgoing calls, these also update the reserved area to | |
183 // include space for arguments and any ABI area. | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
184 CallingConvention* c_calling_convention(const BasicTypeArray* signature); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
185 CallingConvention* java_calling_convention(const BasicTypeArray* signature, bool outgoing); |
0 | 186 |
187 // deopt support | |
188 ByteSize sp_offset_for_orig_pc() { return sp_offset_for_monitor_base(_num_monitors); } | |
189 | |
190 static LIR_Opr as_opr(Register r) { | |
191 return LIR_OprFact::single_cpu(cpu_reg2rnr(r)); | |
192 } | |
193 static LIR_Opr as_oop_opr(Register r) { | |
194 return LIR_OprFact::single_cpu_oop(cpu_reg2rnr(r)); | |
195 } | |
196 | |
6739
8a02ca5e5576
7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents:
6266
diff
changeset
|
197 static LIR_Opr as_metadata_opr(Register r) { |
8a02ca5e5576
7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents:
6266
diff
changeset
|
198 return LIR_OprFact::single_cpu_metadata(cpu_reg2rnr(r)); |
8a02ca5e5576
7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents:
6266
diff
changeset
|
199 } |
8a02ca5e5576
7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents:
6266
diff
changeset
|
200 |
0 | 201 FrameMap(ciMethod* method, int monitors, int reserved_argument_area_size); |
202 bool finalize_frame(int nof_slots); | |
203 | |
204 int reserved_argument_area_size () const { return _reserved_argument_area_size; } | |
205 int framesize () const { assert(_framesize != -1, "hasn't been calculated"); return _framesize; } | |
206 ByteSize framesize_in_bytes () const { return in_ByteSize(framesize() * 4); } | |
207 int num_monitors () const { return _num_monitors; } | |
208 int num_spills () const { assert(_num_spills >= 0, "not set"); return _num_spills; } | |
209 int argcount () const { assert(_argcount >= 0, "not set"); return _argcount; } | |
210 | |
211 int oop_map_arg_count() const { return _oop_map_arg_count; } | |
212 | |
213 CallingConvention* incoming_arguments() const { return _incoming_arguments; } | |
214 | |
215 // convenience routines | |
216 Address address_for_slot(int index, int sp_adjust = 0) const { | |
217 return make_new_address(sp_offset_for_slot(index) + in_ByteSize(sp_adjust)); | |
218 } | |
219 Address address_for_double_slot(int index, int sp_adjust = 0) const { | |
220 return make_new_address(sp_offset_for_double_slot(index) + in_ByteSize(sp_adjust)); | |
221 } | |
222 Address address_for_monitor_lock(int monitor_index) const { | |
223 return make_new_address(sp_offset_for_monitor_lock(monitor_index)); | |
224 } | |
225 Address address_for_monitor_object(int monitor_index) const { | |
226 return make_new_address(sp_offset_for_monitor_object(monitor_index)); | |
227 } | |
228 | |
229 void print_frame_layout() const; | |
230 | |
231 // Creates Location describing desired slot and returns it via pointer | |
232 // to Location object. Returns true if the stack frame offset was legal | |
233 // (as defined by Location::legal_offset_in_bytes()), false otherwise. | |
234 // Do not use the returned location if this returns false. | |
235 bool location_for_sp_offset(ByteSize byte_offset_from_sp, | |
236 Location::Type loc_type, Location* loc) const; | |
237 | |
238 bool location_for_monitor_lock (int monitor_index, Location* loc) const { | |
239 return location_for_sp_offset(sp_offset_for_monitor_lock(monitor_index), Location::normal, loc); | |
240 } | |
241 bool location_for_monitor_object(int monitor_index, Location* loc) const { | |
242 return location_for_sp_offset(sp_offset_for_monitor_object(monitor_index), Location::oop, loc); | |
243 } | |
244 bool locations_for_slot (int index, Location::Type loc_type, | |
245 Location* loc, Location* second = NULL) const; | |
246 | |
247 VMReg slot_regname(int index) const { | |
248 return sp_offset2vmreg(sp_offset_for_slot(index)); | |
249 } | |
250 VMReg monitor_object_regname(int monitor_index) const { | |
251 return sp_offset2vmreg(sp_offset_for_monitor_object(monitor_index)); | |
252 } | |
253 VMReg regname(LIR_Opr opr) const; | |
254 | |
255 static LIR_Opr caller_save_cpu_reg_at(int i) { | |
2002 | 256 assert(i >= 0 && i < max_nof_caller_save_cpu_regs, "out of bounds"); |
0 | 257 return _caller_save_cpu_regs[i]; |
258 } | |
259 | |
260 static LIR_Opr caller_save_fpu_reg_at(int i) { | |
261 assert(i >= 0 && i < nof_caller_save_fpu_regs, "out of bounds"); | |
262 return _caller_save_fpu_regs[i]; | |
263 } | |
264 | |
1584 | 265 static void initialize(); |
0 | 266 }; |
267 | |
268 // CallingConvention | |
269 //-------------------------------------------------------- | |
270 | |
271 class CallingConvention: public ResourceObj { | |
272 private: | |
273 LIR_OprList* _args; | |
274 int _reserved_stack_slots; | |
275 | |
276 public: | |
277 CallingConvention (LIR_OprList* args, int reserved_stack_slots) | |
278 : _args(args) | |
279 , _reserved_stack_slots(reserved_stack_slots) {} | |
280 | |
281 LIR_OprList* args() { return _args; } | |
282 | |
283 LIR_Opr at(int i) const { return _args->at(i); } | |
284 int length() const { return _args->length(); } | |
285 | |
286 // Indicates number of real frame slots used by arguments passed on stack. | |
287 int reserved_stack_slots() const { return _reserved_stack_slots; } | |
288 | |
289 #ifndef PRODUCT | |
290 void print () const { | |
291 for (int i = 0; i < length(); i++) { | |
292 at(i)->print(); | |
293 } | |
294 } | |
295 #endif // PRODUCT | |
296 }; | |
1972 | 297 |
298 #endif // SHARE_VM_C1_C1_FRAMEMAP_HPP |