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