hotspot/src/share/vm/gc/parallel/adjoiningGenerations.cpp
changeset 35061 be6025ebffea
parent 30764 fec48bf5a827
child 37242 91e5f98fff6f
equal deleted inserted replaced
35060:382d0689141c 35061:be6025ebffea
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "gc/parallel/adjoiningGenerations.hpp"
    26 #include "gc/parallel/adjoiningGenerations.hpp"
    27 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
    27 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
    28 #include "gc/parallel/generationSizer.hpp"
    28 #include "gc/parallel/generationSizer.hpp"
    29 #include "gc/parallel/parallelScavengeHeap.hpp"
    29 #include "gc/parallel/parallelScavengeHeap.hpp"
       
    30 #include "logging/log.hpp"
       
    31 #include "memory/resourceArea.hpp"
       
    32 #include "utilities/ostream.hpp"
    30 
    33 
    31 // If boundary moving is being used, create the young gen and old
    34 // If boundary moving is being used, create the young gen and old
    32 // gen with ASPSYoungGen and ASPSOldGen, respectively.  Revert to
    35 // gen with ASPSYoungGen and ASPSOldGen, respectively.  Revert to
    33 // the old behavior otherwise (with PSYoungGen and PSOldGen).
    36 // the old behavior otherwise (with PSYoungGen and PSOldGen).
    34 
    37 
   114 
   117 
   115 size_t AdjoiningGenerations::reserved_byte_size() {
   118 size_t AdjoiningGenerations::reserved_byte_size() {
   116   return virtual_spaces()->reserved_space().size();
   119   return virtual_spaces()->reserved_space().size();
   117 }
   120 }
   118 
   121 
       
   122 void log_before_expansion(bool old, size_t expand_in_bytes, size_t change_in_bytes, size_t max_size) {
       
   123   LogHandle(heap, ergo) log;
       
   124   if (!log.is_debug()) {
       
   125    return;
       
   126   }
       
   127   log.debug("Before expansion of %s gen with boundary move", old ? "old" : "young");
       
   128   log.debug("  Requested change: " SIZE_FORMAT_HEX "  Attempted change: " SIZE_FORMAT_HEX,
       
   129                         expand_in_bytes, change_in_bytes);
       
   130   ResourceMark rm;
       
   131   ParallelScavengeHeap::heap()->print_on(log.debug_stream());
       
   132   log.debug("  PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
       
   133 }
       
   134 
       
   135 void log_after_expansion(bool old, size_t max_size) {
       
   136   LogHandle(heap, ergo) log;
       
   137   if (!log.is_debug()) {
       
   138    return;
       
   139   }
       
   140   log.debug("After expansion of %s gen with boundary move", old ? "old" : "young");
       
   141   ResourceMark rm;
       
   142   ParallelScavengeHeap::heap()->print_on(log.debug_stream());
       
   143   log.debug("  PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
       
   144 }
   119 
   145 
   120 // Make checks on the current sizes of the generations and
   146 // Make checks on the current sizes of the generations and
   121 // the constraints on the sizes of the generations.  Push
   147 // the constraints on the sizes of the generations.  Push
   122 // up the boundary within the constraints.  A partial
   148 // up the boundary within the constraints.  A partial
   123 // push can occur.
   149 // push can occur.
   139 
   165 
   140   if (change_in_bytes == 0) {
   166   if (change_in_bytes == 0) {
   141     return;
   167     return;
   142   }
   168   }
   143 
   169 
   144   if (TraceAdaptiveGCBoundary) {
   170   log_before_expansion(true, expand_in_bytes, change_in_bytes, old_gen()->max_gen_size());
   145     gclog_or_tty->print_cr("Before expansion of old gen with boundary move");
       
   146     gclog_or_tty->print_cr("  Requested change: " SIZE_FORMAT_HEX
       
   147                            "  Attempted change: " SIZE_FORMAT_HEX,
       
   148       expand_in_bytes, change_in_bytes);
       
   149     if (!PrintHeapAtGC) {
       
   150       Universe::print_on(gclog_or_tty);
       
   151     }
       
   152     gclog_or_tty->print_cr("  PSOldGen max size: " SIZE_FORMAT "K",
       
   153       old_gen()->max_gen_size()/K);
       
   154   }
       
   155 
   171 
   156   // Move the boundary between the generations up (smaller young gen).
   172   // Move the boundary between the generations up (smaller young gen).
   157   if (virtual_spaces()->adjust_boundary_up(change_in_bytes)) {
   173   if (virtual_spaces()->adjust_boundary_up(change_in_bytes)) {
   158     young_gen()->reset_after_change();
   174     young_gen()->reset_after_change();
   159     old_gen()->reset_after_change();
   175     old_gen()->reset_after_change();
   165          old_gen()->max_gen_size() + young_gen()->max_size(),
   181          old_gen()->max_gen_size() + young_gen()->max_size(),
   166          "Space is missing");
   182          "Space is missing");
   167   young_gen()->space_invariants();
   183   young_gen()->space_invariants();
   168   old_gen()->space_invariants();
   184   old_gen()->space_invariants();
   169 
   185 
   170   if (TraceAdaptiveGCBoundary) {
   186   log_after_expansion(true, old_gen()->max_gen_size());
   171     gclog_or_tty->print_cr("After expansion of old gen with boundary move");
       
   172     if (!PrintHeapAtGC) {
       
   173       Universe::print_on(gclog_or_tty);
       
   174     }
       
   175     gclog_or_tty->print_cr("  PSOldGen max size: " SIZE_FORMAT "K",
       
   176       old_gen()->max_gen_size()/K);
       
   177   }
       
   178 }
   187 }
   179 
   188 
   180 // See comments on request_old_gen_expansion()
   189 // See comments on request_old_gen_expansion()
   181 bool AdjoiningGenerations::request_young_gen_expansion(size_t expand_in_bytes) {
   190 bool AdjoiningGenerations::request_young_gen_expansion(size_t expand_in_bytes) {
   182   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
   191   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
   198 
   207 
   199   if (change_in_bytes == 0) {
   208   if (change_in_bytes == 0) {
   200     return false;
   209     return false;
   201   }
   210   }
   202 
   211 
   203   if (TraceAdaptiveGCBoundary) {
   212   log_before_expansion(false, expand_in_bytes, change_in_bytes, young_gen()->max_size());
   204     gclog_or_tty->print_cr("Before expansion of young gen with boundary move");
       
   205     gclog_or_tty->print_cr("  Requested change: " SIZE_FORMAT_HEX "  Attempted change: " SIZE_FORMAT_HEX,
       
   206       expand_in_bytes, change_in_bytes);
       
   207     if (!PrintHeapAtGC) {
       
   208       Universe::print_on(gclog_or_tty);
       
   209     }
       
   210     gclog_or_tty->print_cr("  PSYoungGen max size: " SIZE_FORMAT "K",
       
   211       young_gen()->max_size()/K);
       
   212   }
       
   213 
   213 
   214   // Move the boundary between the generations down (smaller old gen).
   214   // Move the boundary between the generations down (smaller old gen).
   215   MutexLocker x(ExpandHeap_lock);
   215   MutexLocker x(ExpandHeap_lock);
   216   if (virtual_spaces()->adjust_boundary_down(change_in_bytes)) {
   216   if (virtual_spaces()->adjust_boundary_down(change_in_bytes)) {
   217     young_gen()->reset_after_change();
   217     young_gen()->reset_after_change();
   225          old_gen()->max_gen_size() + young_gen()->max_size(),
   225          old_gen()->max_gen_size() + young_gen()->max_size(),
   226          "Space is missing");
   226          "Space is missing");
   227   young_gen()->space_invariants();
   227   young_gen()->space_invariants();
   228   old_gen()->space_invariants();
   228   old_gen()->space_invariants();
   229 
   229 
   230   if (TraceAdaptiveGCBoundary) {
   230   log_after_expansion(false, young_gen()->max_size());
   231     gclog_or_tty->print_cr("After expansion of young gen with boundary move");
       
   232     if (!PrintHeapAtGC) {
       
   233       Universe::print_on(gclog_or_tty);
       
   234     }
       
   235     gclog_or_tty->print_cr("  PSYoungGen max size: " SIZE_FORMAT "K",
       
   236       young_gen()->max_size()/K);
       
   237   }
       
   238 
   231 
   239   return result;
   232   return result;
   240 }
   233 }
   241 
   234 
   242 // Additional space is needed in the old generation.  Try to move the boundary
   235 // Additional space is needed in the old generation.  Try to move the boundary