64 Copy::zero_to_words((HeapWord*) &_orig, sizeof(_orig) / sizeof(HeapWord));
65 _data = NULL;
66 _data_size = 0;
67 _extra_data_size = 0;
68 _current_mileage = 0;
69 _invocation_counter = 0;
70 _backedge_counter = 0;
71 _state = empty_state;
72 _saw_free_extra_data = false;
73 // Set an initial hint. Don't use set_hint_di() because
74 // first_di() may be out of bounds if data_size is 0.
75 _hint_di = first_di();
76 // Initialize the escape information (to "don't know.");
77 _eflags = _arg_local = _arg_stack = _arg_returned = 0;
78 _parameters = NULL;
79 }
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
111 void ciMethodData::load_data() {
112 MethodData* mdo = get_MethodData();
113 if (mdo == NULL) {
114 return;
115 }
116
227 case DataLayout::arg_info_data_tag:
228 return new ciArgInfoData(data_layout);
229 case DataLayout::call_type_data_tag:
230 return new ciCallTypeData(data_layout);
231 case DataLayout::virtual_call_type_data_tag:
232 return new ciVirtualCallTypeData(data_layout);
233 case DataLayout::parameters_type_data_tag:
234 return new ciParametersTypeData(data_layout);
235 };
236 }
237
238 // Iteration over data.
239 ciProfileData* ciMethodData::next_data(ciProfileData* current) {
240 int current_index = dp_to_di(current->dp());
241 int next_index = current_index + current->size_in_bytes();
242 ciProfileData* next = data_at(next_index);
243 return next;
244 }
245
246 ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots) {
247 // bci_to_extra_data(bci) ...
248 DataLayout* dp = data_layout_at(data_size());
249 DataLayout* end = data_layout_at(data_size() + extra_data_size());
250 two_free_slots = false;
251 for (;dp < end; dp = MethodData::next_extra(dp)) {
252 switch(dp->tag()) {
253 case DataLayout::no_tag:
254 _saw_free_extra_data = true; // observed an empty slot (common case)
255 two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag);
256 return NULL;
257 case DataLayout::arg_info_data_tag:
258 return NULL; // ArgInfoData is at the end of extra data section.
259 case DataLayout::bit_data_tag:
260 if (m == NULL && dp->bci() == bci) {
261 return new ciBitData(dp);
262 }
263 break;
264 case DataLayout::speculative_trap_data_tag: {
265 ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp);
266 // data->method() might be null if the MDO is snapshotted
267 // concurrently with a trap
268 if (m != NULL && data->method() == m && dp->bci() == bci) {
269 return data;
480 return 0;
481 assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number");
482 return aid->arg_modified(arg);
483 }
484
485 ByteSize ciMethodData::offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data) {
486 // Get offset within MethodData* of the data array
487 ByteSize data_offset = MethodData::data_offset();
488
489 // Get cell offset of the ProfileData within data array
490 int cell_offset = dp_to_di(data->dp());
491
492 // Add in counter_offset, the # of bytes into the ProfileData of counter or flag
493 int offset = in_bytes(data_offset) + cell_offset + in_bytes(slot_offset_in_data);
494
495 return in_ByteSize(offset);
496 }
497
498 ciArgInfoData *ciMethodData::arg_info() const {
499 // Should be last, have to skip all traps.
500 DataLayout* dp = data_layout_at(data_size());
501 DataLayout* end = data_layout_at(data_size() + extra_data_size());
502 for (; dp < end; dp = MethodData::next_extra(dp)) {
503 if (dp->tag() == DataLayout::arg_info_data_tag)
504 return new ciArgInfoData(dp);
505 }
506 return NULL;
507 }
508
509
510 // Implementation of the print method.
511 void ciMethodData::print_impl(outputStream* st) {
512 ciMetadata::print_impl(st);
513 }
514
515 void ciMethodData::dump_replay_data(outputStream* out) {
516 ResourceMark rm;
517 MethodData* mdo = get_MethodData();
518 Method* method = mdo->method();
519 Klass* holder = method->method_holder();
520 out->print("ciMethodData %s %s %s %d %d",
521 holder->name()->as_quoted_ascii(),
582 }
583 }
584 }
585 out->cr();
586 }
587
588 #ifndef PRODUCT
589 void ciMethodData::print() {
590 print_data_on(tty);
591 }
592
593 void ciMethodData::print_data_on(outputStream* st) {
594 ResourceMark rm;
595 ciProfileData* data;
596 for (data = first_data(); is_valid(data); data = next_data(data)) {
597 st->print("%d", dp_to_di(data->dp()));
598 st->fill_to(6);
599 data->print_data_on(st);
600 }
601 st->print_cr("--- Extra data:");
602 DataLayout* dp = data_layout_at(data_size());
603 DataLayout* end = data_layout_at(data_size() + extra_data_size());
604 for (;; dp = MethodData::next_extra(dp)) {
605 assert(dp < end, "moved past end of extra data");
606 switch (dp->tag()) {
607 case DataLayout::no_tag:
608 continue;
609 case DataLayout::bit_data_tag:
610 data = new BitData(dp);
611 break;
612 case DataLayout::arg_info_data_tag:
613 data = new ciArgInfoData(dp);
614 dp = end; // ArgInfoData is at the end of extra data section.
615 break;
616 default:
617 fatal(err_msg("unexpected tag %d", dp->tag()));
618 }
619 st->print("%d", dp_to_di(data->dp()));
620 st->fill_to(6);
621 data->print_data_on(st);
622 if (dp >= end) return;
623 }
|
64 Copy::zero_to_words((HeapWord*) &_orig, sizeof(_orig) / sizeof(HeapWord));
65 _data = NULL;
66 _data_size = 0;
67 _extra_data_size = 0;
68 _current_mileage = 0;
69 _invocation_counter = 0;
70 _backedge_counter = 0;
71 _state = empty_state;
72 _saw_free_extra_data = false;
73 // Set an initial hint. Don't use set_hint_di() because
74 // first_di() may be out of bounds if data_size is 0.
75 _hint_di = first_di();
76 // Initialize the escape information (to "don't know.");
77 _eflags = _arg_local = _arg_stack = _arg_returned = 0;
78 _parameters = NULL;
79 }
80
81 void ciMethodData::load_extra_data() {
82 MethodData* mdo = get_MethodData();
83
84 MutexLocker(mdo->extra_data_lock());
85
86 // speculative trap entries also hold a pointer to a Method so need to be translated
87 DataLayout* dp_src = mdo->extra_data_base();
88 DataLayout* end_src = mdo->args_data_limit();
89 DataLayout* dp_dst = extra_data_base();
90 for (;; dp_src = MethodData::next_extra(dp_src), dp_dst = MethodData::next_extra(dp_dst)) {
91 assert(dp_src < end_src, "moved past end of extra data");
92 assert(((intptr_t)dp_dst) - ((intptr_t)extra_data_base()) == ((intptr_t)dp_src) - ((intptr_t)mdo->extra_data_base()), "source and destination don't match");
93 // New traps in the MDO may have been added since we copied the
94 // data (concurrent deoptimizations before we acquired
95 // extra_data_lock above) or can be removed (a safepoint may occur
96 // in the translate_from call below) as we translate the copy:
97 // update the copy as we go.
98 int tag = dp_src->tag();
99 if (tag != DataLayout::arg_info_data_tag) {
100 memcpy(dp_dst, dp_src, ((intptr_t)MethodData::next_extra(dp_src)) - ((intptr_t)dp_src));
101 }
102
103 switch(tag) {
104 case DataLayout::speculative_trap_data_tag: {
105 ciSpeculativeTrapData* data_dst = new ciSpeculativeTrapData(dp_dst);
106 SpeculativeTrapData* data_src = new SpeculativeTrapData(dp_src);
107
108 data_dst->translate_from(data_src);
109
110 #ifdef ASSERT
111 SpeculativeTrapData* data_src2 = new SpeculativeTrapData(dp_src);
112 assert(data_src2->method() == data_src->method() && data_src2->bci() == data_src->bci(), "entries changed while translating");
113 #endif
114
115 break;
116 }
117 case DataLayout::bit_data_tag:
118 break;
119 case DataLayout::no_tag:
120 case DataLayout::arg_info_data_tag:
121 // An empty slot or ArgInfoData entry marks the end of the trap data
122 return;
123 default:
124 fatal(err_msg("bad tag = %d", dp_dst->tag()));
125 }
126 }
127 }
128
129 void ciMethodData::load_data() {
130 MethodData* mdo = get_MethodData();
131 if (mdo == NULL) {
132 return;
133 }
134
245 case DataLayout::arg_info_data_tag:
246 return new ciArgInfoData(data_layout);
247 case DataLayout::call_type_data_tag:
248 return new ciCallTypeData(data_layout);
249 case DataLayout::virtual_call_type_data_tag:
250 return new ciVirtualCallTypeData(data_layout);
251 case DataLayout::parameters_type_data_tag:
252 return new ciParametersTypeData(data_layout);
253 };
254 }
255
256 // Iteration over data.
257 ciProfileData* ciMethodData::next_data(ciProfileData* current) {
258 int current_index = dp_to_di(current->dp());
259 int next_index = current_index + current->size_in_bytes();
260 ciProfileData* next = data_at(next_index);
261 return next;
262 }
263
264 ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots) {
265 DataLayout* dp = extra_data_base();
266 DataLayout* end = args_data_limit();
267 two_free_slots = false;
268 for (;dp < end; dp = MethodData::next_extra(dp)) {
269 switch(dp->tag()) {
270 case DataLayout::no_tag:
271 _saw_free_extra_data = true; // observed an empty slot (common case)
272 two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag);
273 return NULL;
274 case DataLayout::arg_info_data_tag:
275 return NULL; // ArgInfoData is at the end of extra data section.
276 case DataLayout::bit_data_tag:
277 if (m == NULL && dp->bci() == bci) {
278 return new ciBitData(dp);
279 }
280 break;
281 case DataLayout::speculative_trap_data_tag: {
282 ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp);
283 // data->method() might be null if the MDO is snapshotted
284 // concurrently with a trap
285 if (m != NULL && data->method() == m && dp->bci() == bci) {
286 return data;
497 return 0;
498 assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number");
499 return aid->arg_modified(arg);
500 }
501
502 ByteSize ciMethodData::offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data) {
503 // Get offset within MethodData* of the data array
504 ByteSize data_offset = MethodData::data_offset();
505
506 // Get cell offset of the ProfileData within data array
507 int cell_offset = dp_to_di(data->dp());
508
509 // Add in counter_offset, the # of bytes into the ProfileData of counter or flag
510 int offset = in_bytes(data_offset) + cell_offset + in_bytes(slot_offset_in_data);
511
512 return in_ByteSize(offset);
513 }
514
515 ciArgInfoData *ciMethodData::arg_info() const {
516 // Should be last, have to skip all traps.
517 DataLayout* dp = extra_data_base();
518 DataLayout* end = args_data_limit();
519 for (; dp < end; dp = MethodData::next_extra(dp)) {
520 if (dp->tag() == DataLayout::arg_info_data_tag)
521 return new ciArgInfoData(dp);
522 }
523 return NULL;
524 }
525
526
527 // Implementation of the print method.
528 void ciMethodData::print_impl(outputStream* st) {
529 ciMetadata::print_impl(st);
530 }
531
532 void ciMethodData::dump_replay_data(outputStream* out) {
533 ResourceMark rm;
534 MethodData* mdo = get_MethodData();
535 Method* method = mdo->method();
536 Klass* holder = method->method_holder();
537 out->print("ciMethodData %s %s %s %d %d",
538 holder->name()->as_quoted_ascii(),
599 }
600 }
601 }
602 out->cr();
603 }
604
605 #ifndef PRODUCT
606 void ciMethodData::print() {
607 print_data_on(tty);
608 }
609
610 void ciMethodData::print_data_on(outputStream* st) {
611 ResourceMark rm;
612 ciProfileData* data;
613 for (data = first_data(); is_valid(data); data = next_data(data)) {
614 st->print("%d", dp_to_di(data->dp()));
615 st->fill_to(6);
616 data->print_data_on(st);
617 }
618 st->print_cr("--- Extra data:");
619 DataLayout* dp = extra_data_base();
620 DataLayout* end = args_data_limit();
621 for (;; dp = MethodData::next_extra(dp)) {
622 assert(dp < end, "moved past end of extra data");
623 switch (dp->tag()) {
624 case DataLayout::no_tag:
625 continue;
626 case DataLayout::bit_data_tag:
627 data = new BitData(dp);
628 break;
629 case DataLayout::arg_info_data_tag:
630 data = new ciArgInfoData(dp);
631 dp = end; // ArgInfoData is at the end of extra data section.
632 break;
633 default:
634 fatal(err_msg("unexpected tag %d", dp->tag()));
635 }
636 st->print("%d", dp_to_di(data->dp()));
637 st->fill_to(6);
638 data->print_data_on(st);
639 if (dp >= end) return;
640 }
|