< prev index next >

src/hotspot/share/gc/shared/referenceProcessor.cpp

Print this page
rev 47223 : [mq]: heapz8
rev 47224 : [mq]: heap9a


 245     process_discovered_reflist(_discoveredPhantomRefs, NULL, true,
 246                                is_alive, keep_alive, complete_gc, task_executor, phase_times);
 247   }
 248 
 249   // Weak global JNI references. It would make more sense (semantically) to
 250   // traverse these simultaneously with the regular weak references above, but
 251   // that is not how the JDK1.2 specification is. See #4126360. Native code can
 252   // thus use JNI weak references to circumvent the phantom references and
 253   // resurrect a "post-mortem" object.
 254   {
 255     GCTraceTime(Debug, gc, ref) tt("JNI Weak Reference", phase_times->gc_timer());
 256     if (task_executor != NULL) {
 257       task_executor->set_single_threaded_mode();
 258     }
 259     process_phaseJNI(is_alive, keep_alive, complete_gc);
 260   }
 261 
 262   // Heap Monitoring references
 263   size_t handled;
 264   {
 265     GCTraceTime(Debug, gc, ref) tt("Heap Monitoring Weak Reference", gc_timer);
 266     handled = process_phaseHeapSampling(is_alive, keep_alive, complete_gc, task_executor);
 267   }
 268 
 269   phase_times->set_total_time_ms((os::elapsedTime() - start_time) * 1000);
 270 
 271   log_develop_trace(gc, ref)("JNI Weak Reference count: " SIZE_FORMAT, count_jni_refs());
 272   log_develop_trace(gc, ref)("Heap Sampler Weak Reference handled: " SIZE_FORMAT, handled);
 273 
 274   return stats;
 275 }
 276 
 277 #ifndef PRODUCT
 278 // Calculate the number of jni handles.
 279 size_t ReferenceProcessor::count_jni_refs() {
 280   class CountHandleClosure: public OopClosure {
 281   private:
 282     size_t _count;
 283   public:
 284     CountHandleClosure(): _count(0) {}
 285     void do_oop(oop* unused)       { _count++; }
 286     void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
 287     size_t count() { return _count; }
 288   };
 289   CountHandleClosure global_handle_count;
 290   JNIHandles::weak_oops_do(&global_handle_count);
 291   return global_handle_count.count();
 292 }
 293 #endif
 294 
 295 void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive,
 296                                           OopClosure*        keep_alive,
 297                                           VoidClosure*       complete_gc) {
 298   JNIHandles::weak_oops_do(is_alive, keep_alive);
 299   complete_gc->do_void();
 300 }
 301 
 302 size_t ReferenceProcessor::process_phaseHeapSampling(
 303     BoolObjectClosure*           is_alive,
 304     OopClosure*                  keep_alive,
 305     VoidClosure*                 complete_gc,
 306     AbstractRefProcTaskExecutor* task_executor) {
 307   size_t count = 0;
 308   if (HeapMonitoring::enabled()) {
 309     if (task_executor != NULL) {
 310       task_executor->set_single_threaded_mode();
 311     }
 312     count = HeapMonitoring::weak_oops_do(is_alive, keep_alive);
 313     complete_gc->do_void();
 314   }
 315   return count;
 316 }
 317 
 318 void ReferenceProcessor::enqueue_discovered_references(AbstractRefProcTaskExecutor*  task_executor,
 319                                                        ReferenceProcessorPhaseTimes* phase_times) {
 320   // Enqueue references that are not made active again, and
 321   // clear the decks for the next collection (cycle).
 322   enqueue_discovered_reflists(task_executor, phase_times);
 323 
 324   // Stop treating discovered references specially.
 325   disable_discovery();
 326 }
 327 
 328 void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list) {
 329   // Given a list of refs linked through the "discovered" field
 330   // (java.lang.ref.Reference.discovered), self-loop their "next" field
 331   // thus distinguishing them from active References, then




 245     process_discovered_reflist(_discoveredPhantomRefs, NULL, true,
 246                                is_alive, keep_alive, complete_gc, task_executor, phase_times);
 247   }
 248 
 249   // Weak global JNI references. It would make more sense (semantically) to
 250   // traverse these simultaneously with the regular weak references above, but
 251   // that is not how the JDK1.2 specification is. See #4126360. Native code can
 252   // thus use JNI weak references to circumvent the phantom references and
 253   // resurrect a "post-mortem" object.
 254   {
 255     GCTraceTime(Debug, gc, ref) tt("JNI Weak Reference", phase_times->gc_timer());
 256     if (task_executor != NULL) {
 257       task_executor->set_single_threaded_mode();
 258     }
 259     process_phaseJNI(is_alive, keep_alive, complete_gc);
 260   }
 261 
 262   // Heap Monitoring references
 263   size_t handled;
 264   {
 265     GCTraceTime(Debug, gc, ref) tt("Heap Sampler Weak Reference", phase_times->gc_timer());
 266     handled = process_phaseHeapSampling(is_alive, keep_alive, complete_gc);
 267   }
 268 
 269   phase_times->set_total_time_ms((os::elapsedTime() - start_time) * 1000);
 270 
 271   log_develop_trace(gc, ref)("JNI Weak Reference count: " SIZE_FORMAT, count_jni_refs());
 272   log_develop_trace(gc, ref)("Heap Sampler Weak Reference handled: " SIZE_FORMAT, handled);
 273 
 274   return stats;
 275 }
 276 
 277 #ifndef PRODUCT
 278 // Calculate the number of jni handles.
 279 size_t ReferenceProcessor::count_jni_refs() {
 280   class CountHandleClosure: public OopClosure {
 281   private:
 282     size_t _count;
 283   public:
 284     CountHandleClosure(): _count(0) {}
 285     void do_oop(oop* unused)       { _count++; }
 286     void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
 287     size_t count() { return _count; }
 288   };
 289   CountHandleClosure global_handle_count;
 290   JNIHandles::weak_oops_do(&global_handle_count);
 291   return global_handle_count.count();
 292 }
 293 #endif
 294 
 295 void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive,
 296                                           OopClosure*        keep_alive,
 297                                           VoidClosure*       complete_gc) {
 298   JNIHandles::weak_oops_do(is_alive, keep_alive);
 299   complete_gc->do_void();
 300 }
 301 
 302 size_t ReferenceProcessor::process_phaseHeapSampling(
 303     BoolObjectClosure*           is_alive,
 304     OopClosure*                  keep_alive,
 305     VoidClosure*                 complete_gc) {

 306   size_t count = 0;
 307   if (HeapMonitoring::enabled()) {



 308     count = HeapMonitoring::weak_oops_do(is_alive, keep_alive);
 309     complete_gc->do_void();
 310   }
 311   return count;
 312 }
 313 
 314 void ReferenceProcessor::enqueue_discovered_references(AbstractRefProcTaskExecutor*  task_executor,
 315                                                        ReferenceProcessorPhaseTimes* phase_times) {
 316   // Enqueue references that are not made active again, and
 317   // clear the decks for the next collection (cycle).
 318   enqueue_discovered_reflists(task_executor, phase_times);
 319 
 320   // Stop treating discovered references specially.
 321   disable_discovery();
 322 }
 323 
 324 void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list) {
 325   // Given a list of refs linked through the "discovered" field
 326   // (java.lang.ref.Reference.discovered), self-loop their "next" field
 327   // thus distinguishing them from active References, then


< prev index next >