comparison src/share/vm/oops/methodData.cpp @ 13181:389d40d7d99f

fixed bug in MethodData and added assertion that precomputed size == initialized size reduced diff to upstream HotSpot
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 Nov 2013 02:31:03 +0100
parents d84fa69a9874
children d8041d695d19
comparison
equal deleted inserted replaced
13180:feff37de4465 13181:389d40d7d99f
819 Bytecodes::Code c; 819 Bytecodes::Code c;
820 int empty_bc_count = 0; // number of bytecodes lacking data 820 int empty_bc_count = 0; // number of bytecodes lacking data
821 while ((c = stream.next()) >= 0) { 821 while ((c = stream.next()) >= 0) {
822 int size_in_bytes = compute_data_size(&stream); 822 int size_in_bytes = compute_data_size(&stream);
823 data_size += size_in_bytes; 823 data_size += size_in_bytes;
824 824 if (size_in_bytes == 0 GRAAL_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1;
825 if (is_empty_data(size_in_bytes, c)) empty_bc_count += 1;
826 } 825 }
827 int object_size = in_bytes(data_offset()) + data_size; 826 int object_size = in_bytes(data_offset()) + data_size;
828 827
829 // Add some extra DataLayout cells (at least one) to track stray traps. 828 // Add some extra DataLayout cells (at least one) to track stray traps.
830 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); 829 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
831 object_size += extra_data_count * DataLayout::compute_size_in_bytes(0); 830 object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
832 831
833 #ifndef GRAALVM
834 // Add a cell to record information about modified arguments. 832 // Add a cell to record information about modified arguments.
835 int arg_size = method->size_of_parameters(); 833 int arg_size = method->size_of_parameters();
836 object_size += DataLayout::compute_size_in_bytes(arg_size+1); 834 object_size += DataLayout::compute_size_in_bytes(arg_size+1);
837 835
838 // Reserve room for an area of the MDO dedicated to profiling of 836 // Reserve room for an area of the MDO dedicated to profiling of
839 // parameters 837 // parameters
840 int args_cell = ParametersTypeData::compute_cell_count(method()); 838 int args_cell = ParametersTypeData::compute_cell_count(method());
841 if (args_cell > 0) { 839 if (args_cell > 0) {
842 object_size += DataLayout::compute_size_in_bytes(args_cell); 840 object_size += DataLayout::compute_size_in_bytes(args_cell);
843 } 841 }
844 #endif
845 return object_size; 842 return object_size;
846 } 843 }
847 844
848 // Compute the size of the MethodData* necessary to store 845 // Compute the size of the MethodData* necessary to store
849 // profiling information about a given method. Size is in words 846 // profiling information about a given method. Size is in words
1049 // Set the method back-pointer. 1046 // Set the method back-pointer.
1050 _method = method(); 1047 _method = method();
1051 initialize(); 1048 initialize();
1052 } 1049 }
1053 1050
1054 void MethodData::initialize() { 1051 void MethodData::initialize(bool for_reprofile) {
1055 No_Safepoint_Verifier no_safepoint; // init function atomic wrt GC 1052 No_Safepoint_Verifier no_safepoint; // init function atomic wrt GC
1056 ResourceMark rm; 1053 ResourceMark rm;
1057 1054
1058 init(); 1055 init();
1059 set_creation_mileage(mileage_of(method())); 1056 set_creation_mileage(mileage_of(method()));
1066 BytecodeStream stream(method()); 1063 BytecodeStream stream(method());
1067 Bytecodes::Code c; 1064 Bytecodes::Code c;
1068 while ((c = stream.next()) >= 0) { 1065 while ((c = stream.next()) >= 0) {
1069 int size_in_bytes = initialize_data(&stream, data_size); 1066 int size_in_bytes = initialize_data(&stream, data_size);
1070 data_size += size_in_bytes; 1067 data_size += size_in_bytes;
1071 1068 if (size_in_bytes == 0 GRAAL_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1;
1072 if (is_empty_data(size_in_bytes, c)) empty_bc_count += 1;
1073 } 1069 }
1074 _data_size = data_size; 1070 _data_size = data_size;
1075 int object_size = in_bytes(data_offset()) + data_size; 1071 int object_size = in_bytes(data_offset()) + data_size;
1076 1072
1077 // Add some extra DataLayout cells (at least one) to track stray traps. 1073 // Add some extra DataLayout cells (at least one) to track stray traps.
1078 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); 1074 int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
1079 int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0); 1075 int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0);
1080 object_size += extra_size; 1076
1081 1077 #ifdef GRAAL
1082 Copy::zero_to_bytes((HeapWord*) extra_data_base(), extra_size); 1078 if (for_reprofile) {
1083 1079 // Clear out extra data
1084 #ifndef GRAALVM 1080 Copy::zero_to_bytes((HeapWord*) extra_data_base(), extra_size);
1081 }
1082 #endif
1083
1085 // Add a cell to record information about modified arguments. 1084 // Add a cell to record information about modified arguments.
1086 // Set up _args_modified array after traps cells so that 1085 // Set up _args_modified array after traps cells so that
1087 // the code for traps cells works. 1086 // the code for traps cells works.
1088 DataLayout *dp = data_layout_at(data_size + extra_size); 1087 DataLayout *dp = data_layout_at(data_size + extra_size);
1089 1088
1105 DataLayout *dp = data_layout_at(data_size + extra_size + arg_data_size); 1104 DataLayout *dp = data_layout_at(data_size + extra_size + arg_data_size);
1106 dp->initialize(DataLayout::parameters_type_data_tag, 0, args_cell); 1105 dp->initialize(DataLayout::parameters_type_data_tag, 0, args_cell);
1107 } else { 1106 } else {
1108 _parameters_type_data_di = -1; 1107 _parameters_type_data_di = -1;
1109 } 1108 }
1110 #else
1111 _parameters_type_data_di = -1;
1112 #endif
1113 1109
1114 // Set an initial hint. Don't use set_hint_di() because 1110 // Set an initial hint. Don't use set_hint_di() because
1115 // first_di() may be out of bounds if data_size is 0. 1111 // first_di() may be out of bounds if data_size is 0.
1116 // In that situation, _hint_di is never used, but at 1112 // In that situation, _hint_di is never used, but at
1117 // least well-defined. 1113 // least well-defined.
1118 _hint_di = first_di(); 1114 _hint_di = first_di();
1119 1115
1120 post_initialize(&stream); 1116 post_initialize(&stream);
1121 1117
1118 assert(object_size == compute_allocation_size_in_bytes(methodHandle(_method)), "MethodData: computed size != initialized size");
1122 set_size(object_size); 1119 set_size(object_size);
1123 } 1120 }
1124 1121
1125 void MethodData::init() { 1122 void MethodData::init() {
1126 _invocation_counter.init(); 1123 _invocation_counter.init();
1139 _nof_overflow_traps = 0; 1136 _nof_overflow_traps = 0;
1140 clear_escape_info(); 1137 clear_escape_info();
1141 assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align"); 1138 assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align");
1142 Copy::zero_to_words((HeapWord*) &_trap_hist, 1139 Copy::zero_to_words((HeapWord*) &_trap_hist,
1143 sizeof(_trap_hist) / sizeof(HeapWord)); 1140 sizeof(_trap_hist) / sizeof(HeapWord));
1144 }
1145
1146 bool MethodData::is_empty_data(int size_in_bytes, Bytecodes::Code code) {
1147 #ifdef GRAAL
1148 return size_in_bytes == 0 && Bytecodes::can_trap(code);
1149 #else
1150 return size_in_bytes == 0;
1151 #endif
1152 } 1141 }
1153 1142
1154 // Get a measure of how much mileage the method has on it. 1143 // Get a measure of how much mileage the method has on it.
1155 int MethodData::mileage_of(Method* method) { 1144 int MethodData::mileage_of(Method* method) {
1156 int mileage = 0; 1145 int mileage = 0;