--- a/hotspot/src/share/vm/runtime/arguments.cpp Wed Sep 18 12:52:15 2013 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Thu Sep 19 09:26:08 2013 +0200
@@ -28,6 +28,7 @@
#include "compiler/compilerOracle.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/cardTableRS.hpp"
+#include "memory/genCollectedHeap.hpp"
#include "memory/referenceProcessor.hpp"
#include "memory/universe.inline.hpp"
#include "oops/oop.inline.hpp"
@@ -54,6 +55,8 @@
#endif
#if INCLUDE_ALL_GCS
#include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
+#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
+#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
#endif // INCLUDE_ALL_GCS
// Note: This is a special bug reporting site for the JVM
@@ -90,6 +93,7 @@
SystemProperty* Arguments::_system_properties = NULL;
const char* Arguments::_gc_log_filename = NULL;
bool Arguments::_has_profile = false;
+size_t Arguments::_conservative_max_heap_alignment = 0;
uintx Arguments::_min_heap_size = 0;
Arguments::Mode Arguments::_mode = _mixed;
bool Arguments::_java_compiler = false;
@@ -1391,10 +1395,17 @@
return true;
}
-inline uintx max_heap_for_compressed_oops() {
+uintx Arguments::max_heap_for_compressed_oops() {
// Avoid sign flip.
assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
- LP64_ONLY(return OopEncodingHeapMax - os::vm_page_size());
+ // We need to fit both the NULL page and the heap into the memory budget, while
+ // keeping alignment constraints of the heap. To guarantee the latter, as the
+ // NULL page is located before the heap, we pad the NULL page to the conservative
+ // maximum alignment that the GC may ever impose upon the heap.
+ size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
+ Arguments::conservative_max_heap_alignment());
+
+ LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
NOT_LP64(ShouldNotReachHere(); return 0);
}
@@ -1439,7 +1450,7 @@
if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
warning("Max heap size too large for Compressed Oops");
FLAG_SET_DEFAULT(UseCompressedOops, false);
- FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
+ FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
}
}
#endif // _LP64
@@ -1452,22 +1463,22 @@
void Arguments::set_use_compressed_klass_ptrs() {
#ifndef ZERO
#ifdef _LP64
- // UseCompressedOops must be on for UseCompressedKlassPointers to be on.
+ // UseCompressedOops must be on for UseCompressedClassPointers to be on.
if (!UseCompressedOops) {
- if (UseCompressedKlassPointers) {
- warning("UseCompressedKlassPointers requires UseCompressedOops");
+ if (UseCompressedClassPointers) {
+ warning("UseCompressedClassPointers requires UseCompressedOops");
}
- FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
+ FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
} else {
- // Turn on UseCompressedKlassPointers too
- if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) {
- FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true);
+ // Turn on UseCompressedClassPointers too
+ if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
+ FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
}
- // Check the ClassMetaspaceSize to make sure we use compressed klass ptrs.
- if (UseCompressedKlassPointers) {
- if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) {
- warning("Class metaspace size is too large for UseCompressedKlassPointers");
- FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
+ // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
+ if (UseCompressedClassPointers) {
+ if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
+ warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
+ FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
}
}
}
@@ -1475,6 +1486,23 @@
#endif // !ZERO
}
+void Arguments::set_conservative_max_heap_alignment() {
+ // The conservative maximum required alignment for the heap is the maximum of
+ // the alignments imposed by several sources: any requirements from the heap
+ // itself, the collector policy and the maximum page size we may run the VM
+ // with.
+ size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
+#if INCLUDE_ALL_GCS
+ if (UseParallelGC) {
+ heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
+ } else if (UseG1GC) {
+ heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
+ }
+#endif // INCLUDE_ALL_GCS
+ _conservative_max_heap_alignment = MAX3(heap_alignment, os::max_page_size(),
+ CollectorPolicy::compute_max_alignment());
+}
+
void Arguments::set_ergonomics_flags() {
if (os::is_server_class_machine()) {
@@ -1503,6 +1531,8 @@
}
}
+ set_conservative_max_heap_alignment();
+
#ifndef ZERO
#ifdef _LP64
set_use_compressed_oops();
@@ -2193,8 +2223,8 @@
status = status && verify_object_alignment();
- status = status && verify_interval(ClassMetaspaceSize, 1*M, 3*G,
- "ClassMetaspaceSize");
+ status = status && verify_interval(CompressedClassSpaceSize, 1*M, 3*G,
+ "CompressedClassSpaceSize");
status = status && verify_interval(MarkStackSizeMax,
1, (max_jint - 1), "MarkStackSizeMax");
@@ -3326,13 +3356,13 @@
}
UseSharedSpaces = false;
#ifdef _LP64
- if (!UseCompressedOops || !UseCompressedKlassPointers) {
+ if (!UseCompressedOops || !UseCompressedClassPointers) {
vm_exit_during_initialization(
- "Cannot dump shared archive when UseCompressedOops or UseCompressedKlassPointers is off.", NULL);
+ "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
}
} else {
- // UseCompressedOops and UseCompressedKlassPointers must be on for UseSharedSpaces.
- if (!UseCompressedOops || !UseCompressedKlassPointers) {
+ // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.
+ if (!UseCompressedOops || !UseCompressedClassPointers) {
no_shared_spaces();
}
#endif
@@ -3558,6 +3588,11 @@
no_shared_spaces();
#endif // INCLUDE_CDS
+ return JNI_OK;
+}
+
+jint Arguments::apply_ergo() {
+
// Set flags based on ergonomics.
set_ergonomics_flags();
@@ -3633,7 +3668,7 @@
FLAG_SET_DEFAULT(ProfileInterpreter, false);
FLAG_SET_DEFAULT(UseBiasedLocking, false);
LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
- LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedKlassPointers, false));
+ LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false));
#endif // CC_INTERP
#ifdef COMPILER2
@@ -3662,6 +3697,10 @@
DebugNonSafepoints = true;
}
+ if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
+ warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
+ }
+
#ifndef PRODUCT
if (CompileTheWorld) {
// Force NmethodSweeper to sweep whole CodeCache each time.