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 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GENERATIONSIZER_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GENERATIONSIZER_HPP 27 28 #include "memory/collectorPolicy.hpp" 29 30 // There is a nice batch of tested generation sizing code in 31 // TwoGenerationCollectorPolicy. Lets reuse it! 32 33 class GenerationSizer : public TwoGenerationCollectorPolicy { 34 private: 35 36 void trace_gen_sizes(const char* const str) { 37 if (TracePageSizes) { 38 tty->print_cr("%s: " SIZE_FORMAT "," SIZE_FORMAT " " 39 SIZE_FORMAT "," SIZE_FORMAT " " 40 SIZE_FORMAT, 41 str, 42 _min_gen1_size / K, _max_gen1_size / K, 43 _min_gen0_size / K, _max_gen0_size / K, 44 _max_heap_byte_size / K); 45 } 46 } 47 48 void initialize_alignments() { 49 _space_alignment = _gen_alignment = default_gen_alignment(); 50 _heap_alignment = compute_heap_alignment(); 51 } 52 53 // The alignment used for boundary between young gen and old gen 54 static size_t default_gen_alignment() { 55 return 64 * K * HeapWordSize; 56 } 57 58 void initialize_flags() { 59 // Do basic sizing work 60 TwoGenerationCollectorPolicy::initialize_flags(); 61 62 assert(UseSerialGC || 63 !FLAG_IS_DEFAULT(ParallelGCThreads) || 64 (ParallelGCThreads > 0), 65 "ParallelGCThreads should be set before flag initialization"); 66 67 // The survivor ratio's are calculated "raw", unlike the 68 // default gc, which adds 2 to the ratio value. We need to 69 // make sure the values are valid before using them. 70 if (MinSurvivorRatio < 3) { 71 FLAG_SET_ERGO(uintx, MinSurvivorRatio, 3); 72 } 73 74 if (InitialSurvivorRatio < 3) { 75 FLAG_SET_ERGO(uintx, InitialSurvivorRatio, 3); 76 } 77 } 78 79 void initialize_size_info() { 80 trace_gen_sizes("ps heap raw"); 81 const size_t page_sz = os::page_size_for_region(_min_heap_byte_size, 82 _max_heap_byte_size, 83 8); 84 85 // Can a page size be something else than a power of two? 86 assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2"); 87 size_t new_alignment = round_to(page_sz, _gen_alignment); 88 if (new_alignment != _gen_alignment) { 89 _gen_alignment = new_alignment; 90 // Redo everything from the start 91 initialize_flags(); 92 } 93 TwoGenerationCollectorPolicy::initialize_size_info(); 94 95 trace_gen_sizes("ps heap rnd"); 96 } 97 }; 98 99 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GENERATIONSIZER_HPP | 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 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GENERATIONSIZER_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GENERATIONSIZER_HPP 27 28 #include "memory/collectorPolicy.hpp" 29 30 // There is a nice batch of tested generation sizing code in 31 // TwoGenerationCollectorPolicy. Lets reuse it! 32 33 class GenerationSizer : public TwoGenerationCollectorPolicy { 34 private: 35 36 void trace_gen_sizes(const char* const str); 37 38 // The alignment used for boundary between young gen and old gen 39 static size_t default_gen_alignment() { return 64 * K * HeapWordSize; } 40 41 protected: 42 43 void initialize_alignments(); 44 void initialize_flags(); 45 void initialize_size_info(); 46 }; 47 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GENERATIONSIZER_HPP |