Mercurial > hg > truffle
comparison src/share/vm/ci/ciMethodData.cpp @ 18058:54bc75c144b0
Merge
author | asaha |
---|---|
date | Thu, 29 May 2014 13:14:25 -0700 |
parents | 78bbf4d43a14 |
children | 52b4284cb496 2c6ef90f030a |
comparison
equal
deleted
inserted
replaced
18055:1fa005fb28f5 | 18058:54bc75c144b0 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
76 // Initialize the escape information (to "don't know."); | 76 // Initialize the escape information (to "don't know."); |
77 _eflags = _arg_local = _arg_stack = _arg_returned = 0; | 77 _eflags = _arg_local = _arg_stack = _arg_returned = 0; |
78 _parameters = NULL; | 78 _parameters = NULL; |
79 } | 79 } |
80 | 80 |
81 void ciMethodData::load_extra_data() { | |
82 MethodData* mdo = get_MethodData(); | |
83 | |
84 // speculative trap entries also hold a pointer to a Method so need to be translated | |
85 DataLayout* dp_src = mdo->extra_data_base(); | |
86 DataLayout* end_src = mdo->extra_data_limit(); | |
87 DataLayout* dp_dst = extra_data_base(); | |
88 for (;; dp_src = MethodData::next_extra(dp_src), dp_dst = MethodData::next_extra(dp_dst)) { | |
89 assert(dp_src < end_src, "moved past end of extra data"); | |
90 // New traps in the MDO can be added as we translate the copy so | |
91 // look at the entries in the copy. | |
92 switch(dp_dst->tag()) { | |
93 case DataLayout::speculative_trap_data_tag: { | |
94 ciSpeculativeTrapData* data_dst = new ciSpeculativeTrapData(dp_dst); | |
95 SpeculativeTrapData* data_src = new SpeculativeTrapData(dp_src); | |
96 data_dst->translate_from(data_src); | |
97 break; | |
98 } | |
99 case DataLayout::bit_data_tag: | |
100 break; | |
101 case DataLayout::no_tag: | |
102 case DataLayout::arg_info_data_tag: | |
103 // An empty slot or ArgInfoData entry marks the end of the trap data | |
104 return; | |
105 default: | |
106 fatal(err_msg("bad tag = %d", dp_dst->tag())); | |
107 } | |
108 } | |
109 } | |
110 | |
81 void ciMethodData::load_data() { | 111 void ciMethodData::load_data() { |
82 MethodData* mdo = get_MethodData(); | 112 MethodData* mdo = get_MethodData(); |
83 if (mdo == NULL) { | 113 if (mdo == NULL) { |
84 return; | 114 return; |
85 } | 115 } |
114 _parameters = data_layout_at(mdo->parameters_type_data_di()); | 144 _parameters = data_layout_at(mdo->parameters_type_data_di()); |
115 ciParametersTypeData* parameters = new ciParametersTypeData(_parameters); | 145 ciParametersTypeData* parameters = new ciParametersTypeData(_parameters); |
116 parameters->translate_from(mdo->parameters_type_data()); | 146 parameters->translate_from(mdo->parameters_type_data()); |
117 } | 147 } |
118 | 148 |
149 load_extra_data(); | |
150 | |
119 // Note: Extra data are all BitData, and do not need translation. | 151 // Note: Extra data are all BitData, and do not need translation. |
120 _current_mileage = MethodData::mileage_of(mdo->method()); | 152 _current_mileage = MethodData::mileage_of(mdo->method()); |
121 _invocation_counter = mdo->invocation_count(); | 153 _invocation_counter = mdo->invocation_count(); |
122 _backedge_counter = mdo->backedge_count(); | 154 _backedge_counter = mdo->backedge_count(); |
123 _state = mdo->is_mature()? mature_state: immature_state; | 155 _state = mdo->is_mature()? mature_state: immature_state; |
152 } | 184 } |
153 | 185 |
154 void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) { | 186 void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) { |
155 intptr_t k = ret->type(); | 187 intptr_t k = ret->type(); |
156 set_type(translate_klass(k)); | 188 set_type(translate_klass(k)); |
189 } | |
190 | |
191 void ciSpeculativeTrapData::translate_from(const ProfileData* data) { | |
192 Method* m = data->as_SpeculativeTrapData()->method(); | |
193 ciMethod* ci_m = CURRENT_ENV->get_method(m); | |
194 set_method(ci_m); | |
157 } | 195 } |
158 | 196 |
159 // Get the data at an arbitrary (sort of) data index. | 197 // Get the data at an arbitrary (sort of) data index. |
160 ciProfileData* ciMethodData::data_at(int data_index) { | 198 ciProfileData* ciMethodData::data_at(int data_index) { |
161 if (out_of_bounds(data_index)) { | 199 if (out_of_bounds(data_index)) { |
201 int next_index = current_index + current->size_in_bytes(); | 239 int next_index = current_index + current->size_in_bytes(); |
202 ciProfileData* next = data_at(next_index); | 240 ciProfileData* next = data_at(next_index); |
203 return next; | 241 return next; |
204 } | 242 } |
205 | 243 |
206 // Translate a bci to its corresponding data, or NULL. | 244 ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots) { |
207 ciProfileData* ciMethodData::bci_to_data(int bci) { | |
208 ciProfileData* data = data_before(bci); | |
209 for ( ; is_valid(data); data = next_data(data)) { | |
210 if (data->bci() == bci) { | |
211 set_hint_di(dp_to_di(data->dp())); | |
212 return data; | |
213 } else if (data->bci() > bci) { | |
214 break; | |
215 } | |
216 } | |
217 // bci_to_extra_data(bci) ... | 245 // bci_to_extra_data(bci) ... |
218 DataLayout* dp = data_layout_at(data_size()); | 246 DataLayout* dp = data_layout_at(data_size()); |
219 DataLayout* end = data_layout_at(data_size() + extra_data_size()); | 247 DataLayout* end = data_layout_at(data_size() + extra_data_size()); |
220 for (; dp < end; dp = MethodData::next_extra(dp)) { | 248 two_free_slots = false; |
221 if (dp->tag() == DataLayout::no_tag) { | 249 for (;dp < end; dp = MethodData::next_extra(dp)) { |
250 switch(dp->tag()) { | |
251 case DataLayout::no_tag: | |
222 _saw_free_extra_data = true; // observed an empty slot (common case) | 252 _saw_free_extra_data = true; // observed an empty slot (common case) |
253 two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag); | |
223 return NULL; | 254 return NULL; |
224 } | 255 case DataLayout::arg_info_data_tag: |
225 if (dp->tag() == DataLayout::arg_info_data_tag) { | 256 return NULL; // ArgInfoData is at the end of extra data section. |
226 break; // ArgInfoData is at the end of extra data section. | 257 case DataLayout::bit_data_tag: |
227 } | 258 if (m == NULL && dp->bci() == bci) { |
228 if (dp->bci() == bci) { | 259 return new ciBitData(dp); |
229 assert(dp->tag() == DataLayout::bit_data_tag, "sane"); | 260 } |
230 return new ciBitData(dp); | 261 break; |
231 } | 262 case DataLayout::speculative_trap_data_tag: { |
263 ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp); | |
264 // data->method() might be null if the MDO is snapshotted | |
265 // concurrently with a trap | |
266 if (m != NULL && data->method() == m && dp->bci() == bci) { | |
267 return data; | |
268 } | |
269 break; | |
270 } | |
271 default: | |
272 fatal(err_msg("bad tag = %d", dp->tag())); | |
273 } | |
274 } | |
275 return NULL; | |
276 } | |
277 | |
278 // Translate a bci to its corresponding data, or NULL. | |
279 ciProfileData* ciMethodData::bci_to_data(int bci, ciMethod* m) { | |
280 // If m is not NULL we look for a SpeculativeTrapData entry | |
281 if (m == NULL) { | |
282 ciProfileData* data = data_before(bci); | |
283 for ( ; is_valid(data); data = next_data(data)) { | |
284 if (data->bci() == bci) { | |
285 set_hint_di(dp_to_di(data->dp())); | |
286 return data; | |
287 } else if (data->bci() > bci) { | |
288 break; | |
289 } | |
290 } | |
291 } | |
292 bool two_free_slots = false; | |
293 ciProfileData* result = bci_to_extra_data(bci, m, two_free_slots); | |
294 if (result != NULL) { | |
295 return result; | |
296 } | |
297 if (m != NULL && !two_free_slots) { | |
298 // We were looking for a SpeculativeTrapData entry we didn't | |
299 // find. Room is not available for more SpeculativeTrapData | |
300 // entries, look in the non SpeculativeTrapData entries. | |
301 return bci_to_data(bci, NULL); | |
232 } | 302 } |
233 return NULL; | 303 return NULL; |
234 } | 304 } |
235 | 305 |
236 // Conservatively decode the trap_state of a ciProfileData. | 306 // Conservatively decode the trap_state of a ciProfileData. |
485 ciKlass* k = vdata->receiver(i); | 555 ciKlass* k = vdata->receiver(i); |
486 if (k != NULL) { | 556 if (k != NULL) { |
487 if (round == 0) { | 557 if (round == 0) { |
488 count++; | 558 count++; |
489 } else { | 559 } else { |
490 out->print(" %d %s", dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t), k->name()->as_quoted_ascii()); | 560 out->print(" %d %s", (int)(dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t)), k->name()->as_quoted_ascii()); |
491 } | 561 } |
492 } | 562 } |
493 } | 563 } |
494 } else if (pdata->is_VirtualCallData()) { | 564 } else if (pdata->is_VirtualCallData()) { |
495 ciVirtualCallData* vdata = (ciVirtualCallData*)pdata; | 565 ciVirtualCallData* vdata = (ciVirtualCallData*)pdata; |
497 ciKlass* k = vdata->receiver(i); | 567 ciKlass* k = vdata->receiver(i); |
498 if (k != NULL) { | 568 if (k != NULL) { |
499 if (round == 0) { | 569 if (round == 0) { |
500 count++; | 570 count++; |
501 } else { | 571 } else { |
502 out->print(" %d %s", dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t), k->name()->as_quoted_ascii()); | 572 out->print(" %d %s", (int)(dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t)), k->name()->as_quoted_ascii()); |
503 } | 573 } |
504 } | 574 } |
505 } | 575 } |
506 } | 576 } |
507 } | 577 } |
523 data->print_data_on(st); | 593 data->print_data_on(st); |
524 } | 594 } |
525 st->print_cr("--- Extra data:"); | 595 st->print_cr("--- Extra data:"); |
526 DataLayout* dp = data_layout_at(data_size()); | 596 DataLayout* dp = data_layout_at(data_size()); |
527 DataLayout* end = data_layout_at(data_size() + extra_data_size()); | 597 DataLayout* end = data_layout_at(data_size() + extra_data_size()); |
528 for (; dp < end; dp = MethodData::next_extra(dp)) { | 598 for (;; dp = MethodData::next_extra(dp)) { |
529 if (dp->tag() == DataLayout::no_tag) continue; | 599 assert(dp < end, "moved past end of extra data"); |
530 if (dp->tag() == DataLayout::bit_data_tag) { | 600 switch (dp->tag()) { |
601 case DataLayout::no_tag: | |
602 continue; | |
603 case DataLayout::bit_data_tag: | |
531 data = new BitData(dp); | 604 data = new BitData(dp); |
532 } else { | 605 break; |
533 assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo"); | 606 case DataLayout::arg_info_data_tag: |
534 data = new ciArgInfoData(dp); | 607 data = new ciArgInfoData(dp); |
535 dp = end; // ArgInfoData is at the end of extra data section. | 608 dp = end; // ArgInfoData is at the end of extra data section. |
609 break; | |
610 default: | |
611 fatal(err_msg("unexpected tag %d", dp->tag())); | |
536 } | 612 } |
537 st->print("%d", dp_to_di(data->dp())); | 613 st->print("%d", dp_to_di(data->dp())); |
538 st->fill_to(6); | 614 st->fill_to(6); |
539 data->print_data_on(st); | 615 data->print_data_on(st); |
616 if (dp >= end) return; | |
540 } | 617 } |
541 } | 618 } |
542 | 619 |
543 void ciTypeEntries::print_ciklass(outputStream* st, intptr_t k) { | 620 void ciTypeEntries::print_ciklass(outputStream* st, intptr_t k) { |
544 if (TypeEntries::is_type_none(k)) { | 621 if (TypeEntries::is_type_none(k)) { |
567 st->print("ret "); | 644 st->print("ret "); |
568 print_ciklass(st, type()); | 645 print_ciklass(st, type()); |
569 st->cr(); | 646 st->cr(); |
570 } | 647 } |
571 | 648 |
572 void ciCallTypeData::print_data_on(outputStream* st) const { | 649 void ciCallTypeData::print_data_on(outputStream* st, const char* extra) const { |
573 print_shared(st, "ciCallTypeData"); | 650 print_shared(st, "ciCallTypeData", extra); |
574 if (has_arguments()) { | 651 if (has_arguments()) { |
575 tab(st, true); | 652 tab(st, true); |
576 st->print("argument types"); | 653 st->print("argument types"); |
577 args()->print_data_on(st); | 654 args()->print_data_on(st); |
578 } | 655 } |
597 st->print_cr("(%u)", receiver_count(row)); | 674 st->print_cr("(%u)", receiver_count(row)); |
598 } | 675 } |
599 } | 676 } |
600 } | 677 } |
601 | 678 |
602 void ciReceiverTypeData::print_data_on(outputStream* st) const { | 679 void ciReceiverTypeData::print_data_on(outputStream* st, const char* extra) const { |
603 print_shared(st, "ciReceiverTypeData"); | 680 print_shared(st, "ciReceiverTypeData", extra); |
604 print_receiver_data_on(st); | 681 print_receiver_data_on(st); |
605 } | 682 } |
606 | 683 |
607 void ciVirtualCallData::print_data_on(outputStream* st) const { | 684 void ciVirtualCallData::print_data_on(outputStream* st, const char* extra) const { |
608 print_shared(st, "ciVirtualCallData"); | 685 print_shared(st, "ciVirtualCallData", extra); |
609 rtd_super()->print_receiver_data_on(st); | 686 rtd_super()->print_receiver_data_on(st); |
610 } | 687 } |
611 | 688 |
612 void ciVirtualCallTypeData::print_data_on(outputStream* st) const { | 689 void ciVirtualCallTypeData::print_data_on(outputStream* st, const char* extra) const { |
613 print_shared(st, "ciVirtualCallTypeData"); | 690 print_shared(st, "ciVirtualCallTypeData", extra); |
614 rtd_super()->print_receiver_data_on(st); | 691 rtd_super()->print_receiver_data_on(st); |
615 if (has_arguments()) { | 692 if (has_arguments()) { |
616 tab(st, true); | 693 tab(st, true); |
617 st->print("argument types"); | 694 st->print("argument types"); |
618 args()->print_data_on(st); | 695 args()->print_data_on(st); |
622 st->print("return type"); | 699 st->print("return type"); |
623 ret()->print_data_on(st); | 700 ret()->print_data_on(st); |
624 } | 701 } |
625 } | 702 } |
626 | 703 |
627 void ciParametersTypeData::print_data_on(outputStream* st) const { | 704 void ciParametersTypeData::print_data_on(outputStream* st, const char* extra) const { |
628 st->print_cr("Parametertypes"); | 705 st->print_cr("ciParametersTypeData"); |
629 parameters()->print_data_on(st); | 706 parameters()->print_data_on(st); |
630 } | 707 } |
708 | |
709 void ciSpeculativeTrapData::print_data_on(outputStream* st, const char* extra) const { | |
710 st->print_cr("ciSpeculativeTrapData"); | |
711 tab(st); | |
712 method()->print_short_name(st); | |
713 st->cr(); | |
714 } | |
631 #endif | 715 #endif |