< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




1538       warning("Forcing +ParGCUseLocalOverflow: needed if using compressed references");
1539     }
1540     FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true);
1541   }
1542   assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error");
1543 }
1544 
1545 // Adjust some sizes to suit CMS and/or ParNew needs; these work well on
1546 // sparc/solaris for certain applications, but would gain from
1547 // further optimization and tuning efforts, and would almost
1548 // certainly gain from analysis of platform and environment.
1549 void Arguments::set_cms_and_parnew_gc_flags() {
1550   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
1551   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
1552 
1553   // Turn off AdaptiveSizePolicy by default for cms until it is complete.
1554   disable_adaptive_size_policy("UseConcMarkSweepGC");
1555 
1556   set_parnew_gc_flags();
1557 
1558   size_t max_heap = align_size_down(MaxHeapSize,
1559                                     CardTableRS::ct_max_alignment_constraint());
1560 
1561   // Now make adjustments for CMS
1562   intx   tenuring_default = (intx)6;
1563   size_t young_gen_per_worker = CMSYoungGenPerWorker;
1564 
1565   // Preferred young gen size for "short" pauses:
1566   // upper bound depends on # of threads and NewRatio.
1567   const size_t preferred_max_new_size_unaligned =
1568     MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
1569   size_t preferred_max_new_size =
1570     align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1571 
1572   // Unless explicitly requested otherwise, size young gen
1573   // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1574 
1575   // If either MaxNewSize or NewRatio is set on the command line,
1576   // assume the user is trying to set the size of the young gen.
1577   if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1578 
1579     // Set MaxNewSize to our calculated preferred_max_new_size unless
1580     // NewSize was set on the command line and it is larger than
1581     // preferred_max_new_size.
1582     if (!FLAG_IS_DEFAULT(NewSize)) {   // NewSize explicitly set at command-line
1583       FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
1584     } else {
1585       FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
1586     }
1587     log_trace(gc, heap)("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1588 
1589     // Code along this path potentially sets NewSize and OldSize
1590     log_trace(gc, heap)("CMS set min_heap_size: " SIZE_FORMAT " initial_heap_size:  " SIZE_FORMAT " max_heap: " SIZE_FORMAT,


1664   // Oop encoding heap max
1665   OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1666 
1667   if (SurvivorAlignmentInBytes == 0) {
1668     SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
1669   }
1670 
1671 #if INCLUDE_ALL_GCS
1672   // Set CMS global values
1673   CompactibleFreeListSpace::set_cms_values();
1674 #endif // INCLUDE_ALL_GCS
1675 }
1676 
1677 size_t Arguments::max_heap_for_compressed_oops() {
1678   // Avoid sign flip.
1679   assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1680   // We need to fit both the NULL page and the heap into the memory budget, while
1681   // keeping alignment constraints of the heap. To guarantee the latter, as the
1682   // NULL page is located before the heap, we pad the NULL page to the conservative
1683   // maximum alignment that the GC may ever impose upon the heap.
1684   size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
1685                                                         _conservative_max_heap_alignment);
1686 
1687   LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1688   NOT_LP64(ShouldNotReachHere(); return 0);
1689 }
1690 
1691 void Arguments::set_use_compressed_oops() {
1692 #ifndef ZERO
1693 #ifdef _LP64
1694   // MaxHeapSize is not set up properly at this point, but
1695   // the only value that can override MaxHeapSize if we are
1696   // to use UseCompressedOops is InitialHeapSize.
1697   size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1698 
1699   if (max_heap_size <= max_heap_for_compressed_oops()) {
1700 #if !defined(COMPILER1) || defined(TIERED)
1701     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1702       FLAG_SET_ERGO(bool, UseCompressedOops, true);
1703     }
1704 #endif


2746     } else {
2747       return JNI_ENOMEM;
2748     }
2749   }
2750   return JNI_OK;
2751 }
2752 
2753 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2754 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2755   // The min and max sizes match the values in globals.hpp, but scaled
2756   // with K. The values have been chosen so that alignment with page
2757   // size doesn't change the max value, which makes the conversions
2758   // back and forth between Xss value and ThreadStackSize value easier.
2759   // The values have also been chosen to fit inside a 32-bit signed type.
2760   const julong min_ThreadStackSize = 0;
2761   const julong max_ThreadStackSize = 1 * M;
2762 
2763   const julong min_size = min_ThreadStackSize * K;
2764   const julong max_size = max_ThreadStackSize * K;
2765 
2766   assert(is_size_aligned_(max_size, (size_t)os::vm_page_size()), "Implementation assumption");
2767 
2768   julong size = 0;
2769   ArgsRange errcode = parse_memory_size(tail, &size, min_size, max_size);
2770   if (errcode != arg_in_range) {
2771     bool silent = (option == NULL); // Allow testing to silence error messages
2772     if (!silent) {
2773       jio_fprintf(defaultStream::error_stream(),
2774                   "Invalid thread stack size: %s\n", option->optionString);
2775       describe_range_error(errcode);
2776     }
2777     return JNI_EINVAL;
2778   }
2779 
2780   // Internally track ThreadStackSize in units of 1024 bytes.
2781   const julong size_aligned = align_size_up_(size, K);
2782   assert(size <= size_aligned,
2783          "Overflow: " JULONG_FORMAT " " JULONG_FORMAT,
2784          size, size_aligned);
2785 
2786   const julong size_in_K = size_aligned / K;
2787   assert(size_in_K < (julong)max_intx,
2788          "size_in_K doesn't fit in the type of ThreadStackSize: " JULONG_FORMAT,
2789          size_in_K);
2790 
2791   // Check that code expanding ThreadStackSize to a page aligned number of bytes won't overflow.
2792   const julong max_expanded = align_size_up_(size_in_K * K, (size_t)os::vm_page_size());
2793   assert(max_expanded < max_uintx && max_expanded >= size_in_K,
2794          "Expansion overflowed: " JULONG_FORMAT " " JULONG_FORMAT,
2795          max_expanded, size_in_K);
2796 
2797   *out_ThreadStackSize = (intx)size_in_K;
2798 
2799   return JNI_OK;
2800 }
2801 
2802 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin) {
2803   // For match_option to return remaining or value part of option string
2804   const char* tail;
2805 
2806   // iterate over arguments
2807   for (int index = 0; index < args->nOptions; index++) {
2808     bool is_absolute_path = false;  // for -agentpath vs -agentlib
2809 
2810     const JavaVMOption* option = args->options + index;
2811 
2812     if (!match_option(option, "-Djava.class.path", &tail) &&




1538       warning("Forcing +ParGCUseLocalOverflow: needed if using compressed references");
1539     }
1540     FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true);
1541   }
1542   assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error");
1543 }
1544 
1545 // Adjust some sizes to suit CMS and/or ParNew needs; these work well on
1546 // sparc/solaris for certain applications, but would gain from
1547 // further optimization and tuning efforts, and would almost
1548 // certainly gain from analysis of platform and environment.
1549 void Arguments::set_cms_and_parnew_gc_flags() {
1550   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
1551   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
1552 
1553   // Turn off AdaptiveSizePolicy by default for cms until it is complete.
1554   disable_adaptive_size_policy("UseConcMarkSweepGC");
1555 
1556   set_parnew_gc_flags();
1557 
1558   size_t max_heap = align_down(MaxHeapSize,
1559                                CardTableRS::ct_max_alignment_constraint());
1560 
1561   // Now make adjustments for CMS
1562   intx   tenuring_default = (intx)6;
1563   size_t young_gen_per_worker = CMSYoungGenPerWorker;
1564 
1565   // Preferred young gen size for "short" pauses:
1566   // upper bound depends on # of threads and NewRatio.
1567   const size_t preferred_max_new_size_unaligned =
1568     MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
1569   size_t preferred_max_new_size =
1570     align_up(preferred_max_new_size_unaligned, os::vm_page_size());
1571 
1572   // Unless explicitly requested otherwise, size young gen
1573   // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1574 
1575   // If either MaxNewSize or NewRatio is set on the command line,
1576   // assume the user is trying to set the size of the young gen.
1577   if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1578 
1579     // Set MaxNewSize to our calculated preferred_max_new_size unless
1580     // NewSize was set on the command line and it is larger than
1581     // preferred_max_new_size.
1582     if (!FLAG_IS_DEFAULT(NewSize)) {   // NewSize explicitly set at command-line
1583       FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
1584     } else {
1585       FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
1586     }
1587     log_trace(gc, heap)("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1588 
1589     // Code along this path potentially sets NewSize and OldSize
1590     log_trace(gc, heap)("CMS set min_heap_size: " SIZE_FORMAT " initial_heap_size:  " SIZE_FORMAT " max_heap: " SIZE_FORMAT,


1664   // Oop encoding heap max
1665   OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1666 
1667   if (SurvivorAlignmentInBytes == 0) {
1668     SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
1669   }
1670 
1671 #if INCLUDE_ALL_GCS
1672   // Set CMS global values
1673   CompactibleFreeListSpace::set_cms_values();
1674 #endif // INCLUDE_ALL_GCS
1675 }
1676 
1677 size_t Arguments::max_heap_for_compressed_oops() {
1678   // Avoid sign flip.
1679   assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1680   // We need to fit both the NULL page and the heap into the memory budget, while
1681   // keeping alignment constraints of the heap. To guarantee the latter, as the
1682   // NULL page is located before the heap, we pad the NULL page to the conservative
1683   // maximum alignment that the GC may ever impose upon the heap.
1684   size_t displacement_due_to_null_page = align_up_(os::vm_page_size(),
1685                                                    _conservative_max_heap_alignment);
1686 
1687   LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1688   NOT_LP64(ShouldNotReachHere(); return 0);
1689 }
1690 
1691 void Arguments::set_use_compressed_oops() {
1692 #ifndef ZERO
1693 #ifdef _LP64
1694   // MaxHeapSize is not set up properly at this point, but
1695   // the only value that can override MaxHeapSize if we are
1696   // to use UseCompressedOops is InitialHeapSize.
1697   size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1698 
1699   if (max_heap_size <= max_heap_for_compressed_oops()) {
1700 #if !defined(COMPILER1) || defined(TIERED)
1701     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1702       FLAG_SET_ERGO(bool, UseCompressedOops, true);
1703     }
1704 #endif


2746     } else {
2747       return JNI_ENOMEM;
2748     }
2749   }
2750   return JNI_OK;
2751 }
2752 
2753 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2754 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2755   // The min and max sizes match the values in globals.hpp, but scaled
2756   // with K. The values have been chosen so that alignment with page
2757   // size doesn't change the max value, which makes the conversions
2758   // back and forth between Xss value and ThreadStackSize value easier.
2759   // The values have also been chosen to fit inside a 32-bit signed type.
2760   const julong min_ThreadStackSize = 0;
2761   const julong max_ThreadStackSize = 1 * M;
2762 
2763   const julong min_size = min_ThreadStackSize * K;
2764   const julong max_size = max_ThreadStackSize * K;
2765 
2766   assert(is_aligned_(max_size, (size_t)os::vm_page_size()), "Implementation assumption");
2767 
2768   julong size = 0;
2769   ArgsRange errcode = parse_memory_size(tail, &size, min_size, max_size);
2770   if (errcode != arg_in_range) {
2771     bool silent = (option == NULL); // Allow testing to silence error messages
2772     if (!silent) {
2773       jio_fprintf(defaultStream::error_stream(),
2774                   "Invalid thread stack size: %s\n", option->optionString);
2775       describe_range_error(errcode);
2776     }
2777     return JNI_EINVAL;
2778   }
2779 
2780   // Internally track ThreadStackSize in units of 1024 bytes.
2781   const julong size_aligned = align_up_(size, K);
2782   assert(size <= size_aligned,
2783          "Overflow: " JULONG_FORMAT " " JULONG_FORMAT,
2784          size, size_aligned);
2785 
2786   const julong size_in_K = size_aligned / K;
2787   assert(size_in_K < (julong)max_intx,
2788          "size_in_K doesn't fit in the type of ThreadStackSize: " JULONG_FORMAT,
2789          size_in_K);
2790 
2791   // Check that code expanding ThreadStackSize to a page aligned number of bytes won't overflow.
2792   const julong max_expanded = align_up_(size_in_K * K, (size_t)os::vm_page_size());
2793   assert(max_expanded < max_uintx && max_expanded >= size_in_K,
2794          "Expansion overflowed: " JULONG_FORMAT " " JULONG_FORMAT,
2795          max_expanded, size_in_K);
2796 
2797   *out_ThreadStackSize = (intx)size_in_K;
2798 
2799   return JNI_OK;
2800 }
2801 
2802 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin) {
2803   // For match_option to return remaining or value part of option string
2804   const char* tail;
2805 
2806   // iterate over arguments
2807   for (int index = 0; index < args->nOptions; index++) {
2808     bool is_absolute_path = false;  // for -agentpath vs -agentlib
2809 
2810     const JavaVMOption* option = args->options + index;
2811 
2812     if (!match_option(option, "-Djava.class.path", &tail) &&


< prev index next >