1.1 --- a/src/share/vm/runtime/arguments.cpp Wed Sep 18 12:52:15 2013 -0400 1.2 +++ b/src/share/vm/runtime/arguments.cpp Thu Sep 19 09:26:08 2013 +0200 1.3 @@ -28,6 +28,7 @@ 1.4 #include "compiler/compilerOracle.hpp" 1.5 #include "memory/allocation.inline.hpp" 1.6 #include "memory/cardTableRS.hpp" 1.7 +#include "memory/genCollectedHeap.hpp" 1.8 #include "memory/referenceProcessor.hpp" 1.9 #include "memory/universe.inline.hpp" 1.10 #include "oops/oop.inline.hpp" 1.11 @@ -54,6 +55,8 @@ 1.12 #endif 1.13 #if INCLUDE_ALL_GCS 1.14 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" 1.15 +#include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 1.16 +#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 1.17 #endif // INCLUDE_ALL_GCS 1.18 1.19 // Note: This is a special bug reporting site for the JVM 1.20 @@ -90,6 +93,7 @@ 1.21 SystemProperty* Arguments::_system_properties = NULL; 1.22 const char* Arguments::_gc_log_filename = NULL; 1.23 bool Arguments::_has_profile = false; 1.24 +size_t Arguments::_conservative_max_heap_alignment = 0; 1.25 uintx Arguments::_min_heap_size = 0; 1.26 Arguments::Mode Arguments::_mode = _mixed; 1.27 bool Arguments::_java_compiler = false; 1.28 @@ -1391,10 +1395,17 @@ 1.29 return true; 1.30 } 1.31 1.32 -inline uintx max_heap_for_compressed_oops() { 1.33 +uintx Arguments::max_heap_for_compressed_oops() { 1.34 // Avoid sign flip. 1.35 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size"); 1.36 - LP64_ONLY(return OopEncodingHeapMax - os::vm_page_size()); 1.37 + // We need to fit both the NULL page and the heap into the memory budget, while 1.38 + // keeping alignment constraints of the heap. To guarantee the latter, as the 1.39 + // NULL page is located before the heap, we pad the NULL page to the conservative 1.40 + // maximum alignment that the GC may ever impose upon the heap. 1.41 + size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(), 1.42 + Arguments::conservative_max_heap_alignment()); 1.43 + 1.44 + LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page); 1.45 NOT_LP64(ShouldNotReachHere(); return 0); 1.46 } 1.47 1.48 @@ -1439,7 +1450,7 @@ 1.49 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) { 1.50 warning("Max heap size too large for Compressed Oops"); 1.51 FLAG_SET_DEFAULT(UseCompressedOops, false); 1.52 - FLAG_SET_DEFAULT(UseCompressedKlassPointers, false); 1.53 + FLAG_SET_DEFAULT(UseCompressedClassPointers, false); 1.54 } 1.55 } 1.56 #endif // _LP64 1.57 @@ -1452,22 +1463,22 @@ 1.58 void Arguments::set_use_compressed_klass_ptrs() { 1.59 #ifndef ZERO 1.60 #ifdef _LP64 1.61 - // UseCompressedOops must be on for UseCompressedKlassPointers to be on. 1.62 + // UseCompressedOops must be on for UseCompressedClassPointers to be on. 1.63 if (!UseCompressedOops) { 1.64 - if (UseCompressedKlassPointers) { 1.65 - warning("UseCompressedKlassPointers requires UseCompressedOops"); 1.66 + if (UseCompressedClassPointers) { 1.67 + warning("UseCompressedClassPointers requires UseCompressedOops"); 1.68 } 1.69 - FLAG_SET_DEFAULT(UseCompressedKlassPointers, false); 1.70 + FLAG_SET_DEFAULT(UseCompressedClassPointers, false); 1.71 } else { 1.72 - // Turn on UseCompressedKlassPointers too 1.73 - if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) { 1.74 - FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true); 1.75 + // Turn on UseCompressedClassPointers too 1.76 + if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) { 1.77 + FLAG_SET_ERGO(bool, UseCompressedClassPointers, true); 1.78 } 1.79 - // Check the ClassMetaspaceSize to make sure we use compressed klass ptrs. 1.80 - if (UseCompressedKlassPointers) { 1.81 - if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) { 1.82 - warning("Class metaspace size is too large for UseCompressedKlassPointers"); 1.83 - FLAG_SET_DEFAULT(UseCompressedKlassPointers, false); 1.84 + // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs. 1.85 + if (UseCompressedClassPointers) { 1.86 + if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) { 1.87 + warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers"); 1.88 + FLAG_SET_DEFAULT(UseCompressedClassPointers, false); 1.89 } 1.90 } 1.91 } 1.92 @@ -1475,6 +1486,23 @@ 1.93 #endif // !ZERO 1.94 } 1.95 1.96 +void Arguments::set_conservative_max_heap_alignment() { 1.97 + // The conservative maximum required alignment for the heap is the maximum of 1.98 + // the alignments imposed by several sources: any requirements from the heap 1.99 + // itself, the collector policy and the maximum page size we may run the VM 1.100 + // with. 1.101 + size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment(); 1.102 +#if INCLUDE_ALL_GCS 1.103 + if (UseParallelGC) { 1.104 + heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment(); 1.105 + } else if (UseG1GC) { 1.106 + heap_alignment = G1CollectedHeap::conservative_max_heap_alignment(); 1.107 + } 1.108 +#endif // INCLUDE_ALL_GCS 1.109 + _conservative_max_heap_alignment = MAX3(heap_alignment, os::max_page_size(), 1.110 + CollectorPolicy::compute_max_alignment()); 1.111 +} 1.112 + 1.113 void Arguments::set_ergonomics_flags() { 1.114 1.115 if (os::is_server_class_machine()) { 1.116 @@ -1503,6 +1531,8 @@ 1.117 } 1.118 } 1.119 1.120 + set_conservative_max_heap_alignment(); 1.121 + 1.122 #ifndef ZERO 1.123 #ifdef _LP64 1.124 set_use_compressed_oops(); 1.125 @@ -2193,8 +2223,8 @@ 1.126 1.127 status = status && verify_object_alignment(); 1.128 1.129 - status = status && verify_interval(ClassMetaspaceSize, 1*M, 3*G, 1.130 - "ClassMetaspaceSize"); 1.131 + status = status && verify_interval(CompressedClassSpaceSize, 1*M, 3*G, 1.132 + "CompressedClassSpaceSize"); 1.133 1.134 status = status && verify_interval(MarkStackSizeMax, 1.135 1, (max_jint - 1), "MarkStackSizeMax"); 1.136 @@ -3326,13 +3356,13 @@ 1.137 } 1.138 UseSharedSpaces = false; 1.139 #ifdef _LP64 1.140 - if (!UseCompressedOops || !UseCompressedKlassPointers) { 1.141 + if (!UseCompressedOops || !UseCompressedClassPointers) { 1.142 vm_exit_during_initialization( 1.143 - "Cannot dump shared archive when UseCompressedOops or UseCompressedKlassPointers is off.", NULL); 1.144 + "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); 1.145 } 1.146 } else { 1.147 - // UseCompressedOops and UseCompressedKlassPointers must be on for UseSharedSpaces. 1.148 - if (!UseCompressedOops || !UseCompressedKlassPointers) { 1.149 + // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces. 1.150 + if (!UseCompressedOops || !UseCompressedClassPointers) { 1.151 no_shared_spaces(); 1.152 } 1.153 #endif 1.154 @@ -3558,6 +3588,11 @@ 1.155 no_shared_spaces(); 1.156 #endif // INCLUDE_CDS 1.157 1.158 + return JNI_OK; 1.159 +} 1.160 + 1.161 +jint Arguments::apply_ergo() { 1.162 + 1.163 // Set flags based on ergonomics. 1.164 set_ergonomics_flags(); 1.165 1.166 @@ -3633,7 +3668,7 @@ 1.167 FLAG_SET_DEFAULT(ProfileInterpreter, false); 1.168 FLAG_SET_DEFAULT(UseBiasedLocking, false); 1.169 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false)); 1.170 - LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedKlassPointers, false)); 1.171 + LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false)); 1.172 #endif // CC_INTERP 1.173 1.174 #ifdef COMPILER2 1.175 @@ -3662,6 +3697,10 @@ 1.176 DebugNonSafepoints = true; 1.177 } 1.178 1.179 + if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) { 1.180 + warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used"); 1.181 + } 1.182 + 1.183 #ifndef PRODUCT 1.184 if (CompileTheWorld) { 1.185 // Force NmethodSweeper to sweep whole CodeCache each time.