< prev index next >

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Print this page
rev 49826 : imported patch 6672778-partial-queue-trimming
rev 49827 : imported patch 6672778-refactoring
rev 49828 : imported patch 6672778-stefanj-review


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/metadataOnStackMark.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "code/codeCache.hpp"
  30 #include "code/icBuffer.hpp"
  31 #include "gc/g1/bufferingOopClosure.hpp"
  32 #include "gc/g1/g1Allocator.inline.hpp"
  33 #include "gc/g1/g1BarrierSet.hpp"
  34 #include "gc/g1/g1CollectedHeap.inline.hpp"
  35 #include "gc/g1/g1CollectionSet.hpp"
  36 #include "gc/g1/g1CollectorPolicy.hpp"
  37 #include "gc/g1/g1CollectorState.hpp"
  38 #include "gc/g1/g1ConcurrentRefine.hpp"
  39 #include "gc/g1/g1ConcurrentRefineThread.hpp"
  40 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
  41 #include "gc/g1/g1EvacStats.inline.hpp"
  42 #include "gc/g1/g1FullCollector.hpp"
  43 #include "gc/g1/g1GCPhaseTimes.hpp"
  44 #include "gc/g1/g1HeapSizingPolicy.hpp"
  45 #include "gc/g1/g1HeapTransition.hpp"
  46 #include "gc/g1/g1HeapVerifier.hpp"
  47 #include "gc/g1/g1HotCardCache.hpp"
  48 #include "gc/g1/g1MemoryPool.hpp"
  49 #include "gc/g1/g1OopClosures.inline.hpp"
  50 #include "gc/g1/g1ParScanThreadState.inline.hpp"
  51 #include "gc/g1/g1Policy.hpp"


1823 }
1824 
1825 size_t G1CollectedHeap::capacity() const {
1826   return _hrm.length() * HeapRegion::GrainBytes;
1827 }
1828 
1829 size_t G1CollectedHeap::unused_committed_regions_in_bytes() const {
1830   return _hrm.total_free_bytes();
1831 }
1832 
1833 void G1CollectedHeap::iterate_hcc_closure(CardTableEntryClosure* cl, uint worker_i) {
1834   _hot_card_cache->drain(cl, worker_i);
1835 }
1836 
1837 void G1CollectedHeap::iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i) {
1838   DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set();
1839   size_t n_completed_buffers = 0;
1840   while (dcqs.apply_closure_during_gc(cl, worker_i)) {
1841     n_completed_buffers++;
1842   }
1843   g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::UpdateRS, worker_i, n_completed_buffers);
1844   dcqs.clear_n_completed_buffers();
1845   assert(!dcqs.completed_buffers_exist_dirty(), "Completed buffers exist!");
1846 }
1847 
1848 // Computes the sum of the storage used by the various regions.
1849 size_t G1CollectedHeap::used() const {
1850   size_t result = _summary_bytes_used + _allocator->used_in_alloc_regions();
1851   if (_archive_allocator != NULL) {
1852     result += _archive_allocator->used();
1853   }
1854   return result;
1855 }
1856 
1857 size_t G1CollectedHeap::used_unlocked() const {
1858   return _summary_bytes_used;
1859 }
1860 
1861 class SumUsedClosure: public HeapRegionClosure {
1862   size_t _used;
1863 public:


3112       _n_workers(n_workers)
3113   {}
3114 
3115   void work(uint worker_id) {
3116     if (worker_id >= _n_workers) return;  // no work needed this round
3117 
3118     double start_sec = os::elapsedTime();
3119     _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, start_sec);
3120 
3121     {
3122       ResourceMark rm;
3123       HandleMark   hm;
3124 
3125       ReferenceProcessor*             rp = _g1h->ref_processor_stw();
3126 
3127       G1ParScanThreadState*           pss = _pss->state_for_worker(worker_id);
3128       pss->set_ref_processor(rp);
3129 
3130       double start_strong_roots_sec = os::elapsedTime();
3131 
3132       _root_processor->evacuate_roots(pss->closures(), worker_id);
3133 
3134       // We pass a weak code blobs closure to the remembered set scanning because we want to avoid
3135       // treating the nmethods visited to act as roots for concurrent marking.
3136       // We only want to make sure that the oops in the nmethods are adjusted with regard to the
3137       // objects copied by the current evacuation.
3138       _g1h->g1_rem_set()->oops_into_collection_set_do(pss,
3139                                                       pss->closures()->weak_codeblobs(),
3140                                                       worker_id);
3141 
3142       double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
3143 
3144       double term_sec = 0.0;
3145       size_t evac_term_attempts = 0;
3146       {
3147         double start = os::elapsedTime();
3148         G1ParEvacuateFollowersClosure evac(_g1h, pss, _queues, &_terminator);
3149         evac.do_void();
3150 
3151         evac_term_attempts = evac.term_attempts();
3152         term_sec = evac.term_time();
3153         double elapsed_sec = os::elapsedTime() - start;
3154         _g1h->g1_policy()->phase_times()->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_id, elapsed_sec - term_sec);
3155         _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::Termination, worker_id, term_sec);
3156         _g1h->g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::Termination, worker_id, evac_term_attempts);


3157       }
3158 
3159       assert(pss->queue_is_empty(), "should be empty");
3160 
3161       if (log_is_enabled(Debug, gc, task, stats)) {
3162         MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
3163         size_t lab_waste;
3164         size_t lab_undo_waste;
3165         pss->waste(lab_waste, lab_undo_waste);
3166         _g1h->print_termination_stats(worker_id,
3167                                       (os::elapsedTime() - start_sec) * 1000.0,   /* elapsed time */
3168                                       strong_roots_sec * 1000.0,                  /* strong roots time */
3169                                       term_sec * 1000.0,                          /* evac term time */
3170                                       evac_term_attempts,                         /* evac term attempts */
3171                                       lab_waste,                                  /* alloc buffer waste */
3172                                       lab_undo_waste                              /* undo waste */
3173                                       );
3174       }
3175 
3176       // Close the inner scope so that the ResourceMark and HandleMark




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/metadataOnStackMark.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "code/codeCache.hpp"
  30 #include "code/icBuffer.hpp"

  31 #include "gc/g1/g1Allocator.inline.hpp"
  32 #include "gc/g1/g1BarrierSet.hpp"
  33 #include "gc/g1/g1CollectedHeap.inline.hpp"
  34 #include "gc/g1/g1CollectionSet.hpp"
  35 #include "gc/g1/g1CollectorPolicy.hpp"
  36 #include "gc/g1/g1CollectorState.hpp"
  37 #include "gc/g1/g1ConcurrentRefine.hpp"
  38 #include "gc/g1/g1ConcurrentRefineThread.hpp"
  39 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
  40 #include "gc/g1/g1EvacStats.inline.hpp"
  41 #include "gc/g1/g1FullCollector.hpp"
  42 #include "gc/g1/g1GCPhaseTimes.hpp"
  43 #include "gc/g1/g1HeapSizingPolicy.hpp"
  44 #include "gc/g1/g1HeapTransition.hpp"
  45 #include "gc/g1/g1HeapVerifier.hpp"
  46 #include "gc/g1/g1HotCardCache.hpp"
  47 #include "gc/g1/g1MemoryPool.hpp"
  48 #include "gc/g1/g1OopClosures.inline.hpp"
  49 #include "gc/g1/g1ParScanThreadState.inline.hpp"
  50 #include "gc/g1/g1Policy.hpp"


1822 }
1823 
1824 size_t G1CollectedHeap::capacity() const {
1825   return _hrm.length() * HeapRegion::GrainBytes;
1826 }
1827 
1828 size_t G1CollectedHeap::unused_committed_regions_in_bytes() const {
1829   return _hrm.total_free_bytes();
1830 }
1831 
1832 void G1CollectedHeap::iterate_hcc_closure(CardTableEntryClosure* cl, uint worker_i) {
1833   _hot_card_cache->drain(cl, worker_i);
1834 }
1835 
1836 void G1CollectedHeap::iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i) {
1837   DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set();
1838   size_t n_completed_buffers = 0;
1839   while (dcqs.apply_closure_during_gc(cl, worker_i)) {
1840     n_completed_buffers++;
1841   }
1842   g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::UpdateRS, worker_i, n_completed_buffers, G1GCPhaseTimes::UpdateRSProcessedBuffers);
1843   dcqs.clear_n_completed_buffers();
1844   assert(!dcqs.completed_buffers_exist_dirty(), "Completed buffers exist!");
1845 }
1846 
1847 // Computes the sum of the storage used by the various regions.
1848 size_t G1CollectedHeap::used() const {
1849   size_t result = _summary_bytes_used + _allocator->used_in_alloc_regions();
1850   if (_archive_allocator != NULL) {
1851     result += _archive_allocator->used();
1852   }
1853   return result;
1854 }
1855 
1856 size_t G1CollectedHeap::used_unlocked() const {
1857   return _summary_bytes_used;
1858 }
1859 
1860 class SumUsedClosure: public HeapRegionClosure {
1861   size_t _used;
1862 public:


3111       _n_workers(n_workers)
3112   {}
3113 
3114   void work(uint worker_id) {
3115     if (worker_id >= _n_workers) return;  // no work needed this round
3116 
3117     double start_sec = os::elapsedTime();
3118     _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, start_sec);
3119 
3120     {
3121       ResourceMark rm;
3122       HandleMark   hm;
3123 
3124       ReferenceProcessor*             rp = _g1h->ref_processor_stw();
3125 
3126       G1ParScanThreadState*           pss = _pss->state_for_worker(worker_id);
3127       pss->set_ref_processor(rp);
3128 
3129       double start_strong_roots_sec = os::elapsedTime();
3130 
3131       _root_processor->evacuate_roots(pss, worker_id);
3132 
3133       // We pass a weak code blobs closure to the remembered set scanning because we want to avoid
3134       // treating the nmethods visited to act as roots for concurrent marking.
3135       // We only want to make sure that the oops in the nmethods are adjusted with regard to the
3136       // objects copied by the current evacuation.
3137       _g1h->g1_rem_set()->oops_into_collection_set_do(pss, worker_id);


3138 
3139       double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
3140 
3141       double term_sec = 0.0;
3142       size_t evac_term_attempts = 0;
3143       {
3144         double start = os::elapsedTime();
3145         G1ParEvacuateFollowersClosure evac(_g1h, pss, _queues, &_terminator);
3146         evac.do_void();
3147 
3148         evac_term_attempts = evac.term_attempts();
3149         term_sec = evac.term_time();
3150         double elapsed_sec = os::elapsedTime() - start;
3151 
3152         G1GCPhaseTimes* p = _g1h->g1_policy()->phase_times();
3153         p->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_id, elapsed_sec - term_sec);
3154         p->record_time_secs(G1GCPhaseTimes::Termination, worker_id, term_sec);
3155         p->record_thread_work_item(G1GCPhaseTimes::Termination, worker_id, evac_term_attempts);
3156       }
3157 
3158       assert(pss->queue_is_empty(), "should be empty");
3159 
3160       if (log_is_enabled(Debug, gc, task, stats)) {
3161         MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
3162         size_t lab_waste;
3163         size_t lab_undo_waste;
3164         pss->waste(lab_waste, lab_undo_waste);
3165         _g1h->print_termination_stats(worker_id,
3166                                       (os::elapsedTime() - start_sec) * 1000.0,   /* elapsed time */
3167                                       strong_roots_sec * 1000.0,                  /* strong roots time */
3168                                       term_sec * 1000.0,                          /* evac term time */
3169                                       evac_term_attempts,                         /* evac term attempts */
3170                                       lab_waste,                                  /* alloc buffer waste */
3171                                       lab_undo_waste                              /* undo waste */
3172                                       );
3173       }
3174 
3175       // Close the inner scope so that the ResourceMark and HandleMark


< prev index next >