comparison src/share/vm/oops/methodDataOop.cpp @ 4568:8e1d9c27989a

better allocation of methodData's extraData so that exceptions and deoptimizations can be recorded more accurately
author Christian Haeubl <christian.haeubl@oracle.com>
date Fri, 10 Feb 2012 17:59:35 -0800
parents f7251c729b31
children 18a5539bf19b
comparison
equal deleted inserted replaced
4567:716fa6564c55 4568:8e1d9c27989a
553 // a DataLayout header, with no extra cells. 553 // a DataLayout header, with no extra cells.
554 assert(cell_count >= 0, "sanity"); 554 assert(cell_count >= 0, "sanity");
555 return DataLayout::compute_size_in_bytes(cell_count); 555 return DataLayout::compute_size_in_bytes(cell_count);
556 } 556 }
557 557
558 #ifdef GRAAL
559 int methodDataOopDesc::compute_extra_data_count(int data_size, int empty_bc_count) {
560 if (!ProfileTraps) return 0;
561
562 // Assume that up to 30% of the possibly trapping BCIs with no MDP will need to allocate one.
563 return MIN2(empty_bc_count, MAX2(4, (empty_bc_count * 30) / 100));
564 }
565 #else
558 int methodDataOopDesc::compute_extra_data_count(int data_size, int empty_bc_count) { 566 int methodDataOopDesc::compute_extra_data_count(int data_size, int empty_bc_count) {
559 if (ProfileTraps) { 567 if (ProfileTraps) {
560 // Assume that up to 3% of BCIs with no MDP will need to allocate one. 568 // Assume that up to 3% of BCIs with no MDP will need to allocate one.
561 int extra_data_count = (uint)(empty_bc_count * 3) / 128 + 1; 569 int extra_data_count = (uint)(empty_bc_count * 3) / 128 + 1;
562 // If the method is large, let the extra BCIs grow numerous (to ~1%). 570 // If the method is large, let the extra BCIs grow numerous (to ~1%).
569 return extra_data_count; 577 return extra_data_count;
570 } else { 578 } else {
571 return 0; 579 return 0;
572 } 580 }
573 } 581 }
582 #endif
574 583
575 // Compute the size of the methodDataOop necessary to store 584 // Compute the size of the methodDataOop necessary to store
576 // profiling information about a given method. Size is in bytes. 585 // profiling information about a given method. Size is in bytes.
577 int methodDataOopDesc::compute_allocation_size_in_bytes(methodHandle method) { 586 int methodDataOopDesc::compute_allocation_size_in_bytes(methodHandle method) {
578 int data_size = 0; 587 int data_size = 0;
580 Bytecodes::Code c; 589 Bytecodes::Code c;
581 int empty_bc_count = 0; // number of bytecodes lacking data 590 int empty_bc_count = 0; // number of bytecodes lacking data
582 while ((c = stream.next()) >= 0) { 591 while ((c = stream.next()) >= 0) {
583 int size_in_bytes = compute_data_size(&stream); 592 int size_in_bytes = compute_data_size(&stream);
584 data_size += size_in_bytes; 593 data_size += size_in_bytes;
585 if (size_in_bytes == 0) empty_bc_count += 1; 594
595 if (is_empty_data(size_in_bytes, c)) empty_bc_count++;
586 } 596 }
587 int object_size = in_bytes(data_offset()) + data_size; 597 int object_size = in_bytes(data_offset()) + data_size;
588 598
589 // Add some extra DataLayout cells (at least one) to track stray traps. 599 // Add some extra DataLayout cells (at least one) to track stray traps.
590 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); 600 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
591 object_size += extra_data_count * DataLayout::compute_size_in_bytes(0); 601 object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
592 602
603 #ifndef GRAAL
593 // Add a cell to record information about modified arguments. 604 // Add a cell to record information about modified arguments.
594 int arg_size = method->size_of_parameters(); 605 int arg_size = method->size_of_parameters();
595 object_size += DataLayout::compute_size_in_bytes(arg_size+1); 606 object_size += DataLayout::compute_size_in_bytes(arg_size+1);
607 #endif
596 return object_size; 608 return object_size;
597 } 609 }
598 610
599 // Compute the size of the methodDataOop necessary to store 611 // Compute the size of the methodDataOop necessary to store
600 // profiling information about a given method. Size is in words 612 // profiling information about a given method. Size is in words
779 BytecodeStream stream(method); 791 BytecodeStream stream(method);
780 Bytecodes::Code c; 792 Bytecodes::Code c;
781 while ((c = stream.next()) >= 0) { 793 while ((c = stream.next()) >= 0) {
782 int size_in_bytes = initialize_data(&stream, data_size); 794 int size_in_bytes = initialize_data(&stream, data_size);
783 data_size += size_in_bytes; 795 data_size += size_in_bytes;
784 if (size_in_bytes == 0) empty_bc_count += 1; 796
797 if (is_empty_data(size_in_bytes, c)) empty_bc_count++;
785 } 798 }
786 _data_size = data_size; 799 _data_size = data_size;
787 int object_size = in_bytes(data_offset()) + data_size; 800 int object_size = in_bytes(data_offset()) + data_size;
788 801
789 // Add some extra DataLayout cells (at least one) to track stray traps. 802 // Add some extra DataLayout cells (at least one) to track stray traps.
790 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); 803 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
791 int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0); 804 int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0);
792 805 object_size += extra_size;
806
807 #ifndef GRAAL
793 // Add a cell to record information about modified arguments. 808 // Add a cell to record information about modified arguments.
794 // Set up _args_modified array after traps cells so that 809 // Set up _args_modified array after traps cells so that
795 // the code for traps cells works. 810 // the code for traps cells works.
796 DataLayout *dp = data_layout_at(data_size + extra_size); 811 DataLayout *dp = data_layout_at(data_size + extra_size);
797 812
798 int arg_size = method->size_of_parameters(); 813 int arg_size = method->size_of_parameters();
799 dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1); 814 dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1);
800 815
801 object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1); 816 object_size += DataLayout::compute_size_in_bytes(arg_size+1);
817 #endif
802 818
803 // Set an initial hint. Don't use set_hint_di() because 819 // Set an initial hint. Don't use set_hint_di() because
804 // first_di() may be out of bounds if data_size is 0. 820 // first_di() may be out of bounds if data_size is 0.
805 // In that situation, _hint_di is never used, but at 821 // In that situation, _hint_di is never used, but at
806 // least well-defined. 822 // least well-defined.
807 _hint_di = first_di(); 823 _hint_di = first_di();
808 824
809 post_initialize(&stream); 825 post_initialize(&stream);
810 826
811 set_object_is_parsable(object_size); 827 set_object_is_parsable(object_size);
828 }
829
830 bool methodDataOopDesc::is_empty_data(int size_in_bytes, Bytecodes::Code code) {
831 #ifdef GRAAL
832 return size_in_bytes == 0 && Bytecodes::can_trap(code);
833 #else
834 return size_in_bytes == 0;
835 #endif
812 } 836 }
813 837
814 // Get a measure of how much mileage the method has on it. 838 // Get a measure of how much mileage the method has on it.
815 int methodDataOopDesc::mileage_of(methodOop method) { 839 int methodDataOopDesc::mileage_of(methodOop method) {
816 int mileage = 0; 840 int mileage = 0;