comparison src/share/vm/code/nmethod.cpp @ 15434:7461c3bf278a

Improve PrintNMethodStatistics output: add Shark compiler and metadata size. Properly record nmethods for native wrapper.
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 29 Apr 2014 16:13:28 +0200
parents 62e218478931
children e20a45d17181
comparison
equal deleted inserted replaced
15433:8638307944be 15434:7461c3bf278a
140 int scopes_pcs_size; 140 int scopes_pcs_size;
141 int dependencies_size; 141 int dependencies_size;
142 int handler_table_size; 142 int handler_table_size;
143 int nul_chk_table_size; 143 int nul_chk_table_size;
144 int oops_size; 144 int oops_size;
145 int metadata_size;
145 146
146 void note_nmethod(nmethod* nm) { 147 void note_nmethod(nmethod* nm) {
147 nmethod_count += 1; 148 nmethod_count += 1;
148 total_size += nm->size(); 149 total_size += nm->size();
149 relocation_size += nm->relocation_size(); 150 relocation_size += nm->relocation_size();
150 consts_size += nm->consts_size(); 151 consts_size += nm->consts_size();
151 insts_size += nm->insts_size(); 152 insts_size += nm->insts_size();
152 stub_size += nm->stub_size(); 153 stub_size += nm->stub_size();
153 oops_size += nm->oops_size(); 154 oops_size += nm->oops_size();
155 metadata_size += nm->metadata_size();
154 scopes_data_size += nm->scopes_data_size(); 156 scopes_data_size += nm->scopes_data_size();
155 scopes_pcs_size += nm->scopes_pcs_size(); 157 scopes_pcs_size += nm->scopes_pcs_size();
156 dependencies_size += nm->dependencies_size(); 158 dependencies_size += nm->dependencies_size();
157 handler_table_size += nm->handler_table_size(); 159 handler_table_size += nm->handler_table_size();
158 nul_chk_table_size += nm->nul_chk_table_size(); 160 nul_chk_table_size += nm->nul_chk_table_size();
159 } 161 }
160 void print_nmethod_stats(const char* name) { 162 void print_nmethod_stats(const char* name) {
161 if (nmethod_count == 0) return; 163 if (nmethod_count == 0) return;
162 tty->print_cr("Statistics for %d bytecoded nmethods for %s:", nmethod_count, name); 164 tty->print_cr("Statistics for %d bytecoded nmethods for %s:", nmethod_count, name);
163 if (total_size != 0) tty->print_cr(" total in heap = %d", total_size); 165 if (total_size != 0) tty->print_cr(" total in heap = %d", total_size);
166 if (nmethod_count != 0) tty->print_cr(" header = %d", nmethod_count * sizeof(nmethod));
164 if (relocation_size != 0) tty->print_cr(" relocation = %d", relocation_size); 167 if (relocation_size != 0) tty->print_cr(" relocation = %d", relocation_size);
165 if (consts_size != 0) tty->print_cr(" constants = %d", consts_size); 168 if (consts_size != 0) tty->print_cr(" constants = %d", consts_size);
166 if (insts_size != 0) tty->print_cr(" main code = %d", insts_size); 169 if (insts_size != 0) tty->print_cr(" main code = %d", insts_size);
167 if (stub_size != 0) tty->print_cr(" stub code = %d", stub_size); 170 if (stub_size != 0) tty->print_cr(" stub code = %d", stub_size);
168 if (oops_size != 0) tty->print_cr(" oops = %d", oops_size); 171 if (oops_size != 0) tty->print_cr(" oops = %d", oops_size);
172 if (metadata_size != 0) tty->print_cr(" metadata = %d", metadata_size);
169 if (scopes_data_size != 0) tty->print_cr(" scopes data = %d", scopes_data_size); 173 if (scopes_data_size != 0) tty->print_cr(" scopes data = %d", scopes_data_size);
170 if (scopes_pcs_size != 0) tty->print_cr(" scopes pcs = %d", scopes_pcs_size); 174 if (scopes_pcs_size != 0) tty->print_cr(" scopes pcs = %d", scopes_pcs_size);
171 if (dependencies_size != 0) tty->print_cr(" dependencies = %d", dependencies_size); 175 if (dependencies_size != 0) tty->print_cr(" dependencies = %d", dependencies_size);
172 if (handler_table_size != 0) tty->print_cr(" handler table = %d", handler_table_size); 176 if (handler_table_size != 0) tty->print_cr(" handler table = %d", handler_table_size);
173 if (nul_chk_table_size != 0) tty->print_cr(" nul chk table = %d", nul_chk_table_size); 177 if (nul_chk_table_size != 0) tty->print_cr(" nul chk table = %d", nul_chk_table_size);
178 int native_nmethod_count; 182 int native_nmethod_count;
179 int native_total_size; 183 int native_total_size;
180 int native_relocation_size; 184 int native_relocation_size;
181 int native_insts_size; 185 int native_insts_size;
182 int native_oops_size; 186 int native_oops_size;
187 int native_metadata_size;
183 void note_native_nmethod(nmethod* nm) { 188 void note_native_nmethod(nmethod* nm) {
184 native_nmethod_count += 1; 189 native_nmethod_count += 1;
185 native_total_size += nm->size(); 190 native_total_size += nm->size();
186 native_relocation_size += nm->relocation_size(); 191 native_relocation_size += nm->relocation_size();
187 native_insts_size += nm->insts_size(); 192 native_insts_size += nm->insts_size();
188 native_oops_size += nm->oops_size(); 193 native_oops_size += nm->oops_size();
194 native_metadata_size += nm->metadata_size();
189 } 195 }
190 void print_native_nmethod_stats() { 196 void print_native_nmethod_stats() {
191 if (native_nmethod_count == 0) return; 197 if (native_nmethod_count == 0) return;
192 tty->print_cr("Statistics for %d native nmethods:", native_nmethod_count); 198 tty->print_cr("Statistics for %d native nmethods:", native_nmethod_count);
193 if (native_total_size != 0) tty->print_cr(" N. total size = %d", native_total_size); 199 if (native_total_size != 0) tty->print_cr(" N. total size = %d", native_total_size);
194 if (native_relocation_size != 0) tty->print_cr(" N. relocation = %d", native_relocation_size); 200 if (native_relocation_size != 0) tty->print_cr(" N. relocation = %d", native_relocation_size);
195 if (native_insts_size != 0) tty->print_cr(" N. main code = %d", native_insts_size); 201 if (native_insts_size != 0) tty->print_cr(" N. main code = %d", native_insts_size);
196 if (native_oops_size != 0) tty->print_cr(" N. oops = %d", native_oops_size); 202 if (native_oops_size != 0) tty->print_cr(" N. oops = %d", native_oops_size);
203 if (native_metadata_size != 0) tty->print_cr(" N. metadata = %d", native_metadata_size);
197 } 204 }
198 }; 205 };
199 206
200 struct pc_nmethod_stats_struct { 207 struct pc_nmethod_stats_struct {
201 int pc_desc_resets; // number of resets (= number of caches) 208 int pc_desc_resets; // number of resets (= number of caches)
227 static java_nmethod_stats_struct c2_java_nmethod_stats; 234 static java_nmethod_stats_struct c2_java_nmethod_stats;
228 #endif 235 #endif
229 #ifdef GRAAL 236 #ifdef GRAAL
230 static java_nmethod_stats_struct graal_java_nmethod_stats; 237 static java_nmethod_stats_struct graal_java_nmethod_stats;
231 #endif 238 #endif
239 #ifdef SHARK
240 static java_nmethod_stats_struct shark_java_nmethod_stats;
241 #endif
232 static java_nmethod_stats_struct unknown_java_nmethod_stats; 242 static java_nmethod_stats_struct unknown_java_nmethod_stats;
233 243
234 static native_nmethod_stats_struct native_nmethod_stats; 244 static native_nmethod_stats_struct native_nmethod_stats;
235 static pc_nmethod_stats_struct pc_nmethod_stats; 245 static pc_nmethod_stats_struct pc_nmethod_stats;
246
247 static void note_native_wrapper_nmethod(nmethod* nm) {
248 native_nmethod_stats.note_native_nmethod(nm);
249 }
236 250
237 static void note_java_nmethod(nmethod* nm) { 251 static void note_java_nmethod(nmethod* nm) {
238 #ifdef COMPILER1 252 #ifdef COMPILER1
239 if (nm->is_compiled_by_c1()) { 253 if (nm->is_compiled_by_c1()) {
240 c1_java_nmethod_stats.note_nmethod(nm); 254 c1_java_nmethod_stats.note_nmethod(nm);
246 } else 260 } else
247 #endif 261 #endif
248 #ifdef GRAAL 262 #ifdef GRAAL
249 if (nm->is_compiled_by_graal()) { 263 if (nm->is_compiled_by_graal()) {
250 graal_java_nmethod_stats.note_nmethod(nm); 264 graal_java_nmethod_stats.note_nmethod(nm);
265 } else
266 #endif
267 #ifdef SHARK
268 if (nm->is_compiled_by_shark()) {
269 shark_java_nmethod_stats.note_nmethod(nm);
251 } else 270 } else
252 #endif 271 #endif
253 { 272 {
254 unknown_java_nmethod_stats.note_nmethod(nm); 273 unknown_java_nmethod_stats.note_nmethod(nm);
255 } 274 }
554 nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size, 573 nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size,
555 compile_id, &offsets, 574 compile_id, &offsets,
556 code_buffer, frame_size, 575 code_buffer, frame_size,
557 basic_lock_owner_sp_offset, 576 basic_lock_owner_sp_offset,
558 basic_lock_sp_offset, oop_maps); 577 basic_lock_sp_offset, oop_maps);
559 if (nm != NULL) note_java_nmethod(nm); 578 if (nm != NULL) note_native_wrapper_nmethod(nm);
560 if (PrintAssembly && nm != NULL) { 579 if (PrintAssembly && nm != NULL) {
561 Disassembler::decode(nm); 580 Disassembler::decode(nm);
562 } 581 }
563 } 582 }
564 // verify nmethod 583 // verify nmethod
3081 c2_java_nmethod_stats.print_nmethod_stats("C2"); 3100 c2_java_nmethod_stats.print_nmethod_stats("C2");
3082 #endif 3101 #endif
3083 #ifdef GRAAL 3102 #ifdef GRAAL
3084 graal_java_nmethod_stats.print_nmethod_stats("Graal"); 3103 graal_java_nmethod_stats.print_nmethod_stats("Graal");
3085 #endif 3104 #endif
3105 #ifdef SHARK
3106 shark_java_nmethod_stats.print_nmethod_stats("Shark");
3107 #endif
3086 unknown_java_nmethod_stats.print_nmethod_stats("Unknown"); 3108 unknown_java_nmethod_stats.print_nmethod_stats("Unknown");
3087 DebugInformationRecorder::print_statistics(); 3109 DebugInformationRecorder::print_statistics();
3110 #ifndef PRODUCT
3088 pc_nmethod_stats.print_pc_stats(); 3111 pc_nmethod_stats.print_pc_stats();
3112 #endif
3089 Dependencies::print_statistics(); 3113 Dependencies::print_statistics();
3090 if (xtty != NULL) xtty->tail("statistics"); 3114 if (xtty != NULL) xtty->tail("statistics");
3091 } 3115 }