src/share/vm/oops/methodData.cpp

Print this page




 635 
 636 // Give each of the data entries a chance to perform specific
 637 // data initialization.
 638 void MethodData::post_initialize(BytecodeStream* stream) {
 639   ResourceMark rm;
 640   ProfileData* data;
 641   for (data = first_data(); is_valid(data); data = next_data(data)) {
 642     stream->set_start(data->bci());
 643     stream->next();
 644     data->post_initialize(stream, this);
 645   }
 646 }
 647 
 648 // Initialize the MethodData* corresponding to a given method.
 649 MethodData::MethodData(methodHandle method, int size, TRAPS) {
 650   No_Safepoint_Verifier no_safepoint;  // init function atomic wrt GC
 651   ResourceMark rm;
 652   // Set the method back-pointer.
 653   _method = method();
 654 
 655   _invocation_counter.init();
 656   _backedge_counter.init();
 657   _invocation_counter_start = 0;
 658   _backedge_counter_start = 0;
 659   _num_loops = 0;
 660   _num_blocks = 0;
 661   _highest_comp_level = 0;
 662   _highest_osr_comp_level = 0;
 663   _would_profile = true;
 664   set_creation_mileage(mileage_of(method()));
 665 
 666   // Initialize flags and trap history.
 667   _nof_decompiles = 0;
 668   _nof_overflow_recompiles = 0;
 669   _nof_overflow_traps = 0;
 670   _eflags = 0;
 671   _arg_local = 0;
 672   _arg_stack = 0;
 673   _arg_returned = 0;
 674   assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align");
 675   Copy::zero_to_words((HeapWord*) &_trap_hist,
 676                       sizeof(_trap_hist) / sizeof(HeapWord));
 677 
 678   // Go through the bytecodes and allocate and initialize the
 679   // corresponding data cells.
 680   int data_size = 0;
 681   int empty_bc_count = 0;  // number of bytecodes lacking data
 682   _data[0] = 0;  // apparently not set below.
 683   BytecodeStream stream(method);
 684   Bytecodes::Code c;
 685   while ((c = stream.next()) >= 0) {
 686     int size_in_bytes = initialize_data(&stream, data_size);
 687     data_size += size_in_bytes;
 688     if (size_in_bytes == 0)  empty_bc_count += 1;
 689   }
 690   _data_size = data_size;
 691   int object_size = in_bytes(data_offset()) + data_size;
 692 
 693   // Add some extra DataLayout cells (at least one) to track stray traps.
 694   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
 695   int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0);
 696 
 697   // Add a cell to record information about modified arguments.
 698   // Set up _args_modified array after traps cells so that
 699   // the code for traps cells works.
 700   DataLayout *dp = data_layout_at(data_size + extra_size);
 701 
 702   int arg_size = method->size_of_parameters();
 703   dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1);
 704 
 705   object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1);
 706 
 707   // Set an initial hint. Don't use set_hint_di() because
 708   // first_di() may be out of bounds if data_size is 0.
 709   // In that situation, _hint_di is never used, but at
 710   // least well-defined.
 711   _hint_di = first_di();
 712 
 713   post_initialize(&stream);
 714 
 715   set_size(object_size);

 716 



















 717 }
 718 
 719 // Get a measure of how much mileage the method has on it.
 720 int MethodData::mileage_of(Method* method) {
 721   int mileage = 0;
 722   if (TieredCompilation) {
 723     mileage = MAX2(method->invocation_count(), method->backedge_count());
 724   } else {
 725     int iic = method->interpreter_invocation_count();
 726     if (mileage < iic)  mileage = iic;
 727     InvocationCounter* ic = method->invocation_counter();
 728     InvocationCounter* bc = method->backedge_counter();
 729     int icval = ic->count();
 730     if (ic->carry()) icval += CompileThreshold;
 731     if (mileage < icval)  mileage = icval;
 732     int bcval = bc->count();
 733     if (bc->carry()) bcval += CompileThreshold;
 734     if (mileage < bcval)  mileage = bcval;
 735   }
 736   return mileage;




 635 
 636 // Give each of the data entries a chance to perform specific
 637 // data initialization.
 638 void MethodData::post_initialize(BytecodeStream* stream) {
 639   ResourceMark rm;
 640   ProfileData* data;
 641   for (data = first_data(); is_valid(data); data = next_data(data)) {
 642     stream->set_start(data->bci());
 643     stream->next();
 644     data->post_initialize(stream, this);
 645   }
 646 }
 647 
 648 // Initialize the MethodData* corresponding to a given method.
 649 MethodData::MethodData(methodHandle method, int size, TRAPS) {
 650   No_Safepoint_Verifier no_safepoint;  // init function atomic wrt GC
 651   ResourceMark rm;
 652   // Set the method back-pointer.
 653   _method = method();
 654 
 655   init();








 656   set_creation_mileage(mileage_of(method()));
 657 












 658   // Go through the bytecodes and allocate and initialize the
 659   // corresponding data cells.
 660   int data_size = 0;
 661   int empty_bc_count = 0;  // number of bytecodes lacking data
 662   _data[0] = 0;  // apparently not set below.
 663   BytecodeStream stream(method);
 664   Bytecodes::Code c;
 665   while ((c = stream.next()) >= 0) {
 666     int size_in_bytes = initialize_data(&stream, data_size);
 667     data_size += size_in_bytes;
 668     if (size_in_bytes == 0)  empty_bc_count += 1;
 669   }
 670   _data_size = data_size;
 671   int object_size = in_bytes(data_offset()) + data_size;
 672 
 673   // Add some extra DataLayout cells (at least one) to track stray traps.
 674   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
 675   int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0);
 676 
 677   // Add a cell to record information about modified arguments.
 678   // Set up _args_modified array after traps cells so that
 679   // the code for traps cells works.
 680   DataLayout *dp = data_layout_at(data_size + extra_size);
 681 
 682   int arg_size = method->size_of_parameters();
 683   dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1);
 684 
 685   object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1);
 686 
 687   // Set an initial hint. Don't use set_hint_di() because
 688   // first_di() may be out of bounds if data_size is 0.
 689   // In that situation, _hint_di is never used, but at
 690   // least well-defined.
 691   _hint_di = first_di();
 692 
 693   post_initialize(&stream);
 694 
 695   set_size(object_size);
 696 }
 697 
 698 void MethodData::init() {
 699   _invocation_counter.init();
 700   _backedge_counter.init();
 701   _invocation_counter_start = 0;
 702   _backedge_counter_start = 0;
 703   _num_loops = 0;
 704   _num_blocks = 0;
 705   _highest_comp_level = 0;
 706   _highest_osr_comp_level = 0;
 707   _would_profile = true;
 708 
 709   // Initialize flags and trap history.
 710   _nof_decompiles = 0;
 711   _nof_overflow_recompiles = 0;
 712   _nof_overflow_traps = 0;
 713   clear_escape_info();
 714   assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align");
 715   Copy::zero_to_words((HeapWord*) &_trap_hist,
 716                       sizeof(_trap_hist) / sizeof(HeapWord));
 717 }
 718 
 719 // Get a measure of how much mileage the method has on it.
 720 int MethodData::mileage_of(Method* method) {
 721   int mileage = 0;
 722   if (TieredCompilation) {
 723     mileage = MAX2(method->invocation_count(), method->backedge_count());
 724   } else {
 725     int iic = method->interpreter_invocation_count();
 726     if (mileage < iic)  mileage = iic;
 727     InvocationCounter* ic = method->invocation_counter();
 728     InvocationCounter* bc = method->backedge_counter();
 729     int icval = ic->count();
 730     if (ic->carry()) icval += CompileThreshold;
 731     if (mileage < icval)  mileage = icval;
 732     int bcval = bc->count();
 733     if (bc->carry()) bcval += CompileThreshold;
 734     if (mileage < bcval)  mileage = bcval;
 735   }
 736   return mileage;