< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page

1393 void Arguments::set_use_compressed_oops() {
1394 #ifdef _LP64
1395   // MaxHeapSize is not set up properly at this point, but
1396   // the only value that can override MaxHeapSize if we are
1397   // to use UseCompressedOops are InitialHeapSize and MinHeapSize.
1398   size_t max_heap_size = MAX3(MaxHeapSize, InitialHeapSize, MinHeapSize);
1399 
1400   if (max_heap_size <= max_heap_for_compressed_oops()) {
1401     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1402       FLAG_SET_ERGO(UseCompressedOops, true);
1403     }
1404   } else {
1405     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1406       warning("Max heap size too large for Compressed Oops");
1407       FLAG_SET_DEFAULT(UseCompressedOops, false);
1408     }
1409   }
1410 #endif // _LP64
1411 }
1412 
1413 void Arguments::set_use_compressed_klass_ptrs() {
1414 #ifdef _LP64
1415   assert(!UseCompressedClassPointers || CompressedClassSpaceSize <= KlassEncodingMetaspaceMax,
1416          "CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1417 #endif // _LP64
1418 }
1419 
1420 void Arguments::set_conservative_max_heap_alignment() {
1421   // The conservative maximum required alignment for the heap is the maximum of
1422   // the alignments imposed by several sources: any requirements from the heap
1423   // itself and the maximum page size we may run the VM with.
1424   size_t heap_alignment = GCConfig::arguments()->conservative_max_heap_alignment();
1425   _conservative_max_heap_alignment = MAX4(heap_alignment,
1426                                           os::vm_allocation_granularity(),
1427                                           os::max_page_size(),
1428                                           GCArguments::compute_heap_alignment());
1429 }
1430 
1431 jint Arguments::set_ergonomics_flags() {
1432   GCConfig::initialize();
1433 
1434   set_conservative_max_heap_alignment();
1435 
1436 #ifdef _LP64
1437   set_use_compressed_oops();
1438   set_use_compressed_klass_ptrs();
1439 
1440   // Also checks that certain machines are slower with compressed oops
1441   // in vm_version initialization code.
1442 #endif // _LP64
1443 
1444   return JNI_OK;
1445 }
1446 
1447 size_t Arguments::limit_heap_by_allocatable_memory(size_t limit) {
1448   size_t max_allocatable;
1449   size_t result = limit;
1450   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1451     // The AggressiveHeap check is a temporary workaround to avoid calling
1452     // GCarguments::heap_virtual_to_physical_ratio() before a GC has been
1453     // selected. This works because AggressiveHeap implies UseParallelGC
1454     // where we know the ratio will be 1. Once the AggressiveHeap option is
1455     // removed, this can be cleaned up.
1456     size_t heap_virtual_to_physical_ratio = (AggressiveHeap ? 1 : GCConfig::arguments()->heap_virtual_to_physical_ratio());
1457     size_t fraction = MaxVirtMemFraction * heap_virtual_to_physical_ratio;
1458     result = MIN2(result, max_allocatable / fraction);

2917   UNSUPPORTED_OPTION(ProfileInterpreter);
2918 #endif
2919 
2920   // Parse the CompilationMode flag
2921   if (!CompilationModeFlag::initialize()) {
2922     return JNI_ERR;
2923   }
2924 
2925   if (!check_vm_args_consistency()) {
2926     return JNI_ERR;
2927   }
2928 
2929   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
2930     return JNI_ERR;
2931   }
2932 
2933 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2934   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2935 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2936 































2937   return JNI_OK;
2938 }
2939 
2940 // Helper class for controlling the lifetime of JavaVMInitArgs
2941 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2942 // deleted on the destruction of the ScopedVMInitArgs object.
2943 class ScopedVMInitArgs : public StackObj {
2944  private:
2945   JavaVMInitArgs _args;
2946   char*          _container_name;
2947   bool           _is_set;
2948   char*          _vm_options_file_arg;
2949 
2950  public:
2951   ScopedVMInitArgs(const char *container_name) {
2952     _args.version = JNI_VERSION_1_2;
2953     _args.nOptions = 0;
2954     _args.options = nullptr;
2955     _args.ignoreUnrecognized = false;
2956     _container_name = (char *)container_name;

3626   }
3627 
3628   if (log_is_enabled(Info, arguments)) {
3629     LogStream st(Log(arguments)::info());
3630     Arguments::print_on(&st);
3631   }
3632 
3633   return JNI_OK;
3634 }
3635 
3636 jint Arguments::apply_ergo() {
3637   // Set flags based on ergonomics.
3638   jint result = set_ergonomics_flags();
3639   if (result != JNI_OK) return result;
3640 
3641   // Set heap size based on available physical memory
3642   set_heap_size();
3643 
3644   GCConfig::arguments()->initialize();
3645 




3646   CDSConfig::initialize();
3647 
3648   // Initialize Metaspace flags and alignments
3649   Metaspace::ergo_initialize();
3650 
3651   if (!StringDedup::ergo_initialize()) {
3652     return JNI_EINVAL;
3653   }
3654 
3655   // Set compiler flags after GC is selected and GC specific
3656   // flags (LoopStripMiningIter) are set.
3657   CompilerConfig::ergo_initialize();
3658 
3659   // Set bytecode rewriting flags
3660   set_bytecode_flags();
3661 
3662   // Set flags if aggressive optimization flags are enabled
3663   jint code = set_aggressive_opts_flags();
3664   if (code != JNI_OK) {
3665     return code;

1393 void Arguments::set_use_compressed_oops() {
1394 #ifdef _LP64
1395   // MaxHeapSize is not set up properly at this point, but
1396   // the only value that can override MaxHeapSize if we are
1397   // to use UseCompressedOops are InitialHeapSize and MinHeapSize.
1398   size_t max_heap_size = MAX3(MaxHeapSize, InitialHeapSize, MinHeapSize);
1399 
1400   if (max_heap_size <= max_heap_for_compressed_oops()) {
1401     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1402       FLAG_SET_ERGO(UseCompressedOops, true);
1403     }
1404   } else {
1405     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1406       warning("Max heap size too large for Compressed Oops");
1407       FLAG_SET_DEFAULT(UseCompressedOops, false);
1408     }
1409   }
1410 #endif // _LP64
1411 }
1412 







1413 void Arguments::set_conservative_max_heap_alignment() {
1414   // The conservative maximum required alignment for the heap is the maximum of
1415   // the alignments imposed by several sources: any requirements from the heap
1416   // itself and the maximum page size we may run the VM with.
1417   size_t heap_alignment = GCConfig::arguments()->conservative_max_heap_alignment();
1418   _conservative_max_heap_alignment = MAX4(heap_alignment,
1419                                           os::vm_allocation_granularity(),
1420                                           os::max_page_size(),
1421                                           GCArguments::compute_heap_alignment());
1422 }
1423 
1424 jint Arguments::set_ergonomics_flags() {
1425   GCConfig::initialize();
1426 
1427   set_conservative_max_heap_alignment();
1428 
1429 #ifdef _LP64
1430   set_use_compressed_oops();

1431 
1432   // Also checks that certain machines are slower with compressed oops
1433   // in vm_version initialization code.
1434 #endif // _LP64
1435 
1436   return JNI_OK;
1437 }
1438 
1439 size_t Arguments::limit_heap_by_allocatable_memory(size_t limit) {
1440   size_t max_allocatable;
1441   size_t result = limit;
1442   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1443     // The AggressiveHeap check is a temporary workaround to avoid calling
1444     // GCarguments::heap_virtual_to_physical_ratio() before a GC has been
1445     // selected. This works because AggressiveHeap implies UseParallelGC
1446     // where we know the ratio will be 1. Once the AggressiveHeap option is
1447     // removed, this can be cleaned up.
1448     size_t heap_virtual_to_physical_ratio = (AggressiveHeap ? 1 : GCConfig::arguments()->heap_virtual_to_physical_ratio());
1449     size_t fraction = MaxVirtMemFraction * heap_virtual_to_physical_ratio;
1450     result = MIN2(result, max_allocatable / fraction);

2909   UNSUPPORTED_OPTION(ProfileInterpreter);
2910 #endif
2911 
2912   // Parse the CompilationMode flag
2913   if (!CompilationModeFlag::initialize()) {
2914     return JNI_ERR;
2915   }
2916 
2917   if (!check_vm_args_consistency()) {
2918     return JNI_ERR;
2919   }
2920 
2921   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
2922     return JNI_ERR;
2923   }
2924 
2925 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2926   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2927 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2928 
2929   if (UseObjectMonitorTable && LockingMode != LM_LIGHTWEIGHT) {
2930     // ObjectMonitorTable requires lightweight locking.
2931     FLAG_SET_DEFAULT(LockingMode, LM_LIGHTWEIGHT);
2932   }
2933 
2934 #ifdef _LP64
2935   if (UseCompactObjectHeaders && FLAG_IS_CMDLINE(UseCompressedClassPointers) && !UseCompressedClassPointers) {
2936     warning("Compact object headers require compressed class pointers. Disabling compact object headers.");
2937     FLAG_SET_DEFAULT(UseCompactObjectHeaders, false);
2938   }
2939   if (UseCompactObjectHeaders && LockingMode != LM_LIGHTWEIGHT) {
2940     FLAG_SET_DEFAULT(LockingMode, LM_LIGHTWEIGHT);
2941   }
2942   if (UseCompactObjectHeaders && !UseObjectMonitorTable) {
2943     // If UseCompactObjectHeaders is on the command line, turn on UseObjectMonitorTable.
2944     if (FLAG_IS_CMDLINE(UseCompactObjectHeaders)) {
2945       FLAG_SET_DEFAULT(UseObjectMonitorTable, true);
2946 
2947     // If UseObjectMonitorTable is on the command line, turn off UseCompactObjectHeaders.
2948     } else if (FLAG_IS_CMDLINE(UseObjectMonitorTable)) {
2949       FLAG_SET_DEFAULT(UseCompactObjectHeaders, false);
2950     // If neither on the command line, the defaults are incompatible, but turn on UseObjectMonitorTable.
2951     } else {
2952       FLAG_SET_DEFAULT(UseObjectMonitorTable, true);
2953     }
2954   }
2955   if (UseCompactObjectHeaders && !UseCompressedClassPointers) {
2956     FLAG_SET_DEFAULT(UseCompressedClassPointers, true);
2957   }
2958 #endif
2959 
2960   return JNI_OK;
2961 }
2962 
2963 // Helper class for controlling the lifetime of JavaVMInitArgs
2964 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2965 // deleted on the destruction of the ScopedVMInitArgs object.
2966 class ScopedVMInitArgs : public StackObj {
2967  private:
2968   JavaVMInitArgs _args;
2969   char*          _container_name;
2970   bool           _is_set;
2971   char*          _vm_options_file_arg;
2972 
2973  public:
2974   ScopedVMInitArgs(const char *container_name) {
2975     _args.version = JNI_VERSION_1_2;
2976     _args.nOptions = 0;
2977     _args.options = nullptr;
2978     _args.ignoreUnrecognized = false;
2979     _container_name = (char *)container_name;

3649   }
3650 
3651   if (log_is_enabled(Info, arguments)) {
3652     LogStream st(Log(arguments)::info());
3653     Arguments::print_on(&st);
3654   }
3655 
3656   return JNI_OK;
3657 }
3658 
3659 jint Arguments::apply_ergo() {
3660   // Set flags based on ergonomics.
3661   jint result = set_ergonomics_flags();
3662   if (result != JNI_OK) return result;
3663 
3664   // Set heap size based on available physical memory
3665   set_heap_size();
3666 
3667   GCConfig::arguments()->initialize();
3668 
3669   if (UseCompressedClassPointers) {
3670     CompressedKlassPointers::pre_initialize();
3671   }
3672 
3673   CDSConfig::initialize();
3674 
3675   // Initialize Metaspace flags and alignments
3676   Metaspace::ergo_initialize();
3677 
3678   if (!StringDedup::ergo_initialize()) {
3679     return JNI_EINVAL;
3680   }
3681 
3682   // Set compiler flags after GC is selected and GC specific
3683   // flags (LoopStripMiningIter) are set.
3684   CompilerConfig::ergo_initialize();
3685 
3686   // Set bytecode rewriting flags
3687   set_bytecode_flags();
3688 
3689   // Set flags if aggressive optimization flags are enabled
3690   jint code = set_aggressive_opts_flags();
3691   if (code != JNI_OK) {
3692     return code;
< prev index next >