src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7164841 Sdiff src/share/vm/runtime

src/share/vm/runtime/arguments.cpp

Print this page
7164841: Improvements to the GC log file rotation


1833 #if !INCLUDE_ALL_GCS
1834 #ifdef ASSERT
1835 static bool verify_serial_gc_flags() {
1836   return (UseSerialGC &&
1837         !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1838           UseParallelGC || UseParallelOldGC));
1839 }
1840 #endif // ASSERT
1841 #endif // INCLUDE_ALL_GCS
1842 
1843 // check if do gclog rotation
1844 // +UseGCLogFileRotation is a must,
1845 // no gc log rotation when log file not supplied or
1846 // NumberOfGCLogFiles is 0, or GCLogFileSize is 0
1847 void check_gclog_consistency() {
1848   if (UseGCLogFileRotation) {
1849     if ((Arguments::gc_log_filename() == NULL) ||
1850         (NumberOfGCLogFiles == 0)  ||
1851         (GCLogFileSize == 0)) {
1852       jio_fprintf(defaultStream::output_stream(),
1853                   "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>\n"
1854                   "where num_of_file > 0 and num_of_size > 0\n"
1855                   "GC log rotation is turned off\n");
1856       UseGCLogFileRotation = false;
1857     }
1858   }
1859 
1860   if (UseGCLogFileRotation && GCLogFileSize < 8*K) {
1861         FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
1862         jio_fprintf(defaultStream::output_stream(),
1863                     "GCLogFileSize changed to minimum 8K\n");
1864   }
1865 }
1866 


































1867 // Check consistency of GC selection
1868 bool Arguments::check_gc_consistency() {
1869   check_gclog_consistency();
1870   bool status = true;
1871   // Ensure that the user has not selected conflicting sets
1872   // of collectors. [Note: this check is merely a user convenience;
1873   // collectors over-ride each other so that only a non-conflicting
1874   // set is selected; however what the user gets is not what they
1875   // may have expected from the combination they asked for. It's
1876   // better to reduce user confusion by not allowing them to
1877   // select conflicting combinations.
1878   uint i = 0;
1879   if (UseSerialGC)                       i++;
1880   if (UseConcMarkSweepGC || UseParNewGC) i++;
1881   if (UseParallelGC || UseParallelOldGC) i++;
1882   if (UseG1GC)                           i++;
1883   if (i > 1) {
1884     jio_fprintf(defaultStream::error_stream(),
1885                 "Conflicting collector combinations in option list; "
1886                 "please refer to the release notes for the combinations "


2800         FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
2801         FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false);
2802       } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
2803         return JNI_EINVAL;
2804       }
2805     // -Xdebug
2806     } else if (match_option(option, "-Xdebug", &tail)) {
2807       // note this flag has been used, then ignore
2808       set_xdebug_mode(true);
2809     // -Xnoagent
2810     } else if (match_option(option, "-Xnoagent", &tail)) {
2811       // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
2812     } else if (match_option(option, "-Xboundthreads", &tail)) {
2813       // Bind user level threads to kernel threads (Solaris only)
2814       FLAG_SET_CMDLINE(bool, UseBoundThreads, true);
2815     } else if (match_option(option, "-Xloggc:", &tail)) {
2816       // Redirect GC output to the file. -Xloggc:<filename>
2817       // ostream_init_log(), when called will use this filename
2818       // to initialize a fileStream.
2819       _gc_log_filename = strdup(tail);






2820       FLAG_SET_CMDLINE(bool, PrintGC, true);
2821       FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true);
2822 
2823     // JNI hooks
2824     } else if (match_option(option, "-Xcheck", &tail)) {
2825       if (!strcmp(tail, ":jni")) {
2826 #if !INCLUDE_JNI_CHECK
2827         warning("JNI CHECKING is not supported in this VM");
2828 #else
2829         CheckJNICalls = true;
2830 #endif // INCLUDE_JNI_CHECK
2831       } else if (is_bad_option(option, args->ignoreUnrecognized,
2832                                      "check")) {
2833         return JNI_EINVAL;
2834       }
2835     } else if (match_option(option, "vfprintf", &tail)) {
2836       _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
2837     } else if (match_option(option, "exit", &tail)) {
2838       _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
2839     } else if (match_option(option, "abort", &tail)) {




1833 #if !INCLUDE_ALL_GCS
1834 #ifdef ASSERT
1835 static bool verify_serial_gc_flags() {
1836   return (UseSerialGC &&
1837         !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1838           UseParallelGC || UseParallelOldGC));
1839 }
1840 #endif // ASSERT
1841 #endif // INCLUDE_ALL_GCS
1842 
1843 // check if do gclog rotation
1844 // +UseGCLogFileRotation is a must,
1845 // no gc log rotation when log file not supplied or
1846 // NumberOfGCLogFiles is 0, or GCLogFileSize is 0
1847 void check_gclog_consistency() {
1848   if (UseGCLogFileRotation) {
1849     if ((Arguments::gc_log_filename() == NULL) ||
1850         (NumberOfGCLogFiles == 0)  ||
1851         (GCLogFileSize == 0)) {
1852       jio_fprintf(defaultStream::output_stream(),
1853                   "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>[k|K|m|M|g|G]\n"
1854                   "where num_of_file > 0 and num_of_size > 0\n"
1855                   "GC log rotation is turned off\n");
1856       UseGCLogFileRotation = false;
1857     }
1858   }
1859 
1860   if (UseGCLogFileRotation && GCLogFileSize < 8*K) {
1861         FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
1862         jio_fprintf(defaultStream::output_stream(),
1863                     "GCLogFileSize changed to minimum 8K\n");
1864   }
1865 }
1866 
1867 // check if a file name valid
1868 // A valid file name only contains "[A-Z][a-z][0-9].-_%[p|t]"
1869 // %p and %t only allowed once.
1870 bool is_filename_valid(const char *file_name) {
1871   const char* p = file_name;
1872   int count_p = 0;
1873   int count_t = 0;
1874   while (*p != '\0') {
1875     if ((*p >= '0' && *p <= '9') ||
1876         (*p >= 'A' && *p <= 'Z') ||
1877         (*p >= 'a' && *p <= 'z') ||
1878          *p == '-'               ||
1879          *p == '_'               ||
1880          *p == '.') {
1881        p++;
1882        continue;
1883     }
1884     if (*p == '%') {
1885       if(*(p + 1) == 'p') {
1886         p += 2;
1887         count_p ++;
1888         continue;
1889       }
1890       if (*(p + 1) == 't') {
1891         p += 2;
1892         count_t ++;
1893         continue;
1894       }
1895     }
1896     return false;
1897   }
1898   return count_p < 2 && count_t < 2;
1899 }
1900 
1901 // Check consistency of GC selection
1902 bool Arguments::check_gc_consistency() {
1903   check_gclog_consistency();
1904   bool status = true;
1905   // Ensure that the user has not selected conflicting sets
1906   // of collectors. [Note: this check is merely a user convenience;
1907   // collectors over-ride each other so that only a non-conflicting
1908   // set is selected; however what the user gets is not what they
1909   // may have expected from the combination they asked for. It's
1910   // better to reduce user confusion by not allowing them to
1911   // select conflicting combinations.
1912   uint i = 0;
1913   if (UseSerialGC)                       i++;
1914   if (UseConcMarkSweepGC || UseParNewGC) i++;
1915   if (UseParallelGC || UseParallelOldGC) i++;
1916   if (UseG1GC)                           i++;
1917   if (i > 1) {
1918     jio_fprintf(defaultStream::error_stream(),
1919                 "Conflicting collector combinations in option list; "
1920                 "please refer to the release notes for the combinations "


2834         FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
2835         FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false);
2836       } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
2837         return JNI_EINVAL;
2838       }
2839     // -Xdebug
2840     } else if (match_option(option, "-Xdebug", &tail)) {
2841       // note this flag has been used, then ignore
2842       set_xdebug_mode(true);
2843     // -Xnoagent
2844     } else if (match_option(option, "-Xnoagent", &tail)) {
2845       // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
2846     } else if (match_option(option, "-Xboundthreads", &tail)) {
2847       // Bind user level threads to kernel threads (Solaris only)
2848       FLAG_SET_CMDLINE(bool, UseBoundThreads, true);
2849     } else if (match_option(option, "-Xloggc:", &tail)) {
2850       // Redirect GC output to the file. -Xloggc:<filename>
2851       // ostream_init_log(), when called will use this filename
2852       // to initialize a fileStream.
2853       _gc_log_filename = strdup(tail);
2854      if (!is_filename_valid(_gc_log_filename)) {
2855        jio_fprintf(defaultStream::output_stream(),
2856                   "Filename can only cantain [A-Z][a-z][0-9]-_.%%[p|t]\n"
2857                   "%%p and %%t can only show up once\n" );
2858         return JNI_EINVAL;
2859       }
2860       FLAG_SET_CMDLINE(bool, PrintGC, true);
2861       FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true);
2862 
2863     // JNI hooks
2864     } else if (match_option(option, "-Xcheck", &tail)) {
2865       if (!strcmp(tail, ":jni")) {
2866 #if !INCLUDE_JNI_CHECK
2867         warning("JNI CHECKING is not supported in this VM");
2868 #else
2869         CheckJNICalls = true;
2870 #endif // INCLUDE_JNI_CHECK
2871       } else if (is_bad_option(option, args->ignoreUnrecognized,
2872                                      "check")) {
2873         return JNI_EINVAL;
2874       }
2875     } else if (match_option(option, "vfprintf", &tail)) {
2876       _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
2877     } else if (match_option(option, "exit", &tail)) {
2878       _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
2879     } else if (match_option(option, "abort", &tail)) {


src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File