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