357 DEBUG_ONLY(Thread* my_thread = Thread::current();)
358
359 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
360 assert(my_thread->is_VM_thread() ||
361 my_thread->is_ConcurrentGC_thread(),
362 "incorrect thread type capability");
363 assert(Heap_lock->is_locked(),
364 "the requesting thread should have the Heap_lock");
365 guarantee(!is_gc_active(), "collection is not reentrant");
366 assert(max_level < n_gens(), "sanity check");
367
368 if (GC_locker::check_active_before_gc()) {
369 return; // GC is disabled (e.g. JNI GetXXXCritical operation)
370 }
371
372 const bool do_clear_all_soft_refs = clear_all_soft_refs ||
373 collector_policy()->should_clear_all_soft_refs();
374
375 ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
376
377 const size_t metadata_prev_used = MetaspaceAux::allocated_used_bytes();
378
379 print_heap_before_gc();
380
381 {
382 FlagSetting fl(_is_gc_active, true);
383
384 bool complete = full && (max_level == (n_gens()-1));
385 const char* gc_cause_prefix = complete ? "Full GC" : "GC";
386 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
387 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
388 GCTraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, NULL);
389
390 gc_prologue(complete);
391 increment_total_collections(complete);
392
393 size_t gch_prev_used = used();
394
395 int starting_level = 0;
396 if (full) {
397 // Search for the oldest generation which will collect all younger
|
357 DEBUG_ONLY(Thread* my_thread = Thread::current();)
358
359 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
360 assert(my_thread->is_VM_thread() ||
361 my_thread->is_ConcurrentGC_thread(),
362 "incorrect thread type capability");
363 assert(Heap_lock->is_locked(),
364 "the requesting thread should have the Heap_lock");
365 guarantee(!is_gc_active(), "collection is not reentrant");
366 assert(max_level < n_gens(), "sanity check");
367
368 if (GC_locker::check_active_before_gc()) {
369 return; // GC is disabled (e.g. JNI GetXXXCritical operation)
370 }
371
372 const bool do_clear_all_soft_refs = clear_all_soft_refs ||
373 collector_policy()->should_clear_all_soft_refs();
374
375 ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
376
377 const size_t metadata_prev_used = MetaspaceAux::used_bytes();
378
379 print_heap_before_gc();
380
381 {
382 FlagSetting fl(_is_gc_active, true);
383
384 bool complete = full && (max_level == (n_gens()-1));
385 const char* gc_cause_prefix = complete ? "Full GC" : "GC";
386 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
387 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
388 GCTraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, NULL);
389
390 gc_prologue(complete);
391 increment_total_collections(complete);
392
393 size_t gch_prev_used = used();
394
395 int starting_level = 0;
396 if (full) {
397 // Search for the oldest generation which will collect all younger
|