Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/arguments.cpp @ 20403:8ec8971f511a
8057531: refactor gc argument processing code slightly
Reviewed-by: mgerdin, tschatzl, jmasa
author | jcoomes |
---|---|
date | Thu, 04 Sep 2014 16:53:27 -0700 |
parents | f5164941749c |
children | 76af788b6c16 |
comparison
equal
deleted
inserted
replaced
20402:1202792c966e | 20403:8ec8971f511a |
---|---|
1530 (size_t)os::vm_allocation_granularity(), | 1530 (size_t)os::vm_allocation_granularity(), |
1531 os::max_page_size(), | 1531 os::max_page_size(), |
1532 CollectorPolicy::compute_heap_alignment()); | 1532 CollectorPolicy::compute_heap_alignment()); |
1533 } | 1533 } |
1534 | 1534 |
1535 void Arguments::select_gc_ergonomically() { | |
1536 if (os::is_server_class_machine()) { | |
1537 if (should_auto_select_low_pause_collector()) { | |
1538 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true); | |
1539 } else { | |
1540 FLAG_SET_ERGO(bool, UseParallelGC, true); | |
1541 } | |
1542 } | |
1543 } | |
1544 | |
1545 void Arguments::select_gc() { | |
1546 if (!gc_selected()) { | |
1547 select_gc_ergonomically(); | |
1548 } | |
1549 } | |
1550 | |
1535 void Arguments::set_ergonomics_flags() { | 1551 void Arguments::set_ergonomics_flags() { |
1536 | 1552 select_gc(); |
1537 if (os::is_server_class_machine()) { | 1553 |
1538 // If no other collector is requested explicitly, | |
1539 // let the VM select the collector based on | |
1540 // machine class and automatic selection policy. | |
1541 if (!UseSerialGC && | |
1542 !UseConcMarkSweepGC && | |
1543 !UseG1GC && | |
1544 !UseParNewGC && | |
1545 FLAG_IS_DEFAULT(UseParallelGC)) { | |
1546 if (should_auto_select_low_pause_collector()) { | |
1547 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true); | |
1548 } else { | |
1549 FLAG_SET_ERGO(bool, UseParallelGC, true); | |
1550 } | |
1551 } | |
1552 } | |
1553 #ifdef COMPILER2 | 1554 #ifdef COMPILER2 |
1554 // Shared spaces work fine with other GCs but causes bytecode rewriting | 1555 // Shared spaces work fine with other GCs but causes bytecode rewriting |
1555 // to be disabled, which hurts interpreter performance and decreases | 1556 // to be disabled, which hurts interpreter performance and decreases |
1556 // server performance. When -server is specified, keep the default off | 1557 // server performance. When -server is specified, keep the default off |
1557 // unless it is asked for. Future work: either add bytecode rewriting | 1558 // unless it is asked for. Future work: either add bytecode rewriting |
1667 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); | 1668 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); |
1668 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads); | 1669 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads); |
1669 } | 1670 } |
1670 } | 1671 } |
1671 | 1672 |
1673 #if !INCLUDE_ALL_GCS | |
1674 #ifdef ASSERT | |
1675 static bool verify_serial_gc_flags() { | |
1676 return (UseSerialGC && | |
1677 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC || | |
1678 UseParallelGC || UseParallelOldGC)); | |
1679 } | |
1680 #endif // ASSERT | |
1681 #endif // INCLUDE_ALL_GCS | |
1682 | |
1683 void Arguments::set_gc_specific_flags() { | |
1684 #if INCLUDE_ALL_GCS | |
1685 // Set per-collector flags | |
1686 if (UseParallelGC || UseParallelOldGC) { | |
1687 set_parallel_gc_flags(); | |
1688 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below | |
1689 set_cms_and_parnew_gc_flags(); | |
1690 } else if (UseParNewGC) { // Skipped if CMS is set above | |
1691 set_parnew_gc_flags(); | |
1692 } else if (UseG1GC) { | |
1693 set_g1_gc_flags(); | |
1694 } | |
1695 check_deprecated_gcs(); | |
1696 check_deprecated_gc_flags(); | |
1697 if (AssumeMP && !UseSerialGC) { | |
1698 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { | |
1699 warning("If the number of processors is expected to increase from one, then" | |
1700 " you should configure the number of parallel GC threads appropriately" | |
1701 " using -XX:ParallelGCThreads=N"); | |
1702 } | |
1703 } | |
1704 if (MinHeapFreeRatio == 100) { | |
1705 // Keeping the heap 100% free is hard ;-) so limit it to 99%. | |
1706 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); | |
1707 } | |
1708 #else // INCLUDE_ALL_GCS | |
1709 assert(verify_serial_gc_flags(), "SerialGC unset"); | |
1710 #endif // INCLUDE_ALL_GCS | |
1711 } | |
1712 | |
1672 julong Arguments::limit_by_allocatable_memory(julong limit) { | 1713 julong Arguments::limit_by_allocatable_memory(julong limit) { |
1673 julong max_allocatable; | 1714 julong max_allocatable; |
1674 julong result = limit; | 1715 julong result = limit; |
1675 if (os::has_allocatable_memory_limit(&max_allocatable)) { | 1716 if (os::has_allocatable_memory_limit(&max_allocatable)) { |
1676 result = MIN2(result, max_allocatable / MaxVirtMemFraction); | 1717 result = MIN2(result, max_allocatable / MaxVirtMemFraction); |
1889 jio_fprintf(defaultStream::error_stream(), | 1930 jio_fprintf(defaultStream::error_stream(), |
1890 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", | 1931 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", |
1891 name, value); | 1932 name, value); |
1892 return false; | 1933 return false; |
1893 } | 1934 } |
1894 | |
1895 #if !INCLUDE_ALL_GCS | |
1896 #ifdef ASSERT | |
1897 static bool verify_serial_gc_flags() { | |
1898 return (UseSerialGC && | |
1899 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC || | |
1900 UseParallelGC || UseParallelOldGC)); | |
1901 } | |
1902 #endif // ASSERT | |
1903 #endif // INCLUDE_ALL_GCS | |
1904 | 1935 |
1905 // check if do gclog rotation | 1936 // check if do gclog rotation |
1906 // +UseGCLogFileRotation is a must, | 1937 // +UseGCLogFileRotation is a must, |
1907 // no gc log rotation when log file not supplied or | 1938 // no gc log rotation when log file not supplied or |
1908 // NumberOfGCLogFiles is 0 | 1939 // NumberOfGCLogFiles is 0 |
3782 | 3813 |
3783 | 3814 |
3784 // Set heap size based on available physical memory | 3815 // Set heap size based on available physical memory |
3785 set_heap_size(); | 3816 set_heap_size(); |
3786 | 3817 |
3787 #if INCLUDE_ALL_GCS | 3818 set_gc_specific_flags(); |
3788 // Set per-collector flags | |
3789 if (UseParallelGC || UseParallelOldGC) { | |
3790 set_parallel_gc_flags(); | |
3791 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below | |
3792 set_cms_and_parnew_gc_flags(); | |
3793 } else if (UseParNewGC) { // Skipped if CMS is set above | |
3794 set_parnew_gc_flags(); | |
3795 } else if (UseG1GC) { | |
3796 set_g1_gc_flags(); | |
3797 } | |
3798 check_deprecated_gcs(); | |
3799 check_deprecated_gc_flags(); | |
3800 if (AssumeMP && !UseSerialGC) { | |
3801 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { | |
3802 warning("If the number of processors is expected to increase from one, then" | |
3803 " you should configure the number of parallel GC threads appropriately" | |
3804 " using -XX:ParallelGCThreads=N"); | |
3805 } | |
3806 } | |
3807 if (MinHeapFreeRatio == 100) { | |
3808 // Keeping the heap 100% free is hard ;-) so limit it to 99%. | |
3809 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); | |
3810 } | |
3811 #else // INCLUDE_ALL_GCS | |
3812 assert(verify_serial_gc_flags(), "SerialGC unset"); | |
3813 #endif // INCLUDE_ALL_GCS | |
3814 | 3819 |
3815 // Initialize Metaspace flags and alignments. | 3820 // Initialize Metaspace flags and alignments. |
3816 Metaspace::ergo_initialize(); | 3821 Metaspace::ergo_initialize(); |
3817 | 3822 |
3818 // Set bytecode rewriting flags | 3823 // Set bytecode rewriting flags |