src/share/vm/ci/ciMethodData.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/ci

src/share/vm/ci/ciMethodData.cpp

Print this page
rev 5240 : 8023657: New type profiling points: arguments to call
Summary: x86 interpreter and c1 type profiling for arguments at calls
Reviewed-by:


 106     ci_data = next_data(ci_data);
 107     data = mdo->next_data(data);
 108   }
 109   // Note:  Extra data are all BitData, and do not need translation.
 110   _current_mileage = MethodData::mileage_of(mdo->method());
 111   _invocation_counter = mdo->invocation_count();
 112   _backedge_counter = mdo->backedge_count();
 113   _state = mdo->is_mature()? mature_state: immature_state;
 114 
 115   _eflags = mdo->eflags();
 116   _arg_local = mdo->arg_local();
 117   _arg_stack = mdo->arg_stack();
 118   _arg_returned  = mdo->arg_returned();
 119 #ifndef PRODUCT
 120   if (ReplayCompiles) {
 121     ciReplay::initialize(this);
 122   }
 123 #endif
 124 }
 125 
 126 void ciReceiverTypeData::translate_receiver_data_from(ProfileData* data) {
 127   for (uint row = 0; row < row_limit(); row++) {
 128     Klass* k = data->as_ReceiverTypeData()->receiver(row);
 129     if (k != NULL) {
 130       ciKlass* klass = CURRENT_ENV->get_klass(k);
 131       set_receiver(row, klass);
 132     }
 133   }
 134 }
 135 
 136 







 137 // Get the data at an arbitrary (sort of) data index.
 138 ciProfileData* ciMethodData::data_at(int data_index) {
 139   if (out_of_bounds(data_index)) {
 140     return NULL;
 141   }
 142   DataLayout* data_layout = data_layout_at(data_index);
 143 
 144   switch (data_layout->tag()) {
 145   case DataLayout::no_tag:
 146   default:
 147     ShouldNotReachHere();
 148     return NULL;
 149   case DataLayout::bit_data_tag:
 150     return new ciBitData(data_layout);
 151   case DataLayout::counter_data_tag:
 152     return new ciCounterData(data_layout);
 153   case DataLayout::jump_data_tag:
 154     return new ciJumpData(data_layout);
 155   case DataLayout::receiver_type_data_tag:
 156     return new ciReceiverTypeData(data_layout);
 157   case DataLayout::virtual_call_data_tag:
 158     return new ciVirtualCallData(data_layout);
 159   case DataLayout::ret_data_tag:
 160     return new ciRetData(data_layout);
 161   case DataLayout::branch_data_tag:
 162     return new ciBranchData(data_layout);
 163   case DataLayout::multi_branch_data_tag:
 164     return new ciMultiBranchData(data_layout);
 165   case DataLayout::arg_info_data_tag:
 166     return new ciArgInfoData(data_layout);




 167   };
 168 }
 169 
 170 // Iteration over data.
 171 ciProfileData* ciMethodData::next_data(ciProfileData* current) {
 172   int current_index = dp_to_di(current->dp());
 173   int next_index = current_index + current->size_in_bytes();
 174   ciProfileData* next = data_at(next_index);
 175   return next;
 176 }
 177 
 178 // Translate a bci to its corresponding data, or NULL.
 179 ciProfileData* ciMethodData::bci_to_data(int bci) {
 180   ciProfileData* data = data_before(bci);
 181   for ( ; is_valid(data); data = next_data(data)) {
 182     if (data->bci() == bci) {
 183       set_hint_di(dp_to_di(data->dp()));
 184       return data;
 185     } else if (data->bci() > bci) {
 186       break;


 269   }
 270 }
 271 
 272 void ciMethodData::set_compilation_stats(short loops, short blocks) {
 273   VM_ENTRY_MARK;
 274   MethodData* mdo = get_MethodData();
 275   if (mdo != NULL) {
 276     mdo->set_num_loops(loops);
 277     mdo->set_num_blocks(blocks);
 278   }
 279 }
 280 
 281 void ciMethodData::set_would_profile(bool p) {
 282   VM_ENTRY_MARK;
 283   MethodData* mdo = get_MethodData();
 284   if (mdo != NULL) {
 285     mdo->set_would_profile(p);
 286   }
 287 }
 288 














 289 bool ciMethodData::has_escape_info() {
 290   return eflag_set(MethodData::estimated);
 291 }
 292 
 293 void ciMethodData::set_eflag(MethodData::EscapeFlag f) {
 294   set_bits(_eflags, f);
 295 }
 296 
 297 void ciMethodData::clear_eflag(MethodData::EscapeFlag f) {
 298   clear_bits(_eflags, f);
 299 }
 300 
 301 bool ciMethodData::eflag_set(MethodData::EscapeFlag f) const {
 302   return mask_bits(_eflags, f) != 0;
 303 }
 304 
 305 void ciMethodData::set_arg_local(int i) {
 306   set_nth_bit(_arg_local, i);
 307 }
 308 


 460     data->print_data_on(st);
 461   }
 462   st->print_cr("--- Extra data:");
 463   DataLayout* dp  = data_layout_at(data_size());
 464   DataLayout* end = data_layout_at(data_size() + extra_data_size());
 465   for (; dp < end; dp = MethodData::next_extra(dp)) {
 466     if (dp->tag() == DataLayout::no_tag)  continue;
 467     if (dp->tag() == DataLayout::bit_data_tag) {
 468       data = new BitData(dp);
 469     } else {
 470       assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo");
 471       data = new ciArgInfoData(dp);
 472       dp = end; // ArgInfoData is at the end of extra data section.
 473     }
 474     st->print("%d", dp_to_di(data->dp()));
 475     st->fill_to(6);
 476     data->print_data_on(st);
 477   }
 478 }
 479 
 480 void ciReceiverTypeData::print_receiver_data_on(outputStream* st) {





























 481   uint row;
 482   int entries = 0;
 483   for (row = 0; row < row_limit(); row++) {
 484     if (receiver(row) != NULL)  entries++;
 485   }
 486   st->print_cr("count(%u) entries(%u)", count(), entries);
 487   for (row = 0; row < row_limit(); row++) {
 488     if (receiver(row) != NULL) {
 489       tab(st);
 490       receiver(row)->print_name_on(st);
 491       st->print_cr("(%u)", receiver_count(row));
 492     }
 493   }
 494 }
 495 
 496 void ciReceiverTypeData::print_data_on(outputStream* st) {
 497   print_shared(st, "ciReceiverTypeData");
 498   print_receiver_data_on(st);
 499 }
 500 
 501 void ciVirtualCallData::print_data_on(outputStream* st) {
 502   print_shared(st, "ciVirtualCallData");
 503   rtd_super()->print_receiver_data_on(st);






 504 }
 505 #endif


 106     ci_data = next_data(ci_data);
 107     data = mdo->next_data(data);
 108   }
 109   // Note:  Extra data are all BitData, and do not need translation.
 110   _current_mileage = MethodData::mileage_of(mdo->method());
 111   _invocation_counter = mdo->invocation_count();
 112   _backedge_counter = mdo->backedge_count();
 113   _state = mdo->is_mature()? mature_state: immature_state;
 114 
 115   _eflags = mdo->eflags();
 116   _arg_local = mdo->arg_local();
 117   _arg_stack = mdo->arg_stack();
 118   _arg_returned  = mdo->arg_returned();
 119 #ifndef PRODUCT
 120   if (ReplayCompiles) {
 121     ciReplay::initialize(this);
 122   }
 123 #endif
 124 }
 125 
 126 void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) {
 127   for (uint row = 0; row < row_limit(); row++) {
 128     Klass* k = data->as_ReceiverTypeData()->receiver(row);
 129     if (k != NULL) {
 130       ciKlass* klass = CURRENT_ENV->get_klass(k);
 131       set_receiver(row, klass);
 132     }
 133   }
 134 }
 135 
 136 
 137 void ciTypeStackSlotEntries::translate_type_data_from(const TypeStackSlotEntries* entries) {
 138   for (int i = 0; i < number_of_arguments(); i++) {
 139     intptr_t k = entries->type(i);
 140     TypeStackSlotEntries::set_type(i, translate_klass(k));
 141   }
 142 }
 143 
 144 // Get the data at an arbitrary (sort of) data index.
 145 ciProfileData* ciMethodData::data_at(int data_index) {
 146   if (out_of_bounds(data_index)) {
 147     return NULL;
 148   }
 149   DataLayout* data_layout = data_layout_at(data_index);
 150 
 151   switch (data_layout->tag()) {
 152   case DataLayout::no_tag:
 153   default:
 154     ShouldNotReachHere();
 155     return NULL;
 156   case DataLayout::bit_data_tag:
 157     return new ciBitData(data_layout);
 158   case DataLayout::counter_data_tag:
 159     return new ciCounterData(data_layout);
 160   case DataLayout::jump_data_tag:
 161     return new ciJumpData(data_layout);
 162   case DataLayout::receiver_type_data_tag:
 163     return new ciReceiverTypeData(data_layout);
 164   case DataLayout::virtual_call_data_tag:
 165     return new ciVirtualCallData(data_layout);
 166   case DataLayout::ret_data_tag:
 167     return new ciRetData(data_layout);
 168   case DataLayout::branch_data_tag:
 169     return new ciBranchData(data_layout);
 170   case DataLayout::multi_branch_data_tag:
 171     return new ciMultiBranchData(data_layout);
 172   case DataLayout::arg_info_data_tag:
 173     return new ciArgInfoData(data_layout);
 174   case DataLayout::call_type_data_tag:
 175     return new ciCallTypeData(data_layout);
 176   case DataLayout::virtual_call_type_data_tag:
 177     return new ciVirtualCallTypeData(data_layout);
 178   };
 179 }
 180 
 181 // Iteration over data.
 182 ciProfileData* ciMethodData::next_data(ciProfileData* current) {
 183   int current_index = dp_to_di(current->dp());
 184   int next_index = current_index + current->size_in_bytes();
 185   ciProfileData* next = data_at(next_index);
 186   return next;
 187 }
 188 
 189 // Translate a bci to its corresponding data, or NULL.
 190 ciProfileData* ciMethodData::bci_to_data(int bci) {
 191   ciProfileData* data = data_before(bci);
 192   for ( ; is_valid(data); data = next_data(data)) {
 193     if (data->bci() == bci) {
 194       set_hint_di(dp_to_di(data->dp()));
 195       return data;
 196     } else if (data->bci() > bci) {
 197       break;


 280   }
 281 }
 282 
 283 void ciMethodData::set_compilation_stats(short loops, short blocks) {
 284   VM_ENTRY_MARK;
 285   MethodData* mdo = get_MethodData();
 286   if (mdo != NULL) {
 287     mdo->set_num_loops(loops);
 288     mdo->set_num_blocks(blocks);
 289   }
 290 }
 291 
 292 void ciMethodData::set_would_profile(bool p) {
 293   VM_ENTRY_MARK;
 294   MethodData* mdo = get_MethodData();
 295   if (mdo != NULL) {
 296     mdo->set_would_profile(p);
 297   }
 298 }
 299 
 300 void ciMethodData::set_argument_type(int bci, int i, ciKlass* k) {
 301   VM_ENTRY_MARK;
 302   MethodData* mdo = get_MethodData();
 303   if (mdo != NULL) {
 304     ProfileData* data = mdo->bci_to_data(bci);
 305     if (data->is_CallTypeData()) {
 306       data->as_CallTypeData()->set_argument_type(i, k->get_Klass());
 307     } else {
 308       assert(data->is_VirtualCallTypeData(), "no arguments!");
 309       data->as_VirtualCallTypeData()->set_argument_type(i, k->get_Klass());
 310     }
 311   }
 312 }
 313 
 314 bool ciMethodData::has_escape_info() {
 315   return eflag_set(MethodData::estimated);
 316 }
 317 
 318 void ciMethodData::set_eflag(MethodData::EscapeFlag f) {
 319   set_bits(_eflags, f);
 320 }
 321 
 322 void ciMethodData::clear_eflag(MethodData::EscapeFlag f) {
 323   clear_bits(_eflags, f);
 324 }
 325 
 326 bool ciMethodData::eflag_set(MethodData::EscapeFlag f) const {
 327   return mask_bits(_eflags, f) != 0;
 328 }
 329 
 330 void ciMethodData::set_arg_local(int i) {
 331   set_nth_bit(_arg_local, i);
 332 }
 333 


 485     data->print_data_on(st);
 486   }
 487   st->print_cr("--- Extra data:");
 488   DataLayout* dp  = data_layout_at(data_size());
 489   DataLayout* end = data_layout_at(data_size() + extra_data_size());
 490   for (; dp < end; dp = MethodData::next_extra(dp)) {
 491     if (dp->tag() == DataLayout::no_tag)  continue;
 492     if (dp->tag() == DataLayout::bit_data_tag) {
 493       data = new BitData(dp);
 494     } else {
 495       assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo");
 496       data = new ciArgInfoData(dp);
 497       dp = end; // ArgInfoData is at the end of extra data section.
 498     }
 499     st->print("%d", dp_to_di(data->dp()));
 500     st->fill_to(6);
 501     data->print_data_on(st);
 502   }
 503 }
 504 
 505 void ciTypeEntries::print_ciklass(outputStream* st, intptr_t k) {
 506   if (TypeEntries::is_type_none(k)) {
 507     st->print("none");
 508   } else if (TypeEntries::is_type_unknown(k)) {
 509     st->print("unknown");
 510   } else {
 511     valid_ciklass(k)->print_name_on(st);
 512   }
 513   if (TypeEntries::was_null_seen(k)) {
 514     st->print(" (null seen)");
 515   }
 516 }
 517 
 518 void ciTypeStackSlotEntries::print_data_on(outputStream* st) const {
 519   _pd->tab(st, true);
 520   st->print("argument types");
 521   for (int i = 0; i < number_of_arguments(); i++) {
 522     _pd->tab(st);
 523     st->print("%d: stack (%u) ", i, stack_slot(i));
 524     print_ciklass(st, type(i));
 525     st->cr();
 526   }
 527 }
 528 
 529 void ciCallTypeData::print_data_on(outputStream* st) const {
 530   print_shared(st, "ciCallTypeData");
 531   args()->print_data_on(st);
 532 }
 533 
 534 void ciReceiverTypeData::print_receiver_data_on(outputStream* st) const {
 535   uint row;
 536   int entries = 0;
 537   for (row = 0; row < row_limit(); row++) {
 538     if (receiver(row) != NULL)  entries++;
 539   }
 540   st->print_cr("count(%u) entries(%u)", count(), entries);
 541   for (row = 0; row < row_limit(); row++) {
 542     if (receiver(row) != NULL) {
 543       tab(st);
 544       receiver(row)->print_name_on(st);
 545       st->print_cr("(%u)", receiver_count(row));
 546     }
 547   }
 548 }
 549 
 550 void ciReceiverTypeData::print_data_on(outputStream* st) const {
 551   print_shared(st, "ciReceiverTypeData");
 552   print_receiver_data_on(st);
 553 }
 554 
 555 void ciVirtualCallData::print_data_on(outputStream* st) const {
 556   print_shared(st, "ciVirtualCallData");
 557   rtd_super()->print_receiver_data_on(st);
 558 }
 559 
 560 void ciVirtualCallTypeData::print_data_on(outputStream* st) const {
 561   print_shared(st, "ciVirtualCallTypeData");
 562   rtd_super()->print_receiver_data_on(st);
 563   args()->print_data_on(st);
 564 }
 565 #endif
src/share/vm/ci/ciMethodData.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File