1293 NamedCounter* c = _named_counters; 1294 while (c) { 1295 if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) { 1296 int count = c->count(); 1297 if (count > 0) { 1298 bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter; 1299 if (Verbose) { 1300 tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : ""); 1301 } 1302 total_lock_count += count; 1303 if (eliminated) { 1304 eliminated_lock_count += count; 1305 } 1306 } 1307 } else if (c->tag() == NamedCounter::BiasedLockingCounter) { 1308 BiasedLockingCounters* blc = ((BiasedLockingNamedCounter*)c)->counters(); 1309 if (blc->nonzero()) { 1310 tty->print_cr("%s", c->name()); 1311 blc->print_on(tty); 1312 } 1313 } 1314 c = c->next(); 1315 } 1316 if (total_lock_count > 0) { 1317 tty->print_cr("dynamic locks: %d", total_lock_count); 1318 if (eliminated_lock_count) { 1319 tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count, 1320 (int)(eliminated_lock_count * 100.0 / total_lock_count)); 1321 } 1322 } 1323 } 1324 1325 // 1326 // Allocate a new NamedCounter. The JVMState is used to generate the 1327 // name which consists of method@line for the inlining tree. 1328 // 1329 1330 NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) { 1331 int max_depth = youngest_jvms->depth(); 1332 1333 // Visit scopes from youngest to oldest. 1334 bool first = true; 1335 stringStream st; 1336 for (int depth = max_depth; depth >= 1; depth--) { 1337 JVMState* jvms = youngest_jvms->of_depth(depth); 1338 ciMethod* m = jvms->has_method() ? jvms->method() : NULL; 1339 if (!first) { 1340 st.print(" "); 1341 } else { 1342 first = false; 1343 } 1344 int bci = jvms->bci(); 1345 if (bci < 0) bci = 0; 1346 st.print("%s.%s@%d", m->holder()->name()->as_utf8(), m->name()->as_utf8(), bci); 1347 // To print linenumbers instead of bci use: m->line_number_from_bci(bci) 1348 } 1349 NamedCounter* c; 1350 if (tag == NamedCounter::BiasedLockingCounter) { 1351 c = new BiasedLockingNamedCounter(strdup(st.as_string())); 1352 } else { 1353 c = new NamedCounter(strdup(st.as_string()), tag); 1354 } 1355 1356 // atomically add the new counter to the head of the list. We only 1357 // add counters so this is safe. 1358 NamedCounter* head; 1359 do { 1360 head = _named_counters; 1361 c->set_next(head); 1362 } while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head); 1363 return c; 1364 } 1365 1366 //----------------------------------------------------------------------------- 1367 // Non-product code 1368 #ifndef PRODUCT 1369 1370 int trace_exception_counter = 0; 1371 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) { 1372 ttyLocker ttyl; 1373 trace_exception_counter++; 1374 tty->print("%d [Exception (%s): ", trace_exception_counter, msg); 1375 exception_oop->print_value(); 1376 tty->print(" in "); 1377 CodeBlob* blob = CodeCache::find_blob(exception_pc); 1378 if (blob->is_nmethod()) { 1379 nmethod* nm = blob->as_nmethod_or_null(); | 1293 NamedCounter* c = _named_counters; 1294 while (c) { 1295 if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) { 1296 int count = c->count(); 1297 if (count > 0) { 1298 bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter; 1299 if (Verbose) { 1300 tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : ""); 1301 } 1302 total_lock_count += count; 1303 if (eliminated) { 1304 eliminated_lock_count += count; 1305 } 1306 } 1307 } else if (c->tag() == NamedCounter::BiasedLockingCounter) { 1308 BiasedLockingCounters* blc = ((BiasedLockingNamedCounter*)c)->counters(); 1309 if (blc->nonzero()) { 1310 tty->print_cr("%s", c->name()); 1311 blc->print_on(tty); 1312 } 1313 #if INCLUDE_RTM_OPT 1314 } else if (c->tag() == NamedCounter::RTMLockingCounter) { 1315 RTMLockingCounters* rlc = ((RTMLockingNamedCounter*)c)->counters(); 1316 if (rlc->nonzero()) { 1317 tty->print_cr("%s", c->name()); 1318 rlc->print_on(tty); 1319 } 1320 #endif 1321 } 1322 c = c->next(); 1323 } 1324 if (total_lock_count > 0) { 1325 tty->print_cr("dynamic locks: %d", total_lock_count); 1326 if (eliminated_lock_count) { 1327 tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count, 1328 (int)(eliminated_lock_count * 100.0 / total_lock_count)); 1329 } 1330 } 1331 } 1332 1333 // 1334 // Allocate a new NamedCounter. The JVMState is used to generate the 1335 // name which consists of method@line for the inlining tree. 1336 // 1337 1338 NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) { 1339 int max_depth = youngest_jvms->depth(); 1340 1341 // Visit scopes from youngest to oldest. 1342 bool first = true; 1343 stringStream st; 1344 for (int depth = max_depth; depth >= 1; depth--) { 1345 JVMState* jvms = youngest_jvms->of_depth(depth); 1346 ciMethod* m = jvms->has_method() ? jvms->method() : NULL; 1347 if (!first) { 1348 st.print(" "); 1349 } else { 1350 first = false; 1351 } 1352 int bci = jvms->bci(); 1353 if (bci < 0) bci = 0; 1354 st.print("%s.%s@%d", m->holder()->name()->as_utf8(), m->name()->as_utf8(), bci); 1355 // To print linenumbers instead of bci use: m->line_number_from_bci(bci) 1356 } 1357 NamedCounter* c; 1358 if (tag == NamedCounter::BiasedLockingCounter) { 1359 c = new BiasedLockingNamedCounter(strdup(st.as_string())); 1360 } else if (tag == NamedCounter::RTMLockingCounter) { 1361 c = new RTMLockingNamedCounter(strdup(st.as_string())); 1362 } else { 1363 c = new NamedCounter(strdup(st.as_string()), tag); 1364 } 1365 1366 // atomically add the new counter to the head of the list. We only 1367 // add counters so this is safe. 1368 NamedCounter* head; 1369 do { 1370 c->set_next(NULL); 1371 head = _named_counters; 1372 c->set_next(head); 1373 } while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head); 1374 return c; 1375 } 1376 1377 //----------------------------------------------------------------------------- 1378 // Non-product code 1379 #ifndef PRODUCT 1380 1381 int trace_exception_counter = 0; 1382 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) { 1383 ttyLocker ttyl; 1384 trace_exception_counter++; 1385 tty->print("%d [Exception (%s): ", trace_exception_counter, msg); 1386 exception_oop->print_value(); 1387 tty->print(" in "); 1388 CodeBlob* blob = CodeCache::find_blob(exception_pc); 1389 if (blob->is_nmethod()) { 1390 nmethod* nm = blob->as_nmethod_or_null(); |