src/share/vm/memory/generation.cpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   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 "gc_implementation/shared/spaceDecorator.hpp"
  27 #include "gc_interface/collectedHeap.inline.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/blockOffsetTable.inline.hpp"
  30 #include "memory/cardTableRS.hpp"
  31 #include "memory/gcLocker.inline.hpp"
  32 #include "memory/genCollectedHeap.hpp"
  33 #include "memory/genMarkSweep.hpp"
  34 #include "memory/genOopClosures.hpp"
  35 #include "memory/genOopClosures.inline.hpp"
  36 #include "memory/generation.hpp"
  37 #include "memory/generation.inline.hpp"
  38 #include "memory/space.inline.hpp"
  39 #include "oops/oop.inline.hpp"
  40 #include "runtime/java.hpp"
  41 #include "utilities/copy.hpp"
  42 #include "utilities/events.hpp"
  43 
  44 Generation::Generation(ReservedSpace rs, size_t initial_size, int level) :
  45   _level(level),


 607                              capacity_after_gc / (double) K,
 608                              _capacity_at_prologue / (double) K,
 609                              expansion_for_promotion / (double) K,
 610                              shrink_bytes / (double) K);
 611     }
 612   }
 613   // Don't shrink unless it's significant
 614   if (shrink_bytes >= _min_heap_delta_bytes) {
 615     shrink(shrink_bytes);
 616   }
 617 }
 618 
 619 // Currently nothing to do.
 620 void CardGeneration::prepare_for_verify() {}
 621 
 622 
 623 void OneContigSpaceCardGeneration::collect(bool   full,
 624                                            bool   clear_all_soft_refs,
 625                                            size_t size,
 626                                            bool   is_tlab) {


 627   SpecializationStats::clear();
 628   // Temporarily expand the span of our ref processor, so
 629   // refs discovery is over the entire heap, not just this generation
 630   ReferenceProcessorSpanMutator
 631     x(ref_processor(), GenCollectedHeap::heap()->reserved_region());







 632   GenMarkSweep::invoke_at_safepoint(_level, ref_processor(), clear_all_soft_refs);





 633   SpecializationStats::print();
 634 }
 635 
 636 HeapWord*
 637 OneContigSpaceCardGeneration::expand_and_allocate(size_t word_size,
 638                                                   bool is_tlab,
 639                                                   bool parallel) {
 640   assert(!is_tlab, "OneContigSpaceCardGeneration does not support TLAB allocation");
 641   if (parallel) {
 642     MutexLocker x(ParGCRareEvent_lock);
 643     HeapWord* result = NULL;
 644     size_t byte_size = word_size * HeapWordSize;
 645     while (true) {
 646       expand(byte_size, _min_heap_delta_bytes);
 647       if (GCExpandToAllocateDelayMillis > 0) {
 648         os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
 649       }
 650       result = _the_space->par_allocate(word_size);
 651       if ( result != NULL) {
 652         return result;


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   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 "gc_implementation/shared/gcTimer.hpp"
  27 #include "gc_implementation/shared/gcTrace.hpp"
  28 #include "gc_implementation/shared/spaceDecorator.hpp"
  29 #include "gc_interface/collectedHeap.inline.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/blockOffsetTable.inline.hpp"
  32 #include "memory/cardTableRS.hpp"
  33 #include "memory/gcLocker.inline.hpp"
  34 #include "memory/genCollectedHeap.hpp"
  35 #include "memory/genMarkSweep.hpp"
  36 #include "memory/genOopClosures.hpp"
  37 #include "memory/genOopClosures.inline.hpp"
  38 #include "memory/generation.hpp"
  39 #include "memory/generation.inline.hpp"
  40 #include "memory/space.inline.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "runtime/java.hpp"
  43 #include "utilities/copy.hpp"
  44 #include "utilities/events.hpp"
  45 
  46 Generation::Generation(ReservedSpace rs, size_t initial_size, int level) :
  47   _level(level),


 609                              capacity_after_gc / (double) K,
 610                              _capacity_at_prologue / (double) K,
 611                              expansion_for_promotion / (double) K,
 612                              shrink_bytes / (double) K);
 613     }
 614   }
 615   // Don't shrink unless it's significant
 616   if (shrink_bytes >= _min_heap_delta_bytes) {
 617     shrink(shrink_bytes);
 618   }
 619 }
 620 
 621 // Currently nothing to do.
 622 void CardGeneration::prepare_for_verify() {}
 623 
 624 
 625 void OneContigSpaceCardGeneration::collect(bool   full,
 626                                            bool   clear_all_soft_refs,
 627                                            size_t size,
 628                                            bool   is_tlab) {
 629   GenCollectedHeap* gch = GenCollectedHeap::heap();
 630 
 631   SpecializationStats::clear();
 632   // Temporarily expand the span of our ref processor, so
 633   // refs discovery is over the entire heap, not just this generation
 634   ReferenceProcessorSpanMutator
 635     x(ref_processor(), gch->reserved_region());
 636 
 637   STWGCTimer* gc_timer = GenMarkSweep::gc_timer();
 638   gc_timer->register_gc_start(os::elapsed_counter());
 639 
 640   SerialOldTracer* gc_tracer = GenMarkSweep::gc_tracer();
 641   gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start());
 642 
 643   GenMarkSweep::invoke_at_safepoint(_level, ref_processor(), clear_all_soft_refs);
 644 
 645   gc_timer->register_gc_end(os::elapsed_counter());
 646 
 647   gc_tracer->report_gc_end(os::elapsed_counter(), gc_timer->time_partitions());
 648 
 649   SpecializationStats::print();
 650 }
 651 
 652 HeapWord*
 653 OneContigSpaceCardGeneration::expand_and_allocate(size_t word_size,
 654                                                   bool is_tlab,
 655                                                   bool parallel) {
 656   assert(!is_tlab, "OneContigSpaceCardGeneration does not support TLAB allocation");
 657   if (parallel) {
 658     MutexLocker x(ParGCRareEvent_lock);
 659     HeapWord* result = NULL;
 660     size_t byte_size = word_size * HeapWordSize;
 661     while (true) {
 662       expand(byte_size, _min_heap_delta_bytes);
 663       if (GCExpandToAllocateDelayMillis > 0) {
 664         os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
 665       }
 666       result = _the_space->par_allocate(word_size);
 667       if ( result != NULL) {
 668         return result;