< prev index next >

src/share/vm/gc/serial/defNewGeneration.cpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2015, 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  *


 358   // but the second succeeds and expands the heap to its maximum
 359   // value.
 360   if (GC_locker::is_active()) {
 361     log_debug(gc)("Garbage collection disabled, expanded heap instead");
 362   }
 363 
 364   return success;
 365 }
 366 
 367 size_t DefNewGeneration::adjust_for_thread_increase(size_t new_size_candidate,
 368                                                     size_t new_size_before,
 369                                                     size_t alignment) const {
 370   size_t desired_new_size = new_size_before;
 371 
 372   if (NewSizeThreadIncrease > 0) {
 373     int threads_count;
 374     size_t thread_increase_size = 0;
 375 
 376     // 1. Check an overflow at 'threads_count * NewSizeThreadIncrease'.
 377     threads_count = Threads::number_of_non_daemon_threads();
 378     if (NewSizeThreadIncrease <= max_uintx / threads_count) {
 379       thread_increase_size = threads_count * NewSizeThreadIncrease;
 380 
 381       // 2. Check an overflow at 'new_size_candidate + thread_increase_size'.
 382       if (new_size_candidate <= max_uintx - thread_increase_size) {
 383         new_size_candidate += thread_increase_size;
 384 
 385         // 3. Check an overflow at 'align_size_up'.
 386         size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
 387         if (new_size_candidate <= aligned_max) {
 388           desired_new_size = align_size_up(new_size_candidate, alignment);
 389         }
 390       }
 391     }
 392   }
 393 
 394   return desired_new_size;
 395 }
 396 
 397 void DefNewGeneration::compute_new_size() {
 398   // This is called after a GC that includes the old generation, so from-space


   1 /*
   2  * Copyright (c) 2001, 2016, 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  *


 358   // but the second succeeds and expands the heap to its maximum
 359   // value.
 360   if (GC_locker::is_active()) {
 361     log_debug(gc)("Garbage collection disabled, expanded heap instead");
 362   }
 363 
 364   return success;
 365 }
 366 
 367 size_t DefNewGeneration::adjust_for_thread_increase(size_t new_size_candidate,
 368                                                     size_t new_size_before,
 369                                                     size_t alignment) const {
 370   size_t desired_new_size = new_size_before;
 371 
 372   if (NewSizeThreadIncrease > 0) {
 373     int threads_count;
 374     size_t thread_increase_size = 0;
 375 
 376     // 1. Check an overflow at 'threads_count * NewSizeThreadIncrease'.
 377     threads_count = Threads::number_of_non_daemon_threads();
 378     if (threads_count > 0 && NewSizeThreadIncrease <= max_uintx / threads_count) {
 379       thread_increase_size = threads_count * NewSizeThreadIncrease;
 380 
 381       // 2. Check an overflow at 'new_size_candidate + thread_increase_size'.
 382       if (new_size_candidate <= max_uintx - thread_increase_size) {
 383         new_size_candidate += thread_increase_size;
 384 
 385         // 3. Check an overflow at 'align_size_up'.
 386         size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
 387         if (new_size_candidate <= aligned_max) {
 388           desired_new_size = align_size_up(new_size_candidate, alignment);
 389         }
 390       }
 391     }
 392   }
 393 
 394   return desired_new_size;
 395 }
 396 
 397 void DefNewGeneration::compute_new_size() {
 398   // This is called after a GC that includes the old generation, so from-space


< prev index next >