hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
changeset 43605 07baf498d588
parent 42043 bf17eb48ea3f
child 46505 fd4bc78630b1
equal deleted inserted replaced
43604:49949d36e3f9 43605:07baf498d588
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   486   _intra_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding),
   486   _intra_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding),
   487   _gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) CMSTracer()),
   487   _gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) CMSTracer()),
   488   _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()),
   488   _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()),
   489   _cms_start_registered(false)
   489   _cms_start_registered(false)
   490 {
   490 {
   491   if (ExplicitGCInvokesConcurrentAndUnloadsClasses) {
       
   492     ExplicitGCInvokesConcurrent = true;
       
   493   }
       
   494   // Now expand the span and allocate the collection support structures
   491   // Now expand the span and allocate the collection support structures
   495   // (MUT, marking bit map etc.) to cover both generations subject to
   492   // (MUT, marking bit map etc.) to cover both generations subject to
   496   // collection.
   493   // collection.
   497 
   494 
   498   // For use by dirty card to oop closures.
   495   // For use by dirty card to oop closures.
  2557 #endif // PRODUCT
  2554 #endif // PRODUCT
  2558 
  2555 
  2559 // Decide if we want to enable class unloading as part of the
  2556 // Decide if we want to enable class unloading as part of the
  2560 // ensuing concurrent GC cycle. We will collect and
  2557 // ensuing concurrent GC cycle. We will collect and
  2561 // unload classes if it's the case that:
  2558 // unload classes if it's the case that:
  2562 // (1) an explicit gc request has been made and the flag
  2559 //  (a) class unloading is enabled at the command line, and
  2563 //     ExplicitGCInvokesConcurrentAndUnloadsClasses is set, OR
  2560 //  (b) old gen is getting really full
  2564 // (2) (a) class unloading is enabled at the command line, and
       
  2565 //     (b) old gen is getting really full
       
  2566 // NOTE: Provided there is no change in the state of the heap between
  2561 // NOTE: Provided there is no change in the state of the heap between
  2567 // calls to this method, it should have idempotent results. Moreover,
  2562 // calls to this method, it should have idempotent results. Moreover,
  2568 // its results should be monotonically increasing (i.e. going from 0 to 1,
  2563 // its results should be monotonically increasing (i.e. going from 0 to 1,
  2569 // but not 1 to 0) between successive calls between which the heap was
  2564 // but not 1 to 0) between successive calls between which the heap was
  2570 // not collected. For the implementation below, it must thus rely on
  2565 // not collected. For the implementation below, it must thus rely on
  2573 // _cmsGen->is_too_full() are
  2568 // _cmsGen->is_too_full() are
  2574 // themselves also monotonic in that sense. See check_monotonicity()
  2569 // themselves also monotonic in that sense. See check_monotonicity()
  2575 // below.
  2570 // below.
  2576 void CMSCollector::update_should_unload_classes() {
  2571 void CMSCollector::update_should_unload_classes() {
  2577   _should_unload_classes = false;
  2572   _should_unload_classes = false;
  2578   // Condition 1 above
  2573   if (CMSClassUnloadingEnabled) {
  2579   if (_full_gc_requested && ExplicitGCInvokesConcurrentAndUnloadsClasses) {
       
  2580     _should_unload_classes = true;
       
  2581   } else if (CMSClassUnloadingEnabled) { // Condition 2.a above
       
  2582     // Disjuncts 2.b.(i,ii,iii) above
       
  2583     _should_unload_classes = (concurrent_cycles_since_last_unload() >=
  2574     _should_unload_classes = (concurrent_cycles_since_last_unload() >=
  2584                               CMSClassUnloadingMaxInterval)
  2575                               CMSClassUnloadingMaxInterval)
  2585                            || _cmsGen->is_too_full();
  2576                            || _cmsGen->is_too_full();
  2586   }
  2577   }
  2587 }
  2578 }