Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 11852:d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 30 Sep 2013 18:32:26 +0200 |
parents | 6b0fd0964b87 |
children | ec267141f753 |
comparison
equal
deleted
inserted
replaced
11828:1d64bfb3f481 | 11852:d7964e96b0b0 |
---|---|
1409 st->cr(); | 1409 st->cr(); |
1410 } | 1410 } |
1411 | 1411 |
1412 // ======= JavaThread ======== | 1412 // ======= JavaThread ======== |
1413 | 1413 |
1414 #ifdef GRAAL | |
1415 | |
1416 #if GRAAL_COUNTERS_SIZE > 0 | |
1417 jlong JavaThread::_graal_old_counters[GRAAL_COUNTERS_SIZE]; | |
1418 | |
1419 bool graal_counters_include(oop threadObj) { | |
1420 return !GRAAL_COUNTERS_EXCLUDE_COMPILER_THREADS || threadObj == NULL || threadObj->klass() != SystemDictionary::CompilerThread_klass(); | |
1421 } | |
1422 | |
1423 void JavaThread::collect_counters(typeArrayOop array) { | |
1424 MutexLocker tl(Threads_lock); | |
1425 for (int i = 0; i < array->length(); i++) { | |
1426 array->long_at_put(i, _graal_old_counters[i]); | |
1427 } | |
1428 for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { | |
1429 if (graal_counters_include(tp->threadObj())) { | |
1430 for (int i = 0; i < array->length(); i++) { | |
1431 array->long_at_put(i, array->long_at(i) + tp->_graal_counters[i]); | |
1432 } | |
1433 } | |
1434 } | |
1435 } | |
1436 #else | |
1437 void JavaThread::collect_counters(typeArrayOop array) { | |
1438 // empty | |
1439 } | |
1440 #endif // GRAAL_COUNTERS_SIZE > 0 | |
1441 | |
1442 #endif // GRAAL | |
1443 | |
1414 // A JavaThread is a normal Java thread | 1444 // A JavaThread is a normal Java thread |
1415 | 1445 |
1416 void JavaThread::initialize() { | 1446 void JavaThread::initialize() { |
1417 // Initialize fields | 1447 // Initialize fields |
1418 | 1448 |
1447 _in_deopt_handler = 0; | 1477 _in_deopt_handler = 0; |
1448 _doing_unsafe_access = false; | 1478 _doing_unsafe_access = false; |
1449 _stack_guard_state = stack_guard_unused; | 1479 _stack_guard_state = stack_guard_unused; |
1450 #ifdef GRAAL | 1480 #ifdef GRAAL |
1451 _graal_alternate_call_target = NULL; | 1481 _graal_alternate_call_target = NULL; |
1482 for (int i = 0; i < GRAAL_COUNTERS_SIZE; i++) { | |
1483 _graal_counters[i] = 0; | |
1484 } | |
1452 #endif | 1485 #endif |
1453 _exception_oop = NULL; | 1486 _exception_oop = NULL; |
1454 _exception_pc = 0; | 1487 _exception_pc = 0; |
1455 _exception_handler_pc = 0; | 1488 _exception_handler_pc = 0; |
1456 _is_method_handle_return = 0; | 1489 _is_method_handle_return = 0; |
1636 | 1669 |
1637 // All Java related clean up happens in exit | 1670 // All Java related clean up happens in exit |
1638 ThreadSafepointState::destroy(this); | 1671 ThreadSafepointState::destroy(this); |
1639 if (_thread_profiler != NULL) delete _thread_profiler; | 1672 if (_thread_profiler != NULL) delete _thread_profiler; |
1640 if (_thread_stat != NULL) delete _thread_stat; | 1673 if (_thread_stat != NULL) delete _thread_stat; |
1674 | |
1675 #if defined(GRAAL) && (GRAAL_COUNTERS_SIZE > 0) | |
1676 if (graal_counters_include(threadObj())) { | |
1677 for (int i = 0; i < GRAAL_COUNTERS_SIZE; i++) { | |
1678 _graal_old_counters[i] += _graal_counters[i]; | |
1679 } | |
1680 } | |
1681 #endif | |
1641 } | 1682 } |
1642 | 1683 |
1643 | 1684 |
1644 // The first routine called by a new Java thread | 1685 // The first routine called by a new Java thread |
1645 void JavaThread::run() { | 1686 void JavaThread::run() { |