4111 // can see some null referent objects.
4112 iter.load_ptrs(DEBUG_ONLY(true));
4113 oop ref = iter.obj();
4114
4115 // This will filter nulls.
4116 if (iter.is_referent_alive()) {
4117 iter.make_referent_alive();
4118 }
4119 iter.move_to_next();
4120 }
4121 }
4122
4123 // Drain the queue - which may cause stealing
4124 G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _queues, &_terminator);
4125 drain_queue.do_void();
4126 // Allocation buffers were retired at the end of G1ParEvacuateFollowersClosure
4127 assert(pss->queue_is_empty(), "should be");
4128 }
4129 };
4130
4131 void G1CollectedHeap::process_weak_jni_handles() {
4132 double ref_proc_start = os::elapsedTime();
4133
4134 G1STWIsAliveClosure is_alive(this);
4135 G1KeepAliveClosure keep_alive(this);
4136 JNIHandles::weak_oops_do(&is_alive, &keep_alive);
4137
4138 double ref_proc_time = os::elapsedTime() - ref_proc_start;
4139 g1_policy()->phase_times()->record_ref_proc_time(ref_proc_time * 1000.0);
4140 }
4141
4142 void G1CollectedHeap::preserve_cm_referents(G1ParScanThreadStateSet* per_thread_states) {
4143 // Any reference objects, in the collection set, that were 'discovered'
4144 // by the CM ref processor should have already been copied (either by
4145 // applying the external root copy closure to the discovered lists, or
4146 // by following an RSet entry).
4147 //
4148 // But some of the referents, that are in the collection set, that these
4149 // reference objects point to may not have been copied: the STW ref
4150 // processor would have seen that the reference object had already
4151 // been 'discovered' and would have skipped discovering the reference,
4152 // but would not have treated the reference object as a regular oop.
4153 // As a result the copy closure would not have been applied to the
4154 // referent object.
4155 //
4156 // We need to explicitly copy these referent objects - the references
4157 // will be processed at the end of remarking.
4158 //
4159 // We also need to do this copying before we process the reference
4160 // objects discovered by the STW ref processor in case one of these
4161 // referents points to another object which is also referenced by an
4360
4361 void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
4362 // Process any discovered reference objects - we have
4363 // to do this _before_ we retire the GC alloc regions
4364 // as we may have to copy some 'reachable' referent
4365 // objects (and their reachable sub-graphs) that were
4366 // not copied during the pause.
4367 if (g1_policy()->should_process_references()) {
4368 preserve_cm_referents(per_thread_states);
4369 process_discovered_references(per_thread_states);
4370 } else {
4371 ref_processor_stw()->verify_no_references_recorded();
4372 }
4373
4374 G1STWIsAliveClosure is_alive(this);
4375 G1KeepAliveClosure keep_alive(this);
4376
4377 {
4378 double start = os::elapsedTime();
4379
4380 WeakProcessor::unlink_or_oops_do(&is_alive, &keep_alive);
4381
4382 double time_ms = (os::elapsedTime() - start) * 1000.0;
4383 g1_policy()->phase_times()->record_ref_proc_time(time_ms);
4384 }
4385
4386 if (G1StringDedup::is_enabled()) {
4387 double fixup_start = os::elapsedTime();
4388
4389 G1StringDedup::unlink_or_oops_do(&is_alive, &keep_alive, true, g1_policy()->phase_times());
4390
4391 double fixup_time_ms = (os::elapsedTime() - fixup_start) * 1000.0;
4392 g1_policy()->phase_times()->record_string_dedup_fixup_time(fixup_time_ms);
4393 }
4394
4395 g1_rem_set()->cleanup_after_oops_into_collection_set_do();
4396
4397 if (evacuation_failed()) {
4398 restore_after_evac_failure();
4399
4400 // Reset the G1EvacuationFailureALot counters and flags
|
4111 // can see some null referent objects.
4112 iter.load_ptrs(DEBUG_ONLY(true));
4113 oop ref = iter.obj();
4114
4115 // This will filter nulls.
4116 if (iter.is_referent_alive()) {
4117 iter.make_referent_alive();
4118 }
4119 iter.move_to_next();
4120 }
4121 }
4122
4123 // Drain the queue - which may cause stealing
4124 G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _queues, &_terminator);
4125 drain_queue.do_void();
4126 // Allocation buffers were retired at the end of G1ParEvacuateFollowersClosure
4127 assert(pss->queue_is_empty(), "should be");
4128 }
4129 };
4130
4131 void G1CollectedHeap::preserve_cm_referents(G1ParScanThreadStateSet* per_thread_states) {
4132 // Any reference objects, in the collection set, that were 'discovered'
4133 // by the CM ref processor should have already been copied (either by
4134 // applying the external root copy closure to the discovered lists, or
4135 // by following an RSet entry).
4136 //
4137 // But some of the referents, that are in the collection set, that these
4138 // reference objects point to may not have been copied: the STW ref
4139 // processor would have seen that the reference object had already
4140 // been 'discovered' and would have skipped discovering the reference,
4141 // but would not have treated the reference object as a regular oop.
4142 // As a result the copy closure would not have been applied to the
4143 // referent object.
4144 //
4145 // We need to explicitly copy these referent objects - the references
4146 // will be processed at the end of remarking.
4147 //
4148 // We also need to do this copying before we process the reference
4149 // objects discovered by the STW ref processor in case one of these
4150 // referents points to another object which is also referenced by an
4349
4350 void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
4351 // Process any discovered reference objects - we have
4352 // to do this _before_ we retire the GC alloc regions
4353 // as we may have to copy some 'reachable' referent
4354 // objects (and their reachable sub-graphs) that were
4355 // not copied during the pause.
4356 if (g1_policy()->should_process_references()) {
4357 preserve_cm_referents(per_thread_states);
4358 process_discovered_references(per_thread_states);
4359 } else {
4360 ref_processor_stw()->verify_no_references_recorded();
4361 }
4362
4363 G1STWIsAliveClosure is_alive(this);
4364 G1KeepAliveClosure keep_alive(this);
4365
4366 {
4367 double start = os::elapsedTime();
4368
4369 WeakProcessor::weak_oops_do(&is_alive, &keep_alive);
4370
4371 double time_ms = (os::elapsedTime() - start) * 1000.0;
4372 g1_policy()->phase_times()->record_ref_proc_time(time_ms);
4373 }
4374
4375 if (G1StringDedup::is_enabled()) {
4376 double fixup_start = os::elapsedTime();
4377
4378 G1StringDedup::unlink_or_oops_do(&is_alive, &keep_alive, true, g1_policy()->phase_times());
4379
4380 double fixup_time_ms = (os::elapsedTime() - fixup_start) * 1000.0;
4381 g1_policy()->phase_times()->record_string_dedup_fixup_time(fixup_time_ms);
4382 }
4383
4384 g1_rem_set()->cleanup_after_oops_into_collection_set_do();
4385
4386 if (evacuation_failed()) {
4387 restore_after_evac_failure();
4388
4389 // Reset the G1EvacuationFailureALot counters and flags
|