hotspot/src/share/vm/memory/collectorPolicy.cpp
changeset 15494 b3a322a0bea5
parent 15091 826cff1f58f5
child 15497 cba24d845969
equal deleted inserted replaced
15493:fefe508991bb 15494:b3a322a0bea5
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2013, 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.
   232   GenCollectorPolicy::initialize_flags();
   232   GenCollectorPolicy::initialize_flags();
   233 
   233 
   234   OldSize = align_size_down(OldSize, min_alignment());
   234   OldSize = align_size_down(OldSize, min_alignment());
   235   if (NewSize + OldSize > MaxHeapSize) {
   235   if (NewSize + OldSize > MaxHeapSize) {
   236     MaxHeapSize = NewSize + OldSize;
   236     MaxHeapSize = NewSize + OldSize;
       
   237   }
       
   238 
       
   239   if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(NewSize)) {
       
   240     // NewRatio will be used later to set the young generation size so we use
       
   241     // it to calculate how big the heap should be based on the requested OldSize
       
   242     // and NewRatio.
       
   243     assert(NewRatio > 0, "NewRatio should have been set up earlier");
       
   244     size_t calculated_heapsize = (OldSize / NewRatio) * (NewRatio + 1);
       
   245 
       
   246     calculated_heapsize = align_size_up(calculated_heapsize, max_alignment());
       
   247     MaxHeapSize = calculated_heapsize;
       
   248     InitialHeapSize = calculated_heapsize;
   237   }
   249   }
   238   MaxHeapSize = align_size_up(MaxHeapSize, max_alignment());
   250   MaxHeapSize = align_size_up(MaxHeapSize, max_alignment());
   239 
   251 
   240   always_do_update_barrier = UseConcMarkSweepGC;
   252   always_do_update_barrier = UseConcMarkSweepGC;
   241 
   253 
   382 // is used to make the needed adjustments.  The application of the
   394 // is used to make the needed adjustments.  The application of the
   383 // policies could be more sophisticated (iterative for example) but
   395 // policies could be more sophisticated (iterative for example) but
   384 // keeping it simple also seems a worthwhile goal.
   396 // keeping it simple also seems a worthwhile goal.
   385 bool TwoGenerationCollectorPolicy::adjust_gen0_sizes(size_t* gen0_size_ptr,
   397 bool TwoGenerationCollectorPolicy::adjust_gen0_sizes(size_t* gen0_size_ptr,
   386                                                      size_t* gen1_size_ptr,
   398                                                      size_t* gen1_size_ptr,
   387                                                      size_t heap_size,
   399                                                      const size_t heap_size,
   388                                                      size_t min_gen0_size) {
   400                                                      const size_t min_gen1_size) {
   389   bool result = false;
   401   bool result = false;
       
   402 
   390   if ((*gen1_size_ptr + *gen0_size_ptr) > heap_size) {
   403   if ((*gen1_size_ptr + *gen0_size_ptr) > heap_size) {
   391     if (((*gen0_size_ptr + OldSize) > heap_size) &&
   404     if ((heap_size < (*gen0_size_ptr + min_gen1_size)) &&
   392        (heap_size - min_gen0_size) >= min_alignment()) {
   405         (heap_size >= min_gen1_size + min_alignment())) {
   393       // Adjust gen0 down to accomodate OldSize
   406       // Adjust gen0 down to accommodate min_gen1_size
   394       *gen0_size_ptr = heap_size - min_gen0_size;
   407       *gen0_size_ptr = heap_size - min_gen1_size;
   395       *gen0_size_ptr =
   408       *gen0_size_ptr =
   396         MAX2((uintx)align_size_down(*gen0_size_ptr, min_alignment()),
   409         MAX2((uintx)align_size_down(*gen0_size_ptr, min_alignment()),
   397              min_alignment());
   410              min_alignment());
   398       assert(*gen0_size_ptr > 0, "Min gen0 is too large");
   411       assert(*gen0_size_ptr > 0, "Min gen0 is too large");
   399       result = true;
   412       result = true;