< prev index next >

src/share/vm/gc/parallel/psScavenge.cpp

Print this page
rev 12906 : [mq]: gc_interface


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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/stringTable.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "gc/parallel/cardTableExtension.hpp"
  29 #include "gc/parallel/gcTaskManager.hpp"
  30 #include "gc/parallel/parallelScavengeHeap.hpp"
  31 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  32 #include "gc/parallel/psMarkSweep.hpp"
  33 #include "gc/parallel/psParallelCompact.inline.hpp"
  34 #include "gc/parallel/psScavenge.inline.hpp"
  35 #include "gc/parallel/psTasks.hpp"
  36 #include "gc/shared/collectorPolicy.hpp"
  37 #include "gc/shared/gcCause.hpp"
  38 #include "gc/shared/gcHeapSummary.hpp"
  39 #include "gc/shared/gcId.hpp"
  40 #include "gc/shared/gcLocker.inline.hpp"
  41 #include "gc/shared/gcTimer.hpp"
  42 #include "gc/shared/gcTrace.hpp"
  43 #include "gc/shared/gcTraceTime.inline.hpp"
  44 #include "gc/shared/isGCActiveMark.hpp"
  45 #include "gc/shared/referencePolicy.hpp"
  46 #include "gc/shared/referenceProcessor.hpp"
  47 #include "gc/shared/spaceDecorator.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "logging/log.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "runtime/biasedLocking.hpp"
  52 #include "runtime/fprofiler.hpp"
  53 #include "runtime/handles.inline.hpp"
  54 #include "runtime/threadCritical.hpp"
  55 #include "runtime/vmThread.hpp"
  56 #include "runtime/vm_operations.hpp"
  57 #include "services/memoryService.hpp"
  58 #include "utilities/stack.inline.hpp"
  59 
  60 HeapWord*                  PSScavenge::_to_space_top_before_gc = NULL;
  61 int                        PSScavenge::_consecutive_skipped_scavenges = 0;
  62 ReferenceProcessor*        PSScavenge::_ref_processor = NULL;
  63 CardTableExtension*        PSScavenge::_card_table = NULL;
  64 bool                       PSScavenge::_survivor_overflow = false;
  65 uint                       PSScavenge::_tenuring_threshold = 0;
  66 HeapWord*                  PSScavenge::_young_generation_boundary = NULL;
  67 uintptr_t                  PSScavenge::_young_generation_boundary_compressed = 0;
  68 elapsedTimer               PSScavenge::_accumulated_time;
  69 STWGCTimer                 PSScavenge::_gc_timer;
  70 ParallelScavengeTracer     PSScavenge::_gc_tracer;
  71 CollectorCounters*         PSScavenge::_counters = NULL;
  72 
  73 // Define before use
  74 class PSIsAliveClosure: public BoolObjectClosure {
  75 public:
  76   bool do_object_b(oop p) {
  77     return (!PSScavenge::is_obj_in_young(p)) || p->is_forwarded();
  78   }
  79 };
  80 
  81 PSIsAliveClosure PSScavenge::_is_alive_closure;
  82 
  83 class PSKeepAliveClosure: public OopClosure {


 303     HandleMark hm;
 304 
 305     GCTraceCPUTime tcpu;
 306     GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true);
 307     TraceCollectorStats tcs(counters());
 308     TraceMemoryManagerStats tms(false /* not full GC */,gc_cause);
 309 
 310     if (TraceYoungGenTime) accumulated_time()->start();
 311 
 312     // Let the size policy know we're starting
 313     size_policy->minor_collection_begin();
 314 
 315     // Verify the object start arrays.
 316     if (VerifyObjectStartArray &&
 317         VerifyBeforeGC) {
 318       old_gen->verify_object_start_array();
 319     }
 320 
 321     // Verify no unmarked old->young roots
 322     if (VerifyRememberedSets) {
 323       CardTableExtension::verify_all_young_refs_imprecise();
 324     }
 325 
 326     assert(young_gen->to_space()->is_empty(),
 327            "Attempt to scavenge with live objects in to_space");
 328     young_gen->to_space()->clear(SpaceDecorator::Mangle);
 329 
 330     save_to_space_top_before_gc();
 331 
 332 #if defined(COMPILER2) || INCLUDE_JVMCI
 333     DerivedPointerTable::clear();
 334 #endif
 335 
 336     reference_processor()->enable_discovery();
 337     reference_processor()->setup_policy(false);
 338 
 339     PreGCValues pre_gc_values(heap);
 340 
 341     // Reset our survivor overflow.
 342     set_survivor_overflow(false);
 343 


 584 
 585       assert(young_gen->to_space()->is_empty(), "to space should be empty now");
 586     }
 587 
 588 #if defined(COMPILER2) || INCLUDE_JVMCI
 589     DerivedPointerTable::update_pointers();
 590 #endif
 591 
 592     NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
 593 
 594     // Re-verify object start arrays
 595     if (VerifyObjectStartArray &&
 596         VerifyAfterGC) {
 597       old_gen->verify_object_start_array();
 598     }
 599 
 600     // Verify all old -> young cards are now precise
 601     if (VerifyRememberedSets) {
 602       // Precise verification will give false positives. Until this is fixed,
 603       // use imprecise verification.
 604       // CardTableExtension::verify_all_young_refs_precise();
 605       CardTableExtension::verify_all_young_refs_imprecise();
 606     }
 607 
 608     if (TraceYoungGenTime) accumulated_time()->stop();
 609 
 610     young_gen->print_used_change(pre_gc_values.young_gen_used());
 611     old_gen->print_used_change(pre_gc_values.old_gen_used());
 612     MetaspaceAux::print_metaspace_change(pre_gc_values.metadata_used());
 613 
 614     // Track memory usage and detect low memory
 615     MemoryService::track_memory_usage();
 616     heap->update_counters();
 617 
 618     gc_task_manager()->release_idle_workers();
 619   }
 620 
 621   if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
 622     HandleMark hm;  // Discard invalid handles created during verification
 623     Universe::verify("After GC");
 624   }
 625 


 743   PSOldGen* old_gen = heap->old_gen();
 744 
 745   // Set boundary between young_gen and old_gen
 746   assert(old_gen->reserved().end() <= young_gen->eden_space()->bottom(),
 747          "old above young");
 748   set_young_generation_boundary(young_gen->eden_space()->bottom());
 749 
 750   // Initialize ref handling object for scavenging.
 751   MemRegion mr = young_gen->reserved();
 752 
 753   _ref_processor =
 754     new ReferenceProcessor(mr,                         // span
 755                            ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
 756                            ParallelGCThreads,          // mt processing degree
 757                            true,                       // mt discovery
 758                            ParallelGCThreads,          // mt discovery degree
 759                            true,                       // atomic_discovery
 760                            NULL);                      // header provides liveness info
 761 
 762   // Cache the cardtable
 763   _card_table = barrier_set_cast<CardTableExtension>(heap->barrier_set());
 764 
 765   _counters = new CollectorCounters("PSScavenge", 0);
 766 }


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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/stringTable.hpp"
  27 #include "code/codeCache.hpp"

  28 #include "gc/parallel/gcTaskManager.hpp"
  29 #include "gc/parallel/parallelScavengeHeap.hpp"
  30 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  31 #include "gc/parallel/psMarkSweep.hpp"
  32 #include "gc/parallel/psParallelCompact.inline.hpp"
  33 #include "gc/parallel/psScavenge.inline.hpp"
  34 #include "gc/parallel/psTasks.hpp"
  35 #include "gc/shared/collectorPolicy.hpp"
  36 #include "gc/shared/gcCause.hpp"
  37 #include "gc/shared/gcHeapSummary.hpp"
  38 #include "gc/shared/gcId.hpp"
  39 #include "gc/shared/gcLocker.inline.hpp"
  40 #include "gc/shared/gcTimer.hpp"
  41 #include "gc/shared/gcTrace.hpp"
  42 #include "gc/shared/gcTraceTime.inline.hpp"
  43 #include "gc/shared/isGCActiveMark.hpp"
  44 #include "gc/shared/referencePolicy.hpp"
  45 #include "gc/shared/referenceProcessor.hpp"
  46 #include "gc/shared/spaceDecorator.hpp"
  47 #include "memory/resourceArea.hpp"
  48 #include "logging/log.hpp"
  49 #include "oops/oop.inline.hpp"
  50 #include "runtime/biasedLocking.hpp"
  51 #include "runtime/fprofiler.hpp"
  52 #include "runtime/handles.inline.hpp"
  53 #include "runtime/threadCritical.hpp"
  54 #include "runtime/vmThread.hpp"
  55 #include "runtime/vm_operations.hpp"
  56 #include "services/memoryService.hpp"
  57 #include "utilities/stack.inline.hpp"
  58 
  59 HeapWord*                  PSScavenge::_to_space_top_before_gc = NULL;
  60 int                        PSScavenge::_consecutive_skipped_scavenges = 0;
  61 ReferenceProcessor*        PSScavenge::_ref_processor = NULL;
  62 PSCardTable*               PSScavenge::_card_table = NULL;
  63 bool                       PSScavenge::_survivor_overflow = false;
  64 uint                       PSScavenge::_tenuring_threshold = 0;
  65 HeapWord*                  PSScavenge::_young_generation_boundary = NULL;
  66 uintptr_t                  PSScavenge::_young_generation_boundary_compressed = 0;
  67 elapsedTimer               PSScavenge::_accumulated_time;
  68 STWGCTimer                 PSScavenge::_gc_timer;
  69 ParallelScavengeTracer     PSScavenge::_gc_tracer;
  70 CollectorCounters*         PSScavenge::_counters = NULL;
  71 
  72 // Define before use
  73 class PSIsAliveClosure: public BoolObjectClosure {
  74 public:
  75   bool do_object_b(oop p) {
  76     return (!PSScavenge::is_obj_in_young(p)) || p->is_forwarded();
  77   }
  78 };
  79 
  80 PSIsAliveClosure PSScavenge::_is_alive_closure;
  81 
  82 class PSKeepAliveClosure: public OopClosure {


 302     HandleMark hm;
 303 
 304     GCTraceCPUTime tcpu;
 305     GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true);
 306     TraceCollectorStats tcs(counters());
 307     TraceMemoryManagerStats tms(false /* not full GC */,gc_cause);
 308 
 309     if (TraceYoungGenTime) accumulated_time()->start();
 310 
 311     // Let the size policy know we're starting
 312     size_policy->minor_collection_begin();
 313 
 314     // Verify the object start arrays.
 315     if (VerifyObjectStartArray &&
 316         VerifyBeforeGC) {
 317       old_gen->verify_object_start_array();
 318     }
 319 
 320     // Verify no unmarked old->young roots
 321     if (VerifyRememberedSets) {
 322       PSCardTable::verify_all_young_refs_imprecise();
 323     }
 324 
 325     assert(young_gen->to_space()->is_empty(),
 326            "Attempt to scavenge with live objects in to_space");
 327     young_gen->to_space()->clear(SpaceDecorator::Mangle);
 328 
 329     save_to_space_top_before_gc();
 330 
 331 #if defined(COMPILER2) || INCLUDE_JVMCI
 332     DerivedPointerTable::clear();
 333 #endif
 334 
 335     reference_processor()->enable_discovery();
 336     reference_processor()->setup_policy(false);
 337 
 338     PreGCValues pre_gc_values(heap);
 339 
 340     // Reset our survivor overflow.
 341     set_survivor_overflow(false);
 342 


 583 
 584       assert(young_gen->to_space()->is_empty(), "to space should be empty now");
 585     }
 586 
 587 #if defined(COMPILER2) || INCLUDE_JVMCI
 588     DerivedPointerTable::update_pointers();
 589 #endif
 590 
 591     NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
 592 
 593     // Re-verify object start arrays
 594     if (VerifyObjectStartArray &&
 595         VerifyAfterGC) {
 596       old_gen->verify_object_start_array();
 597     }
 598 
 599     // Verify all old -> young cards are now precise
 600     if (VerifyRememberedSets) {
 601       // Precise verification will give false positives. Until this is fixed,
 602       // use imprecise verification.
 603       // PSCardTable::verify_all_young_refs_precise();
 604       PSCardTable::verify_all_young_refs_imprecise();
 605     }
 606 
 607     if (TraceYoungGenTime) accumulated_time()->stop();
 608 
 609     young_gen->print_used_change(pre_gc_values.young_gen_used());
 610     old_gen->print_used_change(pre_gc_values.old_gen_used());
 611     MetaspaceAux::print_metaspace_change(pre_gc_values.metadata_used());
 612 
 613     // Track memory usage and detect low memory
 614     MemoryService::track_memory_usage();
 615     heap->update_counters();
 616 
 617     gc_task_manager()->release_idle_workers();
 618   }
 619 
 620   if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
 621     HandleMark hm;  // Discard invalid handles created during verification
 622     Universe::verify("After GC");
 623   }
 624 


 742   PSOldGen* old_gen = heap->old_gen();
 743 
 744   // Set boundary between young_gen and old_gen
 745   assert(old_gen->reserved().end() <= young_gen->eden_space()->bottom(),
 746          "old above young");
 747   set_young_generation_boundary(young_gen->eden_space()->bottom());
 748 
 749   // Initialize ref handling object for scavenging.
 750   MemRegion mr = young_gen->reserved();
 751 
 752   _ref_processor =
 753     new ReferenceProcessor(mr,                         // span
 754                            ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
 755                            ParallelGCThreads,          // mt processing degree
 756                            true,                       // mt discovery
 757                            ParallelGCThreads,          // mt discovery degree
 758                            true,                       // atomic_discovery
 759                            NULL);                      // header provides liveness info
 760 
 761   // Cache the cardtable
 762   _card_table = heap->card_table();
 763 
 764   _counters = new CollectorCounters("PSScavenge", 0);
 765 }
< prev index next >