hotspot/src/share/vm/oops/methodDataOop.cpp
changeset 218 a0e996680b05
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
equal deleted inserted replaced
217:c646ef2f5d58 218:a0e996680b05
    30 //
    30 //
    31 // Overlay for generic profiling data.
    31 // Overlay for generic profiling data.
    32 
    32 
    33 // Some types of data layouts need a length field.
    33 // Some types of data layouts need a length field.
    34 bool DataLayout::needs_array_len(u1 tag) {
    34 bool DataLayout::needs_array_len(u1 tag) {
    35   return (tag == multi_branch_data_tag);
    35   return (tag == multi_branch_data_tag) || (tag == arg_info_data_tag);
    36 }
    36 }
    37 
    37 
    38 // Perform generic initialization of the data.  More specific
    38 // Perform generic initialization of the data.  More specific
    39 // initialization occurs in overrides of ProfileData::post_initialize.
    39 // initialization occurs in overrides of ProfileData::post_initialize.
    40 void DataLayout::initialize(u1 tag, u2 bci, int cell_count) {
    40 void DataLayout::initialize(u1 tag, u2 bci, int cell_count) {
   402                  count_at(i), displacement_at(i));
   402                  count_at(i), displacement_at(i));
   403   }
   403   }
   404 }
   404 }
   405 #endif
   405 #endif
   406 
   406 
       
   407 #ifndef PRODUCT
       
   408 void ArgInfoData::print_data_on(outputStream* st) {
       
   409   print_shared(st, "ArgInfoData");
       
   410   int nargs = number_of_args();
       
   411   for (int i = 0; i < nargs; i++) {
       
   412     st->print("  0x%x", arg_modified(i));
       
   413   }
       
   414   st->cr();
       
   415 }
       
   416 
       
   417 #endif
   407 // ==================================================================
   418 // ==================================================================
   408 // methodDataOop
   419 // methodDataOop
   409 //
   420 //
   410 // A methodDataOop holds information which has been collected about
   421 // A methodDataOop holds information which has been collected about
   411 // a method.
   422 // a method.
   506 
   517 
   507   // Add some extra DataLayout cells (at least one) to track stray traps.
   518   // Add some extra DataLayout cells (at least one) to track stray traps.
   508   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
   519   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
   509   object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
   520   object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
   510 
   521 
       
   522   // Add a cell to record information about modified arguments.
       
   523   int arg_size = method->size_of_parameters();
       
   524   object_size += DataLayout::compute_size_in_bytes(arg_size+1);
   511   return object_size;
   525   return object_size;
   512 }
   526 }
   513 
   527 
   514 // Compute the size of the methodDataOop necessary to store
   528 // Compute the size of the methodDataOop necessary to store
   515 // profiling information about a given method.  Size is in words
   529 // profiling information about a given method.  Size is in words
   624     return new RetData(data_layout);
   638     return new RetData(data_layout);
   625   case DataLayout::branch_data_tag:
   639   case DataLayout::branch_data_tag:
   626     return new BranchData(data_layout);
   640     return new BranchData(data_layout);
   627   case DataLayout::multi_branch_data_tag:
   641   case DataLayout::multi_branch_data_tag:
   628     return new MultiBranchData(data_layout);
   642     return new MultiBranchData(data_layout);
       
   643   case DataLayout::arg_info_data_tag:
       
   644     return new ArgInfoData(data_layout);
   629   };
   645   };
   630 }
   646 }
   631 
   647 
   632 // Iteration over data.
   648 // Iteration over data.
   633 ProfileData* methodDataOopDesc::next_data(ProfileData* current) {
   649 ProfileData* methodDataOopDesc::next_data(ProfileData* current) {
   679   _data_size = data_size;
   695   _data_size = data_size;
   680   int object_size = in_bytes(data_offset()) + data_size;
   696   int object_size = in_bytes(data_offset()) + data_size;
   681 
   697 
   682   // Add some extra DataLayout cells (at least one) to track stray traps.
   698   // Add some extra DataLayout cells (at least one) to track stray traps.
   683   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
   699   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
   684   object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
   700   int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0);
       
   701 
       
   702   // Add a cell to record information about modified arguments.
       
   703   // Set up _args_modified array after traps cells so that
       
   704   // the code for traps cells works.
       
   705   DataLayout *dp = data_layout_at(data_size + extra_size);
       
   706 
       
   707   int arg_size = method->size_of_parameters();
       
   708   dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1);
       
   709 
       
   710   object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1);
   685 
   711 
   686   // Set an initial hint. Don't use set_hint_di() because
   712   // Set an initial hint. Don't use set_hint_di() because
   687   // first_di() may be out of bounds if data_size is 0.
   713   // first_di() may be out of bounds if data_size is 0.
   688   // In that situation, _hint_di is never used, but at
   714   // In that situation, _hint_di is never used, but at
   689   // least well-defined.
   715   // least well-defined.
   762   DataLayout* avail = NULL;
   788   DataLayout* avail = NULL;
   763   for (; dp < end; dp = next_extra(dp)) {
   789   for (; dp < end; dp = next_extra(dp)) {
   764     // No need for "OrderAccess::load_acquire" ops,
   790     // No need for "OrderAccess::load_acquire" ops,
   765     // since the data structure is monotonic.
   791     // since the data structure is monotonic.
   766     if (dp->tag() == DataLayout::no_tag)  break;
   792     if (dp->tag() == DataLayout::no_tag)  break;
       
   793     if (dp->tag() == DataLayout::arg_info_data_tag) {
       
   794       dp = end; // ArgInfoData is at the end of extra data section.
       
   795       break;
       
   796     }
   767     if (dp->bci() == bci) {
   797     if (dp->bci() == bci) {
   768       assert(dp->tag() == DataLayout::bit_data_tag, "sane");
   798       assert(dp->tag() == DataLayout::bit_data_tag, "sane");
   769       return new BitData(dp);
   799       return new BitData(dp);
   770     }
   800     }
   771   }
   801   }
   783     return new BitData(dp);
   813     return new BitData(dp);
   784   }
   814   }
   785   return NULL;
   815   return NULL;
   786 }
   816 }
   787 
   817 
       
   818 ArgInfoData *methodDataOopDesc::arg_info() {
       
   819   DataLayout* dp    = extra_data_base();
       
   820   DataLayout* end   = extra_data_limit();
       
   821   for (; dp < end; dp = next_extra(dp)) {
       
   822     if (dp->tag() == DataLayout::arg_info_data_tag)
       
   823       return new ArgInfoData(dp);
       
   824   }
       
   825   return NULL;
       
   826 }
       
   827 
   788 #ifndef PRODUCT
   828 #ifndef PRODUCT
   789 void methodDataOopDesc::print_data_on(outputStream* st) {
   829 void methodDataOopDesc::print_data_on(outputStream* st) {
   790   ResourceMark rm;
   830   ResourceMark rm;
   791   ProfileData* data = first_data();
   831   ProfileData* data = first_data();
   792   for ( ; is_valid(data); data = next_data(data)) {
   832   for ( ; is_valid(data); data = next_data(data)) {
   793     st->print("%d", dp_to_di(data->dp()));
   833     st->print("%d", dp_to_di(data->dp()));
   794     st->fill_to(6);
   834     st->fill_to(6);
   795     data->print_data_on(st);
   835     data->print_data_on(st);
   796   }
   836   }
       
   837   st->print_cr("--- Extra data:");
   797   DataLayout* dp    = extra_data_base();
   838   DataLayout* dp    = extra_data_base();
   798   DataLayout* end   = extra_data_limit();
   839   DataLayout* end   = extra_data_limit();
   799   for (; dp < end; dp = next_extra(dp)) {
   840   for (; dp < end; dp = next_extra(dp)) {
   800     // No need for "OrderAccess::load_acquire" ops,
   841     // No need for "OrderAccess::load_acquire" ops,
   801     // since the data structure is monotonic.
   842     // since the data structure is monotonic.
   802     if (dp->tag() == DataLayout::no_tag)  break;
   843     if (dp->tag() == DataLayout::no_tag)  continue;
   803     if (dp == extra_data_base())
   844     if (dp->tag() == DataLayout::bit_data_tag) {
   804       st->print_cr("--- Extra data:");
   845       data = new BitData(dp);
   805     data = new BitData(dp);
   846     } else {
       
   847       assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo");
       
   848       data = new ArgInfoData(dp);
       
   849       dp = end; // ArgInfoData is at the end of extra data section.
       
   850     }
   806     st->print("%d", dp_to_di(data->dp()));
   851     st->print("%d", dp_to_di(data->dp()));
   807     st->fill_to(6);
   852     st->fill_to(6);
   808     data->print_data_on(st);
   853     data->print_data_on(st);
   809   }
   854   }
   810 }
   855 }