comparison src/share/vm/ci/ciMethodData.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents fdad2932c73f
children 89152779163c
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
1 /* 1 /*
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2012, 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 assert(dp_src->tag() == dp_dst->tag(), err_msg("should be same tags %d != %d", dp_src->tag(), dp_dst->tag()));
91 switch(dp_src->tag()) {
92 case DataLayout::speculative_trap_data_tag: {
93 ciSpeculativeTrapData* data_dst = new ciSpeculativeTrapData(dp_dst);
94 SpeculativeTrapData* data_src = new SpeculativeTrapData(dp_src);
95 data_dst->translate_from(data_src);
96 break;
97 }
98 case DataLayout::bit_data_tag:
99 break;
100 case DataLayout::no_tag:
101 case DataLayout::arg_info_data_tag:
102 // An empty slot or ArgInfoData entry marks the end of the trap data
103 return;
104 default:
105 fatal(err_msg("bad tag = %d", dp_src->tag()));
106 }
107 }
108 }
109
110 void ciMethodData::load_data() { 81 void ciMethodData::load_data() {
111 MethodData* mdo = get_MethodData(); 82 MethodData* mdo = get_MethodData();
112 if (mdo == NULL) { 83 if (mdo == NULL) {
113 return; 84 return;
114 } 85 }
143 _parameters = data_layout_at(mdo->parameters_type_data_di()); 114 _parameters = data_layout_at(mdo->parameters_type_data_di());
144 ciParametersTypeData* parameters = new ciParametersTypeData(_parameters); 115 ciParametersTypeData* parameters = new ciParametersTypeData(_parameters);
145 parameters->translate_from(mdo->parameters_type_data()); 116 parameters->translate_from(mdo->parameters_type_data());
146 } 117 }
147 118
148 load_extra_data();
149
150 // Note: Extra data are all BitData, and do not need translation. 119 // Note: Extra data are all BitData, and do not need translation.
151 _current_mileage = MethodData::mileage_of(mdo->method()); 120 _current_mileage = MethodData::mileage_of(mdo->method());
152 _invocation_counter = mdo->invocation_count(); 121 _invocation_counter = mdo->invocation_count();
153 _backedge_counter = mdo->backedge_count(); 122 _backedge_counter = mdo->backedge_count();
154 _state = mdo->is_mature()? mature_state: immature_state; 123 _state = mdo->is_mature()? mature_state: immature_state;
183 } 152 }
184 153
185 void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) { 154 void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) {
186 intptr_t k = ret->type(); 155 intptr_t k = ret->type();
187 set_type(translate_klass(k)); 156 set_type(translate_klass(k));
188 }
189
190 void ciSpeculativeTrapData::translate_from(const ProfileData* data) {
191 Method* m = data->as_SpeculativeTrapData()->method();
192 ciMethod* ci_m = CURRENT_ENV->get_method(m);
193 set_method(ci_m);
194 } 157 }
195 158
196 // Get the data at an arbitrary (sort of) data index. 159 // Get the data at an arbitrary (sort of) data index.
197 ciProfileData* ciMethodData::data_at(int data_index) { 160 ciProfileData* ciMethodData::data_at(int data_index) {
198 if (out_of_bounds(data_index)) { 161 if (out_of_bounds(data_index)) {
238 int next_index = current_index + current->size_in_bytes(); 201 int next_index = current_index + current->size_in_bytes();
239 ciProfileData* next = data_at(next_index); 202 ciProfileData* next = data_at(next_index);
240 return next; 203 return next;
241 } 204 }
242 205
243 ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots) { 206 // Translate a bci to its corresponding data, or NULL.
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 }
244 // bci_to_extra_data(bci) ... 217 // bci_to_extra_data(bci) ...
245 DataLayout* dp = data_layout_at(data_size()); 218 DataLayout* dp = data_layout_at(data_size());
246 DataLayout* end = data_layout_at(data_size() + extra_data_size()); 219 DataLayout* end = data_layout_at(data_size() + extra_data_size());
247 two_free_slots = false; 220 for (; dp < end; dp = MethodData::next_extra(dp)) {
248 for (;dp < end; dp = MethodData::next_extra(dp)) { 221 if (dp->tag() == DataLayout::no_tag) {
249 switch(dp->tag()) {
250 case DataLayout::no_tag:
251 _saw_free_extra_data = true; // observed an empty slot (common case) 222 _saw_free_extra_data = true; // observed an empty slot (common case)
252 two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag);
253 return NULL; 223 return NULL;
254 case DataLayout::arg_info_data_tag: 224 }
255 return NULL; // ArgInfoData is at the end of extra data section. 225 if (dp->tag() == DataLayout::arg_info_data_tag) {
256 case DataLayout::bit_data_tag: 226 break; // ArgInfoData is at the end of extra data section.
257 if (m == NULL && dp->bci() == bci) { 227 }
258 return new ciBitData(dp); 228 if (dp->bci() == bci) {
259 } 229 assert(dp->tag() == DataLayout::bit_data_tag, "sane");
260 break; 230 return new ciBitData(dp);
261 case DataLayout::speculative_trap_data_tag: { 231 }
262 ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp);
263 // data->method() might be null if the MDO is snapshotted
264 // concurrently with a trap
265 if (m != NULL && data->method() == m && dp->bci() == bci) {
266 return data;
267 }
268 break;
269 }
270 default:
271 fatal(err_msg("bad tag = %d", dp->tag()));
272 }
273 }
274 return NULL;
275 }
276
277 // Translate a bci to its corresponding data, or NULL.
278 ciProfileData* ciMethodData::bci_to_data(int bci, ciMethod* m) {
279 // If m is not NULL we look for a SpeculativeTrapData entry
280 if (m == NULL) {
281 ciProfileData* data = data_before(bci);
282 for ( ; is_valid(data); data = next_data(data)) {
283 if (data->bci() == bci) {
284 set_hint_di(dp_to_di(data->dp()));
285 return data;
286 } else if (data->bci() > bci) {
287 break;
288 }
289 }
290 }
291 bool two_free_slots = false;
292 ciProfileData* result = bci_to_extra_data(bci, m, two_free_slots);
293 if (result != NULL) {
294 return result;
295 }
296 if (m != NULL && !two_free_slots) {
297 // We were looking for a SpeculativeTrapData entry we didn't
298 // find. Room is not available for more SpeculativeTrapData
299 // entries, look in the non SpeculativeTrapData entries.
300 return bci_to_data(bci, NULL);
301 } 232 }
302 return NULL; 233 return NULL;
303 } 234 }
304 235
305 // Conservatively decode the trap_state of a ciProfileData. 236 // Conservatively decode the trap_state of a ciProfileData.
592 data->print_data_on(st); 523 data->print_data_on(st);
593 } 524 }
594 st->print_cr("--- Extra data:"); 525 st->print_cr("--- Extra data:");
595 DataLayout* dp = data_layout_at(data_size()); 526 DataLayout* dp = data_layout_at(data_size());
596 DataLayout* end = data_layout_at(data_size() + extra_data_size()); 527 DataLayout* end = data_layout_at(data_size() + extra_data_size());
597 for (;; dp = MethodData::next_extra(dp)) { 528 for (; dp < end; dp = MethodData::next_extra(dp)) {
598 assert(dp < end, "moved past end of extra data"); 529 if (dp->tag() == DataLayout::no_tag) continue;
599 switch (dp->tag()) { 530 if (dp->tag() == DataLayout::bit_data_tag) {
600 case DataLayout::no_tag:
601 continue;
602 case DataLayout::bit_data_tag:
603 data = new BitData(dp); 531 data = new BitData(dp);
604 break; 532 } else {
605 case DataLayout::arg_info_data_tag: 533 assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo");
606 data = new ciArgInfoData(dp); 534 data = new ciArgInfoData(dp);
607 dp = end; // ArgInfoData is at the end of extra data section. 535 dp = end; // ArgInfoData is at the end of extra data section.
608 break;
609 default:
610 fatal(err_msg("unexpected tag %d", dp->tag()));
611 } 536 }
612 st->print("%d", dp_to_di(data->dp())); 537 st->print("%d", dp_to_di(data->dp()));
613 st->fill_to(6); 538 st->fill_to(6);
614 data->print_data_on(st); 539 data->print_data_on(st);
615 if (dp >= end) return;
616 } 540 }
617 } 541 }
618 542
619 void ciTypeEntries::print_ciklass(outputStream* st, intptr_t k) { 543 void ciTypeEntries::print_ciklass(outputStream* st, intptr_t k) {
620 if (TypeEntries::is_type_none(k)) { 544 if (TypeEntries::is_type_none(k)) {
643 st->print("ret "); 567 st->print("ret ");
644 print_ciklass(st, type()); 568 print_ciklass(st, type());
645 st->cr(); 569 st->cr();
646 } 570 }
647 571
648 void ciCallTypeData::print_data_on(outputStream* st, const char* extra) const { 572 void ciCallTypeData::print_data_on(outputStream* st) const {
649 print_shared(st, "ciCallTypeData", extra); 573 print_shared(st, "ciCallTypeData");
650 if (has_arguments()) { 574 if (has_arguments()) {
651 tab(st, true); 575 tab(st, true);
652 st->print("argument types"); 576 st->print("argument types");
653 args()->print_data_on(st); 577 args()->print_data_on(st);
654 } 578 }
673 st->print_cr("(%u)", receiver_count(row)); 597 st->print_cr("(%u)", receiver_count(row));
674 } 598 }
675 } 599 }
676 } 600 }
677 601
678 void ciReceiverTypeData::print_data_on(outputStream* st, const char* extra) const { 602 void ciReceiverTypeData::print_data_on(outputStream* st) const {
679 print_shared(st, "ciReceiverTypeData", extra); 603 print_shared(st, "ciReceiverTypeData");
680 print_receiver_data_on(st); 604 print_receiver_data_on(st);
681 } 605 }
682 606
683 void ciVirtualCallData::print_data_on(outputStream* st, const char* extra) const { 607 void ciVirtualCallData::print_data_on(outputStream* st) const {
684 print_shared(st, "ciVirtualCallData", extra); 608 print_shared(st, "ciVirtualCallData");
685 rtd_super()->print_receiver_data_on(st); 609 rtd_super()->print_receiver_data_on(st);
686 } 610 }
687 611
688 void ciVirtualCallTypeData::print_data_on(outputStream* st, const char* extra) const { 612 void ciVirtualCallTypeData::print_data_on(outputStream* st) const {
689 print_shared(st, "ciVirtualCallTypeData", extra); 613 print_shared(st, "ciVirtualCallTypeData");
690 rtd_super()->print_receiver_data_on(st); 614 rtd_super()->print_receiver_data_on(st);
691 if (has_arguments()) { 615 if (has_arguments()) {
692 tab(st, true); 616 tab(st, true);
693 st->print("argument types"); 617 st->print("argument types");
694 args()->print_data_on(st); 618 args()->print_data_on(st);
698 st->print("return type"); 622 st->print("return type");
699 ret()->print_data_on(st); 623 ret()->print_data_on(st);
700 } 624 }
701 } 625 }
702 626
703 void ciParametersTypeData::print_data_on(outputStream* st, const char* extra) const { 627 void ciParametersTypeData::print_data_on(outputStream* st) const {
704 st->print_cr("ciParametersTypeData"); 628 st->print_cr("Parametertypes");
705 parameters()->print_data_on(st); 629 parameters()->print_data_on(st);
706 } 630 }
707
708 void ciSpeculativeTrapData::print_data_on(outputStream* st, const char* extra) const {
709 st->print_cr("ciSpeculativeTrapData");
710 tab(st);
711 method()->print_short_name(st);
712 st->cr();
713 }
714 #endif 631 #endif