Mercurial > hg > graal-jvmci-8
annotate src/share/vm/oops/methodData.hpp @ 14420:abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
Summary: Implement profiling for c2 jit compilation. Also enable new cppInterpreter features.
Reviewed-by: kvn
author | goetz |
---|---|
date | Sun, 15 Sep 2013 15:28:58 +0200 |
parents | 92ef81e2f571 |
children | 2b8e28fdf503 |
rev | line source |
---|---|
0 | 1 /* |
7956 | 2 * Copyright (c) 2000, 2013, 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:
1251
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1251
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:
1251
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_OOPS_METHODDATAOOP_HPP |
26 #define SHARE_VM_OOPS_METHODDATAOOP_HPP | |
27 | |
28 #include "interpreter/bytecodes.hpp" | |
29 #include "memory/universe.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
30 #include "oops/method.hpp" |
1972 | 31 #include "oops/oop.hpp" |
32 #include "runtime/orderAccess.hpp" | |
33 | |
0 | 34 class BytecodeStream; |
7956 | 35 class KlassSizeStats; |
0 | 36 |
37 // The MethodData object collects counts and other profile information | |
38 // during zeroth-tier (interpretive) and first-tier execution. | |
39 // The profile is used later by compilation heuristics. Some heuristics | |
40 // enable use of aggressive (or "heroic") optimizations. An aggressive | |
41 // optimization often has a down-side, a corner case that it handles | |
42 // poorly, but which is thought to be rare. The profile provides | |
43 // evidence of this rarity for a given method or even BCI. It allows | |
44 // the compiler to back out of the optimization at places where it | |
45 // has historically been a poor choice. Other heuristics try to use | |
46 // specific information gathered about types observed at a given site. | |
47 // | |
48 // All data in the profile is approximate. It is expected to be accurate | |
49 // on the whole, but the system expects occasional inaccuraces, due to | |
50 // counter overflow, multiprocessor races during data collection, space | |
51 // limitations, missing MDO blocks, etc. Bad or missing data will degrade | |
52 // optimization quality but will not affect correctness. Also, each MDO | |
53 // is marked with its birth-date ("creation_mileage") which can be used | |
54 // to assess the quality ("maturity") of its data. | |
55 // | |
56 // Short (<32-bit) counters are designed to overflow to a known "saturated" | |
57 // state. Also, certain recorded per-BCI events are given one-bit counters | |
58 // which overflow to a saturated state which applied to all counters at | |
59 // that BCI. In other words, there is a small lattice which approximates | |
60 // the ideal of an infinite-precision counter for each event at each BCI, | |
61 // and the lattice quickly "bottoms out" in a state where all counters | |
62 // are taken to be indefinitely large. | |
63 // | |
64 // The reader will find many data races in profile gathering code, starting | |
65 // with invocation counter incrementation. None of these races harm correct | |
66 // execution of the compiled code. | |
67 | |
941 | 68 // forward decl |
69 class ProfileData; | |
70 | |
0 | 71 // DataLayout |
72 // | |
73 // Overlay for generic profiling data. | |
74 class DataLayout VALUE_OBJ_CLASS_SPEC { | |
75 private: | |
76 // Every data layout begins with a header. This header | |
77 // contains a tag, which is used to indicate the size/layout | |
78 // of the data, 4 bits of flags, which can be used in any way, | |
79 // 4 bits of trap history (none/one reason/many reasons), | |
80 // and a bci, which is used to tie this piece of data to a | |
81 // specific bci in the bytecodes. | |
82 union { | |
83 intptr_t _bits; | |
84 struct { | |
85 u1 _tag; | |
86 u1 _flags; | |
87 u2 _bci; | |
88 } _struct; | |
89 } _header; | |
90 | |
91 // The data layout has an arbitrary number of cells, each sized | |
92 // to accomodate a pointer or an integer. | |
93 intptr_t _cells[1]; | |
94 | |
95 // Some types of data layouts need a length field. | |
96 static bool needs_array_len(u1 tag); | |
97 | |
98 public: | |
99 enum { | |
100 counter_increment = 1 | |
101 }; | |
102 | |
103 enum { | |
104 cell_size = sizeof(intptr_t) | |
105 }; | |
106 | |
107 // Tag values | |
108 enum { | |
109 no_tag, | |
110 bit_data_tag, | |
111 counter_data_tag, | |
112 jump_data_tag, | |
113 receiver_type_data_tag, | |
114 virtual_call_data_tag, | |
115 ret_data_tag, | |
116 branch_data_tag, | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
117 multi_branch_data_tag, |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
118 arg_info_data_tag |
0 | 119 }; |
120 | |
121 enum { | |
122 // The _struct._flags word is formatted as [trap_state:4 | flags:4]. | |
123 // The trap state breaks down further as [recompile:1 | reason:3]. | |
124 // This further breakdown is defined in deoptimization.cpp. | |
125 // See Deoptimization::trap_state_reason for an assert that | |
126 // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT. | |
127 // | |
128 // The trap_state is collected only if ProfileTraps is true. | |
129 trap_bits = 1+3, // 3: enough to distinguish [0..Reason_RECORDED_LIMIT]. | |
130 trap_shift = BitsPerByte - trap_bits, | |
131 trap_mask = right_n_bits(trap_bits), | |
132 trap_mask_in_place = (trap_mask << trap_shift), | |
133 flag_limit = trap_shift, | |
134 flag_mask = right_n_bits(flag_limit), | |
135 first_flag = 0 | |
136 }; | |
137 | |
138 // Size computation | |
139 static int header_size_in_bytes() { | |
140 return cell_size; | |
141 } | |
142 static int header_size_in_cells() { | |
143 return 1; | |
144 } | |
145 | |
146 static int compute_size_in_bytes(int cell_count) { | |
147 return header_size_in_bytes() + cell_count * cell_size; | |
148 } | |
149 | |
150 // Initialization | |
151 void initialize(u1 tag, u2 bci, int cell_count); | |
152 | |
153 // Accessors | |
154 u1 tag() { | |
155 return _header._struct._tag; | |
156 } | |
157 | |
158 // Return a few bits of trap state. Range is [0..trap_mask]. | |
159 // The state tells if traps with zero, one, or many reasons have occurred. | |
160 // It also tells whether zero or many recompilations have occurred. | |
161 // The associated trap histogram in the MDO itself tells whether | |
162 // traps are common or not. If a BCI shows that a trap X has | |
163 // occurred, and the MDO shows N occurrences of X, we make the | |
164 // simplifying assumption that all N occurrences can be blamed | |
165 // on that BCI. | |
166 int trap_state() { | |
167 return ((_header._struct._flags >> trap_shift) & trap_mask); | |
168 } | |
169 | |
170 void set_trap_state(int new_state) { | |
171 assert(ProfileTraps, "used only under +ProfileTraps"); | |
172 uint old_flags = (_header._struct._flags & flag_mask); | |
173 _header._struct._flags = (new_state << trap_shift) | old_flags; | |
174 } | |
175 | |
176 u1 flags() { | |
177 return _header._struct._flags; | |
178 } | |
179 | |
180 u2 bci() { | |
181 return _header._struct._bci; | |
182 } | |
183 | |
184 void set_header(intptr_t value) { | |
185 _header._bits = value; | |
186 } | |
187 void release_set_header(intptr_t value) { | |
188 OrderAccess::release_store_ptr(&_header._bits, value); | |
189 } | |
190 intptr_t header() { | |
191 return _header._bits; | |
192 } | |
193 void set_cell_at(int index, intptr_t value) { | |
194 _cells[index] = value; | |
195 } | |
196 void release_set_cell_at(int index, intptr_t value) { | |
197 OrderAccess::release_store_ptr(&_cells[index], value); | |
198 } | |
199 intptr_t cell_at(int index) { | |
200 return _cells[index]; | |
201 } | |
202 | |
203 void set_flag_at(int flag_number) { | |
204 assert(flag_number < flag_limit, "oob"); | |
205 _header._struct._flags |= (0x1 << flag_number); | |
206 } | |
207 bool flag_at(int flag_number) { | |
208 assert(flag_number < flag_limit, "oob"); | |
209 return (_header._struct._flags & (0x1 << flag_number)) != 0; | |
210 } | |
211 | |
212 // Low-level support for code generation. | |
213 static ByteSize header_offset() { | |
214 return byte_offset_of(DataLayout, _header); | |
215 } | |
216 static ByteSize tag_offset() { | |
217 return byte_offset_of(DataLayout, _header._struct._tag); | |
218 } | |
219 static ByteSize flags_offset() { | |
220 return byte_offset_of(DataLayout, _header._struct._flags); | |
221 } | |
222 static ByteSize bci_offset() { | |
223 return byte_offset_of(DataLayout, _header._struct._bci); | |
224 } | |
225 static ByteSize cell_offset(int index) { | |
2333
f767174aac14
7021653: Parfait issue in hotspot/src/share/vm/oops/methodDataOops.hpp
coleenp
parents:
2264
diff
changeset
|
226 return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); |
0 | 227 } |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
228 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
229 static int cell_offset_in_bytes(int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
230 return (int)offset_of(DataLayout, _cells[index]); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
231 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
232 #endif // CC_INTERP |
0 | 233 // Return a value which, when or-ed as a byte into _flags, sets the flag. |
234 static int flag_number_to_byte_constant(int flag_number) { | |
235 assert(0 <= flag_number && flag_number < flag_limit, "oob"); | |
236 DataLayout temp; temp.set_header(0); | |
237 temp.set_flag_at(flag_number); | |
238 return temp._header._struct._flags; | |
239 } | |
240 // Return a value which, when or-ed as a word into _header, sets the flag. | |
241 static intptr_t flag_mask_to_header_mask(int byte_constant) { | |
242 DataLayout temp; temp.set_header(0); | |
243 temp._header._struct._flags = byte_constant; | |
244 return temp._header._bits; | |
245 } | |
941 | 246 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
247 ProfileData* data_in(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
248 |
941 | 249 // GC support |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
250 void clean_weak_klass_links(BoolObjectClosure* cl); |
0 | 251 }; |
252 | |
253 | |
254 // ProfileData class hierarchy | |
255 class ProfileData; | |
256 class BitData; | |
257 class CounterData; | |
258 class ReceiverTypeData; | |
259 class VirtualCallData; | |
260 class RetData; | |
261 class JumpData; | |
262 class BranchData; | |
263 class ArrayData; | |
264 class MultiBranchData; | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
265 class ArgInfoData; |
0 | 266 |
267 | |
268 // ProfileData | |
269 // | |
270 // A ProfileData object is created to refer to a section of profiling | |
271 // data in a structured way. | |
272 class ProfileData : public ResourceObj { | |
273 private: | |
274 #ifndef PRODUCT | |
275 enum { | |
276 tab_width_one = 16, | |
277 tab_width_two = 36 | |
278 }; | |
279 #endif // !PRODUCT | |
280 | |
281 // This is a pointer to a section of profiling data. | |
282 DataLayout* _data; | |
283 | |
284 protected: | |
285 DataLayout* data() { return _data; } | |
286 | |
287 enum { | |
288 cell_size = DataLayout::cell_size | |
289 }; | |
290 | |
291 public: | |
292 // How many cells are in this? | |
293 virtual int cell_count() { | |
294 ShouldNotReachHere(); | |
295 return -1; | |
296 } | |
297 | |
298 // Return the size of this data. | |
299 int size_in_bytes() { | |
300 return DataLayout::compute_size_in_bytes(cell_count()); | |
301 } | |
302 | |
303 protected: | |
304 // Low-level accessors for underlying data | |
305 void set_intptr_at(int index, intptr_t value) { | |
306 assert(0 <= index && index < cell_count(), "oob"); | |
307 data()->set_cell_at(index, value); | |
308 } | |
309 void release_set_intptr_at(int index, intptr_t value) { | |
310 assert(0 <= index && index < cell_count(), "oob"); | |
311 data()->release_set_cell_at(index, value); | |
312 } | |
313 intptr_t intptr_at(int index) { | |
314 assert(0 <= index && index < cell_count(), "oob"); | |
315 return data()->cell_at(index); | |
316 } | |
317 void set_uint_at(int index, uint value) { | |
318 set_intptr_at(index, (intptr_t) value); | |
319 } | |
320 void release_set_uint_at(int index, uint value) { | |
321 release_set_intptr_at(index, (intptr_t) value); | |
322 } | |
323 uint uint_at(int index) { | |
324 return (uint)intptr_at(index); | |
325 } | |
326 void set_int_at(int index, int value) { | |
327 set_intptr_at(index, (intptr_t) value); | |
328 } | |
329 void release_set_int_at(int index, int value) { | |
330 release_set_intptr_at(index, (intptr_t) value); | |
331 } | |
332 int int_at(int index) { | |
333 return (int)intptr_at(index); | |
334 } | |
335 int int_at_unchecked(int index) { | |
336 return (int)data()->cell_at(index); | |
337 } | |
338 void set_oop_at(int index, oop value) { | |
339 set_intptr_at(index, (intptr_t) value); | |
340 } | |
341 oop oop_at(int index) { | |
342 return (oop)intptr_at(index); | |
343 } | |
344 | |
345 void set_flag_at(int flag_number) { | |
346 data()->set_flag_at(flag_number); | |
347 } | |
348 bool flag_at(int flag_number) { | |
349 return data()->flag_at(flag_number); | |
350 } | |
351 | |
352 // two convenient imports for use by subclasses: | |
353 static ByteSize cell_offset(int index) { | |
354 return DataLayout::cell_offset(index); | |
355 } | |
356 static int flag_number_to_byte_constant(int flag_number) { | |
357 return DataLayout::flag_number_to_byte_constant(flag_number); | |
358 } | |
359 | |
360 ProfileData(DataLayout* data) { | |
361 _data = data; | |
362 } | |
363 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
364 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
365 // Static low level accessors for DataLayout with ProfileData's semantics. |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
366 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
367 static int cell_offset_in_bytes(int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
368 return DataLayout::cell_offset_in_bytes(index); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
369 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
370 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
371 static void increment_uint_at_no_overflow(DataLayout* layout, int index, |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
372 int inc = DataLayout::counter_increment) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
373 uint count = ((uint)layout->cell_at(index)) + inc; |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
374 if (count == 0) return; |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
375 layout->set_cell_at(index, (intptr_t) count); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
376 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
377 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
378 static int int_at(DataLayout* layout, int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
379 return (int)layout->cell_at(index); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
380 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
381 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
382 static int uint_at(DataLayout* layout, int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
383 return (uint)layout->cell_at(index); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
384 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
385 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
386 static oop oop_at(DataLayout* layout, int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
387 return (oop)layout->cell_at(index); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
388 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
389 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
390 static void set_intptr_at(DataLayout* layout, int index, intptr_t value) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
391 layout->set_cell_at(index, (intptr_t) value); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
392 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
393 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
394 static void set_flag_at(DataLayout* layout, int flag_number) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
395 layout->set_flag_at(flag_number); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
396 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
397 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
398 |
0 | 399 public: |
400 // Constructor for invalid ProfileData. | |
401 ProfileData(); | |
402 | |
403 u2 bci() { | |
404 return data()->bci(); | |
405 } | |
406 | |
407 address dp() { | |
408 return (address)_data; | |
409 } | |
410 | |
411 int trap_state() { | |
412 return data()->trap_state(); | |
413 } | |
414 void set_trap_state(int new_state) { | |
415 data()->set_trap_state(new_state); | |
416 } | |
417 | |
418 // Type checking | |
419 virtual bool is_BitData() { return false; } | |
420 virtual bool is_CounterData() { return false; } | |
421 virtual bool is_JumpData() { return false; } | |
422 virtual bool is_ReceiverTypeData(){ return false; } | |
423 virtual bool is_VirtualCallData() { return false; } | |
424 virtual bool is_RetData() { return false; } | |
425 virtual bool is_BranchData() { return false; } | |
426 virtual bool is_ArrayData() { return false; } | |
427 virtual bool is_MultiBranchData() { return false; } | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
428 virtual bool is_ArgInfoData() { return false; } |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
429 |
0 | 430 |
431 BitData* as_BitData() { | |
432 assert(is_BitData(), "wrong type"); | |
433 return is_BitData() ? (BitData*) this : NULL; | |
434 } | |
435 CounterData* as_CounterData() { | |
436 assert(is_CounterData(), "wrong type"); | |
437 return is_CounterData() ? (CounterData*) this : NULL; | |
438 } | |
439 JumpData* as_JumpData() { | |
440 assert(is_JumpData(), "wrong type"); | |
441 return is_JumpData() ? (JumpData*) this : NULL; | |
442 } | |
443 ReceiverTypeData* as_ReceiverTypeData() { | |
444 assert(is_ReceiverTypeData(), "wrong type"); | |
445 return is_ReceiverTypeData() ? (ReceiverTypeData*)this : NULL; | |
446 } | |
447 VirtualCallData* as_VirtualCallData() { | |
448 assert(is_VirtualCallData(), "wrong type"); | |
449 return is_VirtualCallData() ? (VirtualCallData*)this : NULL; | |
450 } | |
451 RetData* as_RetData() { | |
452 assert(is_RetData(), "wrong type"); | |
453 return is_RetData() ? (RetData*) this : NULL; | |
454 } | |
455 BranchData* as_BranchData() { | |
456 assert(is_BranchData(), "wrong type"); | |
457 return is_BranchData() ? (BranchData*) this : NULL; | |
458 } | |
459 ArrayData* as_ArrayData() { | |
460 assert(is_ArrayData(), "wrong type"); | |
461 return is_ArrayData() ? (ArrayData*) this : NULL; | |
462 } | |
463 MultiBranchData* as_MultiBranchData() { | |
464 assert(is_MultiBranchData(), "wrong type"); | |
465 return is_MultiBranchData() ? (MultiBranchData*)this : NULL; | |
466 } | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
467 ArgInfoData* as_ArgInfoData() { |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
468 assert(is_ArgInfoData(), "wrong type"); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
469 return is_ArgInfoData() ? (ArgInfoData*)this : NULL; |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
470 } |
0 | 471 |
472 | |
473 // Subclass specific initialization | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
474 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {} |
0 | 475 |
476 // GC support | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
477 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) {} |
0 | 478 |
479 // CI translation: ProfileData can represent both MethodDataOop data | |
480 // as well as CIMethodData data. This function is provided for translating | |
481 // an oop in a ProfileData to the ci equivalent. Generally speaking, | |
482 // most ProfileData don't require any translation, so we provide the null | |
483 // translation here, and the required translators are in the ci subclasses. | |
484 virtual void translate_from(ProfileData* data) {} | |
485 | |
486 virtual void print_data_on(outputStream* st) { | |
487 ShouldNotReachHere(); | |
488 } | |
489 | |
490 #ifndef PRODUCT | |
491 void print_shared(outputStream* st, const char* name); | |
492 void tab(outputStream* st); | |
493 #endif | |
494 }; | |
495 | |
496 // BitData | |
497 // | |
498 // A BitData holds a flag or two in its header. | |
499 class BitData : public ProfileData { | |
500 protected: | |
501 enum { | |
502 // null_seen: | |
503 // saw a null operand (cast/aastore/instanceof) | |
504 null_seen_flag = DataLayout::first_flag + 0 | |
505 }; | |
506 enum { bit_cell_count = 0 }; // no additional data fields needed. | |
507 public: | |
508 BitData(DataLayout* layout) : ProfileData(layout) { | |
509 } | |
510 | |
511 virtual bool is_BitData() { return true; } | |
512 | |
513 static int static_cell_count() { | |
514 return bit_cell_count; | |
515 } | |
516 | |
517 virtual int cell_count() { | |
518 return static_cell_count(); | |
519 } | |
520 | |
521 // Accessor | |
522 | |
523 // The null_seen flag bit is specially known to the interpreter. | |
524 // Consulting it allows the compiler to avoid setting up null_check traps. | |
525 bool null_seen() { return flag_at(null_seen_flag); } | |
526 void set_null_seen() { set_flag_at(null_seen_flag); } | |
527 | |
528 | |
529 // Code generation support | |
530 static int null_seen_byte_constant() { | |
531 return flag_number_to_byte_constant(null_seen_flag); | |
532 } | |
533 | |
534 static ByteSize bit_data_size() { | |
535 return cell_offset(bit_cell_count); | |
536 } | |
537 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
538 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
539 static int bit_data_size_in_bytes() { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
540 return cell_offset_in_bytes(bit_cell_count); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
541 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
542 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
543 static void set_null_seen(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
544 set_flag_at(layout, null_seen_flag); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
545 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
546 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
547 static DataLayout* advance(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
548 return (DataLayout*) (((address)layout) + (ssize_t)BitData::bit_data_size_in_bytes()); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
549 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
550 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
551 |
0 | 552 #ifndef PRODUCT |
553 void print_data_on(outputStream* st); | |
554 #endif | |
555 }; | |
556 | |
557 // CounterData | |
558 // | |
559 // A CounterData corresponds to a simple counter. | |
560 class CounterData : public BitData { | |
561 protected: | |
562 enum { | |
563 count_off, | |
564 counter_cell_count | |
565 }; | |
566 public: | |
567 CounterData(DataLayout* layout) : BitData(layout) {} | |
568 | |
569 virtual bool is_CounterData() { return true; } | |
570 | |
571 static int static_cell_count() { | |
572 return counter_cell_count; | |
573 } | |
574 | |
575 virtual int cell_count() { | |
576 return static_cell_count(); | |
577 } | |
578 | |
579 // Direct accessor | |
580 uint count() { | |
581 return uint_at(count_off); | |
582 } | |
583 | |
584 // Code generation support | |
585 static ByteSize count_offset() { | |
586 return cell_offset(count_off); | |
587 } | |
588 static ByteSize counter_data_size() { | |
589 return cell_offset(counter_cell_count); | |
590 } | |
591 | |
1251
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
592 void set_count(uint count) { |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
593 set_uint_at(count_off, count); |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
594 } |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
595 |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
596 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
597 static int counter_data_size_in_bytes() { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
598 return cell_offset_in_bytes(counter_cell_count); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
599 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
600 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
601 static void increment_count_no_overflow(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
602 increment_uint_at_no_overflow(layout, count_off); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
603 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
604 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
605 // Support counter decrementation at checkcast / subtype check failed. |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
606 static void decrement_count(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
607 increment_uint_at_no_overflow(layout, count_off, -1); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
608 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
609 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
610 static DataLayout* advance(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
611 return (DataLayout*) (((address)layout) + (ssize_t)CounterData::counter_data_size_in_bytes()); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
612 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
613 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
614 |
0 | 615 #ifndef PRODUCT |
616 void print_data_on(outputStream* st); | |
617 #endif | |
618 }; | |
619 | |
620 // JumpData | |
621 // | |
622 // A JumpData is used to access profiling information for a direct | |
623 // branch. It is a counter, used for counting the number of branches, | |
624 // plus a data displacement, used for realigning the data pointer to | |
625 // the corresponding target bci. | |
626 class JumpData : public ProfileData { | |
627 protected: | |
628 enum { | |
629 taken_off_set, | |
630 displacement_off_set, | |
631 jump_cell_count | |
632 }; | |
633 | |
634 void set_displacement(int displacement) { | |
635 set_int_at(displacement_off_set, displacement); | |
636 } | |
637 | |
638 public: | |
639 JumpData(DataLayout* layout) : ProfileData(layout) { | |
640 assert(layout->tag() == DataLayout::jump_data_tag || | |
641 layout->tag() == DataLayout::branch_data_tag, "wrong type"); | |
642 } | |
643 | |
644 virtual bool is_JumpData() { return true; } | |
645 | |
646 static int static_cell_count() { | |
647 return jump_cell_count; | |
648 } | |
649 | |
650 virtual int cell_count() { | |
651 return static_cell_count(); | |
652 } | |
653 | |
654 // Direct accessor | |
655 uint taken() { | |
656 return uint_at(taken_off_set); | |
657 } | |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
658 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
659 void set_taken(uint cnt) { |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
660 set_uint_at(taken_off_set, cnt); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
661 } |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
662 |
0 | 663 // Saturating counter |
664 uint inc_taken() { | |
665 uint cnt = taken() + 1; | |
666 // Did we wrap? Will compiler screw us?? | |
667 if (cnt == 0) cnt--; | |
668 set_uint_at(taken_off_set, cnt); | |
669 return cnt; | |
670 } | |
671 | |
672 int displacement() { | |
673 return int_at(displacement_off_set); | |
674 } | |
675 | |
676 // Code generation support | |
677 static ByteSize taken_offset() { | |
678 return cell_offset(taken_off_set); | |
679 } | |
680 | |
681 static ByteSize displacement_offset() { | |
682 return cell_offset(displacement_off_set); | |
683 } | |
684 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
685 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
686 static void increment_taken_count_no_overflow(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
687 increment_uint_at_no_overflow(layout, taken_off_set); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
688 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
689 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
690 static DataLayout* advance_taken(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
691 return (DataLayout*) (((address)layout) + (ssize_t)int_at(layout, displacement_off_set)); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
692 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
693 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
694 static uint taken_count(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
695 return (uint) uint_at(layout, taken_off_set); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
696 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
697 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
698 |
0 | 699 // Specific initialization. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
700 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
0 | 701 |
702 #ifndef PRODUCT | |
703 void print_data_on(outputStream* st); | |
704 #endif | |
705 }; | |
706 | |
707 // ReceiverTypeData | |
708 // | |
709 // A ReceiverTypeData is used to access profiling information about a | |
710 // dynamic type check. It consists of a counter which counts the total times | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
711 // that the check is reached, and a series of (Klass*, count) pairs |
0 | 712 // which are used to store a type profile for the receiver of the check. |
713 class ReceiverTypeData : public CounterData { | |
714 protected: | |
715 enum { | |
716 receiver0_offset = counter_cell_count, | |
717 count0_offset, | |
718 receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset | |
719 }; | |
720 | |
721 public: | |
722 ReceiverTypeData(DataLayout* layout) : CounterData(layout) { | |
723 assert(layout->tag() == DataLayout::receiver_type_data_tag || | |
724 layout->tag() == DataLayout::virtual_call_data_tag, "wrong type"); | |
725 } | |
726 | |
727 virtual bool is_ReceiverTypeData() { return true; } | |
728 | |
729 static int static_cell_count() { | |
730 return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count; | |
731 } | |
732 | |
733 virtual int cell_count() { | |
734 return static_cell_count(); | |
735 } | |
736 | |
737 // Direct accessors | |
738 static uint row_limit() { | |
739 return TypeProfileWidth; | |
740 } | |
741 static int receiver_cell_index(uint row) { | |
742 return receiver0_offset + row * receiver_type_row_cell_count; | |
743 } | |
744 static int receiver_count_cell_index(uint row) { | |
745 return count0_offset + row * receiver_type_row_cell_count; | |
746 } | |
747 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
748 Klass* receiver(uint row) { |
0 | 749 assert(row < row_limit(), "oob"); |
750 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
751 Klass* recv = (Klass*)intptr_at(receiver_cell_index(row)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
752 assert(recv == NULL || recv->is_klass(), "wrong type"); |
0 | 753 return recv; |
754 } | |
755 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
756 void set_receiver(uint row, Klass* k) { |
941 | 757 assert((uint)row < row_limit(), "oob"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
758 set_intptr_at(receiver_cell_index(row), (uintptr_t)k); |
941 | 759 } |
760 | |
0 | 761 uint receiver_count(uint row) { |
762 assert(row < row_limit(), "oob"); | |
763 return uint_at(receiver_count_cell_index(row)); | |
764 } | |
765 | |
941 | 766 void set_receiver_count(uint row, uint count) { |
767 assert(row < row_limit(), "oob"); | |
768 set_uint_at(receiver_count_cell_index(row), count); | |
769 } | |
770 | |
771 void clear_row(uint row) { | |
772 assert(row < row_limit(), "oob"); | |
1251
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
773 // Clear total count - indicator of polymorphic call site. |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
774 // The site may look like as monomorphic after that but |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
775 // it allow to have more accurate profiling information because |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
776 // there was execution phase change since klasses were unloaded. |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
777 // If the site is still polymorphic then MDO will be updated |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
778 // to reflect it. But it could be the case that the site becomes |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
779 // only bimorphic. Then keeping total count not 0 will be wrong. |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
780 // Even if we use monomorphic (when it is not) for compilation |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
781 // we will only have trap, deoptimization and recompile again |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
782 // with updated MDO after executing method in Interpreter. |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
783 // An additional receiver will be recorded in the cleaned row |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
784 // during next call execution. |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
785 // |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
786 // Note: our profiling logic works with empty rows in any slot. |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
787 // We do sorting a profiling info (ciCallProfile) for compilation. |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
788 // |
576e77447e3c
6923002: assert(false,"this call site should not be polymorphic")
kvn
parents:
1206
diff
changeset
|
789 set_count(0); |
941 | 790 set_receiver(row, NULL); |
791 set_receiver_count(row, 0); | |
792 } | |
793 | |
0 | 794 // Code generation support |
795 static ByteSize receiver_offset(uint row) { | |
796 return cell_offset(receiver_cell_index(row)); | |
797 } | |
798 static ByteSize receiver_count_offset(uint row) { | |
799 return cell_offset(receiver_count_cell_index(row)); | |
800 } | |
801 static ByteSize receiver_type_data_size() { | |
802 return cell_offset(static_cell_count()); | |
803 } | |
804 | |
805 // GC support | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
806 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); |
0 | 807 |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
808 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
809 static int receiver_type_data_size_in_bytes() { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
810 return cell_offset_in_bytes(static_cell_count()); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
811 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
812 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
813 static Klass *receiver_unchecked(DataLayout* layout, uint row) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
814 oop recv = oop_at(layout, receiver_cell_index(row)); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
815 return (Klass *)recv; |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
816 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
817 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
818 static void increment_receiver_count_no_overflow(DataLayout* layout, Klass *rcvr) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
819 const int num_rows = row_limit(); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
820 // Receiver already exists? |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
821 for (int row = 0; row < num_rows; row++) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
822 if (receiver_unchecked(layout, row) == rcvr) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
823 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
824 return; |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
825 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
826 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
827 // New receiver, find a free slot. |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
828 for (int row = 0; row < num_rows; row++) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
829 if (receiver_unchecked(layout, row) == NULL) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
830 set_intptr_at(layout, receiver_cell_index(row), (intptr_t)rcvr); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
831 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
832 return; |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
833 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
834 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
835 // Receiver did not match any saved receiver and there is no empty row for it. |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
836 // Increment total counter to indicate polymorphic case. |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
837 increment_count_no_overflow(layout); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
838 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
839 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
840 static DataLayout* advance(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
841 return (DataLayout*) (((address)layout) + (ssize_t)ReceiverTypeData::receiver_type_data_size_in_bytes()); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
842 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
843 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
844 |
0 | 845 #ifndef PRODUCT |
846 void print_receiver_data_on(outputStream* st); | |
847 void print_data_on(outputStream* st); | |
848 #endif | |
849 }; | |
850 | |
851 // VirtualCallData | |
852 // | |
853 // A VirtualCallData is used to access profiling information about a | |
854 // virtual call. For now, it has nothing more than a ReceiverTypeData. | |
855 class VirtualCallData : public ReceiverTypeData { | |
856 public: | |
857 VirtualCallData(DataLayout* layout) : ReceiverTypeData(layout) { | |
858 assert(layout->tag() == DataLayout::virtual_call_data_tag, "wrong type"); | |
859 } | |
860 | |
861 virtual bool is_VirtualCallData() { return true; } | |
862 | |
863 static int static_cell_count() { | |
864 // At this point we could add more profile state, e.g., for arguments. | |
865 // But for now it's the same size as the base record type. | |
866 return ReceiverTypeData::static_cell_count(); | |
867 } | |
868 | |
869 virtual int cell_count() { | |
870 return static_cell_count(); | |
871 } | |
872 | |
873 // Direct accessors | |
874 static ByteSize virtual_call_data_size() { | |
875 return cell_offset(static_cell_count()); | |
876 } | |
877 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
878 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
879 static int virtual_call_data_size_in_bytes() { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
880 return cell_offset_in_bytes(static_cell_count()); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
881 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
882 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
883 static DataLayout* advance(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
884 return (DataLayout*) (((address)layout) + (ssize_t)VirtualCallData::virtual_call_data_size_in_bytes()); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
885 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
886 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
887 |
0 | 888 #ifndef PRODUCT |
889 void print_data_on(outputStream* st); | |
890 #endif | |
891 }; | |
892 | |
893 // RetData | |
894 // | |
895 // A RetData is used to access profiling information for a ret bytecode. | |
896 // It is composed of a count of the number of times that the ret has | |
897 // been executed, followed by a series of triples of the form | |
898 // (bci, count, di) which count the number of times that some bci was the | |
899 // target of the ret and cache a corresponding data displacement. | |
900 class RetData : public CounterData { | |
901 protected: | |
902 enum { | |
903 bci0_offset = counter_cell_count, | |
904 count0_offset, | |
905 displacement0_offset, | |
906 ret_row_cell_count = (displacement0_offset + 1) - bci0_offset | |
907 }; | |
908 | |
909 void set_bci(uint row, int bci) { | |
910 assert((uint)row < row_limit(), "oob"); | |
911 set_int_at(bci0_offset + row * ret_row_cell_count, bci); | |
912 } | |
913 void release_set_bci(uint row, int bci) { | |
914 assert((uint)row < row_limit(), "oob"); | |
915 // 'release' when setting the bci acts as a valid flag for other | |
916 // threads wrt bci_count and bci_displacement. | |
917 release_set_int_at(bci0_offset + row * ret_row_cell_count, bci); | |
918 } | |
919 void set_bci_count(uint row, uint count) { | |
920 assert((uint)row < row_limit(), "oob"); | |
921 set_uint_at(count0_offset + row * ret_row_cell_count, count); | |
922 } | |
923 void set_bci_displacement(uint row, int disp) { | |
924 set_int_at(displacement0_offset + row * ret_row_cell_count, disp); | |
925 } | |
926 | |
927 public: | |
928 RetData(DataLayout* layout) : CounterData(layout) { | |
929 assert(layout->tag() == DataLayout::ret_data_tag, "wrong type"); | |
930 } | |
931 | |
932 virtual bool is_RetData() { return true; } | |
933 | |
934 enum { | |
935 no_bci = -1 // value of bci when bci1/2 are not in use. | |
936 }; | |
937 | |
938 static int static_cell_count() { | |
939 return counter_cell_count + (uint) BciProfileWidth * ret_row_cell_count; | |
940 } | |
941 | |
942 virtual int cell_count() { | |
943 return static_cell_count(); | |
944 } | |
945 | |
946 static uint row_limit() { | |
947 return BciProfileWidth; | |
948 } | |
949 static int bci_cell_index(uint row) { | |
950 return bci0_offset + row * ret_row_cell_count; | |
951 } | |
952 static int bci_count_cell_index(uint row) { | |
953 return count0_offset + row * ret_row_cell_count; | |
954 } | |
955 static int bci_displacement_cell_index(uint row) { | |
956 return displacement0_offset + row * ret_row_cell_count; | |
957 } | |
958 | |
959 // Direct accessors | |
960 int bci(uint row) { | |
961 return int_at(bci_cell_index(row)); | |
962 } | |
963 uint bci_count(uint row) { | |
964 return uint_at(bci_count_cell_index(row)); | |
965 } | |
966 int bci_displacement(uint row) { | |
967 return int_at(bci_displacement_cell_index(row)); | |
968 } | |
969 | |
970 // Interpreter Runtime support | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
971 address fixup_ret(int return_bci, MethodData* mdo); |
0 | 972 |
973 // Code generation support | |
974 static ByteSize bci_offset(uint row) { | |
975 return cell_offset(bci_cell_index(row)); | |
976 } | |
977 static ByteSize bci_count_offset(uint row) { | |
978 return cell_offset(bci_count_cell_index(row)); | |
979 } | |
980 static ByteSize bci_displacement_offset(uint row) { | |
981 return cell_offset(bci_displacement_cell_index(row)); | |
982 } | |
983 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
984 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
985 static DataLayout* advance(MethodData *md, int bci); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
986 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
987 |
0 | 988 // Specific initialization. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
989 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
0 | 990 |
991 #ifndef PRODUCT | |
992 void print_data_on(outputStream* st); | |
993 #endif | |
994 }; | |
995 | |
996 // BranchData | |
997 // | |
998 // A BranchData is used to access profiling data for a two-way branch. | |
999 // It consists of taken and not_taken counts as well as a data displacement | |
1000 // for the taken case. | |
1001 class BranchData : public JumpData { | |
1002 protected: | |
1003 enum { | |
1004 not_taken_off_set = jump_cell_count, | |
1005 branch_cell_count | |
1006 }; | |
1007 | |
1008 void set_displacement(int displacement) { | |
1009 set_int_at(displacement_off_set, displacement); | |
1010 } | |
1011 | |
1012 public: | |
1013 BranchData(DataLayout* layout) : JumpData(layout) { | |
1014 assert(layout->tag() == DataLayout::branch_data_tag, "wrong type"); | |
1015 } | |
1016 | |
1017 virtual bool is_BranchData() { return true; } | |
1018 | |
1019 static int static_cell_count() { | |
1020 return branch_cell_count; | |
1021 } | |
1022 | |
1023 virtual int cell_count() { | |
1024 return static_cell_count(); | |
1025 } | |
1026 | |
1027 // Direct accessor | |
1028 uint not_taken() { | |
1029 return uint_at(not_taken_off_set); | |
1030 } | |
1031 | |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
1032 void set_not_taken(uint cnt) { |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
1033 set_uint_at(not_taken_off_set, cnt); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
1034 } |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3345
diff
changeset
|
1035 |
0 | 1036 uint inc_not_taken() { |
1037 uint cnt = not_taken() + 1; | |
1038 // Did we wrap? Will compiler screw us?? | |
1039 if (cnt == 0) cnt--; | |
1040 set_uint_at(not_taken_off_set, cnt); | |
1041 return cnt; | |
1042 } | |
1043 | |
1044 // Code generation support | |
1045 static ByteSize not_taken_offset() { | |
1046 return cell_offset(not_taken_off_set); | |
1047 } | |
1048 static ByteSize branch_data_size() { | |
1049 return cell_offset(branch_cell_count); | |
1050 } | |
1051 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1052 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1053 static int branch_data_size_in_bytes() { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1054 return cell_offset_in_bytes(branch_cell_count); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1055 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1056 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1057 static void increment_not_taken_count_no_overflow(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1058 increment_uint_at_no_overflow(layout, not_taken_off_set); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1059 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1060 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1061 static DataLayout* advance_not_taken(DataLayout* layout) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1062 return (DataLayout*) (((address)layout) + (ssize_t)BranchData::branch_data_size_in_bytes()); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1063 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1064 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1065 |
0 | 1066 // Specific initialization. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1067 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
0 | 1068 |
1069 #ifndef PRODUCT | |
1070 void print_data_on(outputStream* st); | |
1071 #endif | |
1072 }; | |
1073 | |
1074 // ArrayData | |
1075 // | |
1076 // A ArrayData is a base class for accessing profiling data which does | |
1077 // not have a statically known size. It consists of an array length | |
1078 // and an array start. | |
1079 class ArrayData : public ProfileData { | |
1080 protected: | |
1081 friend class DataLayout; | |
1082 | |
1083 enum { | |
1084 array_len_off_set, | |
1085 array_start_off_set | |
1086 }; | |
1087 | |
1088 uint array_uint_at(int index) { | |
1089 int aindex = index + array_start_off_set; | |
1090 return uint_at(aindex); | |
1091 } | |
1092 int array_int_at(int index) { | |
1093 int aindex = index + array_start_off_set; | |
1094 return int_at(aindex); | |
1095 } | |
1096 oop array_oop_at(int index) { | |
1097 int aindex = index + array_start_off_set; | |
1098 return oop_at(aindex); | |
1099 } | |
1100 void array_set_int_at(int index, int value) { | |
1101 int aindex = index + array_start_off_set; | |
1102 set_int_at(aindex, value); | |
1103 } | |
1104 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1105 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1106 // Static low level accessors for DataLayout with ArrayData's semantics. |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1107 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1108 static void increment_array_uint_at_no_overflow(DataLayout* layout, int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1109 int aindex = index + array_start_off_set; |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1110 increment_uint_at_no_overflow(layout, aindex); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1111 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1112 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1113 static int array_int_at(DataLayout* layout, int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1114 int aindex = index + array_start_off_set; |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1115 return int_at(layout, aindex); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1116 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1117 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1118 |
0 | 1119 // Code generation support for subclasses. |
1120 static ByteSize array_element_offset(int index) { | |
1121 return cell_offset(array_start_off_set + index); | |
1122 } | |
1123 | |
1124 public: | |
1125 ArrayData(DataLayout* layout) : ProfileData(layout) {} | |
1126 | |
1127 virtual bool is_ArrayData() { return true; } | |
1128 | |
1129 static int static_cell_count() { | |
1130 return -1; | |
1131 } | |
1132 | |
1133 int array_len() { | |
1134 return int_at_unchecked(array_len_off_set); | |
1135 } | |
1136 | |
1137 virtual int cell_count() { | |
1138 return array_len() + 1; | |
1139 } | |
1140 | |
1141 // Code generation support | |
1142 static ByteSize array_len_offset() { | |
1143 return cell_offset(array_len_off_set); | |
1144 } | |
1145 static ByteSize array_start_offset() { | |
1146 return cell_offset(array_start_off_set); | |
1147 } | |
1148 }; | |
1149 | |
1150 // MultiBranchData | |
1151 // | |
1152 // A MultiBranchData is used to access profiling information for | |
1153 // a multi-way branch (*switch bytecodes). It consists of a series | |
1154 // of (count, displacement) pairs, which count the number of times each | |
1155 // case was taken and specify the data displacment for each branch target. | |
1156 class MultiBranchData : public ArrayData { | |
1157 protected: | |
1158 enum { | |
1159 default_count_off_set, | |
1160 default_disaplacement_off_set, | |
1161 case_array_start | |
1162 }; | |
1163 enum { | |
1164 relative_count_off_set, | |
1165 relative_displacement_off_set, | |
1166 per_case_cell_count | |
1167 }; | |
1168 | |
1169 void set_default_displacement(int displacement) { | |
1170 array_set_int_at(default_disaplacement_off_set, displacement); | |
1171 } | |
1172 void set_displacement_at(int index, int displacement) { | |
1173 array_set_int_at(case_array_start + | |
1174 index * per_case_cell_count + | |
1175 relative_displacement_off_set, | |
1176 displacement); | |
1177 } | |
1178 | |
1179 public: | |
1180 MultiBranchData(DataLayout* layout) : ArrayData(layout) { | |
1181 assert(layout->tag() == DataLayout::multi_branch_data_tag, "wrong type"); | |
1182 } | |
1183 | |
1184 virtual bool is_MultiBranchData() { return true; } | |
1185 | |
1186 static int compute_cell_count(BytecodeStream* stream); | |
1187 | |
1188 int number_of_cases() { | |
1189 int alen = array_len() - 2; // get rid of default case here. | |
1190 assert(alen % per_case_cell_count == 0, "must be even"); | |
1191 return (alen / per_case_cell_count); | |
1192 } | |
1193 | |
1194 uint default_count() { | |
1195 return array_uint_at(default_count_off_set); | |
1196 } | |
1197 int default_displacement() { | |
1198 return array_int_at(default_disaplacement_off_set); | |
1199 } | |
1200 | |
1201 uint count_at(int index) { | |
1202 return array_uint_at(case_array_start + | |
1203 index * per_case_cell_count + | |
1204 relative_count_off_set); | |
1205 } | |
1206 int displacement_at(int index) { | |
1207 return array_int_at(case_array_start + | |
1208 index * per_case_cell_count + | |
1209 relative_displacement_off_set); | |
1210 } | |
1211 | |
1212 // Code generation support | |
1213 static ByteSize default_count_offset() { | |
1214 return array_element_offset(default_count_off_set); | |
1215 } | |
1216 static ByteSize default_displacement_offset() { | |
1217 return array_element_offset(default_disaplacement_off_set); | |
1218 } | |
1219 static ByteSize case_count_offset(int index) { | |
1220 return case_array_offset() + | |
1221 (per_case_size() * index) + | |
1222 relative_count_offset(); | |
1223 } | |
1224 static ByteSize case_array_offset() { | |
1225 return array_element_offset(case_array_start); | |
1226 } | |
1227 static ByteSize per_case_size() { | |
1228 return in_ByteSize(per_case_cell_count) * cell_size; | |
1229 } | |
1230 static ByteSize relative_count_offset() { | |
1231 return in_ByteSize(relative_count_off_set) * cell_size; | |
1232 } | |
1233 static ByteSize relative_displacement_offset() { | |
1234 return in_ByteSize(relative_displacement_off_set) * cell_size; | |
1235 } | |
1236 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1237 #ifdef CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1238 static void increment_count_no_overflow(DataLayout* layout, int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1239 if (index == -1) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1240 increment_array_uint_at_no_overflow(layout, default_count_off_set); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1241 } else { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1242 increment_array_uint_at_no_overflow(layout, case_array_start + |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1243 index * per_case_cell_count + |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1244 relative_count_off_set); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1245 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1246 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1247 |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1248 static DataLayout* advance(DataLayout* layout, int index) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1249 if (index == -1) { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1250 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, default_disaplacement_off_set)); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1251 } else { |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1252 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, case_array_start + |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1253 index * per_case_cell_count + |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1254 relative_displacement_off_set)); |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1255 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1256 } |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1257 #endif // CC_INTERP |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1258 |
0 | 1259 // Specific initialization. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1260 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
0 | 1261 |
1262 #ifndef PRODUCT | |
1263 void print_data_on(outputStream* st); | |
1264 #endif | |
1265 }; | |
1266 | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1267 class ArgInfoData : public ArrayData { |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1268 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1269 public: |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1270 ArgInfoData(DataLayout* layout) : ArrayData(layout) { |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1271 assert(layout->tag() == DataLayout::arg_info_data_tag, "wrong type"); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1272 } |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1273 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1274 virtual bool is_ArgInfoData() { return true; } |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1275 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1276 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1277 int number_of_args() { |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1278 return array_len(); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1279 } |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1280 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1281 uint arg_modified(int arg) { |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1282 return array_uint_at(arg); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1283 } |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1284 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1285 void set_arg_modified(int arg, uint val) { |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1286 array_set_int_at(arg, val); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1287 } |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1288 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1289 #ifndef PRODUCT |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1290 void print_data_on(outputStream* st); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1291 #endif |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1292 }; |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1293 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1294 // MethodData* |
0 | 1295 // |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1296 // A MethodData* holds information which has been collected about |
0 | 1297 // a method. Its layout looks like this: |
1298 // | |
1299 // ----------------------------- | |
1300 // | header | | |
1301 // | klass | | |
1302 // ----------------------------- | |
1303 // | method | | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1304 // | size of the MethodData* | |
0 | 1305 // ----------------------------- |
1306 // | Data entries... | | |
1307 // | (variable size) | | |
1308 // | | | |
1309 // . . | |
1310 // . . | |
1311 // . . | |
1312 // | | | |
1313 // ----------------------------- | |
1314 // | |
1315 // The data entry area is a heterogeneous array of DataLayouts. Each | |
1316 // DataLayout in the array corresponds to a specific bytecode in the | |
1317 // method. The entries in the array are sorted by the corresponding | |
1318 // bytecode. Access to the data is via resource-allocated ProfileData, | |
1319 // which point to the underlying blocks of DataLayout structures. | |
1320 // | |
1321 // During interpretation, if profiling in enabled, the interpreter | |
1322 // maintains a method data pointer (mdp), which points at the entry | |
1323 // in the array corresponding to the current bci. In the course of | |
1324 // intepretation, when a bytecode is encountered that has profile data | |
1325 // associated with it, the entry pointed to by mdp is updated, then the | |
1326 // mdp is adjusted to point to the next appropriate DataLayout. If mdp | |
1327 // is NULL to begin with, the interpreter assumes that the current method | |
1328 // is not (yet) being profiled. | |
1329 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1330 // In MethodData* parlance, "dp" is a "data pointer", the actual address |
0 | 1331 // of a DataLayout element. A "di" is a "data index", the offset in bytes |
1332 // from the base of the data entry array. A "displacement" is the byte offset | |
1333 // in certain ProfileData objects that indicate the amount the mdp must be | |
1334 // adjusted in the event of a change in control flow. | |
1335 // | |
1336 | |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1337 CC_INTERP_ONLY(class BytecodeInterpreter;) |
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1338 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1339 class MethodData : public Metadata { |
0 | 1340 friend class VMStructs; |
14420
abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents:
10265
diff
changeset
|
1341 CC_INTERP_ONLY(friend class BytecodeInterpreter;) |
0 | 1342 private: |
1343 friend class ProfileData; | |
1344 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1345 // Back pointer to the Method* |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1346 Method* _method; |
0 | 1347 |
1348 // Size of this oop in bytes | |
1349 int _size; | |
1350 | |
1351 // Cached hint for bci_to_dp and bci_to_data | |
1352 int _hint_di; | |
1353 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1354 MethodData(methodHandle method, int size, TRAPS); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1355 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1356 static MethodData* allocate(ClassLoaderData* loader_data, methodHandle method, TRAPS); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1357 MethodData() {}; // For ciMethodData |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1358 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1359 bool is_methodData() const volatile { return true; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1360 |
0 | 1361 // Whole-method sticky bits and flags |
1362 enum { | |
3345 | 1363 _trap_hist_limit = 17, // decoupled from Deoptimization::Reason_LIMIT |
0 | 1364 _trap_hist_mask = max_jubyte, |
1365 _extra_data_count = 4 // extra DataLayout headers, for trap history | |
1366 }; // Public flag values | |
1367 private: | |
1368 uint _nof_decompiles; // count of all nmethod removals | |
1369 uint _nof_overflow_recompiles; // recompile count, excluding recomp. bits | |
1370 uint _nof_overflow_traps; // trap count, excluding _trap_hist | |
1371 union { | |
1372 intptr_t _align; | |
1373 u1 _array[_trap_hist_limit]; | |
1374 } _trap_hist; | |
1375 | |
1376 // Support for interprocedural escape analysis, from Thomas Kotzmann. | |
1377 intx _eflags; // flags on escape information | |
1378 intx _arg_local; // bit set of non-escaping arguments | |
1379 intx _arg_stack; // bit set of stack-allocatable arguments | |
1380 intx _arg_returned; // bit set of returned arguments | |
1381 | |
1783 | 1382 int _creation_mileage; // method mileage at MDO creation |
1383 | |
1384 // How many invocations has this MDO seen? | |
1385 // These counters are used to determine the exact age of MDO. | |
1386 // We need those because in tiered a method can be concurrently | |
1387 // executed at different levels. | |
1388 InvocationCounter _invocation_counter; | |
1389 // Same for backedges. | |
1390 InvocationCounter _backedge_counter; | |
2252 | 1391 // Counter values at the time profiling started. |
1392 int _invocation_counter_start; | |
1393 int _backedge_counter_start; | |
1783 | 1394 // Number of loops and blocks is computed when compiling the first |
1395 // time with C1. It is used to determine if method is trivial. | |
1396 short _num_loops; | |
1397 short _num_blocks; | |
1398 // Highest compile level this method has ever seen. | |
1399 u1 _highest_comp_level; | |
1400 // Same for OSR level | |
1401 u1 _highest_osr_comp_level; | |
1402 // Does this method contain anything worth profiling? | |
1403 bool _would_profile; | |
0 | 1404 |
1405 // Size of _data array in bytes. (Excludes header and extra_data fields.) | |
1406 int _data_size; | |
1407 | |
1408 // Beginning of the data entries | |
1409 intptr_t _data[1]; | |
1410 | |
1411 // Helper for size computation | |
1412 static int compute_data_size(BytecodeStream* stream); | |
1413 static int bytecode_cell_count(Bytecodes::Code code); | |
1414 enum { no_profile_data = -1, variable_cell_count = -2 }; | |
1415 | |
1416 // Helper for initialization | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1417 DataLayout* data_layout_at(int data_index) const { |
0 | 1418 assert(data_index % sizeof(intptr_t) == 0, "unaligned"); |
1419 return (DataLayout*) (((address)_data) + data_index); | |
1420 } | |
1421 | |
1422 // Initialize an individual data segment. Returns the size of | |
1423 // the segment in bytes. | |
1424 int initialize_data(BytecodeStream* stream, int data_index); | |
1425 | |
1426 // Helper for data_at | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1427 DataLayout* limit_data_position() const { |
0 | 1428 return (DataLayout*)((address)data_base() + _data_size); |
1429 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1430 bool out_of_bounds(int data_index) const { |
0 | 1431 return data_index >= data_size(); |
1432 } | |
1433 | |
1434 // Give each of the data entries a chance to perform specific | |
1435 // data initialization. | |
1436 void post_initialize(BytecodeStream* stream); | |
1437 | |
1438 // hint accessors | |
1439 int hint_di() const { return _hint_di; } | |
1440 void set_hint_di(int di) { | |
1441 assert(!out_of_bounds(di), "hint_di out of bounds"); | |
1442 _hint_di = di; | |
1443 } | |
1444 ProfileData* data_before(int bci) { | |
1445 // avoid SEGV on this edge case | |
1446 if (data_size() == 0) | |
1447 return NULL; | |
1448 int hint = hint_di(); | |
1449 if (data_layout_at(hint)->bci() <= bci) | |
1450 return data_at(hint); | |
1451 return first_data(); | |
1452 } | |
1453 | |
1454 // What is the index of the first data entry? | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1455 int first_di() const { return 0; } |
0 | 1456 |
1457 // Find or create an extra ProfileData: | |
1458 ProfileData* bci_to_extra_data(int bci, bool create_if_missing); | |
1459 | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1460 // return the argument info cell |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1461 ArgInfoData *arg_info(); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1462 |
0 | 1463 public: |
1464 static int header_size() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1465 return sizeof(MethodData)/wordSize; |
0 | 1466 } |
1467 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1468 // Compute the size of a MethodData* before it is created. |
0 | 1469 static int compute_allocation_size_in_bytes(methodHandle method); |
1470 static int compute_allocation_size_in_words(methodHandle method); | |
1471 static int compute_extra_data_count(int data_size, int empty_bc_count); | |
1472 | |
1473 // Determine if a given bytecode can have profile information. | |
1474 static bool bytecode_has_profile(Bytecodes::Code code) { | |
1475 return bytecode_cell_count(code) != no_profile_data; | |
1476 } | |
1477 | |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8000
diff
changeset
|
1478 // reset into original state |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8000
diff
changeset
|
1479 void init(); |
0 | 1480 |
1481 // My size | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1482 int size_in_bytes() const { return _size; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1483 int size() const { return align_object_size(align_size_up(_size, BytesPerWord)/BytesPerWord); } |
7956 | 1484 #if INCLUDE_SERVICES |
1485 void collect_statistics(KlassSizeStats *sz) const; | |
1486 #endif | |
0 | 1487 |
1488 int creation_mileage() const { return _creation_mileage; } | |
1489 void set_creation_mileage(int x) { _creation_mileage = x; } | |
1783 | 1490 |
1491 int invocation_count() { | |
1492 if (invocation_counter()->carry()) { | |
1493 return InvocationCounter::count_limit; | |
1494 } | |
1495 return invocation_counter()->count(); | |
1496 } | |
1497 int backedge_count() { | |
1498 if (backedge_counter()->carry()) { | |
1499 return InvocationCounter::count_limit; | |
1500 } | |
1501 return backedge_counter()->count(); | |
1502 } | |
1503 | |
2252 | 1504 int invocation_count_start() { |
1505 if (invocation_counter()->carry()) { | |
1506 return 0; | |
1507 } | |
1508 return _invocation_counter_start; | |
1509 } | |
1510 | |
1511 int backedge_count_start() { | |
1512 if (backedge_counter()->carry()) { | |
1513 return 0; | |
1514 } | |
1515 return _backedge_counter_start; | |
1516 } | |
1517 | |
1518 int invocation_count_delta() { return invocation_count() - invocation_count_start(); } | |
1519 int backedge_count_delta() { return backedge_count() - backedge_count_start(); } | |
1520 | |
1521 void reset_start_counters() { | |
1522 _invocation_counter_start = invocation_count(); | |
1523 _backedge_counter_start = backedge_count(); | |
1524 } | |
1525 | |
1783 | 1526 InvocationCounter* invocation_counter() { return &_invocation_counter; } |
1527 InvocationCounter* backedge_counter() { return &_backedge_counter; } | |
1528 | |
1529 void set_would_profile(bool p) { _would_profile = p; } | |
1530 bool would_profile() const { return _would_profile; } | |
1531 | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
9080
diff
changeset
|
1532 int highest_comp_level() const { return _highest_comp_level; } |
1783 | 1533 void set_highest_comp_level(int level) { _highest_comp_level = level; } |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
9080
diff
changeset
|
1534 int highest_osr_comp_level() const { return _highest_osr_comp_level; } |
1783 | 1535 void set_highest_osr_comp_level(int level) { _highest_osr_comp_level = level; } |
1536 | |
1537 int num_loops() const { return _num_loops; } | |
1538 void set_num_loops(int n) { _num_loops = n; } | |
1539 int num_blocks() const { return _num_blocks; } | |
1540 void set_num_blocks(int n) { _num_blocks = n; } | |
1541 | |
0 | 1542 bool is_mature() const; // consult mileage and ProfileMaturityPercentage |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1543 static int mileage_of(Method* m); |
0 | 1544 |
1545 // Support for interprocedural escape analysis, from Thomas Kotzmann. | |
1546 enum EscapeFlag { | |
1547 estimated = 1 << 0, | |
78
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
1548 return_local = 1 << 1, |
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
1549 return_allocated = 1 << 2, |
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
1550 allocated_escapes = 1 << 3, |
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
1551 unknown_modified = 1 << 4 |
0 | 1552 }; |
1553 | |
1554 intx eflags() { return _eflags; } | |
1555 intx arg_local() { return _arg_local; } | |
1556 intx arg_stack() { return _arg_stack; } | |
1557 intx arg_returned() { return _arg_returned; } | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1558 uint arg_modified(int a) { ArgInfoData *aid = arg_info(); |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8000
diff
changeset
|
1559 assert(aid != NULL, "arg_info must be not null"); |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1560 assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1561 return aid->arg_modified(a); } |
0 | 1562 |
1563 void set_eflags(intx v) { _eflags = v; } | |
1564 void set_arg_local(intx v) { _arg_local = v; } | |
1565 void set_arg_stack(intx v) { _arg_stack = v; } | |
1566 void set_arg_returned(intx v) { _arg_returned = v; } | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1567 void set_arg_modified(int a, uint v) { ArgInfoData *aid = arg_info(); |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8000
diff
changeset
|
1568 assert(aid != NULL, "arg_info must be not null"); |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1569 assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
1570 aid->set_arg_modified(a, v); } |
0 | 1571 |
1572 void clear_escape_info() { _eflags = _arg_local = _arg_stack = _arg_returned = 0; } | |
1573 | |
1574 // Location and size of data area | |
1575 address data_base() const { | |
1576 return (address) _data; | |
1577 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1578 int data_size() const { |
0 | 1579 return _data_size; |
1580 } | |
1581 | |
1582 // Accessors | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1583 Method* method() const { return _method; } |
0 | 1584 |
1585 // Get the data at an arbitrary (sort of) data index. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1586 ProfileData* data_at(int data_index) const; |
0 | 1587 |
1588 // Walk through the data in order. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1589 ProfileData* first_data() const { return data_at(first_di()); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1590 ProfileData* next_data(ProfileData* current) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1591 bool is_valid(ProfileData* current) const { return current != NULL; } |
0 | 1592 |
1593 // Convert a dp (data pointer) to a di (data index). | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1594 int dp_to_di(address dp) const { |
0 | 1595 return dp - ((address)_data); |
1596 } | |
1597 | |
1598 address di_to_dp(int di) { | |
1599 return (address)data_layout_at(di); | |
1600 } | |
1601 | |
1602 // bci to di/dp conversion. | |
1603 address bci_to_dp(int bci); | |
1604 int bci_to_di(int bci) { | |
1605 return dp_to_di(bci_to_dp(bci)); | |
1606 } | |
1607 | |
1608 // Get the data at an arbitrary bci, or NULL if there is none. | |
1609 ProfileData* bci_to_data(int bci); | |
1610 | |
1611 // Same, but try to create an extra_data record if one is needed: | |
1612 ProfileData* allocate_bci_to_data(int bci) { | |
1613 ProfileData* data = bci_to_data(bci); | |
1614 return (data != NULL) ? data : bci_to_extra_data(bci, true); | |
1615 } | |
1616 | |
1617 // Add a handful of extra data records, for trap tracking. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1618 DataLayout* extra_data_base() const { return limit_data_position(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1619 DataLayout* extra_data_limit() const { return (DataLayout*)((address)this + size_in_bytes()); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1620 int extra_data_size() const { return (address)extra_data_limit() |
0 | 1621 - (address)extra_data_base(); } |
1622 static DataLayout* next_extra(DataLayout* dp) { return (DataLayout*)((address)dp + in_bytes(DataLayout::cell_offset(0))); } | |
1623 | |
1624 // Return (uint)-1 for overflow. | |
1625 uint trap_count(int reason) const { | |
1626 assert((uint)reason < _trap_hist_limit, "oob"); | |
1627 return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1; | |
1628 } | |
1629 // For loops: | |
1630 static uint trap_reason_limit() { return _trap_hist_limit; } | |
1631 static uint trap_count_limit() { return _trap_hist_mask; } | |
1632 uint inc_trap_count(int reason) { | |
1633 // Count another trap, anywhere in this method. | |
1634 assert(reason >= 0, "must be single trap"); | |
1635 if ((uint)reason < _trap_hist_limit) { | |
1636 uint cnt1 = 1 + _trap_hist._array[reason]; | |
1637 if ((cnt1 & _trap_hist_mask) != 0) { // if no counter overflow... | |
1638 _trap_hist._array[reason] = cnt1; | |
1639 return cnt1; | |
1640 } else { | |
1641 return _trap_hist_mask + (++_nof_overflow_traps); | |
1642 } | |
1643 } else { | |
1644 // Could not represent the count in the histogram. | |
1645 return (++_nof_overflow_traps); | |
1646 } | |
1647 } | |
1648 | |
1649 uint overflow_trap_count() const { | |
1650 return _nof_overflow_traps; | |
1651 } | |
1652 uint overflow_recompile_count() const { | |
1653 return _nof_overflow_recompiles; | |
1654 } | |
1655 void inc_overflow_recompile_count() { | |
1656 _nof_overflow_recompiles += 1; | |
1657 } | |
1658 uint decompile_count() const { | |
1659 return _nof_decompiles; | |
1660 } | |
1661 void inc_decompile_count() { | |
1662 _nof_decompiles += 1; | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
948
diff
changeset
|
1663 if (decompile_count() > (uint)PerMethodRecompilationCutoff) { |
7998 | 1664 method()->set_not_compilable(CompLevel_full_optimization, true, "decompile_count > PerMethodRecompilationCutoff"); |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
948
diff
changeset
|
1665 } |
0 | 1666 } |
1667 | |
1668 // Support for code generation | |
1669 static ByteSize data_offset() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1670 return byte_offset_of(MethodData, _data[0]); |
0 | 1671 } |
1672 | |
1783 | 1673 static ByteSize invocation_counter_offset() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1674 return byte_offset_of(MethodData, _invocation_counter); |
1783 | 1675 } |
1676 static ByteSize backedge_counter_offset() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1677 return byte_offset_of(MethodData, _backedge_counter); |
1783 | 1678 } |
1679 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1680 // Deallocation support - no pointer fields to deallocate |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1681 void deallocate_contents(ClassLoaderData* loader_data) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1682 |
0 | 1683 // GC support |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1684 void set_size(int object_size_in_bytes) { _size = object_size_in_bytes; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1685 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1686 // Printing |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1687 #ifndef PRODUCT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1688 void print_on (outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1689 #endif |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1690 void print_value_on(outputStream* st) const; |
0 | 1691 |
1692 #ifndef PRODUCT | |
1693 // printing support for method data | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1694 void print_data_on(outputStream* st) const; |
0 | 1695 #endif |
1696 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1697 const char* internal_name() const { return "{method data}"; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1698 |
0 | 1699 // verification |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3905
diff
changeset
|
1700 void verify_on(outputStream* st); |
0 | 1701 void verify_data_on(outputStream* st); |
1702 }; | |
1972 | 1703 |
1704 #endif // SHARE_VM_OOPS_METHODDATAOOP_HPP |