< prev index next >
src/share/vm/runtime/thread.cpp
Print this page
@@ -3181,10 +3181,11 @@
JavaThread* Threads::_thread_list = NULL;
int Threads::_number_of_threads = 0;
int Threads::_number_of_non_daemon_threads = 0;
int Threads::_return_code = 0;
+int Threads::_thread_claim_parity = 0;
size_t JavaThread::_stack_size_at_create = 0;
#ifdef ASSERT
bool Threads::_vm_complete = false;
#endif
@@ -3215,11 +3216,10 @@
}
// If CompilerThreads ever become non-JavaThreads, add them here
}
-
void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
TraceTime timer("Initialize java.lang classes", TraceStartupTime);
if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
create_vm_init_libraries();
@@ -4044,10 +4044,30 @@
p->oops_do(f, cld_f, cf);
}
VMThread::vm_thread()->oops_do(f, cld_f, cf);
}
+void Threads::change_thread_claim_parity() {
+ // Set the new claim parity.
+ assert(_thread_claim_parity >= 0 && _thread_claim_parity <= 2,
+ "Not in range.");
+ _thread_claim_parity++;
+ if (_thread_claim_parity == 3) _thread_claim_parity = 1;
+ assert(_thread_claim_parity >= 1 && _thread_claim_parity <= 2,
+ "Not in range.");
+}
+
+#ifndef PRODUCT
+void Threads::assert_all_threads_claimed() {
+ ALL_JAVA_THREADS(p) {
+ const int thread_parity = p->oops_do_parity();
+ assert((thread_parity == _thread_claim_parity),
+ err_msg("Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity));
+ }
+}
+#endif // PRODUCT
+
void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
// Introduce a mechanism allowing parallel threads to claim threads as
// root groups. Overhead should be small enough to use all the time,
// even in sequential code.
SharedHeap* sh = SharedHeap::heap();
@@ -4058,11 +4078,11 @@
// is being used for parallelism elsewhere.
bool is_par = sh->n_par_threads() > 0;
assert(!is_par ||
(SharedHeap::heap()->n_par_threads() ==
SharedHeap::heap()->workers()->active_workers()), "Mismatch");
- int cp = SharedHeap::heap()->strong_roots_parity();
+ int cp = Threads::thread_claim_parity();
ALL_JAVA_THREADS(p) {
if (p->claim_oops_do(is_par, cp)) {
p->oops_do(f, cld_f, cf);
}
}
< prev index next >