Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 13796:8cd953e97e2d
rework of benchmark counters: fix size at VM entry, not at build time
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 29 Jan 2014 09:21:50 +0100 |
parents | ac1e626432f9 |
children | 49db2c1e3bee |
comparison
equal
deleted
inserted
replaced
13795:cfe85a075924 | 13796:8cd953e97e2d |
---|---|
1416 | 1416 |
1417 // ======= JavaThread ======== | 1417 // ======= JavaThread ======== |
1418 | 1418 |
1419 #ifdef GRAAL | 1419 #ifdef GRAAL |
1420 | 1420 |
1421 #if GRAAL_COUNTERS_SIZE > 0 | 1421 jlong* JavaThread::_graal_old_thread_counters; |
1422 jlong JavaThread::_graal_old_thread_counters[GRAAL_COUNTERS_SIZE]; | |
1423 | 1422 |
1424 bool graal_counters_include(oop threadObj) { | 1423 bool graal_counters_include(oop threadObj) { |
1425 return !GRAAL_COUNTERS_EXCLUDE_COMPILER_THREADS || threadObj == NULL || threadObj->klass() != SystemDictionary::CompilerThread_klass(); | 1424 return !GraalCountersExcludeCompiler || threadObj == NULL || threadObj->klass() != SystemDictionary::CompilerThread_klass(); |
1426 } | 1425 } |
1427 | 1426 |
1428 void JavaThread::collect_counters(typeArrayOop array) { | 1427 void JavaThread::collect_counters(typeArrayOop array) { |
1429 MutexLocker tl(Threads_lock); | 1428 if (GraalCounterSize > 0) { |
1430 for (int i = 0; i < array->length(); i++) { | 1429 MutexLocker tl(Threads_lock); |
1431 array->long_at_put(i, _graal_old_thread_counters[i]); | 1430 for (int i = 0; i < array->length(); i++) { |
1432 } | 1431 array->long_at_put(i, _graal_old_thread_counters[i]); |
1433 for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { | 1432 } |
1434 if (graal_counters_include(tp->threadObj())) { | 1433 for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { |
1435 for (int i = 0; i < array->length(); i++) { | 1434 if (graal_counters_include(tp->threadObj())) { |
1436 array->long_at_put(i, array->long_at(i) + tp->_graal_counters[i]); | 1435 for (int i = 0; i < array->length(); i++) { |
1436 array->long_at_put(i, array->long_at(i) + tp->_graal_counters[i]); | |
1437 } | |
1437 } | 1438 } |
1438 } | 1439 } |
1439 } | 1440 } |
1440 } | 1441 } |
1441 #else | |
1442 void JavaThread::collect_counters(typeArrayOop array) { | |
1443 // empty | |
1444 } | |
1445 #endif // GRAAL_COUNTERS_SIZE > 0 | |
1446 | 1442 |
1447 #endif // GRAAL | 1443 #endif // GRAAL |
1448 | 1444 |
1449 // A JavaThread is a normal Java thread | 1445 // A JavaThread is a normal Java thread |
1450 | 1446 |
1484 _stack_guard_state = stack_guard_unused; | 1480 _stack_guard_state = stack_guard_unused; |
1485 #ifdef GRAAL | 1481 #ifdef GRAAL |
1486 _graal_alternate_call_target = NULL; | 1482 _graal_alternate_call_target = NULL; |
1487 _graal_implicit_exception_pc = NULL; | 1483 _graal_implicit_exception_pc = NULL; |
1488 _graal_compiling = false; | 1484 _graal_compiling = false; |
1489 #if GRAAL_COUNTERS_SIZE > 0 | 1485 if (GraalCounterSize > 0) { |
1490 for (int i = 0; i < GRAAL_COUNTERS_SIZE; i++) { | 1486 _graal_counters = NEW_C_HEAP_ARRAY(jlong, GraalCounterSize, mtInternal); |
1491 _graal_counters[i] = 0; | 1487 memset(_graal_counters, 0, sizeof(jlong) * GraalCounterSize); |
1492 } | 1488 } else { |
1493 #endif // GRAAL_COUNTER_SIZE > 0 | 1489 _graal_counters = NULL; |
1490 } | |
1494 #endif // GRAAL | 1491 #endif // GRAAL |
1495 (void)const_cast<oop&>(_exception_oop = NULL); | 1492 (void)const_cast<oop&>(_exception_oop = NULL); |
1496 _exception_pc = 0; | 1493 _exception_pc = 0; |
1497 _exception_handler_pc = 0; | 1494 _exception_handler_pc = 0; |
1498 _is_method_handle_return = 0; | 1495 _is_method_handle_return = 0; |
1678 // All Java related clean up happens in exit | 1675 // All Java related clean up happens in exit |
1679 ThreadSafepointState::destroy(this); | 1676 ThreadSafepointState::destroy(this); |
1680 if (_thread_profiler != NULL) delete _thread_profiler; | 1677 if (_thread_profiler != NULL) delete _thread_profiler; |
1681 if (_thread_stat != NULL) delete _thread_stat; | 1678 if (_thread_stat != NULL) delete _thread_stat; |
1682 | 1679 |
1683 #if defined(GRAAL) && (GRAAL_COUNTERS_SIZE > 0) | 1680 #ifdef GRAAL |
1684 if (graal_counters_include(threadObj())) { | 1681 if (GraalCounterSize > 0 && graal_counters_include(threadObj())) { |
1685 for (int i = 0; i < GRAAL_COUNTERS_SIZE; i++) { | 1682 for (int i = 0; i < GraalCounterSize; i++) { |
1686 _graal_old_thread_counters[i] += _graal_counters[i]; | 1683 _graal_old_thread_counters[i] += _graal_counters[i]; |
1687 } | 1684 } |
1688 } | 1685 FREE_C_HEAP_ARRAY(jlong, _graal_counters, mtInternal); |
1689 #endif | 1686 } |
1687 #endif // GRAAL | |
1690 } | 1688 } |
1691 | 1689 |
1692 | 1690 |
1693 // The first routine called by a new Java thread | 1691 // The first routine called by a new Java thread |
1694 void JavaThread::run() { | 1692 void JavaThread::run() { |
3456 _number_of_non_daemon_threads = 0; | 3454 _number_of_non_daemon_threads = 0; |
3457 | 3455 |
3458 // Initialize global data structures and create system classes in heap | 3456 // Initialize global data structures and create system classes in heap |
3459 vm_init_globals(); | 3457 vm_init_globals(); |
3460 | 3458 |
3459 #ifdef GRAAL | |
3460 if (GraalCounterSize > 0) { | |
3461 JavaThread::_graal_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, GraalCounterSize, mtInternal); | |
3462 memset(JavaThread::_graal_old_thread_counters, 0, sizeof(jlong) * GraalCounterSize); | |
3463 } else { | |
3464 JavaThread::_graal_old_thread_counters = NULL; | |
3465 } | |
3466 #endif // GRAAL | |
3467 | |
3461 // Attach the main thread to this os thread | 3468 // Attach the main thread to this os thread |
3462 JavaThread* main_thread = new JavaThread(); | 3469 JavaThread* main_thread = new JavaThread(); |
3463 main_thread->set_thread_state(_thread_in_vm); | 3470 main_thread->set_thread_state(_thread_in_vm); |
3464 // must do this before set_active_handles and initialize_thread_local_storage | 3471 // must do this before set_active_handles and initialize_thread_local_storage |
3465 // Note: on solaris initialize_thread_local_storage() will (indirectly) | 3472 // Note: on solaris initialize_thread_local_storage() will (indirectly) |
4106 VM_Exit::set_vm_exited(); | 4113 VM_Exit::set_vm_exited(); |
4107 | 4114 |
4108 notify_vm_shutdown(); | 4115 notify_vm_shutdown(); |
4109 | 4116 |
4110 delete thread; | 4117 delete thread; |
4118 | |
4119 #ifdef GRAAL | |
4120 if (GraalCounterSize > 0) { | |
4121 FREE_C_HEAP_ARRAY(jlong, JavaThread::_graal_old_thread_counters, mtInternal); | |
4122 } | |
4123 #endif // GRAAL | |
4111 | 4124 |
4112 // exit_globals() will delete tty | 4125 // exit_globals() will delete tty |
4113 exit_globals(); | 4126 exit_globals(); |
4114 | 4127 |
4115 return true; | 4128 return true; |