356 }
357 #endif // INCLUDE_ALL_GCS
358
359 Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) {
360 #if INCLUDE_ALL_GCS
361 if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) {
362 CommandLineError::print(verbose,
363 "ParGCStridesPerThread (" UINTX_FORMAT ") must be "
364 "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
365 value, ((uintx)max_jint / (uintx)ParallelGCThreads));
366 return Flag::VIOLATES_CONSTRAINT;
367 }
368 #endif
369 return Flag::SUCCESS;
370 }
371
372 Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
373 #if INCLUDE_ALL_GCS
374 if (UseConcMarkSweepGC) {
375 // ParGCCardsPerStrideChunk should be compared with card table size.
376 size_t heap_size = Universe::heap()->reserved_region().word_size();
377 CardTableModRefBS* bs = (CardTableModRefBS*)GenCollectedHeap::heap()->rem_set()->bs();
378 size_t card_table_size = bs->cards_required(heap_size) - 1; // Valid card table size
379
380 if ((size_t)value > card_table_size) {
381 CommandLineError::print(verbose,
382 "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and "
383 "must be less than or equal to card table size (" SIZE_FORMAT ")\n",
384 value, card_table_size);
385 return Flag::VIOLATES_CONSTRAINT;
386 }
387
388 // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
389 // from CardTableModRefBSForCTRS::process_stride(). Note that ParGCStridesPerThread is already checked
390 // not to make an overflow with ParallelGCThreads from its constraint function.
391 uintx n_strides = ParallelGCThreads * ParGCStridesPerThread;
392 uintx ergo_max = max_uintx / n_strides;
393 if ((uintx)value > ergo_max) {
394 CommandLineError::print(verbose,
395 "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
396 "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
735 // We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
736 // so AfterMemoryInit type is enough to check.
737 Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
738 if (UseTLAB) {
739 size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
740
741 // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'.
742 if (refill_waste_limit > (max_uintx - value)) {
743 CommandLineError::print(verbose,
744 "TLABWasteIncrement (" UINTX_FORMAT ") must be "
745 "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
746 value, (max_uintx - refill_waste_limit));
747 return Flag::VIOLATES_CONSTRAINT;
748 }
749 }
750 return Flag::SUCCESS;
751 }
752
753 Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
754 if (FLAG_IS_CMDLINE(SurvivorRatio) &&
755 (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
756 CommandLineError::print(verbose,
757 "SurvivorRatio (" UINTX_FORMAT ") must be "
758 "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
759 value,
760 (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
761 return Flag::VIOLATES_CONSTRAINT;
762 } else {
763 return Flag::SUCCESS;
764 }
765 }
766
767 Flag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) {
768 if (value > MaxMetaspaceSize) {
769 CommandLineError::print(verbose,
770 "MetaspaceSize (" SIZE_FORMAT ") must be "
771 "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n",
772 value, MaxMetaspaceSize);
773 return Flag::VIOLATES_CONSTRAINT;
774 } else {
775 return Flag::SUCCESS;
776 }
777 }
778
779 Flag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
780 if (value < MetaspaceSize) {
|
356 }
357 #endif // INCLUDE_ALL_GCS
358
359 Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) {
360 #if INCLUDE_ALL_GCS
361 if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) {
362 CommandLineError::print(verbose,
363 "ParGCStridesPerThread (" UINTX_FORMAT ") must be "
364 "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
365 value, ((uintx)max_jint / (uintx)ParallelGCThreads));
366 return Flag::VIOLATES_CONSTRAINT;
367 }
368 #endif
369 return Flag::SUCCESS;
370 }
371
372 Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
373 #if INCLUDE_ALL_GCS
374 if (UseConcMarkSweepGC) {
375 // ParGCCardsPerStrideChunk should be compared with card table size.
376 size_t heap_size = GC::gc()->heap()->reserved_region().word_size();
377 CardTableModRefBS* bs = (CardTableModRefBS*)GenCollectedHeap::heap()->rem_set()->bs();
378 size_t card_table_size = bs->cards_required(heap_size) - 1; // Valid card table size
379
380 if ((size_t)value > card_table_size) {
381 CommandLineError::print(verbose,
382 "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and "
383 "must be less than or equal to card table size (" SIZE_FORMAT ")\n",
384 value, card_table_size);
385 return Flag::VIOLATES_CONSTRAINT;
386 }
387
388 // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
389 // from CardTableModRefBSForCTRS::process_stride(). Note that ParGCStridesPerThread is already checked
390 // not to make an overflow with ParallelGCThreads from its constraint function.
391 uintx n_strides = ParallelGCThreads * ParGCStridesPerThread;
392 uintx ergo_max = max_uintx / n_strides;
393 if ((uintx)value > ergo_max) {
394 CommandLineError::print(verbose,
395 "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
396 "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
735 // We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
736 // so AfterMemoryInit type is enough to check.
737 Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
738 if (UseTLAB) {
739 size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
740
741 // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'.
742 if (refill_waste_limit > (max_uintx - value)) {
743 CommandLineError::print(verbose,
744 "TLABWasteIncrement (" UINTX_FORMAT ") must be "
745 "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
746 value, (max_uintx - refill_waste_limit));
747 return Flag::VIOLATES_CONSTRAINT;
748 }
749 }
750 return Flag::SUCCESS;
751 }
752
753 Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
754 if (FLAG_IS_CMDLINE(SurvivorRatio) &&
755 (value > (MaxHeapSize / GC::gc()->heap()->collector_policy()->space_alignment()))) {
756 CommandLineError::print(verbose,
757 "SurvivorRatio (" UINTX_FORMAT ") must be "
758 "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
759 value,
760 (MaxHeapSize / GC::gc()->heap()->collector_policy()->space_alignment()));
761 return Flag::VIOLATES_CONSTRAINT;
762 } else {
763 return Flag::SUCCESS;
764 }
765 }
766
767 Flag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) {
768 if (value > MaxMetaspaceSize) {
769 CommandLineError::print(verbose,
770 "MetaspaceSize (" SIZE_FORMAT ") must be "
771 "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n",
772 value, MaxMetaspaceSize);
773 return Flag::VIOLATES_CONSTRAINT;
774 } else {
775 return Flag::SUCCESS;
776 }
777 }
778
779 Flag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
780 if (value < MetaspaceSize) {
|