< prev index next >
src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
Print this page
rev 9473 : [mq]: webrev.00
*** 29,38 ****
--- 29,39 ----
#include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintsGC.hpp"
#include "runtime/commandLineFlagRangeList.hpp"
#include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp"
+ #include "runtime/thread.inline.hpp"
#include "utilities/defaultStream.hpp"
#if INCLUDE_ALL_GCS
#include "gc/g1/g1_globals.hpp"
#include "gc/g1/heapRegionBounds.inline.hpp"
*** 504,513 ****
--- 505,527 ----
return Flag::VIOLATES_CONSTRAINT;
}
return Flag::SUCCESS;
}
+ // To avoid an overflow by 'align_size_up(value, alignment).
+ static Flag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) {
+ size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
+ if (value > aligned_max) {
+ CommandLineError::print(verbose,
+ "%s (" SIZE_FORMAT ") must be "
+ "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
+ name, value, aligned_max);
+ return Flag::VIOLATES_CONSTRAINT;
+ }
+ return Flag::SUCCESS;
+ }
+
static Flag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
// For G1 GC, we don't know until G1CollectorPolicy is created.
size_t heap_alignment;
#if INCLUDE_ALL_GCS
*** 517,536 ****
#endif
{
heap_alignment = CollectorPolicy::compute_heap_alignment();
}
! // Not to overflow 'align_size_up(value, _heap_alignment) used from CollectorPolicy::initialize_flags()'.
! size_t aligned_max = ((max_uintx - heap_alignment) & ~(heap_alignment-1));
! if (value > aligned_max) {
! CommandLineError::print(verbose,
! "%s (" SIZE_FORMAT ") must be "
! "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
! name, value, aligned_max);
! return Flag::VIOLATES_CONSTRAINT;
! }
! return Flag::SUCCESS;
}
Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
}
--- 531,541 ----
#endif
{
heap_alignment = CollectorPolicy::compute_heap_alignment();
}
! return MaxSizeForAlignment(name, value, heap_alignment, verbose);
}
Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
}
*** 542,551 ****
--- 547,569 ----
status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
}
return status;
}
+ Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
+ return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
+ }
+
+ Flag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbose) {
+ if (UseNUMA && UseNUMAInterleaving) {
+ size_t min_interleave_granularity = UseLargePages ? os::large_page_size() : os::vm_allocation_granularity();
+ return MaxSizeForAlignment("NUMAInterleaveGranularity", value, min_interleave_granularity, verbose);
+ } else {
+ return Flag::SUCCESS;
+ }
+ }
+
Flag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
#ifdef _LP64
#if INCLUDE_ALL_GCS
// Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length
// when the value to be assigned exceeds uint range.
*** 593,602 ****
--- 611,638 ----
return Flag::VIOLATES_CONSTRAINT;
}
}
return Flag::SUCCESS;
}
+
+ // We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
+ // so AfterMemoryInit type is enough to check.
+ Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
+ if (UseTLAB) {
+ size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
+
+ // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'.
+ if (refill_waste_limit > (max_uintx - value)) {
+ CommandLineError::print(verbose,
+ "TLABWasteIncrement (" UINTX_FORMAT ") must be "
+ "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
+ value, (max_uintx - refill_waste_limit));
+ return Flag::VIOLATES_CONSTRAINT;
+ }
+ }
+ return Flag::SUCCESS;
+ }
Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
if (FLAG_IS_CMDLINE(SurvivorRatio) &&
(value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
CommandLineError::print(verbose,
< prev index next >