From 4e1f9dca20128e3c23b1e60d7606dc9f553480a1 Mon Sep 17 00:00:00 2001 From: Ravali Yatham Date: Mon, 5 Sep 2022 13:04:30 +0530 Subject: [PATCH] Add standalone JIT option -XX:[+-]PerfTool When specifying multiple JIT options, currently only the last JIT option will be in effect. Added a standalone alternative for -Xjit:perfTool in -XX:+PerfTool to avoid clobbering pre-existing JIT command line options. New Options -XX:+PerfTool Enables Perf Tool -XX:-PerfTool Disables Perf Tool Fixes: #14157 Signed-off-by: Ravali Yatham --- runtime/compiler/control/DLLMain.cpp | 10 ++++++++++ runtime/compiler/control/J9Options.cpp | 1 + runtime/compiler/control/J9Options.hpp | 1 + runtime/compiler/control/rossa.cpp | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/runtime/compiler/control/DLLMain.cpp b/runtime/compiler/control/DLLMain.cpp index 37305310b2a..75c044e9364 100644 --- a/runtime/compiler/control/DLLMain.cpp +++ b/runtime/compiler/control/DLLMain.cpp @@ -79,6 +79,9 @@ IDATA J9VMDllMain(J9JavaVM* vm, IDATA stage, void * reserved) IDATA argIndexRIEnabled = 0; IDATA argIndexRIDisabled = 0; + IDATA argIndexPerfEnabled = 0; + IDATA argIndexPerfDisabled = 0; + static bool isJIT = false; static bool isAOT = false; @@ -135,6 +138,13 @@ IDATA J9VMDllMain(J9JavaVM* vm, IDATA stage, void * reserved) if (argIndexRIEnabled >= 0 || argIndexRIDisabled >= 0) TR::Options::_hwProfilerEnabled = (argIndexRIDisabled > argIndexRIEnabled) ? TR_no : TR_yes; + argIndexPerfEnabled = FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XX:+PerfTool", 0); + argIndexPerfDisabled = FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XX:-PerfTool", 0); + + // Determine if user disabled PerfTool + if (argIndexPerfEnabled >= 0 || argIndexPerfDisabled >= 0) + TR::Options::_perfToolEnabled = (argIndexPerfDisabled > argIndexPerfEnabled) ? TR_no : TR_yes; + TR::Options::_doNotProcessEnvVars = (FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XX:doNotProcessJitEnvVars", 0) >= 0); isQuickstart = J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_TUNE_QUICKSTART); diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index 395da172537..3a8c4c3e27a 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -219,6 +219,7 @@ int32_t J9::Options::_weightOfAOTLoad = 1; // must be between 0 and 256 int32_t J9::Options::_weightOfJSR292 = 12; // must be between 0 and 256 TR_YesNoMaybe J9::Options::_hwProfilerEnabled = TR_maybe; +TR_YesNoMaybe J9::Options::_perfToolEnabled = TR_no; int32_t J9::Options::_hwprofilerNumOutstandingBuffers = 256; // 1MB / 4KB buffers // These numbers are cast into floats divided by 10000 diff --git a/runtime/compiler/control/J9Options.hpp b/runtime/compiler/control/J9Options.hpp index ac0b76bf66a..7bcf31a0bc7 100644 --- a/runtime/compiler/control/J9Options.hpp +++ b/runtime/compiler/control/J9Options.hpp @@ -305,6 +305,7 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector static int32_t _hwprofilerNumOutstandingBuffers; static TR_YesNoMaybe _hwProfilerEnabled; + static TR_YesNoMaybe _perfToolEnabled; static uint32_t _hwprofilerHotOptLevelThreshold; static uint32_t _hwprofilerScorchingOptLevelThreshold; static uint32_t _hwprofilerWarmOptLevelThreshold; diff --git a/runtime/compiler/control/rossa.cpp b/runtime/compiler/control/rossa.cpp index 41d4b8b6446..8a6fd4783ec 100644 --- a/runtime/compiler/control/rossa.cpp +++ b/runtime/compiler/control/rossa.cpp @@ -1318,6 +1318,10 @@ onLoadInternal( return -1; } + // Enable perfTool + if (TR::Options::_perfToolEnabled == TR_yes) + TR::Options::getCmdLineOptions()->setOption(TR_PerfTool); + // Now that the options have been processed we can initialize the RuntimeAssumptionTables // If we cannot allocate various runtime assumption hash tables, fail the JVM