1462
1463 void WatcherThread::print_on(outputStream* st) const {
1464 st->print("\"%s\" ", name());
1465 Thread::print_on(st);
1466 st->cr();
1467 }
1468
1469 // ======= JavaThread ========
1470
1471 #if INCLUDE_JVMCI
1472
1473 jlong* JavaThread::_jvmci_old_thread_counters;
1474
1475 bool jvmci_counters_include(JavaThread* thread) {
1476 oop threadObj = thread->threadObj();
1477 return !JVMCICountersExcludeCompiler || !thread->is_Compiler_thread();
1478 }
1479
1480 void JavaThread::collect_counters(typeArrayOop array) {
1481 if (JVMCICounterSize > 0) {
1482 // dcubed - Looks like the Threads_lock is for stable access
1483 // to _jvmci_old_thread_counters and _jvmci_counters.
1484 MutexLocker tl(Threads_lock);
1485 JavaThreadIteratorWithHandle jtiwh;
1486 for (int i = 0; i < array->length(); i++) {
1487 array->long_at_put(i, _jvmci_old_thread_counters[i]);
1488 }
1489 for (; JavaThread *tp = jtiwh.next(); ) {
1490 if (jvmci_counters_include(tp)) {
1491 for (int i = 0; i < array->length(); i++) {
1492 array->long_at_put(i, array->long_at(i) + tp->_jvmci_counters[i]);
1493 }
1494 }
1495 }
1496 }
1497 }
1498
1499 #endif // INCLUDE_JVMCI
1500
1501 // A JavaThread is a normal Java thread
1502
1503 void JavaThread::initialize() {
4633 if (version == JNI_VERSION_1_4) return JNI_TRUE;
4634 if (version == JNI_VERSION_1_6) return JNI_TRUE;
4635 if (version == JNI_VERSION_1_8) return JNI_TRUE;
4636 if (version == JNI_VERSION_9) return JNI_TRUE;
4637 if (version == JNI_VERSION_10) return JNI_TRUE;
4638 return JNI_FALSE;
4639 }
4640
4641 // Hash table of pointers found by a scan. Used for collecting hazard
4642 // pointers (ThreadsList references). Also used for collecting JavaThreads
4643 // that are indirectly referenced by hazard ptrs. An instance of this
4644 // class only contains one type of pointer.
4645 //
4646 class ThreadScanHashtable : public CHeapObj<mtThread> {
4647 private:
4648 static bool ptr_equals(void * const& s1, void * const& s2) {
4649 return s1 == s2;
4650 }
4651
4652 static unsigned int ptr_hash(void * const& s1) {
4653 return (unsigned int)(((uint32_t)(uintptr_t)s1) * 2654435761u);
4654 }
4655
4656 int _table_size;
4657 // ResourceHashtable SIZE is specified at compile time so our
4658 // dynamic _table_size is unused for now; 1031 is the first prime
4659 // after 1024.
4660 typedef ResourceHashtable<void *, int, &ThreadScanHashtable::ptr_hash,
4661 &ThreadScanHashtable::ptr_equals, 1031,
4662 ResourceObj::C_HEAP, mtThread> PtrTable;
4663 PtrTable * _ptrs;
4664
4665 public:
4666 // ResourceHashtable is passed to various functions and populated in
4667 // different places so we allocate it using C_HEAP to make it immune
4668 // from any ResourceMarks that happen to be in the code paths.
4669 ThreadScanHashtable(int table_size) : _table_size(table_size), _ptrs(new (ResourceObj::C_HEAP, mtThread) PtrTable()) {}
4670
4671 ~ThreadScanHashtable() { delete _ptrs; }
4672
|
1462
1463 void WatcherThread::print_on(outputStream* st) const {
1464 st->print("\"%s\" ", name());
1465 Thread::print_on(st);
1466 st->cr();
1467 }
1468
1469 // ======= JavaThread ========
1470
1471 #if INCLUDE_JVMCI
1472
1473 jlong* JavaThread::_jvmci_old_thread_counters;
1474
1475 bool jvmci_counters_include(JavaThread* thread) {
1476 oop threadObj = thread->threadObj();
1477 return !JVMCICountersExcludeCompiler || !thread->is_Compiler_thread();
1478 }
1479
1480 void JavaThread::collect_counters(typeArrayOop array) {
1481 if (JVMCICounterSize > 0) {
1482 MutexLocker tl(Threads_lock);
1483 JavaThreadIteratorWithHandle jtiwh;
1484 for (int i = 0; i < array->length(); i++) {
1485 array->long_at_put(i, _jvmci_old_thread_counters[i]);
1486 }
1487 for (; JavaThread *tp = jtiwh.next(); ) {
1488 if (jvmci_counters_include(tp)) {
1489 for (int i = 0; i < array->length(); i++) {
1490 array->long_at_put(i, array->long_at(i) + tp->_jvmci_counters[i]);
1491 }
1492 }
1493 }
1494 }
1495 }
1496
1497 #endif // INCLUDE_JVMCI
1498
1499 // A JavaThread is a normal Java thread
1500
1501 void JavaThread::initialize() {
4631 if (version == JNI_VERSION_1_4) return JNI_TRUE;
4632 if (version == JNI_VERSION_1_6) return JNI_TRUE;
4633 if (version == JNI_VERSION_1_8) return JNI_TRUE;
4634 if (version == JNI_VERSION_9) return JNI_TRUE;
4635 if (version == JNI_VERSION_10) return JNI_TRUE;
4636 return JNI_FALSE;
4637 }
4638
4639 // Hash table of pointers found by a scan. Used for collecting hazard
4640 // pointers (ThreadsList references). Also used for collecting JavaThreads
4641 // that are indirectly referenced by hazard ptrs. An instance of this
4642 // class only contains one type of pointer.
4643 //
4644 class ThreadScanHashtable : public CHeapObj<mtThread> {
4645 private:
4646 static bool ptr_equals(void * const& s1, void * const& s2) {
4647 return s1 == s2;
4648 }
4649
4650 static unsigned int ptr_hash(void * const& s1) {
4651 // 2654435761 = 2^32 * Phi (golden ratio)
4652 return (unsigned int)(((uint32_t)(uintptr_t)s1) * 2654435761u);
4653 }
4654
4655 int _table_size;
4656 // ResourceHashtable SIZE is specified at compile time so our
4657 // dynamic _table_size is unused for now; 1031 is the first prime
4658 // after 1024.
4659 typedef ResourceHashtable<void *, int, &ThreadScanHashtable::ptr_hash,
4660 &ThreadScanHashtable::ptr_equals, 1031,
4661 ResourceObj::C_HEAP, mtThread> PtrTable;
4662 PtrTable * _ptrs;
4663
4664 public:
4665 // ResourceHashtable is passed to various functions and populated in
4666 // different places so we allocate it using C_HEAP to make it immune
4667 // from any ResourceMarks that happen to be in the code paths.
4668 ThreadScanHashtable(int table_size) : _table_size(table_size), _ptrs(new (ResourceObj::C_HEAP, mtThread) PtrTable()) {}
4669
4670 ~ThreadScanHashtable() { delete _ptrs; }
4671
|