Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8179026

Remove explicit code cache options processing

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 10
    • 9, 10
    • hotspot
    • b36

      XX:CodeCacheExpansionSize, XX:NonNMethodCodeHeapSize, XX:ProfiledCodeHeapSize and XX:NonProfiledCodeHeapSize options explictly processed in the hotspot/src/share/vm/runtime/arguments.cpp file:
          } else if (match_option(option, "-XX:CodeCacheExpansionSize=", &tail)) {
            julong long_CodeCacheExpansionSize = 0;
            ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size());
            if (errcode != arg_in_range) {
              jio_fprintf(defaultStream::error_stream(),
                         "Invalid argument: %s. Must be at least %luK.\n", option->optionString,
                         os::vm_page_size()/K);
              return JNI_EINVAL;
            }
            if (FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize) != Flag::SUCCESS) {
              return JNI_EINVAL;
            }
      ...
            // -XX:NonNMethodCodeHeapSize=
          } else if (match_option(option, "-XX:NonNMethodCodeHeapSize=", &tail)) {
            julong long_NonNMethodCodeHeapSize = 0;

            ArgsRange errcode = parse_memory_size(tail, &long_NonNMethodCodeHeapSize, 1);
            if (errcode != arg_in_range) {
              jio_fprintf(defaultStream::error_stream(),
                          "Invalid maximum non-nmethod code heap size: %s.\n", option->optionString);
              return JNI_EINVAL;
            }
            if (FLAG_SET_CMDLINE(uintx, NonNMethodCodeHeapSize, (uintx)long_NonNMethodCodeHeapSize) != Flag::SUCCESS) {
              return JNI_EINVAL;
            }
            // -XX:ProfiledCodeHeapSize=
          } else if (match_option(option, "-XX:ProfiledCodeHeapSize=", &tail)) {
            julong long_ProfiledCodeHeapSize = 0;

            ArgsRange errcode = parse_memory_size(tail, &long_ProfiledCodeHeapSize, 1);
            if (errcode != arg_in_range) {
              jio_fprintf(defaultStream::error_stream(),
                          "Invalid maximum profiled code heap size: %s.\n", option->optionString);
              return JNI_EINVAL;
            }
            if (FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize) != Flag::SUCCESS) {
              return JNI_EINVAL;
            }
            // -XX:NonProfiledCodeHeapSizee=
          } else if (match_option(option, "-XX:NonProfiledCodeHeapSize=", &tail)) {
            julong long_NonProfiledCodeHeapSize = 0;
            ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1);
            if (errcode != arg_in_range) {
              jio_fprintf(defaultStream::error_stream(),
                          "Invalid maximum non-profiled code heap size: %s.\n", option->optionString);
              return JNI_EINVAL;
            }
            if (FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize) != Flag::SUCCESS) {
              return JNI_EINVAL;
            }

      It seems that explicit processing can be deleted, because generic option processing can process numeric and memory values(10m) and JEP-245 allow to specify valid ranges(e.g. min value).
      Currently min value for these options is specified to 0(in hotspot/src/src/share/vm/runtime/globals.hpp file), but it can be adjusted according to the values in processing code in arguments.cpp file.

      Removing explicit processing of these options makes very big if statement more simple.

            thartmann Tobias Hartmann
            ddmitriev Dmitry Dmitriev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: