4423 // Drain the queue - which may cause stealing
4424 G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _queues, &_terminator);
4425 drain_queue.do_void();
4426 // Allocation buffers were retired at the end of G1ParEvacuateFollowersClosure
4427 assert(pss->queue_is_empty(), "should be");
4428 }
4429 };
4430
4431 void G1CollectedHeap::process_weak_jni_handles() {
4432 double ref_proc_start = os::elapsedTime();
4433
4434 G1STWIsAliveClosure is_alive(this);
4435 G1KeepAliveClosure keep_alive(this);
4436 JNIHandles::weak_oops_do(&is_alive, &keep_alive);
4437
4438 double ref_proc_time = os::elapsedTime() - ref_proc_start;
4439 g1_policy()->phase_times()->record_ref_proc_time(ref_proc_time * 1000.0);
4440 }
4441
4442 void G1CollectedHeap::preserve_cm_referents(G1ParScanThreadStateSet* per_thread_states) {
4443 double preserve_cm_referents_start = os::elapsedTime();
4444 // Any reference objects, in the collection set, that were 'discovered'
4445 // by the CM ref processor should have already been copied (either by
4446 // applying the external root copy closure to the discovered lists, or
4447 // by following an RSet entry).
4448 //
4449 // But some of the referents, that are in the collection set, that these
4450 // reference objects point to may not have been copied: the STW ref
4451 // processor would have seen that the reference object had already
4452 // been 'discovered' and would have skipped discovering the reference,
4453 // but would not have treated the reference object as a regular oop.
4454 // As a result the copy closure would not have been applied to the
4455 // referent object.
4456 //
4457 // We need to explicitly copy these referent objects - the references
4458 // will be processed at the end of remarking.
4459 //
4460 // We also need to do this copying before we process the reference
4461 // objects discovered by the STW ref processor in case one of these
4462 // referents points to another object which is also referenced by an
4463 // object discovered by the STW ref processor.
4464
4465 uint no_of_gc_workers = workers()->active_workers();
4466
4467 G1ParPreserveCMReferentsTask keep_cm_referents(this,
4468 per_thread_states,
4469 no_of_gc_workers,
4470 _task_queues);
4471 workers()->run_task(&keep_cm_referents);
4472
4473 g1_policy()->phase_times()->record_preserve_cm_referents_time_ms((os::elapsedTime() - preserve_cm_referents_start) * 1000.0);
4474 }
4475
4476 // Weak Reference processing during an evacuation pause (part 1).
4477 void G1CollectedHeap::process_discovered_references(G1ParScanThreadStateSet* per_thread_states) {
4478 double ref_proc_start = os::elapsedTime();
4479
4480 ReferenceProcessor* rp = _ref_processor_stw;
4481 assert(rp->discovery_enabled(), "should have been enabled");
4482
4483 // Closure to test whether a referent is alive.
4484 G1STWIsAliveClosure is_alive(this);
4485
4486 // Even when parallel reference processing is enabled, the processing
4487 // of JNI refs is serial and performed serially by the current thread
4488 // rather than by a worker. The following PSS will be used for processing
4489 // JNI refs.
4490
4491 // Use only a single queue for this PSS.
4492 G1ParScanThreadState* pss = per_thread_states->state_for_worker(0);
4493 pss->set_ref_processor(NULL);
|
4423 // Drain the queue - which may cause stealing
4424 G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _queues, &_terminator);
4425 drain_queue.do_void();
4426 // Allocation buffers were retired at the end of G1ParEvacuateFollowersClosure
4427 assert(pss->queue_is_empty(), "should be");
4428 }
4429 };
4430
4431 void G1CollectedHeap::process_weak_jni_handles() {
4432 double ref_proc_start = os::elapsedTime();
4433
4434 G1STWIsAliveClosure is_alive(this);
4435 G1KeepAliveClosure keep_alive(this);
4436 JNIHandles::weak_oops_do(&is_alive, &keep_alive);
4437
4438 double ref_proc_time = os::elapsedTime() - ref_proc_start;
4439 g1_policy()->phase_times()->record_ref_proc_time(ref_proc_time * 1000.0);
4440 }
4441
4442 void G1CollectedHeap::preserve_cm_referents(G1ParScanThreadStateSet* per_thread_states) {
4443 // Any reference objects, in the collection set, that were 'discovered'
4444 // by the CM ref processor should have already been copied (either by
4445 // applying the external root copy closure to the discovered lists, or
4446 // by following an RSet entry).
4447 //
4448 // But some of the referents, that are in the collection set, that these
4449 // reference objects point to may not have been copied: the STW ref
4450 // processor would have seen that the reference object had already
4451 // been 'discovered' and would have skipped discovering the reference,
4452 // but would not have treated the reference object as a regular oop.
4453 // As a result the copy closure would not have been applied to the
4454 // referent object.
4455 //
4456 // We need to explicitly copy these referent objects - the references
4457 // will be processed at the end of remarking.
4458 //
4459 // We also need to do this copying before we process the reference
4460 // objects discovered by the STW ref processor in case one of these
4461 // referents points to another object which is also referenced by an
4462 // object discovered by the STW ref processor.
4463 double preserve_cm_referents_time = 0.0;
4464
4465 // To avoid spawning task when there is no work to do, check that
4466 // a concurrent cycle is active and that some references have been
4467 // discovered.
4468 if (concurrent_mark()->cmThread()->during_cycle() &&
4469 ref_processor_cm()->has_discovered_references()) {
4470 double preserve_cm_referents_start = os::elapsedTime();
4471 uint no_of_gc_workers = workers()->active_workers();
4472 G1ParPreserveCMReferentsTask keep_cm_referents(this,
4473 per_thread_states,
4474 no_of_gc_workers,
4475 _task_queues);
4476 workers()->run_task(&keep_cm_referents);
4477 preserve_cm_referents_time = os::elapsedTime() - preserve_cm_referents_start;
4478 }
4479
4480 g1_policy()->phase_times()->record_preserve_cm_referents_time_ms(preserve_cm_referents_time * 1000.0);
4481 }
4482
4483 // Weak Reference processing during an evacuation pause (part 1).
4484 void G1CollectedHeap::process_discovered_references(G1ParScanThreadStateSet* per_thread_states) {
4485 double ref_proc_start = os::elapsedTime();
4486
4487 ReferenceProcessor* rp = _ref_processor_stw;
4488 assert(rp->discovery_enabled(), "should have been enabled");
4489
4490 // Closure to test whether a referent is alive.
4491 G1STWIsAliveClosure is_alive(this);
4492
4493 // Even when parallel reference processing is enabled, the processing
4494 // of JNI refs is serial and performed serially by the current thread
4495 // rather than by a worker. The following PSS will be used for processing
4496 // JNI refs.
4497
4498 // Use only a single queue for this PSS.
4499 G1ParScanThreadState* pss = per_thread_states->state_for_worker(0);
4500 pss->set_ref_processor(NULL);
|