35 #include "runtime/arguments.hpp"
36 #include "runtime/globals_extension.hpp"
37 #include "runtime/java.hpp"
38 #include "services/management.hpp"
39 #include "services/memTracker.hpp"
40 #include "utilities/defaultStream.hpp"
41 #include "utilities/macros.hpp"
42 #include "utilities/taskqueue.hpp"
43 #ifdef TARGET_OS_FAMILY_linux
44 # include "os_linux.inline.hpp"
45 #endif
46 #ifdef TARGET_OS_FAMILY_solaris
47 # include "os_solaris.inline.hpp"
48 #endif
49 #ifdef TARGET_OS_FAMILY_windows
50 # include "os_windows.inline.hpp"
51 #endif
52 #ifdef TARGET_OS_FAMILY_bsd
53 # include "os_bsd.inline.hpp"
54 #endif
55 #if INCLUDE_ALL_GCS
56 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
57 #endif // INCLUDE_ALL_GCS
58
59 // Note: This is a special bug reporting site for the JVM
60 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
61 #define DEFAULT_JAVA_LAUNCHER "generic"
62
63 // Disable options not supported in this release, with a warning if they
64 // were explicitly requested on the command-line
65 #define UNSUPPORTED_OPTION(opt, description) \
66 do { \
67 if (opt) { \
68 if (FLAG_IS_CMDLINE(opt)) { \
69 warning(description " is disabled in this release."); \
70 } \
71 FLAG_SET_DEFAULT(opt, false); \
72 } \
73 } while(0)
74
75 #define UNSUPPORTED_GC_OPTION(gc) \
76 do { \
77 if (gc) { \
78 if (FLAG_IS_CMDLINE(gc)) { \
79 warning(#gc " is not supported in this VM. Using Serial GC."); \
80 } \
81 FLAG_SET_DEFAULT(gc, false); \
82 } \
83 } while(0)
84
85 char** Arguments::_jvm_flags_array = NULL;
86 int Arguments::_num_jvm_flags = 0;
87 char** Arguments::_jvm_args_array = NULL;
88 int Arguments::_num_jvm_args = 0;
89 char* Arguments::_java_command = NULL;
90 SystemProperty* Arguments::_system_properties = NULL;
91 const char* Arguments::_gc_log_filename = NULL;
92 bool Arguments::_has_profile = false;
93 uintx Arguments::_min_heap_size = 0;
94 Arguments::Mode Arguments::_mode = _mixed;
95 bool Arguments::_java_compiler = false;
96 bool Arguments::_xdebug_mode = false;
97 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
98 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
99 int Arguments::_sun_java_launcher_pid = -1;
100 bool Arguments::_created_by_gamma_launcher = false;
101
102 // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
103 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
104 bool Arguments::_UseOnStackReplacement = UseOnStackReplacement;
105 bool Arguments::_BackgroundCompilation = BackgroundCompilation;
106 bool Arguments::_ClipInlining = ClipInlining;
107
108 char* Arguments::SharedArchivePath = NULL;
109
110 AgentLibraryList Arguments::_libraryList;
111 AgentLibraryList Arguments::_agentList;
112
1374 }
1375 // It does not make sense to have big object alignment
1376 // since a space lost due to alignment will be greater
1377 // then a saved space from compressed oops.
1378 if ((int)ObjectAlignmentInBytes > 256) {
1379 jio_fprintf(defaultStream::error_stream(),
1380 "error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
1381 (int)ObjectAlignmentInBytes);
1382 return false;
1383 }
1384 // In case page size is very small.
1385 if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
1386 jio_fprintf(defaultStream::error_stream(),
1387 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
1388 (int)ObjectAlignmentInBytes, os::vm_page_size());
1389 return false;
1390 }
1391 return true;
1392 }
1393
1394 inline uintx max_heap_for_compressed_oops() {
1395 // Avoid sign flip.
1396 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1397 LP64_ONLY(return OopEncodingHeapMax - os::vm_page_size());
1398 NOT_LP64(ShouldNotReachHere(); return 0);
1399 }
1400
1401 bool Arguments::should_auto_select_low_pause_collector() {
1402 if (UseAutoGCSelectPolicy &&
1403 !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1404 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1405 if (PrintGCDetails) {
1406 // Cannot use gclog_or_tty yet.
1407 tty->print_cr("Automatic selection of the low pause collector"
1408 " based on pause goal of %d (ms)", MaxGCPauseMillis);
1409 }
1410 return true;
1411 }
1412 return false;
1413 }
1414
1415 void Arguments::set_use_compressed_oops() {
1416 #ifndef ZERO
1417 #ifdef _LP64
1458 warning("UseCompressedKlassPointers requires UseCompressedOops");
1459 }
1460 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1461 } else {
1462 // Turn on UseCompressedKlassPointers too
1463 if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) {
1464 FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true);
1465 }
1466 // Check the ClassMetaspaceSize to make sure we use compressed klass ptrs.
1467 if (UseCompressedKlassPointers) {
1468 if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) {
1469 warning("Class metaspace size is too large for UseCompressedKlassPointers");
1470 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1471 }
1472 }
1473 }
1474 #endif // _LP64
1475 #endif // !ZERO
1476 }
1477
1478 void Arguments::set_ergonomics_flags() {
1479
1480 if (os::is_server_class_machine()) {
1481 // If no other collector is requested explicitly,
1482 // let the VM select the collector based on
1483 // machine class and automatic selection policy.
1484 if (!UseSerialGC &&
1485 !UseConcMarkSweepGC &&
1486 !UseG1GC &&
1487 !UseParNewGC &&
1488 FLAG_IS_DEFAULT(UseParallelGC)) {
1489 if (should_auto_select_low_pause_collector()) {
1490 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1491 } else {
1492 FLAG_SET_ERGO(bool, UseParallelGC, true);
1493 }
1494 }
1495 // Shared spaces work fine with other GCs but causes bytecode rewriting
1496 // to be disabled, which hurts interpreter performance and decreases
1497 // server performance. On server class machines, keep the default
1498 // off unless it is asked for. Future work: either add bytecode rewriting
1499 // at link time, or rewrite bytecodes in non-shared methods.
1500 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1501 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1502 no_shared_spaces();
1503 }
1504 }
1505
1506 #ifndef ZERO
1507 #ifdef _LP64
1508 set_use_compressed_oops();
1509
1510 // set_use_compressed_klass_ptrs() must be called after calling
1511 // set_use_compressed_oops().
1512 set_use_compressed_klass_ptrs();
1513
1514 // Also checks that certain machines are slower with compressed oops
1515 // in vm_version initialization code.
1516 #endif // _LP64
1517 #endif // !ZERO
1518 }
1519
1520 void Arguments::set_parallel_gc_flags() {
1521 assert(UseParallelGC || UseParallelOldGC, "Error");
1522 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
1523 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
1524 FLAG_SET_DEFAULT(UseParallelOldGC, true);
1525 }
3499
3500 // Set object alignment values.
3501 set_object_alignment();
3502
3503 #if !INCLUDE_ALL_GCS
3504 force_serial_gc();
3505 #endif // INCLUDE_ALL_GCS
3506 #if !INCLUDE_CDS
3507 if (DumpSharedSpaces || RequireSharedSpaces) {
3508 jio_fprintf(defaultStream::error_stream(),
3509 "Shared spaces are not supported in this VM\n");
3510 return JNI_ERR;
3511 }
3512 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
3513 warning("Shared spaces are not supported in this VM");
3514 FLAG_SET_DEFAULT(UseSharedSpaces, false);
3515 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3516 }
3517 no_shared_spaces();
3518 #endif // INCLUDE_CDS
3519
3520 // Set flags based on ergonomics.
3521 set_ergonomics_flags();
3522
3523 set_shared_spaces_flags();
3524
3525 // Check the GC selections again.
3526 if (!check_gc_consistency()) {
3527 return JNI_EINVAL;
3528 }
3529
3530 if (TieredCompilation) {
3531 set_tiered_flags();
3532 } else {
3533 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
3534 if (CompilationPolicyChoice >= 2) {
3535 vm_exit_during_initialization(
3536 "Incompatible compilation policy selected", NULL);
3537 }
3538 }
|
35 #include "runtime/arguments.hpp"
36 #include "runtime/globals_extension.hpp"
37 #include "runtime/java.hpp"
38 #include "services/management.hpp"
39 #include "services/memTracker.hpp"
40 #include "utilities/defaultStream.hpp"
41 #include "utilities/macros.hpp"
42 #include "utilities/taskqueue.hpp"
43 #ifdef TARGET_OS_FAMILY_linux
44 # include "os_linux.inline.hpp"
45 #endif
46 #ifdef TARGET_OS_FAMILY_solaris
47 # include "os_solaris.inline.hpp"
48 #endif
49 #ifdef TARGET_OS_FAMILY_windows
50 # include "os_windows.inline.hpp"
51 #endif
52 #ifdef TARGET_OS_FAMILY_bsd
53 # include "os_bsd.inline.hpp"
54 #endif
55 #include "memory/genCollectedHeap.hpp"
56 #if INCLUDE_ALL_GCS
57 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
58 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
59 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
60 #endif // INCLUDE_ALL_GCS
61
62 // Note: This is a special bug reporting site for the JVM
63 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
64 #define DEFAULT_JAVA_LAUNCHER "generic"
65
66 // Disable options not supported in this release, with a warning if they
67 // were explicitly requested on the command-line
68 #define UNSUPPORTED_OPTION(opt, description) \
69 do { \
70 if (opt) { \
71 if (FLAG_IS_CMDLINE(opt)) { \
72 warning(description " is disabled in this release."); \
73 } \
74 FLAG_SET_DEFAULT(opt, false); \
75 } \
76 } while(0)
77
78 #define UNSUPPORTED_GC_OPTION(gc) \
79 do { \
80 if (gc) { \
81 if (FLAG_IS_CMDLINE(gc)) { \
82 warning(#gc " is not supported in this VM. Using Serial GC."); \
83 } \
84 FLAG_SET_DEFAULT(gc, false); \
85 } \
86 } while(0)
87
88 char** Arguments::_jvm_flags_array = NULL;
89 int Arguments::_num_jvm_flags = 0;
90 char** Arguments::_jvm_args_array = NULL;
91 int Arguments::_num_jvm_args = 0;
92 char* Arguments::_java_command = NULL;
93 SystemProperty* Arguments::_system_properties = NULL;
94 const char* Arguments::_gc_log_filename = NULL;
95 bool Arguments::_has_profile = false;
96 size_t Arguments::_largest_heap_alignment = 0;
97 uintx Arguments::_min_heap_size = 0;
98 Arguments::Mode Arguments::_mode = _mixed;
99 bool Arguments::_java_compiler = false;
100 bool Arguments::_xdebug_mode = false;
101 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
102 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
103 int Arguments::_sun_java_launcher_pid = -1;
104 bool Arguments::_created_by_gamma_launcher = false;
105
106 // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
107 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
108 bool Arguments::_UseOnStackReplacement = UseOnStackReplacement;
109 bool Arguments::_BackgroundCompilation = BackgroundCompilation;
110 bool Arguments::_ClipInlining = ClipInlining;
111
112 char* Arguments::SharedArchivePath = NULL;
113
114 AgentLibraryList Arguments::_libraryList;
115 AgentLibraryList Arguments::_agentList;
116
1378 }
1379 // It does not make sense to have big object alignment
1380 // since a space lost due to alignment will be greater
1381 // then a saved space from compressed oops.
1382 if ((int)ObjectAlignmentInBytes > 256) {
1383 jio_fprintf(defaultStream::error_stream(),
1384 "error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
1385 (int)ObjectAlignmentInBytes);
1386 return false;
1387 }
1388 // In case page size is very small.
1389 if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
1390 jio_fprintf(defaultStream::error_stream(),
1391 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
1392 (int)ObjectAlignmentInBytes, os::vm_page_size());
1393 return false;
1394 }
1395 return true;
1396 }
1397
1398 uintx Arguments::max_heap_for_compressed_oops() {
1399 // Avoid sign flip.
1400 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1401 size_t aligned_null_page_size = align_size_up_(os::vm_page_size(), Arguments::largest_heap_alignment());
1402
1403 LP64_ONLY(return OopEncodingHeapMax - aligned_null_page_size);
1404 NOT_LP64(ShouldNotReachHere(); return 0);
1405 }
1406
1407 bool Arguments::should_auto_select_low_pause_collector() {
1408 if (UseAutoGCSelectPolicy &&
1409 !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1410 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1411 if (PrintGCDetails) {
1412 // Cannot use gclog_or_tty yet.
1413 tty->print_cr("Automatic selection of the low pause collector"
1414 " based on pause goal of %d (ms)", MaxGCPauseMillis);
1415 }
1416 return true;
1417 }
1418 return false;
1419 }
1420
1421 void Arguments::set_use_compressed_oops() {
1422 #ifndef ZERO
1423 #ifdef _LP64
1464 warning("UseCompressedKlassPointers requires UseCompressedOops");
1465 }
1466 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1467 } else {
1468 // Turn on UseCompressedKlassPointers too
1469 if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) {
1470 FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true);
1471 }
1472 // Check the ClassMetaspaceSize to make sure we use compressed klass ptrs.
1473 if (UseCompressedKlassPointers) {
1474 if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) {
1475 warning("Class metaspace size is too large for UseCompressedKlassPointers");
1476 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1477 }
1478 }
1479 }
1480 #endif // _LP64
1481 #endif // !ZERO
1482 }
1483
1484 void Arguments::set_largest_max_heap_alignment() {
1485 size_t gc_alignment;
1486 #if INCLUDE_ALL_GCS
1487 if (UseParallelGC) {
1488 gc_alignment = ParallelScavengeHeap::max_heap_alignment();
1489 } else if (UseG1GC) {
1490 gc_alignment = G1CollectedHeap::max_heap_alignment();
1491 } else {
1492 #endif // INCLUDE_ALL_GCS
1493 gc_alignment = GenCollectedHeap::max_heap_alignment();
1494 #if INCLUDE_ALL_GCS
1495 }
1496 #endif // INCLUDE_ALL_GCS
1497 _largest_heap_alignment = MAX3(gc_alignment, os::max_page_size(),
1498 CollectorPolicy::compute_largest_heap_alignment());
1499 }
1500
1501 void Arguments::set_ergonomics_flags() {
1502
1503 if (os::is_server_class_machine()) {
1504 // If no other collector is requested explicitly,
1505 // let the VM select the collector based on
1506 // machine class and automatic selection policy.
1507 if (!UseSerialGC &&
1508 !UseConcMarkSweepGC &&
1509 !UseG1GC &&
1510 !UseParNewGC &&
1511 FLAG_IS_DEFAULT(UseParallelGC)) {
1512 if (should_auto_select_low_pause_collector()) {
1513 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1514 } else {
1515 FLAG_SET_ERGO(bool, UseParallelGC, true);
1516 }
1517 }
1518 // Shared spaces work fine with other GCs but causes bytecode rewriting
1519 // to be disabled, which hurts interpreter performance and decreases
1520 // server performance. On server class machines, keep the default
1521 // off unless it is asked for. Future work: either add bytecode rewriting
1522 // at link time, or rewrite bytecodes in non-shared methods.
1523 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1524 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1525 no_shared_spaces();
1526 }
1527 }
1528
1529 set_largest_max_heap_alignment();
1530
1531 #ifndef ZERO
1532 #ifdef _LP64
1533 set_use_compressed_oops();
1534
1535 // set_use_compressed_klass_ptrs() must be called after calling
1536 // set_use_compressed_oops().
1537 set_use_compressed_klass_ptrs();
1538
1539 // Also checks that certain machines are slower with compressed oops
1540 // in vm_version initialization code.
1541 #endif // _LP64
1542 #endif // !ZERO
1543 }
1544
1545 void Arguments::set_parallel_gc_flags() {
1546 assert(UseParallelGC || UseParallelOldGC, "Error");
1547 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
1548 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
1549 FLAG_SET_DEFAULT(UseParallelOldGC, true);
1550 }
3524
3525 // Set object alignment values.
3526 set_object_alignment();
3527
3528 #if !INCLUDE_ALL_GCS
3529 force_serial_gc();
3530 #endif // INCLUDE_ALL_GCS
3531 #if !INCLUDE_CDS
3532 if (DumpSharedSpaces || RequireSharedSpaces) {
3533 jio_fprintf(defaultStream::error_stream(),
3534 "Shared spaces are not supported in this VM\n");
3535 return JNI_ERR;
3536 }
3537 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
3538 warning("Shared spaces are not supported in this VM");
3539 FLAG_SET_DEFAULT(UseSharedSpaces, false);
3540 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3541 }
3542 no_shared_spaces();
3543 #endif // INCLUDE_CDS
3544
3545 // We need to initialize large page support here because ergonomics takes some
3546 // decisions depending on large page support and the calculated large page size.
3547 // Ergonomics may turn off large page support off later again.
3548 os::large_page_init();
3549
3550 // Set flags based on ergonomics.
3551 set_ergonomics_flags();
3552
3553 set_shared_spaces_flags();
3554
3555 // Check the GC selections again.
3556 if (!check_gc_consistency()) {
3557 return JNI_EINVAL;
3558 }
3559
3560 if (TieredCompilation) {
3561 set_tiered_flags();
3562 } else {
3563 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
3564 if (CompilationPolicyChoice >= 2) {
3565 vm_exit_during_initialization(
3566 "Incompatible compilation policy selected", NULL);
3567 }
3568 }
|