Path: blob/master/runtime/compiler/control/J9Options.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2022 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#ifndef J9_OPTIONS_INCL23#define J9_OPTIONS_INCL2425/*26* The following #define and typedef must appear before any #includes in this file27*/28#ifndef J9_OPTIONS_CONNECTOR29#define J9_OPTIONS_CONNECTOR30namespace J9 { class Options; }31namespace J9 { typedef J9::Options OptionsConnector; }32#endif3334#include "control/OMROptions.hpp"3536#include <stdint.h>37#include "control/OptionsUtil.hpp"38#include "env/jittypes.h"39#if defined(J9VM_OPT_JITSERVER)40namespace TR { class CompilationInfoPerThreadBase; }41#endif /* defined(J9VM_OPT_JITSERVER) */4243namespace J944{4546class OMR_EXTENSIBLE Options : public OMR::OptionsConnector47{48public:4950Options() : OMR::OptionsConnector() {}5152Options(TR_Memory * m,53int32_t index,54int32_t lineNumber,55TR_ResolvedMethod *compilee,56void *oldStartPC,57TR_OptimizationPlan *optimizationPlan,58bool isAOT=false,59int32_t compThreadID=-1)60: OMR::OptionsConnector(m,index,lineNumber,compilee,oldStartPC,optimizationPlan,isAOT,compThreadID)61{}6263Options(TR::Options &other) : OMR::OptionsConnector(other) {}64656667static bool _doNotProcessEnvVars;6869static bool _reportByteCodeInfoAtCatchBlock;70/** \brief71* Returns the _reportByteCodeInfoAtCatchBlock72*73* \details74* reportByteCodeInfoAtCatchBlock defines whether Byte Code Information should be reported on a catch block.75*76*/77static inline bool getReportByteCodeInfoAtCatchBlock() { return _reportByteCodeInfoAtCatchBlock; }78/** \brief79* Setter for _reportByteCodeInfoAtCatchBlock80*81*/82static inline bool setReportByteCodeInfoAtCatchBlock(bool b = true) { return _reportByteCodeInfoAtCatchBlock = b; }8384static int32_t _samplingFrequencyInIdleMode;85static int32_t getSamplingFrequencyInIdleMode() {return _samplingFrequencyInIdleMode;}8687#if defined(J9VM_OPT_JITSERVER)88static int32_t _statisticsFrequency;89static int32_t getStatisticsFrequency() {return _statisticsFrequency;}9091static uint32_t _compilationSequenceNumber;92#endif /* defined(J9VM_OPT_JITSERVER) */9394static int32_t _samplingFrequencyInDeepIdleMode;95static int32_t getSamplingFrequencyInDeepIdleMode() {return _samplingFrequencyInDeepIdleMode;}9697static int32_t _highActiveThreadThreshold;98static int32_t getHighActiveThreadThreshold() {return _highActiveThreadThreshold;}99100static int32_t _veryHighActiveThreadThreshold;101static int32_t getVeryHighActiveThreadThreshold() {return _veryHighActiveThreadThreshold;}102103static int32_t _maxCheckcastProfiledClassTests;104static int32_t getCheckcastMaxProfiledClassTests() {return _maxCheckcastProfiledClassTests;}105106static int32_t _maxOnsiteCacheSlotForInstanceOf;107/** \brief108* Returns the _maxOnsiteCacheSlotForInstanceOf109*110* \details111* maxOnsiteCacheSlotForInstanceOf node defines number of onsite cache slots to generate per site of instanceOf112* Set this value to 0 to disable generation of onsite cache test for instanceOf113*114*/115static int32_t getMaxOnsiteCacheSlotForInstanceOf() {return _maxOnsiteCacheSlotForInstanceOf;}116/** \brief117* Setter for _maxOnsiteCacheSlotForInstanceOf118*119*/120static int32_t setMaxOnsiteCacheSlotForInstanceOf(int32_t m) {return _maxOnsiteCacheSlotForInstanceOf = m;}121122static int32_t _resetCountThreshold;123124static int32_t _scorchingSampleThreshold;125static int32_t _conservativeScorchingSampleThreshold; // used when many CPUs126127static int32_t _upperBoundNumProcForScaling;128static int32_t _lowerBoundNumProcForScaling;129static int32_t _veryHotSampleThreshold;130static int32_t _relaxedCompilationLimitsSampleThreshold;131static int32_t _sampleThresholdVariationAllowance;132static int32_t _cpuEntitlementForConservativeScorching;133134static int32_t _sampleHeartbeatInterval;135static int32_t getSamplingHeartbeatInterval() { return _sampleHeartbeatInterval;}136137static int32_t _sampleDontSwitchToProfilingThreshold;138static int32_t _stackSize;139static int32_t _profilerStackSize;140static int32_t _smallMethodBytecodeSizeThreshold; // used on setting invocation counts141static int32_t _smallMethodBytecodeSizeThresholdForCold; // used in GCR filtering142static int32_t _smallMethodBytecodeSizeThresholdForJITServerAOTCache; // for determining which methods to convert to AOT done remotely143144static int32_t _countForMethodsCompiledDuringStartup;145static int32_t getCountForMethodsCompiledDuringStartup() { return _countForMethodsCompiledDuringStartup; }146147static int32_t _countForLoopyBootstrapMethods;148static int32_t _countForLooplessBootstrapMethods;149static int32_t getCountForLoopyBootstrapMethods() { return _countForLoopyBootstrapMethods; }150static int32_t getCountForLooplessBootstrapMethods() { return _countForLooplessBootstrapMethods; }151152// fast JNI option153static TR::SimpleRegex *_jniAccelerator;154static TR::SimpleRegex * getJniAccelerator() { return _jniAccelerator; }155static void setJniAccelerator(TR::SimpleRegex *ja) { _jniAccelerator = ja; }156157static int32_t _classLoadingPhaseInterval;158static int32_t _experimentalClassLoadPhaseInterval;159static int32_t _classLoadingPhaseThreshold;160static int32_t _classLoadingPhaseVariance;161static int32_t _classLoadingRateAverage;162static int32_t _secondaryClassLoadingPhaseThreshold;163static int32_t _numClassLoadPhaseQuiesceIntervals;164static int32_t _bigAppSampleThresholdAdjust; //shift value assigned to certain big app's ho and scorching threshold165static int32_t _availableCPUPercentage;166static int32_t _userClassLoadingPhaseThreshold;167static bool _userClassLoadingPhase;168169static int32_t _cpuCompTimeExpensiveThreshold;170int32_t getCpuCompTimeExpensiveThreshold() { return _cpuCompTimeExpensiveThreshold; }171172static uintptr_t _compThreadAffinityMask;173static int32_t _interpreterSamplingThreshold;174static int32_t _interpreterSamplingDivisor;175static int32_t _interpreterSamplingThresholdInStartupMode;176static int32_t _interpreterSamplingThresholdInJSR292;177static int32_t _activeThreadsThreshold; // -1 means 'determine dynamically', 0 means feature disabled178static int32_t _samplingThreadExpirationTime;179static int32_t _compilationExpirationTime;180static int32_t _catchSamplingSizeThreshold;181static int32_t _compilationThreadPriorityCode; // a number between 0 and 4182static int32_t _disableIProfilerClassUnloadThreshold;183static int32_t _iprofilerReactivateThreshold;184static int32_t _iprofilerIntToTotalSampleRatio;185static int32_t _iprofilerSamplesBeforeTurningOff;186static int32_t _iprofilerNumOutstandingBuffers;187static int32_t _iprofilerBufferMaxPercentageToDiscard;188static int32_t _iProfilerBufferInterarrivalTimeToExitDeepIdle; // ms189static int32_t _iprofilerBufferSize; //iprofilerbuffer size in kb190191static int32_t _maxIprofilingCount; // when invocation count is larger than192// this value Iprofiler will not collect data193static int32_t _maxIprofilingCountInStartupMode; // same as above but value is used194// during STARTUP phase (and only during classLoadPhase)195static int32_t _iprofilerFailRateThreshold; // will reactivate Iprofiler if failure rate exceeds this threshold196static int32_t _iprofilerFailHistorySize;197static int32_t _iProfilerMemoryConsumptionLimit;198static int32_t _IprofilerOffSubtractionFactor;199static int32_t _IprofilerOffDivisionFactor;200201static int32_t _LoopyMethodSubtractionFactor;202static int32_t _LoopyMethodDivisionFactor;203204static int32_t _localCSEFrequencyThreshold;205static int32_t _profileAllTheTime;206static int32_t _seriousCompFailureThreshold; // above this threshold we generate a trace point in the Snap file207static bool _useCPUsToDetermineMaxNumberOfCompThreadsToActivate;208209static int32_t _numCodeCachesToCreateAtStartup;210static int32_t getNumCodeCachesToCreateAtStartup() { return _numCodeCachesToCreateAtStartup; }211212static int32_t _dataCacheQuantumSize;213static int32_t _dataCacheMinQuanta;214static int32_t getDataCacheQuantumSize() { return _dataCacheQuantumSize; }215static int32_t getDataCacheMinQuanta() { return _dataCacheMinQuanta; }216217static size_t _scratchSpaceLimitKBWhenLowVirtualMemory;218static size_t getScratchSpaceLimitKBWhenLowVirtualMemory() { return _scratchSpaceLimitKBWhenLowVirtualMemory; }219220static int32_t _scratchSpaceFactorWhenJSR292Workload;221static int32_t getScratchSpaceFactorWhenJSR292Workload() { return _scratchSpaceFactorWhenJSR292Workload; }222223static size_t _scratchSpaceLimitForHotCompilations; // Only used under -Xtune:throughput224static size_t getScratchSpaceLimitForHotCompilations() { return _scratchSpaceLimitForHotCompilations; }225226#if defined(J9VM_OPT_JITSERVER)227static int32_t _scratchSpaceFactorWhenJITServerWorkload;228static int32_t getScratchSpaceFactorWhenJITServerWorkload() { return _scratchSpaceFactorWhenJITServerWorkload; }229#endif /* defined(J9VM_OPT_JITSERVER) */230231static int32_t _lowVirtualMemoryMBThreshold;232static int32_t getLowVirtualMemoryMBThreshold() { return _lowVirtualMemoryMBThreshold; }233234static int32_t _safeReservePhysicalMemoryValue;235inline static int32_t getSafeReservePhysicalMemoryValue() { return _safeReservePhysicalMemoryValue; }236inline static void setSafeReservePhysicalMemoryValue(int32_t size) { _safeReservePhysicalMemoryValue = size; }237238static int32_t _updateFreeMemoryMinPeriod;239inline static int32_t getUpdateFreeMemoryMinPeriod() { return _updateFreeMemoryMinPeriod; }240inline static void setUpdateFreeMemoryMinPeriod(int32_t value) { _updateFreeMemoryMinPeriod = value; }241242static int32_t _numDLTBufferMatchesToEagerlyIssueCompReq;243static int32_t _dltPostponeThreshold;244245246247static int32_t _minSamplingPeriod;248int32_t getMinSamplingPeriod() {return _minSamplingPeriod;}249static int32_t _compilationBudget;250251static int32_t _compYieldStatsThreshold;252static int32_t _compYieldStatsHeartbeatPeriod;253static int32_t _numberOfUserClassesLoaded;254static int32_t _numQueuedInvReqToDowngradeOptLevel;255static int32_t _qszThresholdToDowngradeOptLevel;256static int32_t _qsziThresholdToDowngradeDuringCLP;257static int32_t _qszThresholdToDowngradeOptLevelDuringStartup;258static int32_t _cpuUtilThresholdForStarvation;259static int32_t _qszLimit; // maximum size of the compilation queue260static int32_t _compPriorityQSZThreshold;261static int32_t _GCRQueuedThresholdForCounting; // if too many GCR are queued we stop counting262static int32_t _minimumSuperclassArraySize; //size of the minimum superclass array263264static int32_t _TLHPrefetchSize;265static int32_t _TLHPrefetchLineSize;266static int32_t _TLHPrefetchLineCount;267static int32_t _TLHPrefetchStaggeredLineCount;268static int32_t _TLHPrefetchBoundaryLineCount;269static int32_t _TLHPrefetchTLHEndLineCount;270static int32_t _numFirstTimeCompilationsToExitIdleMode; // use large number to disable the feature271272#if defined(J9VM_OPT_JITSERVER)273static int64_t _oldAge;274static int64_t _oldAgeUnderLowMemory;275static int64_t _timeBetweenPurges;276static bool _shareROMClasses;277static int32_t _sharedROMClassCacheNumPartitions;278static int32_t _reconnectWaitTimeMs;279static const uint32_t DEFAULT_JITCLIENT_TIMEOUT = 10000; // ms280static const uint32_t DEFAULT_JITSERVER_TIMEOUT = 30000; // ms281#endif /* defined(J9VM_OPT_JITSERVER) */282283static int32_t _waitTimeToEnterIdleMode;284static int32_t _waitTimeToEnterDeepIdleMode;285static int32_t _waitTimeToExitStartupMode;286static int32_t _waitTimeToGCR;287static int32_t _waitTimeToStartIProfiler;288static int32_t _compilationDelayTime;289290static int32_t _invocationThresholdToTriggerLowPriComp; // we trigger an LPQ comp req only if the method291// was invoked at least this many times292static int32_t _aotMethodThreshold; // when number of methods found in shared cache exceeds this threshold293// we stop AOTing new methods to be put in shared cache UNLESS294static int32_t _aotMethodCompilesThreshold; // we have already AOT compiled at least this many methods295// complication due to zOS trade scenario: two JVMs share a cache296static int32_t _aotWarmSCCThreshold; // if there are at least that many AOT bodies in SCC at startup297// then we declare the SCC to be warm298static int32_t _largeTranslationTime; // usec299static int32_t _weightOfAOTLoad;300static int32_t _weightOfJSR292;301302static int32_t _hwprofilerNumOutstandingBuffers;303304static TR_YesNoMaybe _hwProfilerEnabled;305static uint32_t _hwprofilerHotOptLevelThreshold;306static uint32_t _hwprofilerScorchingOptLevelThreshold;307static uint32_t _hwprofilerWarmOptLevelThreshold;308static uint32_t _hwprofilerReducedWarmOptLevelThreshold;309static uint32_t _hwprofilerAOTWarmOptLevelThreshold;310static uint32_t _hwprofilerLastOptLevel;311static uint32_t _hwprofilerRecompilationInterval;312static uint32_t _hwprofilerRIBufferPoolSize;313static int32_t _hwProfilerRIBufferProcessingFrequency;314static int32_t _hwProfilerRecompFrequencyThreshold;315static int32_t _hwProfilerRecompDecisionWindow;316static int32_t _numDowngradesToTurnRION;317static int32_t _qszThresholdToTurnRION;318static int32_t _qszMaxThresholdToRIDowngrade;319static int32_t _qszMinThresholdToRIDowngrade;320static int32_t _hwProfilerBufferMaxPercentageToDiscard;321322static uint32_t _hwprofilerPRISamplingRate;323324static uint32_t _hwProfilerExpirationTime;325326static uint32_t _hwprofilerRIBufferThreshold;327static uint32_t _hwprofilerZRIBufferSize;328static uint32_t _hwprofilerZRIMode;329static uint32_t _hwprofilerZRIRGS;330static uint32_t _hwprofilerZRISF;331332static int32_t _expensiveCompWeight; // weight of a comp request to be considered expensive333static int32_t _jProfilingEnablementSampleThreshold;334335static bool _aggressiveLockReservation;336337static void printPID();338339340341342343344static char *kcaOffsets(char *option, void *, TR::OptionTable *entry);345346static char *gcOnResolveOption(char *option, void *, TR::OptionTable *entry);347348static char *tprofOption(char *option, void *, TR::OptionTable *entry);349350static char *loadLimitOption(char *option, void *, TR::OptionTable *entry);351352static char *loadLimitfileOption(char *option, void *, TR::OptionTable *entry);353354static char *vmStateOption(char *option, void *, TR::OptionTable *entry);355356static char *setJitConfigRuntimeFlag(char *option, void *base, TR::OptionTable *entry);357static char *resetJitConfigRuntimeFlag(char *option, void *base, TR::OptionTable *entry);358static char *setJitConfigNumericValue(char *option, void *base, TR::OptionTable *entry);359360static bool useCompressedPointers();361static char *limitOption(char *option, void *, TR::OptionTable *entry);362static char *inlinefileOption(char *option, void *, TR::OptionTable *entry);363static char *limitfileOption(char *option, void *, TR::OptionTable *entry);364static char *versionOption(char *option, void *, TR::OptionTable *entry);365366/** \brief367* Set memory manager functions related configuration.368*369* \param vm370* J9JavaVM pointer.371*372* \param jitConfig373* J9JITConfig pointer.374*/375void preProcessMmf(J9JavaVM *vm, J9JITConfig *jitConfig);376377/** \brief378* Set compiler mode.379*380* \param vm381* J9JavaVM pointer.382*383* \param jitConfig384* J9JITConfig pointer.385*/386void preProcessMode(J9JavaVM *vm, J9JITConfig *jitConfig);387388/** \brief389* Set JNI related configuration.390*391* \param vm392* J9JavaVM pointer.393*/394void preProcessJniAccelerator(J9JavaVM *vm);395396/** \brief397* Increase code cache total size based on codecachetotal options.398*399* \param vm400* J9JavaVM pointer.401*402* \param jitConfig403* J9JITConfig pointer.404*/405void preProcessCodeCacheIncreaseTotalSize(J9JavaVM *vm, J9JITConfig *jitConfig);406407/** \brief408* Set print code cache usage option.409*410* \param vm411* J9JavaVM pointer.412*/413void preProcessCodeCachePrintCodeCache(J9JavaVM *vm);414415/** \brief416* Set large code page size and flags.417*418* \param vm419* J9JavaVM pointer.420*421* \param jitConfig422* J9JITConfig pointer.423*424* \return true if successfully processed large code page size and flags.425*/426bool preProcessCodeCacheXlpCodeCache(J9JavaVM *vm, J9JITConfig *jitConfig);427428/** \brief429* Set code cache related configuration.430*431* \param vm432* J9JavaVM pointer.433*434* \param jitConfig435* J9JITConfig pointer.436*437* \return true if successfully processed code cache related438*/439bool preProcessCodeCache(J9JavaVM *vm, J9JITConfig *jitConfig);440441/** \brief442* Set sampling thread expiration time.443*444* \param vm445* J9JavaVM pointer.446*/447void preProcessSamplingExpirationTime(J9JavaVM *vm);448449/** \brief450* Set number of usable compilation threads.451*452* \param vm453* J9JavaVM pointer.454*455* \param jitConfig456* J9JITConfig pointer.457*/458void preProcessCompilationThreads(J9JavaVM *vm, J9JITConfig *jitConfig);459460/** \brief461* Set thread local heap related configuration.462*463* \param vm464* J9JavaVM pointer.465*/466void preProcessTLHPrefetch(J9JavaVM *vm);467468/** \brief469* Set hardware profiler related configuration.470*471* \param vm472* J9JavaVM pointer.473*/474void preProcessHwProfiler(J9JavaVM *vm);475476/** \brief477* Set deterministic mode related configuration.478*479* \param vm480* J9JavaVM pointer.481*/482void preProcessDeterministicMode(J9JavaVM *vm);483484/** \brief485* Set jit server related configuration.486*487* \param vm488* J9JavaVM pointer.489*490* \param jitConfig491* J9JITConfig pointer.492*493* \return true if successfully set jit server related configuration.494*/495bool preProcessJitServer(J9JavaVM *vm, J9JITConfig *jitConfig);496497bool fePreProcess(void *base);498bool fePostProcessAOT(void *base);499bool fePostProcessJIT(void *base);500bool feLatePostProcess(void *base, TR::OptionSet *optionSet);501bool showOptionsInEffect();502bool showPID();503void openLogFiles(J9JITConfig *jitConfig);504505#if defined(J9VM_OPT_JITSERVER)506void setupJITServerOptions();507508static std::string packOptions(const TR::Options *origOptions);509static TR::Options *unpackOptions(char *clientOptions, size_t clientOptionsSize, TR::CompilationInfoPerThreadBase* compInfoPT,510TR_J9VMBase *fe, TR_Memory *trMemory);511static std::string packLogFile(TR::FILE *fp);512int writeLogFileFromServer(const std::string& logFileContent);513void setLogFileForClientOptions(int suffixNumber = 0);514void closeLogFileForClientOptions();515#endif /* defined(J9VM_OPT_JITSERVER) */516};517518}519520#endif521522523