diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index 81f2ca33944..43c76e435df 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -375,7 +375,9 @@ char * J9::Options::_externalOptionStrings[J9::ExternalOptions::TR_NumExternalOp "-XX:codecachetotalMaxRAMPercentage=", // = 67 "-XX:+JITServerAOTCacheDelayMethodRelocation", // = 68 "-XX:-JITServerAOTCacheDelayMethodRelocation", // = 69 - // TR_NumExternalOptions = 70 + "-XX:+IProfileDuringStartupPhase", // = 70 + "-XX:-IProfileDuringStartupPhase", // = 71 + // TR_NumExternalOptions = 72 }; //************************************************************************ @@ -3142,25 +3144,38 @@ bool J9::Options::feLatePostProcess(void * base, TR::OptionSet * optionSet) } else // do AOT { - if (!self()->getOption(TR_DisablePersistIProfile)) + // Turn off Iprofiler for the warm runs, but not if we cache only bootstrap classes + // This is because we may be missing IProfiler information for non-bootstrap classes + // that could not be stored in SCC + if (!self()->getOption(TR_DisablePersistIProfile) && + J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES)) { - // Turn off Iprofiler for the warm runs, but not if we cache only bootstrap classes - // This is because we may be missing IProfiler information for non-bootstrap classes - // that could not be stored in SCC - if (J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES)) + TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig); + if (compInfo->isWarmSCC() == TR_yes) { - TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig); - static char * dnipdsp = feGetEnv("TR_DisableNoIProfilerDuringStartupPhase"); - if (compInfo->isWarmSCC() == TR_yes && !dnipdsp) - { - self()->setOption(TR_NoIProfilerDuringStartupPhase); - } + self()->setOption(TR_NoIProfilerDuringStartupPhase); } } } } #endif + // The use of -XX:[+/-]IProfileDuringStartupPhase sets if we always/never IProfile + // during the startup phase + { + // The FIND_ARG_IN_VMARGS macro expect the J9JavaVM to be in the `vm` variable, instead of `javaVM` + // The method uses the `vm` variable for the TR_J9VMBase + J9JavaVM * vm = javaVM; + const char *xxIProfileDuringStartupPhase = J9::Options::_externalOptionStrings[J9::ExternalOptions::XXplusIProfileDuringStartupPhase]; + const char *xxDisableIProfileDuringStartupPhase = J9::Options::_externalOptionStrings[J9::ExternalOptions::XXminusIProfileDuringStartupPhase]; + int32_t xxIProfileDuringStartupPhaseArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxIProfileDuringStartupPhase, 0); + int32_t xxDisableIProfileDuringStartupPhaseArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableIProfileDuringStartupPhase, 0); + if (xxIProfileDuringStartupPhaseArgIndex > xxDisableIProfileDuringStartupPhaseArgIndex) + self()->setOption(TR_NoIProfilerDuringStartupPhase, false); // Override -Xjit:noIProfilerDuringStartupPhase + else if (xxDisableIProfileDuringStartupPhaseArgIndex >= 0) + self()->setOption(TR_NoIProfilerDuringStartupPhase); + } + // Divide by 0 checks if (TR::Options::_LoopyMethodDivisionFactor == 0) TR::Options::_LoopyMethodDivisionFactor = 16; // Reset it back to the default value diff --git a/runtime/compiler/control/J9Options.hpp b/runtime/compiler/control/J9Options.hpp index 234034eb0e5..ca7ac0f8216 100644 --- a/runtime/compiler/control/J9Options.hpp +++ b/runtime/compiler/control/J9Options.hpp @@ -123,7 +123,9 @@ enum ExternalOptions XXcodecachetotalMaxRAMPercentage = 67, XXplusJITServerAOTCacheDelayMethodRelocation = 68, XXminusJITServerAOTCacheDelayMethodRelocation = 69, - TR_NumExternalOptions = 70 + XXplusIProfileDuringStartupPhase = 70, + XXminusIProfileDuringStartupPhase = 71, + TR_NumExternalOptions = 72 }; class OMR_EXTENSIBLE Options : public OMR::OptionsConnector diff --git a/runtime/compiler/control/OptionsPostRestore.cpp b/runtime/compiler/control/OptionsPostRestore.cpp index 7e12b6fd3d4..68bee60bfcd 100644 --- a/runtime/compiler/control/OptionsPostRestore.cpp +++ b/runtime/compiler/control/OptionsPostRestore.cpp @@ -78,7 +78,9 @@ J9::OptionsPostRestore::OptionsPostRestore(J9VMThread *vmThread, J9JITConfig *ji _argIndexUseJITServer(-1), _argIndexDisableUseJITServer(-1), _argIndexJITServerAddress(-1), - _argIndexJITServerAOTCacheName(-1) + _argIndexJITServerAOTCacheName(-1), + _argIndexIProfileDuringStartupPhase(-1), + _argIndexDisableIProfileDuringStartupPhase(-1) { J9JavaVM *vm = jitConfig->javaVM; if (vm->sharedClassConfig) @@ -276,6 +278,18 @@ J9::OptionsPostRestore::iterateOverExternalOptions() } break; + case J9::ExternalOptions::XXplusIProfileDuringStartupPhase: + { + _argIndexIProfileDuringStartupPhase = FIND_ARG_IN_RESTORE_ARGS(EXACT_MATCH, optString, 0); + } + break; + + case J9::ExternalOptions::XXminusIProfileDuringStartupPhase: + { + _argIndexDisableIProfileDuringStartupPhase = FIND_ARG_IN_RESTORE_ARGS(EXACT_MATCH, optString, 0); + } + break; + default: TR_ASSERT_FATAL(false, "Option %s not addressed post restore\n", TR::Options::_externalOptionStrings[option]); } @@ -713,6 +727,26 @@ J9::OptionsPostRestore::postProcessInternalCompilerOptions() if (TR::Options::getCmdLineOptions()->getOption(TR_DisableAsyncCompilation)) TR::Options::getCmdLineOptions()->setOption(TR_DisableAsyncCompilation, false); } + + // Set/Reset TR_NoIProfilerDuringStartupPhase if -XX:[+/-]IProfileDuringStartupPhase is used + // Otherwise use the default logic to determine if TR_NoIProfilerDuringStartupPhase is set + if ((_argIndexIProfileDuringStartupPhase >= 0) || (_argIndexDisableIProfileDuringStartupPhase >= 0)) + { + bool IProfileDuringStartupPhase = (_argIndexIProfileDuringStartupPhase > _argIndexDisableIProfileDuringStartupPhase); + TR::Options::getCmdLineOptions()->setOption(TR_NoIProfilerDuringStartupPhase, !IProfileDuringStartupPhase); + } + else if (!disableAOT) + { + if (!TR::Options::getCmdLineOptions()->getOption(TR_DisablePersistIProfile) && + J9_ARE_ALL_BITS_SET(vm->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES)) + { + if (_compInfo->isWarmSCC() == TR_yes) + { + TR::Options::getCmdLineOptions()->setOption(TR_NoIProfilerDuringStartupPhase); + } + } + } + } void diff --git a/runtime/compiler/control/OptionsPostRestore.hpp b/runtime/compiler/control/OptionsPostRestore.hpp index 0746dd043df..cbc3254cdbe 100644 --- a/runtime/compiler/control/OptionsPostRestore.hpp +++ b/runtime/compiler/control/OptionsPostRestore.hpp @@ -183,6 +183,8 @@ class OptionsPostRestore int32_t _argIndexDisableUseJITServer; int32_t _argIndexJITServerAddress; int32_t _argIndexJITServerAOTCacheName; + int32_t _argIndexIProfileDuringStartupPhase; + int32_t _argIndexDisableIProfileDuringStartupPhase; }; }