Path: blob/master/runtime/compiler/control/J9Options.cpp
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#include "control/J9Options.hpp"2324#include <algorithm>25#if defined(J9VM_OPT_JITSERVER)26#include <random>27#endif /* defined(J9VM_OPT_JITSERVER) */28#include <ctype.h>29#include <stdint.h>30#include "jitprotos.h"31#include "j2sever.h"32#include "j9.h"33#include "j9cfg.h"34#include "j9modron.h"35#include "jvminit.h"36#if defined(J9VM_OPT_JITSERVER)37#include "j9vmnls.h"38#include "omrformatconsts.h"39#endif /* defined(J9VM_OPT_JITSERVER) */40#include "codegen/CodeGenerator.hpp"41#include "compile/Compilation.hpp"42#include "control/Recompilation.hpp"43#include "control/RecompilationInfo.hpp"44#include "env/CompilerEnv.hpp"45#include "env/IO.hpp"46#include "env/VMJ9.h"47#include "env/VerboseLog.hpp"48#include "env/jittypes.h"49#include "infra/SimpleRegex.hpp"50#include "control/CompilationRuntime.hpp"51#include "control/CompilationThread.hpp"52#include "runtime/IProfiler.hpp"53#if defined(J9VM_OPT_JITSERVER)54#include "env/j9methodServer.hpp"55#include "control/JITServerCompilationThread.hpp"56#endif /* defined(J9VM_OPT_JITSERVER) */5758#if defined(J9VM_OPT_SHARED_CLASSES)59#include "j9jitnls.h"60#endif6162#define SET_OPTION_BIT(x) TR::Options::setBit, offsetof(OMR::Options,_options[(x)&TR_OWM]), ((x)&~TR_OWM)6364// For use with TPROF only, disable JVMPI hooks even if -Xrun is specified.65// The only hook that is required is J9HOOK_COMPILED_METHOD_LOAD.66//67bool enableCompiledMethodLoadHookOnly = false;6869// -----------------------------------------------------------------------------70// Static data initialization71// -----------------------------------------------------------------------------7273bool J9::Options::_doNotProcessEnvVars = false; // set through XX options in Java74bool J9::Options::_reportByteCodeInfoAtCatchBlock = false;75int32_t J9::Options::_samplingFrequencyInIdleMode = 1000; // ms76#if defined(J9VM_OPT_JITSERVER)77int32_t J9::Options::_statisticsFrequency = 0; // ms78uint32_t J9::Options::_compilationSequenceNumber = 0;79static const size_t JITSERVER_LOG_FILENAME_MAX_SIZE = 1025;80#endif /* defined(J9VM_OPT_JITSERVER) */81int32_t J9::Options::_samplingFrequencyInDeepIdleMode = 100000; // ms82int32_t J9::Options::_resetCountThreshold = 0; // Disable the feature83int32_t J9::Options::_scorchingSampleThreshold = 240;84int32_t J9::Options::_conservativeScorchingSampleThreshold = 80; // used when many CPUs (> _upperBoundNumProc)85int32_t J9::Options::_upperBoundNumProcForScaling = 64; // used for scaling _scorchingSampleThreshold based on numProc86int32_t J9::Options::_lowerBoundNumProcForScaling = 8; // used for scaling _scorchingSampleThreshold based on numProd]c87int32_t J9::Options::_veryHotSampleThreshold = 480;88int32_t J9::Options::_relaxedCompilationLimitsSampleThreshold = 120; // normally should be lower than the scorchingSampleThreshold89int32_t J9::Options::_sampleThresholdVariationAllowance = 30;9091int32_t J9::Options::_maxCheckcastProfiledClassTests = 3;92int32_t J9::Options::_maxOnsiteCacheSlotForInstanceOf = 0; // Setting this value to zero will disable onsite cache in instanceof.93int32_t J9::Options::_cpuEntitlementForConservativeScorching = 801; // 801 means more than 800%, i.e. 8 cpus94// A very large number disables the feature95int32_t J9::Options::_sampleHeartbeatInterval = 10;96int32_t J9::Options::_sampleDontSwitchToProfilingThreshold = 3000; // default=1% use large value to disable// To be tuned97int32_t J9::Options::_stackSize = 1024;98int32_t J9::Options::_profilerStackSize = 128;99100int32_t J9::Options::_smallMethodBytecodeSizeThreshold = 0;101int32_t J9::Options::_smallMethodBytecodeSizeThresholdForCold = -1; // -1 means not set (or disabled)102int32_t J9::Options::_smallMethodBytecodeSizeThresholdForJITServerAOTCache = 0; // 0 means disabled; good values to try 0-32103104int32_t J9::Options::_countForMethodsCompiledDuringStartup = 10;105106int32_t J9::Options::_countForLoopyBootstrapMethods = -1; // -1 means feature disabled107int32_t J9::Options::_countForLooplessBootstrapMethods = -1; // -1 means feature disabled108109TR::SimpleRegex *J9::Options::_jniAccelerator = NULL;110111int32_t J9::Options::_classLoadingPhaseInterval = 500; // ms112int32_t J9::Options::_experimentalClassLoadPhaseInterval = 40;113int32_t J9::Options::_classLoadingPhaseThreshold = 155; // classes per second114int32_t J9::Options::_classLoadingPhaseVariance = 70; // percentage 0..99115int32_t J9::Options::_classLoadingRateAverage = 800; // classes per second116int32_t J9::Options::_secondaryClassLoadingPhaseThreshold = 10000;117int32_t J9::Options::_numClassLoadPhaseQuiesceIntervals = 1;118int32_t J9::Options::_userClassLoadingPhaseThreshold = 5;119bool J9::Options::_userClassLoadingPhase = false;120121int32_t J9::Options::_bigAppSampleThresholdAdjust = 3; //amount to shift the hot and scorching threshold122int32_t J9::Options::_availableCPUPercentage = 100;123int32_t J9::Options::_cpuCompTimeExpensiveThreshold = 4000;124uintptr_t J9::Options::_compThreadAffinityMask = 0;125126#if defined(J9VM_OPT_JITSERVER)127int64_t J9::Options::_oldAge = 1000 * 60 * 1000; // 1000 minutes128int64_t J9::Options::_oldAgeUnderLowMemory = 1000 * 60 * 5; // 5 minutes129int64_t J9::Options::_timeBetweenPurges = 1000 * 60 * 1; // 1 minute130bool J9::Options::_shareROMClasses = false;131int32_t J9::Options::_sharedROMClassCacheNumPartitions = 16;132int32_t J9::Options::_reconnectWaitTimeMs = 1000;133int32_t J9::Options::_highActiveThreadThreshold = -1;134int32_t J9::Options::_veryHighActiveThreadThreshold = -1;135#endif /* defined(J9VM_OPT_JITSERVER) */136137int32_t J9::Options::_interpreterSamplingThreshold = 300;138int32_t J9::Options::_interpreterSamplingDivisor = TR_DEFAULT_INTERPRETER_SAMPLING_DIVISOR;139int32_t J9::Options::_interpreterSamplingThresholdInStartupMode = TR_DEFAULT_INITIAL_BCOUNT; // 3000140int32_t J9::Options::_interpreterSamplingThresholdInJSR292 = TR_DEFAULT_INITIAL_COUNT - 2; // Run stuff twice before getting too excited about interpreter ticks141int32_t J9::Options::_activeThreadsThreshold = 0; // -1 means 'determine dynamically', 0 means feature disabled142int32_t J9::Options::_samplingThreadExpirationTime = -1;143int32_t J9::Options::_compilationExpirationTime = -1;144145int32_t J9::Options::_minSamplingPeriod = 10; // ms146int32_t J9::Options::_compilationBudget = 0; // ms; 0 means disabled147148int32_t J9::Options::_catchSamplingSizeThreshold = -1; // measured in nodes; -1 means not initialized149int32_t J9::Options::_compilationThreadPriorityCode = 4; // these codes are converted into150// priorities in startCompilationThread151int32_t J9::Options::_disableIProfilerClassUnloadThreshold = 20000;// The usefulness of IProfiling is questionable at this point152int32_t J9::Options::_iprofilerReactivateThreshold=10;153int32_t J9::Options::_iprofilerIntToTotalSampleRatio=2;154int32_t J9::Options::_iprofilerSamplesBeforeTurningOff = 1000000; // samples155int32_t J9::Options::_iprofilerNumOutstandingBuffers = 10;156int32_t J9::Options::_iprofilerBufferMaxPercentageToDiscard = 0;157int32_t J9::Options::_iProfilerBufferInterarrivalTimeToExitDeepIdle = 5000; // 5 seconds158int32_t J9::Options::_iprofilerBufferSize = 1024;159#ifdef TR_HOST_64BIT160int32_t J9::Options::_iProfilerMemoryConsumptionLimit=32*1024*1024;161#else162int32_t J9::Options::_iProfilerMemoryConsumptionLimit=18*1024*1024;163#endif164int32_t J9::Options::_IprofilerOffSubtractionFactor = 500;165int32_t J9::Options::_IprofilerOffDivisionFactor = 16;166167168169int32_t J9::Options::_maxIprofilingCount = TR_DEFAULT_INITIAL_COUNT; // 3000170int32_t J9::Options::_maxIprofilingCountInStartupMode = TR_QUICKSTART_INITIAL_COUNT; // 1000171int32_t J9::Options::_iprofilerFailRateThreshold = 70; // percent 1-100172int32_t J9::Options::_iprofilerFailHistorySize = 10; // percent 1-100173174int32_t J9::Options::_compYieldStatsThreshold = 1000; // usec175int32_t J9::Options::_compYieldStatsHeartbeatPeriod = 0; // ms176int32_t J9::Options::_numberOfUserClassesLoaded = 0;177int32_t J9::Options::_compPriorityQSZThreshold = 200;178int32_t J9::Options::_numQueuedInvReqToDowngradeOptLevel = 20; // If more than 20 inv req are queued we compiled them at cold179int32_t J9::Options::_qszThresholdToDowngradeOptLevel = -1; // not yet set180int32_t J9::Options::_qsziThresholdToDowngradeDuringCLP = 0; // -1 or 0 disables the feature and reverts to old behavior181int32_t J9::Options::_qszThresholdToDowngradeOptLevelDuringStartup = 100000; // a large number disables the feature182int32_t J9::Options::_cpuUtilThresholdForStarvation = 25; // 25%183int32_t J9::Options::_qszLimit = 5000; // when limit is reached the JIT will postpone new compilation requests184185// If too many GCR are queued we stop counting.186// Use a large value to disable the feature. 400 is a good default187// Don't use a value smaller than GCR_HYSTERESIS==100188int32_t J9::Options::_GCRQueuedThresholdForCounting = 1000000; // 400;189190int32_t J9::Options::_minimumSuperclassArraySize = 5;191int32_t J9::Options::_TLHPrefetchSize = 0;192int32_t J9::Options::_TLHPrefetchLineSize = 0;193int32_t J9::Options::_TLHPrefetchLineCount = 0;194int32_t J9::Options::_TLHPrefetchStaggeredLineCount = 0;195int32_t J9::Options::_TLHPrefetchBoundaryLineCount = 0;196int32_t J9::Options::_TLHPrefetchTLHEndLineCount = 0;197198int32_t J9::Options::_numFirstTimeCompilationsToExitIdleMode = 25; // Use a large number to disable the feature199int32_t J9::Options::_waitTimeToEnterIdleMode = 5000; // ms200int32_t J9::Options::_waitTimeToEnterDeepIdleMode = 50000; // ms201int32_t J9::Options::_waitTimeToExitStartupMode = DEFAULT_WAIT_TIME_TO_EXIT_STARTUP_MODE; // ms202int32_t J9::Options::_waitTimeToGCR = 10000; // ms203int32_t J9::Options::_waitTimeToStartIProfiler = 1000; // ms204int32_t J9::Options::_compilationDelayTime = 0; // sec; 0 means disabled205206int32_t J9::Options::_invocationThresholdToTriggerLowPriComp = 250;207208int32_t J9::Options::_aotMethodThreshold = 200;209int32_t J9::Options::_aotMethodCompilesThreshold = 200;210int32_t J9::Options::_aotWarmSCCThreshold = 200;211212int32_t J9::Options::_largeTranslationTime = -1; // usec213int32_t J9::Options::_weightOfAOTLoad = 1; // must be between 0 and 256214int32_t J9::Options::_weightOfJSR292 = 12; // must be between 0 and 256215216TR_YesNoMaybe J9::Options::_hwProfilerEnabled = TR_maybe;217int32_t J9::Options::_hwprofilerNumOutstandingBuffers = 256; // 1MB / 4KB buffers218219// These numbers are cast into floats divided by 10000220uint32_t J9::Options::_hwprofilerWarmOptLevelThreshold = 1; // 0.0001221uint32_t J9::Options::_hwprofilerReducedWarmOptLevelThreshold=0; // 0 ==> upgrade methods with just 1 tick in any given interval222uint32_t J9::Options::_hwprofilerAOTWarmOptLevelThreshold = 10; // 0.001223uint32_t J9::Options::_hwprofilerHotOptLevelThreshold = 100; // 0.01224uint32_t J9::Options::_hwprofilerScorchingOptLevelThreshold = 1250; // 0.125225226uint32_t J9::Options::_hwprofilerLastOptLevel = warm; // warm227uint32_t J9::Options::_hwprofilerRecompilationInterval = 10000;228uint32_t J9::Options::_hwprofilerRIBufferThreshold = 50; // process buffer when it is at least 50% full229uint32_t J9::Options::_hwprofilerRIBufferPoolSize = 1 * 1024 * 1024; // 1 MB230int32_t J9::Options::_hwProfilerRIBufferProcessingFrequency= 0; // process buffer every time231int32_t J9::Options::_hwProfilerRecompFrequencyThreshold = 5000; // less than 1 in 5000 will turn RI off232233int32_t J9::Options::_hwProfilerRecompDecisionWindow = 5000; // Should be at least as big as _hwProfilerRecompFrequencyThreshold234int32_t J9::Options::_numDowngradesToTurnRION = 250;235int32_t J9::Options::_qszThresholdToTurnRION = 100;236int32_t J9::Options::_qszMaxThresholdToRIDowngrade = 250;237int32_t J9::Options::_qszMinThresholdToRIDowngrade = 50; // should be smaller than _qszMaxThresholdToRIDowngrade238uint32_t J9::Options::_hwprofilerPRISamplingRate = 500000;239240int32_t J9::Options::_hwProfilerBufferMaxPercentageToDiscard = 5;241uint32_t J9::Options::_hwProfilerExpirationTime = 0; // ms; 0 means disabled242uint32_t J9::Options::_hwprofilerZRIBufferSize = 4 * 1024; // 4 kb243uint32_t J9::Options::_hwprofilerZRIMode = 0; // cycle based profiling244uint32_t J9::Options::_hwprofilerZRIRGS = 0; // only collect instruction records245uint32_t J9::Options::_hwprofilerZRISF = 10000000;246247int32_t J9::Options::_LoopyMethodSubtractionFactor = 500;248int32_t J9::Options::_LoopyMethodDivisionFactor = 16;249250int32_t J9::Options::_localCSEFrequencyThreshold = 1000;251int32_t J9::Options::_profileAllTheTime = 0;252253int32_t J9::Options::_seriousCompFailureThreshold = 10; // above this threshold we generate a trace point in the Snap file254255bool J9::Options::_useCPUsToDetermineMaxNumberOfCompThreadsToActivate = false;256int32_t J9::Options::_numCodeCachesToCreateAtStartup = 0; // 0 means no change from default which is 1257258int32_t J9::Options::_dataCacheQuantumSize = 64;259int32_t J9::Options::_dataCacheMinQuanta = 2;260261int32_t J9::Options::_updateFreeMemoryMinPeriod = 500; // 500 ms262263264size_t J9::Options::_scratchSpaceLimitKBWhenLowVirtualMemory = 64*1024; // 64MB; currently, only used on 32 bit Windows265266int32_t J9::Options::_scratchSpaceFactorWhenJSR292Workload = JSR292_SCRATCH_SPACE_FACTOR;267size_t J9::Options::_scratchSpaceLimitForHotCompilations = 512 * 1024 * 1024; // 512 MB268#if defined(J9VM_OPT_JITSERVER)269int32_t J9::Options::_scratchSpaceFactorWhenJITServerWorkload = 2;270#endif /* defined(J9VM_OPT_JITSERVER) */271int32_t J9::Options::_lowVirtualMemoryMBThreshold = 300; // Used on 32 bit Windows, Linux, 31 bit z/OS, Linux272int32_t J9::Options::_safeReservePhysicalMemoryValue = 32 << 20; // 32 MB273274int32_t J9::Options::_numDLTBufferMatchesToEagerlyIssueCompReq = 8; //a value of 1 or less disables the DLT tracking mechanism275int32_t J9::Options::_dltPostponeThreshold = 2;276277int32_t J9::Options::_expensiveCompWeight = TR::CompilationInfo::JSR292_WEIGHT;278int32_t J9::Options::_jProfilingEnablementSampleThreshold = 10000;279280bool J9::Options::_aggressiveLockReservation = false;281282//************************************************************************283//284// Options handling - the following code implements the VM-specific285// jit command-line options.286//287// Options processing is table-driven, the table for VM-specific options288// here (see Options.hpp for a description of the table entries).289//290//************************************************************************291292// Helper routines to parse and format -Xlp:codecache Options293enum TR_XlpCodeCacheOptions294{295XLPCC_PARSING_FIRST_OPTION,296XLPCC_PARSING_OPTION,297XLPCC_PARSING_COMMA,298XLPCC_PARSING_ERROR299};300301// Returns large page flag type string for error handling.302char *303getLargePageTypeString(UDATA pageFlags)304{305if (0 != (J9PORT_VMEM_PAGE_FLAG_PAGEABLE & pageFlags))306return "pageable";307else if (0 != (J9PORT_VMEM_PAGE_FLAG_FIXED & pageFlags))308return "nonpageable";309else310return "not used";311}312313// Formats size to be in terms of X bytes to XX(K/M/G) for printing314void315qualifiedSize(UDATA *byteSize, char **qualifier)316{317UDATA size;318319size = *byteSize;320*qualifier = "";321if(!(size % 1024)) {322size /= 1024;323*qualifier = "K";324if(size && !(size % 1024)) {325size /= 1024;326*qualifier = "M";327if(size && !(size % 1024)) {328size /= 1024;329*qualifier = "G";330}331}332}333*byteSize = size;334}335336337bool338J9::Options::useCompressedPointers()339{340return TR::Compiler->om.compressObjectReferences();341}342343344#ifdef DEBUG345#define BUILD_TYPE "(debug)"346#else347#define BUILD_TYPE ""348#endif349350char *351J9::Options::versionOption(char * option, void * base, TR::OptionTable *entry)352{353J9JITConfig * jitConfig = (J9JITConfig*)base;354PORT_ACCESS_FROM_JAVAVM(jitConfig->javaVM);355j9tty_printf(PORTLIB, "JIT: using build \"%s %s\" %s\n", __DATE__, __TIME__, BUILD_TYPE);356j9tty_printf(PORTLIB, "JIT level: %s\n", TR_BUILD_NAME);357return option;358}359#undef BUILD_TYPE360361362char *363J9::Options::limitOption(char * option, void * base, TR::OptionTable *entry)364{365if (!J9::Options::getDebug() && !J9::Options::createDebug())366return 0;367368if (J9::Options::getJITCmdLineOptions() == NULL)369{370// if JIT options are NULL, means we're processing AOT options now371return J9::Options::getDebug()->limitOption(option, base, entry, TR::Options::getAOTCmdLineOptions(), false);372}373else374{375// otherwise, we're processing JIT options376return J9::Options::getDebug()->limitOption(option, base, entry, TR::Options::getJITCmdLineOptions(), false);377}378}379380381char *382J9::Options::limitfileOption(char * option, void * base, TR::OptionTable *entry)383{384if (!J9::Options::getDebug() && !J9::Options::createDebug())385return 0;386387J9JITConfig * jitConfig = (J9JITConfig*)base;388TR_PseudoRandomNumbersListElement **pseudoRandomNumbersListPtr = NULL;389if (jitConfig != 0)390{391TR::CompilationInfo * compInfo = TR::CompilationInfo::get(jitConfig);392pseudoRandomNumbersListPtr = compInfo->getPersistentInfo()->getPseudoRandomNumbersListPtr();393}394395if (J9::Options::getJITCmdLineOptions() == NULL)396{397// if JIT options are NULL, means we're processing AOT options now398return J9::Options::getDebug()->limitfileOption(option, base, entry, TR::Options::getAOTCmdLineOptions(), false, pseudoRandomNumbersListPtr);399}400else401{402// otherwise, we're processing JIT options403return J9::Options::getDebug()->limitfileOption(option, base, entry, TR::Options::getJITCmdLineOptions(), false, pseudoRandomNumbersListPtr);404}405}406407char *408J9::Options::inlinefileOption(char * option, void * base, TR::OptionTable *entry)409{410if (!J9::Options::getDebug() && !J9::Options::createDebug())411return 0;412413if (J9::Options::getJITCmdLineOptions() == NULL)414{415// if JIT options are NULL, means we're processing AOT options now416return J9::Options::getDebug()->inlinefileOption(option, base, entry, TR::Options::getAOTCmdLineOptions());417}418else419{420// otherwise, we're processing JIT options421return J9::Options::getDebug()->inlinefileOption(option, base, entry, TR::Options::getJITCmdLineOptions());422}423}424425426struct vmX427{428uint32_t _xstate;429const char *_xname;430int32_t _xsize;431};432433434static const struct vmX vmSharedStateArray[] =435{436{J9VMSTATE_SHAREDCLASS_FIND, "J9VMSTATE_SHAREDCLASS_FIND", 0}, //9 0x80001437{J9VMSTATE_SHAREDCLASS_STORE, "J9VMSTATE_SHAREDCLASS_STORE", 0}, //10 0x80002438{J9VMSTATE_SHAREDCLASS_MARKSTALE, "J9VMSTATE_SHAREDCLASS_MARKSTALE", 0}, //11 0x80003439{J9VMSTATE_SHAREDAOT_FIND, "J9VMSTATE_SHAREDAOT_FIND", 0}, //12 0x80004440{J9VMSTATE_SHAREDAOT_STORE, "J9VMSTATE_SHAREDAOT_STORE", 0}, //13 0x80005441{J9VMSTATE_SHAREDDATA_FIND, "J9VMSTATE_SHAREDDATA_FIND", 0}, //14 0x80006442{J9VMSTATE_SHAREDDATA_STORE, "J9VMSTATE_SHAREDDATA_STORE", 0}, //15 0x80007443{J9VMSTATE_SHAREDCHARARRAY_FIND, "J9VMSTATE_SHAREDCHARARRAY_FIND", 0}, //16 0x80008444{J9VMSTATE_SHAREDCHARARRAY_STORE, "J9VMSTATE_SHAREDCHARARRAY_STORE", 0}, //17 0x80009445{J9VMSTATE_ATTACHEDDATA_STORE, "J9VMSTATE_ATTACHEDDATA_STORE", 0}, //18 0x8000a446{J9VMSTATE_ATTACHEDDATA_FIND, "J9VMSTATE_ATTACHEDDATA_FIND", 0}, //19 0x8000b447{J9VMSTATE_ATTACHEDDATA_UPDATE, "J9VMSTATE_ATTACHEDDATA_UPDATE", 0}, //20 0x8000c448};449450451static const struct vmX vmJniStateArray[] =452{453{J9VMSTATE_JNI, "J9VMSTATE_JNI", 0}, //4 0x40000454{J9VMSTATE_JNI_FROM_JIT, "J9VMSTATE_JNI_FROM_JIT", 0}, // 0x40001455};456457458static const struct vmX vmStateArray[] =459{460{0xdead, "unknown", 0}, //0461{J9VMSTATE_INTERPRETER, "J9VMSTATE_INTERPRETER", 0}, //1 0x10000462{J9VMSTATE_GC, "J9VMSTATE_GC", 0}, //2 0x20000463{J9VMSTATE_GROW_STACK, "J9VMSTATE_GROW_STACK", 0}, //3 0x30000464{J9VMSTATE_JNI, "special", 2}, //4 0x40000465{J9VMSTATE_JIT, "J9VMSTATE_JIT", 0}, //5 0x50000466{J9VMSTATE_BCVERIFY, "J9VMSTATE_BCVERIFY", 0}, //6 0x60000467{J9VMSTATE_RTVERIFY, "J9VMSTATE_RTVERIFY", 0}, //7 0x70000468{J9VMSTATE_SHAREDCLASS_FIND, "special", 12}, //8 0x80000469{J9VMSTATE_SNW_STACK_VALIDATE, "J9VMSTATE_SNW_STACK_VALIDATE", 0}, //9 0x110000470{J9VMSTATE_GP, "J9VMSTATE_GP", 0} //10 0xFFFF0000471};472473474namespace J9475{476477char *478Options::gcOnResolveOption(char * option, void * base, TR::OptionTable *entry)479{480J9JITConfig * jitConfig = (J9JITConfig*)base;481482jitConfig->gcOnResolveThreshold = 0;483jitConfig->runtimeFlags |= J9JIT_SCAVENGE_ON_RESOLVE;484if (* option == '=')485{486for (option++; * option >= '0' && * option <= '9'; option++)487jitConfig->gcOnResolveThreshold = jitConfig->gcOnResolveThreshold *10 + * option - '0';488}489entry->msgInfo = jitConfig->gcOnResolveThreshold;490return option;491}492493494char *495Options::vmStateOption(char * option, void * base, TR::OptionTable *entry)496{497J9JITConfig * jitConfig = (J9JITConfig*)base;498PORT_ACCESS_FROM_JAVAVM(jitConfig->javaVM);499char *p = option;500int32_t state = strtol(option, &p, 16);501if (state > 0)502{503uint32_t index = (state >> 16) & 0xFF;504bool invalidState = false;505if (!isValidVmStateIndex(index))506invalidState = true;507508if (!invalidState)509{510uint32_t origState = vmStateArray[index]._xstate;511switch (index)512{513case ((J9VMSTATE_JNI>>16) & 0xF):514invalidState = true;515if ((state & 0xFFFF0) == origState)516{517int32_t lowState = state & 0xF;518if (lowState >= 0 && lowState < vmStateArray[index]._xsize)519{520invalidState = false;521j9tty_printf(PORTLIB, "vmState [0x%x]: {%s}\n", state, vmJniStateArray[lowState]._xname);522}523}524break;525case ((J9VMSTATE_SHAREDCLASS_FIND>>16) & 0xF):526invalidState = true;527if ((state & 0xFFFF0) == (origState & 0xFFFF0))528{529int32_t lowState = state & 0xF;530if (lowState >= 0x1 && lowState <= vmStateArray[index]._xsize)531{532invalidState = false;533j9tty_printf(PORTLIB, "vmState [0x%x]: {%s}\n", state, vmSharedStateArray[--lowState]._xname);534}535}536break;537case ((J9VMSTATE_JIT >> 16) & 0xF):538{539if ((state & 0xFF00) == 0) // ILGeneratorPhase540{541j9tty_printf(PORTLIB, "vmState [0x%x]: {%s} {ILGeneration}\n", state, vmStateArray[index]._xname);542}543else if ((state & J9VMSTATE_JIT_OPTIMIZER) == J9VMSTATE_JIT_OPTIMIZER)544{545OMR::Optimizations opts = static_cast<OMR::Optimizations>((state & 0xFF00) >> 8);546if (opts < OMR::numOpts)547{548j9tty_printf(PORTLIB, "vmState [0x%x]: {%s} {%s}\n", state, vmStateArray[index]._xname, OMR::Optimizer::getOptimizationName(opts));549}550else551j9tty_printf(PORTLIB, "vmState [0x%x]: {%s} {Illegal optimization number}\n", state, vmStateArray[index]._xname);552}553else if ((state & J9VMSTATE_JIT_CODEGEN) == J9VMSTATE_JIT_CODEGEN)554{555TR::CodeGenPhase::PhaseValue phase = static_cast<TR::CodeGenPhase::PhaseValue>(state & 0xFF);556if ( phase < TR::CodeGenPhase::getNumPhases())557j9tty_printf(PORTLIB, "vmState [0x%x]: {%s} {%s}\n", state, vmStateArray[index]._xname, TR::CodeGenPhase::getName(phase));558else559j9tty_printf(PORTLIB, "vmState [0x%x]: {%s} {Illegal codegen phase number}\n", state, vmStateArray[index]._xname);560}561else562invalidState = true;563}564break;565default:566if (state != origState)567invalidState = true;568else569j9tty_printf(PORTLIB, "vmState [0x%x]: {%s}\n", state, vmStateArray[index]._xname);570break;571}572}573574if (invalidState)575j9tty_printf(PORTLIB, "vmState [0x%x]: not a valid vmState\n", state);576}577else578{579// a bad vmState, eat it up atleast580//581j9tty_printf(PORTLIB, "vmState [0x%x]: not a valid vmState\n", state);582}583for (; *p; p++);584585return p;586}587588589char *590Options::loadLimitOption(char * option, void * base, TR::OptionTable *entry)591{592if (!TR::Options::getDebug() && !TR::Options::createDebug())593return 0;594if (TR::Options::getJITCmdLineOptions() == NULL)595{596// if JIT options are NULL, means we're processing AOT options now597return TR::Options::getDebug()->limitOption(option, base, entry, TR::Options::getAOTCmdLineOptions(), true);598}599else600{601// otherwise, we're processing JIT options602J9JITConfig * jitConfig = (J9JITConfig*)base;603PORT_ACCESS_FROM_JAVAVM(jitConfig->javaVM);604// otherwise, we're processing JIT options605j9tty_printf(PORTLIB, "<JIT: loadLimit option should be specified on -Xaot --> '%s'>\n", option);606return option;607//return J9::Options::getDebug()->limitOption(option, base, entry, getJITCmdLineOptions(), true);608}609}610611612char *613Options::loadLimitfileOption(char * option, void * base, TR::OptionTable *entry)614{615if (!TR::Options::getDebug() && !TR::Options::createDebug())616return 0;617618J9JITConfig * jitConfig = (J9JITConfig*)base;619TR_PseudoRandomNumbersListElement **pseudoRandomNumbersListPtr = NULL;620if (jitConfig != 0)621{622TR::CompilationInfo * compInfo = TR::CompilationInfo::get(jitConfig);623pseudoRandomNumbersListPtr = compInfo->getPersistentInfo()->getPseudoRandomNumbersListPtr();624}625626if (TR::Options::getJITCmdLineOptions() == NULL)627{628// if JIT options are NULL, means we're processing AOT options now629return TR::Options::getDebug()->limitfileOption(option, base, entry, TR::Options::getAOTCmdLineOptions(), true /* new param */, pseudoRandomNumbersListPtr);630}631else632{633J9JITConfig * jitConfig = (J9JITConfig*)base;634PORT_ACCESS_FROM_JAVAVM(jitConfig->javaVM);635// otherwise, we're processing JIT options636j9tty_printf(PORTLIB, "<JIT: loadLimitfile option should be specified on -Xaot --> '%s'>\n", option);637return option;638}639}640641642char *643Options::tprofOption(char * option, void * base, TR::OptionTable *entry)644{645J9JITConfig * jitConfig = (J9JITConfig*)base;646PORT_ACCESS_FROM_JAVAVM(jitConfig->javaVM);647enableCompiledMethodLoadHookOnly = true;648return option;649}650651char *652Options::setJitConfigRuntimeFlag(char *option, void *base, TR::OptionTable *entry)653{654J9JITConfig *jitConfig = (J9JITConfig*)_feBase;655jitConfig->runtimeFlags |= entry->parm2;656return option;657}658659char *660Options::resetJitConfigRuntimeFlag(char *option, void *base, TR::OptionTable *entry)661{662J9JITConfig *jitConfig = (J9JITConfig*)_feBase;663jitConfig->runtimeFlags &= ~(entry->parm2);664return option;665}666667char *668Options::setJitConfigNumericValue(char *option, void *base, TR::OptionTable *entry)669{670char *jitConfig = (char*)_feBase;671// All numeric fields in jitConfig are declared as UDATA672*((intptr_t*)(jitConfig + entry->parm1)) = (intptr_t)TR::Options::getNumericValue(option);673return option;674}675676}677678#define SET_JITCONFIG_RUNTIME_FLAG(x) J9::Options::setJitConfigRuntimeFlag, 0, (x), "F", NOT_IN_SUBSET679#define RESET_JITCONFIG_RUNTIME_FLAG(x) J9::Options::resetJitConfigRuntimeFlag, 0, (x), "F", NOT_IN_SUBSET680681// DMDM: hack682TR::OptionTable OMR::Options::_feOptions[] = {683684{"activeThreadsThresholdForInterpreterSampling=", "M<nnn>\tSampling does not affect invocation count beyond this threshold",685TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_activeThreadsThreshold, 0, "F%d", NOT_IN_SUBSET },686{"aotMethodCompilesThreshold=", "R<nnn>\tIf this many AOT methods are compiled before exceeding aotMethodThreshold, don't stop AOT compiling",687TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_aotMethodCompilesThreshold, 0, "F%d", NOT_IN_SUBSET},688{"aotMethodThreshold=", "R<nnn>\tNumber of methods found in shared cache after which we stop AOTing",689TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_aotMethodThreshold, 0, "F%d", NOT_IN_SUBSET},690{"aotWarmSCCThreshold=", "R<nnn>\tNumber of methods found in shared cache at startup to declare SCC as warm",691TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_aotWarmSCCThreshold, 0, "F%d", NOT_IN_SUBSET },692{"availableCPUPercentage=", "M<nnn>\tUse it when java process has a fraction of a CPU. Number 1..99 ",693TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_availableCPUPercentage, 0, "F%d", NOT_IN_SUBSET},694{"bcLimit=", "C<nnn>\tbytecode size limit",695TR::Options::setJitConfigNumericValue, offsetof(J9JITConfig, bcSizeLimit), 0, "P%d"},696{"bcountForBootstrapMethods=", "M<nnn>\tcount for loopy methods belonging to bootstrap classes. "697"Used in no AOT cases",698TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_countForLoopyBootstrapMethods, 250, "F%d", NOT_IN_SUBSET },699{"bigAppSampleThresholdAdjust=", "O\tadjust the hot and scorching threshold for certain 'big' apps",700TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_bigAppSampleThresholdAdjust, 0, "F%d", NOT_IN_SUBSET},701{"catchSamplingSizeThreshold=", "R<nnn>\tThe sample counter will not be decremented in a catch block "702"if the number of nodes in the compiled method exceeds this threshold",703TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_catchSamplingSizeThreshold, 0, "F%d", NOT_IN_SUBSET},704{"classLoadPhaseInterval=", "O<nnn>\tnumber of sampling ticks before we run "705"again the code for a class loading phase detection",706TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_classLoadingPhaseInterval, 0, "P%d", NOT_IN_SUBSET},707{"classLoadPhaseQuiesceIntervals=", "O<nnn>\tnumber of intervals we remain in classLoadPhase after it ended",708TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_numClassLoadPhaseQuiesceIntervals, 0, "F%d", NOT_IN_SUBSET},709{"classLoadPhaseThreshold=", "O<nnn>\tnumber of classes loaded per sampling tick that "710"needs to be attained to enter the class loading phase. "711"Specify a very large value to disable this optimization",712TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_classLoadingPhaseThreshold, 0, "P%d", NOT_IN_SUBSET},713{"classLoadPhaseVariance=", "O<nnn>\tHow much the classLoadPhaseThreshold can deviate from "714"its average value (as a percentage). Specify an integer 0-99",715TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_classLoadingPhaseVariance, 0, "F%d", NOT_IN_SUBSET},716{"classLoadRateAverage=", "O<nnn>\tnumber of classes loaded per second on an average machine",717TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_classLoadingRateAverage, 0, "F%d", NOT_IN_SUBSET},718{"clinit", "D\tforce compilation of <clinit> methods", SET_JITCONFIG_RUNTIME_FLAG(J9JIT_COMPILE_CLINIT) },719{"code=", "C<nnn>\tcode cache size, in KB",720TR::Options::setJitConfigNumericValue, offsetof(J9JITConfig, codeCacheKB), 0, "F%d (KB)"},721{"codepad=", "C<nnn>\ttotal code cache pad size, in KB",722TR::Options::setJitConfigNumericValue, offsetof(J9JITConfig, codeCachePadKB), 0, "F%d (KB)"},723{"codetotal=", "C<nnn>\ttotal code memory limit, in KB",724TR::Options::setJitConfigNumericValue, offsetof(J9JITConfig, codeCacheTotalKB), 0, "F%d (KB)"},725{"compilationBudget=", "O<nnn>\tnumber of usec. Used to better interleave compilation"726"with computation. Use 80000 as a starting point",727TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_compilationBudget, 0, "P%d", NOT_IN_SUBSET},728{"compilationDelayTime=", "M<nnn>\tnumber of seconds after which we allow compiling",729TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_compilationDelayTime, 0, "F%d", NOT_IN_SUBSET },730{"compilationExpirationTime=", "R<nnn>\tnumber of seconds after which point we will stop compiling",731TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_compilationExpirationTime, 0, "F%d", NOT_IN_SUBSET},732{"compilationPriorityQSZThreshold=", "M<nnn>\tCompilation queue size threshold when priority of post-profiling"733"compilation requests is increased",734TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_compPriorityQSZThreshold , 0, "F%d", NOT_IN_SUBSET},735{"compilationQueueSizeLimit=", "R<nnn>\tWhen limit is reached, first-time compilations are postponed by replenishing the invocation count",736TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_qszLimit, 0, "F%d", NOT_IN_SUBSET},737{"compilationThreadAffinityMask=", "M<nnn>\taffinity mask for compilation threads. Use hexa without 0x",738TR::Options::setStaticHexadecimal, (intptr_t)&TR::Options::_compThreadAffinityMask, 0, "F%d", NOT_IN_SUBSET},739{"compilationYieldStatsHeartbeatPeriod=", "M<nnn>\tperiodically print stats about compilation yield points "740"Period is in ms. Default is 0 which means don't do it. "741"Values between 1 and 99 ms will be upgraded to 100 ms.",742TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_compYieldStatsHeartbeatPeriod, 0, "F%d", NOT_IN_SUBSET},743{"compilationYieldStatsThreshold=", "M<nnn>\tprint stats about compilation yield points if the "744"threshold is exceeded. Default 1000 usec. ",745TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_compYieldStatsThreshold, 0, "F%d", NOT_IN_SUBSET},746{"compThreadPriority=", "M<nnn>\tThe priority of the compilation thread. "747"Use an integer between 0 and 4. Default is 4 (highest priority)",748TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_compilationThreadPriorityCode, 0, "F%d", NOT_IN_SUBSET},749{"conservativeScorchingSampleThreshold=", "R<nnn>\tLower bound for scorchingSamplingThreshold when scaling based on numProc",750TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_conservativeScorchingSampleThreshold, 0, "F%d", NOT_IN_SUBSET},751{"countForBootstrapMethods=", "M<nnn>\tcount for loopless methods belonging to bootstrap classes. "752"Used in no AOT cases",753TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_countForLooplessBootstrapMethods, 1000, "F%d", NOT_IN_SUBSET },754{"cpuCompTimeExpensiveThreshold=", "M<nnn>\tthreshold for when hot & very-hot compilations occupied enough cpu time to be considered expensive in millisecond",755TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_cpuCompTimeExpensiveThreshold, 0, "F%d", NOT_IN_SUBSET},756{"cpuEntitlementForConservativeScorching=", "M<nnn>\tPercentage. 200 means two full cpus",757TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_cpuEntitlementForConservativeScorching, 0, "F%d", NOT_IN_SUBSET },758{"cpuUtilThresholdForStarvation=", "M<nnn>\tThreshold for deciding that a comp thread is not starved",759TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_cpuUtilThresholdForStarvation , 0, "F%d", NOT_IN_SUBSET},760{"data=", "C<nnn>\tdata cache size, in KB",761TR::Options::setJitConfigNumericValue, offsetof(J9JITConfig, dataCacheKB), 0, "F%d (KB)"},762{"dataCacheMinQuanta=", "I<nnn>\tMinimum number of quantums per data cache allocation",763TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_dataCacheMinQuanta, 0, "F%d", NOT_IN_SUBSET},764{"dataCacheQuantumSize=", "I<nnn>\tLargest guaranteed common byte multiple of data cache allocations. This value will be rounded up for pointer alignment.",765TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_dataCacheQuantumSize, 0, "F%d", NOT_IN_SUBSET},766{"datatotal=", "C<nnn>\ttotal data memory limit, in KB",767TR::Options::setJitConfigNumericValue, offsetof(J9JITConfig, dataCacheTotalKB), 0, "F%d (KB)"},768{"disableIProfilerClassUnloadThreshold=", "R<nnn>\tNumber of classes that can be unloaded before we disable the IProfiler",769TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_disableIProfilerClassUnloadThreshold, 0, "F%d", NOT_IN_SUBSET},770{"dltPostponeThreshold=", "M<nnn>\tNumber of dlt attempts inv. count for a method is seen not advancing",771TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_dltPostponeThreshold, 0, "F%d", NOT_IN_SUBSET },772{"exclude=", "D<xxx>\tdo not compile methods beginning with xxx", TR::Options::limitOption, 1, 0, "P%s"},773{"expensiveCompWeight=", "M<nnn>\tweight of a comp request to be considered expensive",774TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_expensiveCompWeight, 0, "F%d", NOT_IN_SUBSET },775{"experimentalClassLoadPhaseInterval=", "O<nnn>\tnumber of sampling ticks to stay in a class load phase",776TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_experimentalClassLoadPhaseInterval, 0, "P%d", NOT_IN_SUBSET},777{"gcNotify", "L\tlog scavenge/ggc notifications to stdout", SET_JITCONFIG_RUNTIME_FLAG(J9JIT_GC_NOTIFY) },778{"gcOnResolve", "D[=<nnn>]\tscavenge on every resolve, or every resolve after nnn",779TR::Options::gcOnResolveOption, 0, 0, "F=%d"},780{"GCRQueuedThresholdForCounting=", "M<nnn>\tDisable GCR counting if number of queued GCR requests exceeds this threshold",781TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_GCRQueuedThresholdForCounting , 0, "F%d", NOT_IN_SUBSET},782#ifdef DEBUG783{"gcTrace=", "D<nnn>\ttrace gc stack walks after gc number nnn",784TR::Options::setJitConfigNumericValue, offsetof(J9JITConfig, gcTraceThreshold), 0, "F%d"},785#endif786#if defined(J9VM_OPT_JITSERVER)787{"highActiveThreadThreshold=", " \tDefines what is a high Threshold for active compilations",788TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_highActiveThreadThreshold, 0, "F%d"},789#endif /* defined(J9VM_OPT_JITSERVER) */790{"HWProfilerAOTWarmOptLevelThreshold=", "O<nnn>\tAOT Warm Opt Level Threshold",791TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerAOTWarmOptLevelThreshold, 0, "F%d", NOT_IN_SUBSET},792{"HWProfilerBufferMaxPercentageToDiscard=", "O<nnn>\tpercentage of HW profiling buffers "793"that JIT is allowed to discard instead of processing",794TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwProfilerBufferMaxPercentageToDiscard, 0, "F%d", NOT_IN_SUBSET},795{"HWProfilerDisableAOT", "O<nnn>\tDisable RI AOT",796SET_OPTION_BIT(TR_HWProfilerDisableAOT), "F", NOT_IN_SUBSET},797{"HWProfilerDisableRIOverPrivageLinkage","O<nnn>\tDisable RI over private linkage",798SET_OPTION_BIT(TR_HWProfilerDisableRIOverPrivateLinkage), "F", NOT_IN_SUBSET},799{"HWProfilerExpirationTime=", "R<nnn>\t",800TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwProfilerExpirationTime, 0, "F%d", NOT_IN_SUBSET },801{"HWProfilerHotOptLevelThreshold=", "O<nnn>\tHot Opt Level Threshold",802TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerHotOptLevelThreshold, 0, "F%d", NOT_IN_SUBSET},803{"HWProfilerLastOptLevel=", "O<nnn>\tLast Opt level",804TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerLastOptLevel, 0, "F%d", NOT_IN_SUBSET},805{"HWProfilerNumDowngradesToTurnRION=", "R<nnn>\t",806TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_numDowngradesToTurnRION, 0, "F%d", NOT_IN_SUBSET },807{"HWProfilerNumOutstandingBuffers=", "O<nnn>\tnumber of outstanding hardware profiling buffers "808"allowed in the system. Specify 0 to disable this optimization",809TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerNumOutstandingBuffers, 0, "F%d", NOT_IN_SUBSET},810{"HWProfilerPRISamplingRate=", "O<nnn>\tP RI Scaling Factor",811TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerPRISamplingRate, 0, "F%d", NOT_IN_SUBSET},812{"HWProfilerQSZMaxThresholdToRIDowngrade=", "R<nnn>\t",813TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_qszMaxThresholdToRIDowngrade, 0, "F%d", NOT_IN_SUBSET },814{"HWProfilerQSZMinThresholdToRIDowngrade=", "R<nnn>\t",815TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_qszMinThresholdToRIDowngrade, 0, "F%d", NOT_IN_SUBSET },816{"HWProfilerQSZToTurnRION=", "R<nnn>\t",817TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_qszThresholdToTurnRION, 0, "F%d", NOT_IN_SUBSET },818{"HWProfilerRecompilationDecisionWindow=", "R<nnn>\tNumber of decisions to wait for before looking at stats decision outcome",819TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwProfilerRecompDecisionWindow, 0, "F%d", NOT_IN_SUBSET },820{"HWProfilerRecompilationFrequencyThreshold=", "R<nnn>\tLess than 1 in N decisions to recompile, turns RI off",821TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwProfilerRecompFrequencyThreshold, 0, "F%d", NOT_IN_SUBSET },822{"HWProfilerRecompilationInterval=", "O<nnn>\tRecompilation Interval",823TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerRecompilationInterval, 0, "F%d", NOT_IN_SUBSET},824{"HWProfilerReducedWarmOptLevelThreshold=", "O<nnn>\tReduced Warm Opt Level Threshold",825TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerReducedWarmOptLevelThreshold, 0, "F%d", NOT_IN_SUBSET},826{"HWProfilerRIBufferPoolSize=", "O<nnn>\tRI Buffer Pool Size",827TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerRIBufferPoolSize, 0, "F%d", NOT_IN_SUBSET},828{"HWProfilerRIBufferProcessingFrequency=", "O<nnn>\tRI Buffer Processing Frequency",829TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwProfilerRIBufferProcessingFrequency, 0, "F%d", NOT_IN_SUBSET},830{"HWProfilerRIBufferThreshold=", "O<nnn>\tRI Buffer Threshold",831TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerRIBufferThreshold, 0, "F%d", NOT_IN_SUBSET},832{"HWProfilerScorchingOptLevelThreshold=", "O<nnn>\tScorching Opt Level Threshold",833TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerScorchingOptLevelThreshold, 0, "F%d", NOT_IN_SUBSET},834{"HWProfilerWarmOptLevelThreshold=", "O<nnn>\tWarm Opt Level Threshold",835TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerWarmOptLevelThreshold, 0, "F%d", NOT_IN_SUBSET},836{"HWProfilerZRIBufferSize=", "O<nnn>\tZ RI Buffer Size",837TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerZRIBufferSize, 0, "F%d", NOT_IN_SUBSET},838{"HWProfilerZRIMode=", "O<nnn>\tZ RI Mode",839TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerZRIMode, 0, "F%d", NOT_IN_SUBSET},840{"HWProfilerZRIRGS=", "O<nnn>\tZ RI Reporting Group Size",841TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerZRIRGS, 0, "F%d", NOT_IN_SUBSET},842{"HWProfilerZRISF=", "O<nnn>\tZ RI Scaling Factor",843TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_hwprofilerZRISF, 0, "F%d", NOT_IN_SUBSET},844{"inlinefile=", "D<filename>\tinline filter defined in filename. "845"Use inlinefile=filename", TR::Options::inlinefileOption, 0, 0, "F%s"},846{"interpreterSamplingDivisor=", "R<nnn>\tThe divisor used to decrease the invocation count when an interpreted method is sampled",847TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_interpreterSamplingDivisor, 0, "F%d", NOT_IN_SUBSET},848{"interpreterSamplingThreshold=", "R<nnn>\tThe maximum invocation count at which a sampling hit will result in the count being divided by the value of interpreterSamplingDivisor",849TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_interpreterSamplingThreshold, 0, "F%d", NOT_IN_SUBSET},850{"interpreterSamplingThresholdInJSR292=", "R<nnn>\tThe maximum invocation count at which a sampling hit will result in the count being divided by the value of interpreterSamplingDivisor on a MethodHandle-oriented workload",851TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_interpreterSamplingThresholdInJSR292, 0, "F%d", NOT_IN_SUBSET},852{"interpreterSamplingThresholdInStartupMode=", "R<nnn>\tThe maximum invocation count at which a sampling hit will result in the count being divided by the value of interpreterSamplingDivisor",853TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_interpreterSamplingThresholdInStartupMode, 0, "F%d", NOT_IN_SUBSET},854{"invocationThresholdToTriggerLowPriComp=", "M<nnn>\tNumber of times a loopy method must be invoked to be eligible for LPQ",855TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_invocationThresholdToTriggerLowPriComp, 0, "F%d", NOT_IN_SUBSET },856{"iprofilerBufferInterarrivalTimeToExitDeepIdle=", "M<nnn>\tIn ms. If 4 IP buffers arrive back-to-back more frequently than this value, JIT exits DEEP_IDLE",857TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iProfilerBufferInterarrivalTimeToExitDeepIdle, 0, "F%d", NOT_IN_SUBSET },858{"iprofilerBufferMaxPercentageToDiscard=", "O<nnn>\tpercentage of interpreter profiling buffers "859"that JIT is allowed to discard instead of processing",860TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerBufferMaxPercentageToDiscard, 0, "F%d", NOT_IN_SUBSET},861{"iprofilerBufferSize=", "I<nnn>\t set the size of each iprofiler buffer",862TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerBufferSize, 0, "F%d", NOT_IN_SUBSET},863{"iprofilerFailHistorySize=", "I<nnn>\tNumber of entries for the failure history buffer maintained by Iprofiler",864TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerFailHistorySize, 0, "F%d", NOT_IN_SUBSET},865{"iprofilerFailRateThreshold=", "I<nnn>\tReactivate Iprofiler if fail rate exceeds this threshold. 1-100",866TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerFailRateThreshold, 0, "F%d", NOT_IN_SUBSET},867{"iprofilerIntToTotalSampleRatio=", "O<nnn>\tRatio of Interpreter samples to Total samples",868TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerIntToTotalSampleRatio, 0, "F%d", NOT_IN_SUBSET},869{"iprofilerMaxCount=", "O<nnn>\tmax invocation count for IProfiler to be active",870TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_maxIprofilingCount, 0, "F%d", NOT_IN_SUBSET},871{"iprofilerMaxCountInStartupMode=", "O<nnn>\tmax invocation count for IProfiler to be active in STARTUP phase",872TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_maxIprofilingCountInStartupMode, 0, "F%d", NOT_IN_SUBSET},873{"iprofilerMemoryConsumptionLimit=", "O<nnn>\tlimit on memory consumption for interpreter profiling data",874TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iProfilerMemoryConsumptionLimit, 0, "P%d", NOT_IN_SUBSET},875{"iprofilerNumOutstandingBuffers=", "O<nnn>\tnumber of outstanding interpreter profiling buffers "876"allowed in the system. Specify 0 to disable this optimization",877TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerNumOutstandingBuffers, 0, "F%d", NOT_IN_SUBSET},878{"iprofilerOffDivisionFactor=", "O<nnn>\tCounts Division factor when IProfiler is Off",879TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_IprofilerOffDivisionFactor, 0, "F%d", NOT_IN_SUBSET},880{"iprofilerOffSubtractionFactor=", "O<nnn>\tCounts Subtraction factor when IProfiler is Off",881TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_IprofilerOffSubtractionFactor, 0, "F%d", NOT_IN_SUBSET},882{"iprofilerSamplesBeforeTurningOff=", "O<nnn>\tnumber of interpreter profiling samples "883"needs to be taken after the profiling starts going off to completely turn it off. "884"Specify a very large value to disable this optimization",885TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerSamplesBeforeTurningOff, 0, "P%d", NOT_IN_SUBSET},886{"itFileNamePrefix=", "L<filename>\tprefix for itrace filename",887TR::Options::setStringForPrivateBase, offsetof(TR_JitPrivateConfig,itraceFileNamePrefix), 0, "P%s"},888{"jProfilingEnablementSampleThreshold=", "M<nnn>\tNumber of global samples to allow generation of JProfiling bodies",889TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_jProfilingEnablementSampleThreshold, 0, "F%d", NOT_IN_SUBSET },890{"kcaoffsets", "I\tGenerate a header file with offset data for use with KCA", TR::Options::kcaOffsets, 0, 0, "F" },891{"largeTranslationTime=", "D<nnn>\tprint IL trees for methods that take more than this value (usec)"892"to compile. Need to have a log file defined on command line",893TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_largeTranslationTime, 0, "F%d", NOT_IN_SUBSET},894{"limit=", "D<xxx>\tonly compile methods beginning with xxx", TR::Options::limitOption, 0, 0, "P%s"},895{"limitfile=", "D<filename>\tfilter method compilation as defined in filename. "896"Use limitfile=(filename,firstLine,lastLine) to limit lines considered from firstLine to lastLine",897TR::Options::limitfileOption, 0, 0, "F%s"},898{"loadExclude=", "D<xxx>\tdo not relocate AOT methods beginning with xxx", TR::Options::loadLimitOption, 1, 0, "P%s"},899{"loadLimit=", "D<xxx>\tonly relocate AOT methods beginning with xxx", TR::Options::loadLimitOption, 0, 0, "P%s"},900{"loadLimitFile=", "D<filename>\tfilter AOT method relocation as defined in filename. "901"Use loadLimitfile=(filename,firstLine,lastLine) to limit lines considered from firstLine to lastLine",902TR::Options::loadLimitfileOption, 0, 0, "P%s"},903{"localCSEFrequencyThreshold=", "O<nnn>\tBlocks with frequency lower than the threshold will not be considered by localCSE",904TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_localCSEFrequencyThreshold, 0, "F%d", NOT_IN_SUBSET },905{"loopyMethodDivisionFactor=", "O<nnn>\tCounts Division factor for Loopy methods",906TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_LoopyMethodDivisionFactor, 0, "F%d", NOT_IN_SUBSET},907{"loopyMethodSubtractionFactor=", "O<nnn>\tCounts Subtraction factor for Loopy methods",908TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_LoopyMethodSubtractionFactor, 0, "F%d", NOT_IN_SUBSET},909{"lowerBoundNumProcForScaling=", "M<nnn>\tLower than this numProc we'll use the default scorchingSampleThreshold",910TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_lowerBoundNumProcForScaling, 0, "F%d", NOT_IN_SUBSET},911{"lowVirtualMemoryMBThreshold=","M<nnn>\tThreshold when we declare we are running low on virtual memory. Use 0 to disable the feature",912TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_lowVirtualMemoryMBThreshold, 0, "F%d", NOT_IN_SUBSET},913{"maxCheckcastProfiledClassTests=", "R<nnn>\tnumber inlined profiled classes for profiledclass test in checkcast/instanceof",914TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_maxCheckcastProfiledClassTests, 0, "F%d", NOT_IN_SUBSET},915{"maxOnsiteCacheSlotForInstanceOf=", "R<nnn>\tnumber of onsite cache slots for instanceOf",916TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_maxOnsiteCacheSlotForInstanceOf, 0, "F%d", NOT_IN_SUBSET},917{"minSamplingPeriod=", "R<nnn>\tminimum number of milliseconds between samples for hotness",918TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_minSamplingPeriod, 0, "P%d", NOT_IN_SUBSET},919{"minSuperclassArraySize=", "I<nnn>\t set the size of the minimum superclass array size",920TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_minimumSuperclassArraySize, 0, "F%d", NOT_IN_SUBSET},921{"noregmap", 0, RESET_JITCONFIG_RUNTIME_FLAG(J9JIT_CG_REGISTER_MAPS) },922{"numCodeCachesOnStartup=", "R<nnn>\tnumber of code caches to create at startup",923TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_numCodeCachesToCreateAtStartup, 0, "F%d", NOT_IN_SUBSET},924{"numDLTBufferMatchesToEagerlyIssueCompReq=", "R<nnn>\t",925TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_numDLTBufferMatchesToEagerlyIssueCompReq, 0, "F%d", NOT_IN_SUBSET},926{"numInterpCompReqToExitIdleMode=", "M<nnn>\tNumber of first time comp. req. that takes the JIT out of idle mode",927TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_numFirstTimeCompilationsToExitIdleMode, 0, "F%d", NOT_IN_SUBSET },928#if defined(J9VM_OPT_JITSERVER)929{"oldAge=", " \tDefines what an old JITServer cache entry means",930TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_oldAge, 0, "F%d"},931{"oldAgeUnderLowMemory=", " \tDefines what an old JITServer cache entry means when memory is low",932TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_oldAgeUnderLowMemory, 0, "F%d" },933#endif /* defined(J9VM_OPT_JITSERVER) */934{"profileAllTheTime=", "R<nnn>\tInterpreter profiling will be on all the time",935TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_profileAllTheTime, 0, "F%d", NOT_IN_SUBSET},936{"queuedInvReqThresholdToDowngradeOptLevel=", "M<nnn>\tDowngrade opt level if too many inv req",937TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_numQueuedInvReqToDowngradeOptLevel , 0, "F%d", NOT_IN_SUBSET},938{"queueSizeThresholdToDowngradeDuringCLP=", "M<nnn>\tCompilation queue size threshold (interpreted methods) when opt level is downgraded during class load phase",939TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_qsziThresholdToDowngradeDuringCLP, 0, "F%d", NOT_IN_SUBSET },940{"queueSizeThresholdToDowngradeOptLevel=", "M<nnn>\tCompilation queue size threshold when opt level is downgraded",941TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_qszThresholdToDowngradeOptLevel , 0, "F%d", NOT_IN_SUBSET},942{"queueSizeThresholdToDowngradeOptLevelDuringStartup=", "M<nnn>\tCompilation queue size threshold when opt level is downgraded during startup phase",943TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_qszThresholdToDowngradeOptLevelDuringStartup , 0, "F%d", NOT_IN_SUBSET },944#if defined(J9VM_OPT_JITSERVER)945{"reconnectWaitTimeMs=", " \tInitial wait time in milliseconds until attempting to reconnect to JITServer",946TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_reconnectWaitTimeMs, 0, "F%d", NOT_IN_SUBSET},947#endif /* defined(J9VM_OPT_JITSERVER) */948{"regmap", 0, SET_JITCONFIG_RUNTIME_FLAG(J9JIT_CG_REGISTER_MAPS) },949{"relaxedCompilationLimitsSampleThreshold=", "R<nnn>\tGlobal samples below this threshold means we can use higher compilation limits",950TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_relaxedCompilationLimitsSampleThreshold, 0, "F%d", NOT_IN_SUBSET },951{"resetCountThreshold=", "R<nnn>\tThe number of global samples which if exceed during a method's sampling interval will cause the method's sampling counter to be incremented by the number of samples in a sampling interval",952TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_resetCountThreshold, 0, "F%d", NOT_IN_SUBSET},953{"rtlog=", "L<filename>\twrite verbose run-time output to filename",954TR::Options::setStringForPrivateBase, offsetof(TR_JitPrivateConfig,rtLogFileName), 0, "P%s"},955{"rtResolve", "D\ttreat all data references as unresolved", SET_JITCONFIG_RUNTIME_FLAG(J9JIT_RUNTIME_RESOLVE) },956{"safeReservePhysicalMemoryValue=", "C<nnn>\tsafe buffer value before we risk running out of physical memory, in KB",957TR::Options::setStaticNumericKBAdjusted, (intptr_t)&TR::Options::_safeReservePhysicalMemoryValue, 0, "F%d (bytes)"},958{"sampleDontSwitchToProfilingThreshold=", "R<nnn>\tThe maximum number of global samples taken during a sample interval for which the method is denied swithing to profiling",959TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_sampleDontSwitchToProfilingThreshold, 0, "F%d", NOT_IN_SUBSET},960{"sampleThresholdVariationAllowance=", "R<nnn>\tThe percentage that we add or subtract from"961" the original threshold to adjust for method code size."962" Must be 0--100. Make it 0 to disable this optimization.",963TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_sampleThresholdVariationAllowance, 0, "P%d", NOT_IN_SUBSET},964{"samplingFrequencyInDeepIdleMode=", "R<nnn>\tnumber of milliseconds between samples for hotness - in deep idle mode",965TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_samplingFrequencyInDeepIdleMode, 0, "F%d", NOT_IN_SUBSET},966{"samplingFrequencyInIdleMode=", "R<nnn>\tnumber of milliseconds between samples for hotness - in idle mode",967TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_samplingFrequencyInIdleMode, 0, "F%d", NOT_IN_SUBSET},968{"samplingHeartbeatInterval=", "R<nnn>\tnumber of 100ms periods before sampling heartbeat",969TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_sampleHeartbeatInterval, 0, "F%d", NOT_IN_SUBSET},970{"samplingThreadExpirationTime=", "R<nnn>\tnumber of seconds after which point we will stop the sampling thread",971TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_samplingThreadExpirationTime, 0, "F%d", NOT_IN_SUBSET},972{"scorchingSampleThreshold=", "R<nnn>\tThe maximum number of global samples taken during a sample interval for which the method will be recompiled as scorching",973TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_scorchingSampleThreshold, 0, "F%d", NOT_IN_SUBSET},974#if defined(J9VM_OPT_JITSERVER)975{"scratchSpaceFactorWhenJITServerWorkload=","M<nnn>\tMultiplier for scratch space limit at JITServer",976TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_scratchSpaceFactorWhenJITServerWorkload, 0, "F%d", NOT_IN_SUBSET},977#endif /* defined(J9VM_OPT_JITSERVER) */978{"scratchSpaceFactorWhenJSR292Workload=","M<nnn>\tMultiplier for scratch space limit when MethodHandles are in use",979TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_scratchSpaceFactorWhenJSR292Workload, 0, "F%d", NOT_IN_SUBSET},980{"scratchSpaceLimitKBForHotCompilations=","M<nnn>\tLimit for memory used by JIT when compiling at hot and above (in KB)",981TR::Options::setStaticNumericKBAdjusted, (intptr_t)&TR::Options::_scratchSpaceLimitForHotCompilations, 0, "F%d (bytes)", NOT_IN_SUBSET},982{"scratchSpaceLimitKBWhenLowVirtualMemory=","M<nnn>\tLimit for memory used by JIT when running on low virtual memory",983TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_scratchSpaceLimitKBWhenLowVirtualMemory, 0, "F%d", NOT_IN_SUBSET},984{"secondaryClassLoadPhaseThreshold=", "O<nnn>\tWhen class load rate just dropped under the CLP threshold "985"we use this secondary threshold to determine class load phase",986TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_secondaryClassLoadingPhaseThreshold, 0, "F%d", NOT_IN_SUBSET},987{"seriousCompFailureThreshold=", "M<nnn>\tnumber of srious compilation failures after which we write a trace point in the snap file",988TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_seriousCompFailureThreshold, 0, "F%d", NOT_IN_SUBSET},989#if defined(J9VM_OPT_JITSERVER)990{"sharedROMClassCacheNumPartitions=", " \tnumber of JITServer ROMClass cache partitions (each has its own monitor)",991TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_sharedROMClassCacheNumPartitions, 0, "F%d", NOT_IN_SUBSET},992#endif /* defined(J9VM_OPT_JITSERVER) */993{"singleCache", "C\tallow only one code cache and one data cache to be allocated", RESET_JITCONFIG_RUNTIME_FLAG(J9JIT_GROW_CACHES) },994{"smallMethodBytecodeSizeThreshold=", "O<nnn> \tThreshold for determining small methods "995"(measured in number of bytecodes)",996TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_smallMethodBytecodeSizeThreshold, 0, "F%d", NOT_IN_SUBSET},997{"smallMethodBytecodeSizeThresholdForCold=", "O<nnn>\tThreshold for determining small methods at cold "998"(measured in number of bytecodes)",999TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_smallMethodBytecodeSizeThresholdForCold, 0, "F%d", NOT_IN_SUBSET},1000{"smallMethodBytecodeSizeThresholdForJITServerAOTCache=", "O<nnn>\tThreshold for determining small methods that should "1001"not be converted to AOT, but rather be jitted remotely",1002TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_smallMethodBytecodeSizeThresholdForJITServerAOTCache, 0, "F%d", NOT_IN_SUBSET},1003{"stack=", "C<nnn>\tcompilation thread stack size in KB",1004TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_stackSize, 0, "F%d", NOT_IN_SUBSET},1005#if defined(J9VM_OPT_JITSERVER)1006{"statisticsFrequency=", "R<nnn>\tnumber of milliseconds between statistics print",1007TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_statisticsFrequency, 0, "F%d", NOT_IN_SUBSET},1008#endif /* defined(J9VM_OPT_JITSERVER) */1009{"testMode", "D\tequivalent to tossCode", SET_JITCONFIG_RUNTIME_FLAG(J9JIT_TOSS_CODE) },1010#if defined(J9VM_OPT_JITSERVER)1011{"timeBetweenPurges=", " \tDefines how often we are willing to scan for old entries to be purged",1012TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_timeBetweenPurges, 0, "F%d"},1013#endif /* defined(J9VM_OPT_JITSERVER) */1014#if defined(TR_HOST_X86) || defined(TR_HOST_POWER) || defined(TR_HOST_ARM64)1015{"tlhPrefetchBoundaryLineCount=", "O<nnn>\tallocation prefetch boundary line for allocation prefetch",1016TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_TLHPrefetchBoundaryLineCount, 0, "P%d", NOT_IN_SUBSET},1017{"tlhPrefetchLineCount=", "O<nnn>\tallocation prefetch line count for allocation prefetch",1018TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_TLHPrefetchLineCount, 0, "P%d", NOT_IN_SUBSET},1019{"tlhPrefetchLineSize=", "O<nnn>\tallocation prefetch line size for allocation prefetch",1020TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_TLHPrefetchLineSize, 0, "P%d", NOT_IN_SUBSET},1021{"tlhPrefetchSize=", "O<nnn>\tallocation prefetch size for allocation prefetch",1022TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_TLHPrefetchSize, 0, "P%d", NOT_IN_SUBSET},1023{"tlhPrefetchStaggeredLineCount=", "O<nnn>\tallocation prefetch staggered line for allocation prefetch",1024TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_TLHPrefetchStaggeredLineCount, 0, "P%d", NOT_IN_SUBSET},1025{"tlhPrefetchTLHEndLineCount=", "O<nnn>\tallocation prefetch line count for end of TLH check",1026TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_TLHPrefetchTLHEndLineCount, 0, "P%d", NOT_IN_SUBSET},1027#endif1028{"tossCode", "D\tthrow code and data away after compiling", SET_JITCONFIG_RUNTIME_FLAG(J9JIT_TOSS_CODE) },1029{"tprof", "D\tgenerate time profiles with SWTRACE (requires -Xrunjprof12x:jita2n)",1030TR::Options::tprofOption, 0, 0, "F"},1031{"updateFreeMemoryMinPeriod=", "R<nnn>\tnumber of milliseconds after which point we will update the free physical memory available",1032TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_updateFreeMemoryMinPeriod, 0, "F%d", NOT_IN_SUBSET},1033{"upperBoundNumProcForScaling=", "M<nnn>\tHigher than this numProc we'll use the conservativeScorchingSampleThreshold",1034TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_upperBoundNumProcForScaling, 0, "F%d", NOT_IN_SUBSET},1035{ "userClassLoadPhaseThreshold=", "O<nnn>\tnumber of user classes loaded per sampling tick that "1036"needs to be attained to enter the class loading phase. "1037"Specify a very large value to disable this optimization",1038TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_userClassLoadingPhaseThreshold, 0, "P%d", NOT_IN_SUBSET },1039{"verbose", "L\twrite compiled method names to vlog file or stdout in limitfile format",1040TR::Options::setVerboseBitsInJitPrivateConfig, offsetof(J9JITConfig, privateConfig), 5, "F=1"},1041{"verbose=", "L{regex}\tlist of verbose output to write to vlog or stdout",1042TR::Options::setVerboseBitsInJitPrivateConfig, offsetof(J9JITConfig, privateConfig), 0, "F"},1043{"version", "L\tdisplay the jit build version",1044TR::Options::versionOption, 0, 0, "F"},1045#if defined(J9VM_OPT_JITSERVER)1046{"veryHighActiveThreadThreshold=", " \tDefines what is a very high Threshold for active compilations",1047TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_veryHighActiveThreadThreshold, 0, "F%d"},1048#endif /* defined(J9VM_OPT_JITSERVER) */1049{"veryHotSampleThreshold=", "R<nnn>\tThe maximum number of global samples taken during a sample interval for which the method will be recompiled at hot with normal priority",1050TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_veryHotSampleThreshold, 0, "F%d", NOT_IN_SUBSET},1051{"vlog=", "L<filename>\twrite verbose output to filename",1052TR::Options::setString, offsetof(J9JITConfig,vLogFileName), 0, "F%s"},1053{"vmState=", "L<vmState>\tdecode a given vmState",1054TR::Options::vmStateOption, 0, 0, "F"},1055{"waitTimeToEnterDeepIdleMode=", "M<nnn>\tTime spent in idle mode (ms) after which we enter deep idle mode sampling",1056TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_waitTimeToEnterDeepIdleMode, 0, "F%d", NOT_IN_SUBSET},1057{"waitTimeToEnterIdleMode=", "M<nnn>\tIdle time (ms) after which we enter idle mode sampling",1058TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_waitTimeToEnterIdleMode, 0, "F%d", NOT_IN_SUBSET},1059{"waitTimeToExitStartupMode=", "M<nnn>\tTime (ms) spent outside startup needed to declare NON_STARTUP mode",1060TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_waitTimeToExitStartupMode, 0, "F%d", NOT_IN_SUBSET},1061{"waitTimeToGCR=", "M<nnn>\tTime (ms) spent outside startup needed to start guarded counting recompilations",1062TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_waitTimeToGCR, 0, "F%d", NOT_IN_SUBSET},1063{"waitTimeToStartIProfiler=", "M<nnn>\tTime (ms) spent outside startup needed to start IProfiler if it was off",1064TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_waitTimeToStartIProfiler, 0, "F%d", NOT_IN_SUBSET},1065{"weightOfAOTLoad=", "M<nnn>\tWeight of an AOT load. 0 by default",1066TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_weightOfAOTLoad, 0, "F%d", NOT_IN_SUBSET},1067{"weightOfJSR292=", "M<nnn>\tWeight of an JSR292 compilation. Number between 0 and 255",1068TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_weightOfJSR292, 0, "F%d", NOT_IN_SUBSET },1069{0}1070};107110721073bool J9::Options::showOptionsInEffect()1074{1075if (this == TR::Options::getAOTCmdLineOptions() && self()->getOption(TR_NoLoadAOT) && self()->getOption(TR_NoStoreAOT))1076return false;1077else1078return (TR::Options::isAnyVerboseOptionSet(TR_VerboseOptions, TR_VerboseExtended));1079}10801081// z/OS tool FIXMAPC doesn't allow duplicated ASID statements.1082// For the case of -Xjit:verbose={mmap} and -Xaot:verbose={mmap} will generate two ASID statements.1083// Make sure only have one ASID statement1084bool J9::Options::showPID()1085{1086static bool showedAlready=false;10871088if (!showedAlready)1089{1090if (TR::Options::getVerboseOption(TR_VerboseMMap))1091{1092showedAlready = true;1093return true;1094}1095}1096return false;1097}10981099#if defined(J9VM_OPT_JITSERVER)1100static std::string readFileToString(char *fileName)1101{1102PORT_ACCESS_FROM_PORT(TR::Compiler->portLib);1103FILE *f = fopen(fileName, "rb");1104if (!f)1105{1106j9tty_printf(PORTLIB, "Fatal Error: Unable to open file (%s)\n", fileName);1107return "";1108}1109const uint32_t BUFFER_SIZE = 4096; // 4KB1110const uint32_t MAX_FILE_SIZE_IN_PAGES = 16; // 64KB1111char buf[BUFFER_SIZE];1112std::string fileStr("");1113int readSize = 0;1114int iter = 0;1115do {1116readSize = fread(buf, 1, BUFFER_SIZE, f);1117fileStr = fileStr.append(buf, readSize);1118++iter;1119} while ((readSize == BUFFER_SIZE) && (iter <= MAX_FILE_SIZE_IN_PAGES));1120fclose(f);11211122if (iter <= MAX_FILE_SIZE_IN_PAGES)1123{1124return fileStr;1125}1126else1127{1128j9tty_printf(1129PORTLIB,1130"Fatal Error: File (%s) is too large, max allowed size is %dKB\n",1131fileName,1132BUFFER_SIZE * MAX_FILE_SIZE_IN_PAGES / 1000);1133return "";1134}1135}11361137static bool JITServerParseCommonOptions(J9JavaVM *vm, TR::CompilationInfo *compInfo)1138{1139const char *xxJITServerPortOption = "-XX:JITServerPort=";1140const char *xxJITServerTimeoutOption = "-XX:JITServerTimeout=";1141const char *xxJITServerSSLKeyOption = "-XX:JITServerSSLKey=";1142const char *xxJITServerSSLCertOption = "-XX:JITServerSSLCert=";1143const char *xxJITServerSSLRootCertsOption = "-XX:JITServerSSLRootCerts=";1144const char *xxJITServerUseAOTCacheOption = "-XX:+JITServerUseAOTCache";1145const char *xxDisableJITServerUseAOTCacheOption = "-XX:-JITServerUseAOTCache";1146const char *xxRequireJITServerOption = "-XX:+RequireJITServer";1147const char *xxDisableRequireJITServerOption = "-XX:-RequireJITServer";1148const char *xxJITServerLogConnections = "-XX:+JITServerLogConnections";1149const char *xxDisableJITServerLogConnections = "-XX:-JITServerLogConnections";11501151int32_t xxJITServerPortArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerPortOption, 0);1152int32_t xxJITServerTimeoutArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerTimeoutOption, 0);1153int32_t xxJITServerSSLKeyArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerSSLKeyOption, 0);1154int32_t xxJITServerSSLCertArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerSSLCertOption, 0);1155int32_t xxJITServerSSLRootCertsArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerSSLRootCertsOption, 0);1156int32_t xxJITServerUseAOTCacheArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxJITServerUseAOTCacheOption, 0);1157int32_t xxDisableJITServerUseAOTCacheArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableJITServerUseAOTCacheOption, 0);1158int32_t xxRequireJITServerArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxRequireJITServerOption, 0);1159int32_t xxDisableRequireJITServerArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableRequireJITServerOption, 0);1160int32_t xxJITServerLogConnectionsArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxJITServerLogConnections, 0);1161int32_t xxDisableJITServerLogConnectionsArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableJITServerLogConnections, 0);11621163if (xxJITServerPortArgIndex >= 0)1164{1165uint32_t port=0;1166IDATA ret = GET_INTEGER_VALUE(xxJITServerPortArgIndex, xxJITServerPortOption, port);1167if (ret == OPTION_OK)1168compInfo->getPersistentInfo()->setJITServerPort(port);1169}11701171if (xxRequireJITServerArgIndex > xxDisableRequireJITServerArgIndex)1172{1173// If a debugging option to require JITServer connection is enabled, increase socket timeout,1174// to prevent false positives from streams failing due to timeout.1175// User-provided values still take priority.1176compInfo->getPersistentInfo()->setRequireJITServer(true);1177compInfo->getPersistentInfo()->setSocketTimeout(60000);1178}11791180if (xxJITServerTimeoutArgIndex >= 0)1181{1182uint32_t timeoutMs=0;1183IDATA ret = GET_INTEGER_VALUE(xxJITServerTimeoutArgIndex, xxJITServerTimeoutOption, timeoutMs);1184if (ret == OPTION_OK)1185compInfo->getPersistentInfo()->setSocketTimeout(timeoutMs);1186}11871188// key and cert have to be set as a pair at the server1189if ((xxJITServerSSLKeyArgIndex >= 0) && (xxJITServerSSLCertArgIndex >= 0))1190{1191char *keyFileName = NULL;1192char *certFileName = NULL;1193GET_OPTION_VALUE(xxJITServerSSLKeyArgIndex, '=', &keyFileName);1194GET_OPTION_VALUE(xxJITServerSSLCertArgIndex, '=', &certFileName);1195std::string key = readFileToString(keyFileName);1196std::string cert = readFileToString(certFileName);11971198if (!key.empty() && !cert.empty())1199{1200compInfo->addJITServerSslKey(key);1201compInfo->addJITServerSslCert(cert);1202}1203else1204{1205return false;1206}1207}12081209if (xxJITServerSSLRootCertsArgIndex >= 0)1210{1211char *fileName = NULL;1212GET_OPTION_VALUE(xxJITServerSSLRootCertsArgIndex, '=', &fileName);1213std::string cert = readFileToString(fileName);1214if (!cert.empty())1215compInfo->setJITServerSslRootCerts(cert);1216else1217return false;1218}12191220if (xxJITServerUseAOTCacheArgIndex > xxDisableJITServerUseAOTCacheArgIndex)1221compInfo->getPersistentInfo()->setJITServerUseAOTCache(true);1222else1223compInfo->getPersistentInfo()->setJITServerUseAOTCache(false);12241225if (xxJITServerLogConnectionsArgIndex > xxDisableJITServerLogConnectionsArgIndex)1226{1227TR::Options::setVerboseOption(TR_VerboseJITServerConns);1228}12291230return true;1231}1232#endif /* defined(J9VM_OPT_JITSERVER) */12331234void J9::Options::preProcessMmf(J9JavaVM *vm, J9JITConfig *jitConfig)1235{1236J9MemoryManagerFunctions * mmf = vm->memoryManagerFunctions;12371238#if defined(J9VM_GC_HEAP_CARD_TABLE)1239TR_J9VMBase * fe = TR_J9VMBase::get(jitConfig, 0);1240if (!fe->isAOT_DEPRECATED_DO_NOT_USE())1241{1242self()->setGcCardSize(mmf->j9gc_concurrent_getCardSize(vm));1243self()->setHeapBase(mmf->j9gc_concurrent_getHeapBase(vm));1244self()->setHeapTop(mmf->j9gc_concurrent_getHeapBase(vm) + mmf->j9gc_get_initial_heap_size(vm));1245}1246#endif12471248uintptr_t value;12491250value = mmf->j9gc_modron_getConfigurationValueForKey(vm, j9gc_modron_configuration_heapBaseForBarrierRange0_isVariable, &value) ? value : 0;1251self()->setIsVariableHeapBaseForBarrierRange0(value);12521253value = mmf->j9gc_modron_getConfigurationValueForKey(vm, j9gc_modron_configuration_heapSizeForBarrierRange0_isVariable, &value) ? value : 0;1254self()->setIsVariableHeapSizeForBarrierRange0(value);12551256value = mmf->j9gc_modron_getConfigurationValueForKey(vm, j9gc_modron_configuration_activeCardTableBase_isVariable, &value) ? value : 0;1257self()->setIsVariableActiveCardTableBase(value);12581259value = mmf->j9gc_modron_getConfigurationValueForKey(vm, j9gc_modron_configuration_heapAddressToCardAddressShift, &value) ? value : 0;1260self()->setHeapAddressToCardAddressShift(value);12611262// Pull the constant heap parameters from a VMThread (it doesn't matter which one).1263//1264J9VMThread *vmThread = jitConfig->javaVM->internalVMFunctions->currentVMThread(jitConfig->javaVM);12651266if (vmThread)1267{1268self()->setHeapBaseForBarrierRange0((uintptr_t)vmThread->heapBaseForBarrierRange0);1269self()->setHeapSizeForBarrierRange0((uintptr_t)vmThread->heapSizeForBarrierRange0);1270self()->setActiveCardTableBase((uintptr_t)vmThread->activeCardTableBase);1271}1272else1273{1274// The heap information could not be found at compile-time. Make sure this information1275// is loaded from the vmThread at runtime.1276//1277self()->setIsVariableHeapBaseForBarrierRange0(true);1278self()->setIsVariableHeapSizeForBarrierRange0(true);1279self()->setIsVariableActiveCardTableBase(true);1280}12811282if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_ENABLE_PORTABLE_SHARED_CACHE)1283#if defined(J9VM_OPT_CRIU_SUPPORT)1284|| vm->internalVMFunctions->isCheckpointAllowed(vmThread)1285#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */1286)1287{1288// Disable any fixed-size heap optimizations under portable shared cache mode1289self()->setIsVariableHeapSizeForBarrierRange0(true);1290}12911292#if defined(TR_TARGET_64BIT) && defined(J9ZOS390)1293PORT_ACCESS_FROM_JAVAVM(vm);12941295OMROSDesc desc;1296j9sysinfo_get_os_description(&desc);12971298// Enable RMODE64 if and only if the z/OS version has proper kernel support1299if (j9sysinfo_os_has_feature(&desc, OMRPORT_ZOS_FEATURE_RMODE64))1300{1301self()->setOption(TR_EnableRMODE64);1302}1303#endif13041305// { RTSJ Support Begin13061307#if defined(J9VM_OPT_REAL_TIME_LOCKING_SUPPORT)1308self()->setOption(TR_DisableMonitorOpts);1309#endif131013111312value = mmf->j9gc_modron_getConfigurationValueForKey(vm, j9gc_modron_configuration_allocationType,&value) ?value:0;1313if (j9gc_modron_allocation_type_segregated == value)1314self()->setRealTimeGC(true);1315else1316self()->setRealTimeGC(false);1317// } RTSJ Support End1318}13191320void J9::Options::preProcessMode(J9JavaVM *vm, J9JITConfig *jitConfig)1321{1322// Determine the mode we want to be in1323if (vm->runtimeFlags & J9_RUNTIME_AGGRESSIVE)1324{1325self()->setOption(TR_AggressiveOpts);1326}13271328// The _aggressivenessLevel is a static and needs to be set only once1329if (_aggressivenessLevel == -1) // not yet set1330{1331// Start with a default level and override as needed1332_aggressivenessLevel = TR::Options::TR_AggresivenessLevel::DEFAULT;13331334// -Xquickstart/-Xtune:quickstart, -Xtune:virtualized and -Xtune:throughput are mutually exclusive1335// This is ensured by VM option processing1336if (J9_ARE_ANY_BITS_SET(jitConfig->runtimeFlags, J9JIT_QUICKSTART))1337{1338_aggressivenessLevel = TR::Options::TR_AggresivenessLevel::QUICKSTART;1339}1340else if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_TUNE_THROUGHPUT))1341{1342_aggressivenessLevel = TR::Options::TR_AggresivenessLevel::AGGRESSIVE_THROUGHPUT;1343}1344else if (J9_ARE_ANY_BITS_SET(vm->runtimeFlags, J9_RUNTIME_TUNE_VIRTUALIZED))1345{1346_aggressivenessLevel = TR::Options::TR_AggresivenessLevel::AGGRESSIVE_AOT;1347_scratchSpaceFactorWhenJSR292Workload = 1;1348}1349else1350{1351// The aggressivenessLevel can be set directly with -XaggressivenessLevel1352// This option is a second hand citizen option; if other options contradict it, this option is1353// ignored even if it appears later1354char *aggressiveOption = "-XaggressivenessLevel";1355int32_t argIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, aggressiveOption, 0);1356if (argIndex >= 0)1357{1358UDATA aggressivenessValue = 0;1359IDATA ret = GET_INTEGER_VALUE(argIndex, aggressiveOption, aggressivenessValue);1360if (ret == OPTION_OK && aggressivenessValue >= 0)1361{1362_aggressivenessLevel = aggressivenessValue;1363}1364}1365}1366}1367}13681369void J9::Options::preProcessJniAccelerator(J9JavaVM *vm)1370{1371static bool doneWithJniAcc = false;1372char *jniAccOption = "-XjniAcc:";1373if (!doneWithJniAcc)1374{1375int32_t argIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, jniAccOption, 0);1376if (argIndex >= 0)1377{1378char *optValue;1379doneWithJniAcc = true;1380GET_OPTION_VALUE(argIndex, ':', &optValue);1381if (*optValue == '{')1382{1383if (!_debug)1384TR::Options::createDebug();1385if (_debug)1386{1387TR::SimpleRegex *mRegex;1388mRegex = TR::SimpleRegex::create(optValue);1389if (!mRegex || *optValue != 0)1390{1391TR_VerboseLog::writeLine(TR_Vlog_FAILURE, "Bad regular expression at --> '%s'", optValue);1392}1393else1394{1395TR::Options::setJniAccelerator(mRegex);1396}1397}1398}1399}1400}1401}14021403void J9::Options::preProcessCodeCacheIncreaseTotalSize(J9JavaVM *vm, J9JITConfig *jitConfig)1404{1405PORT_ACCESS_FROM_JAVAVM(vm);1406OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);14071408// Check for option to increase code cache total size1409static bool codecachetotalAlreadyParsed = false;1410if (!codecachetotalAlreadyParsed) // avoid processing twice for AOT and JIT and produce duplicate messages1411{1412codecachetotalAlreadyParsed = true;1413char *xccOption = "-Xcodecachetotal";1414char *xxccOption = "-XX:codecachetotal=";1415int32_t codeCacheTotalArgIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, xccOption, 0);1416int32_t XXcodeCacheTotalArgIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, xxccOption, 0);1417int32_t argIndex = 0;1418// Check if option is at all specified1419if (codeCacheTotalArgIndex >= 0 || XXcodeCacheTotalArgIndex >= 0)1420{1421char *ccTotalOption;1422if (XXcodeCacheTotalArgIndex > codeCacheTotalArgIndex)1423{1424argIndex = XXcodeCacheTotalArgIndex;1425ccTotalOption = xxccOption;1426}1427else1428{1429argIndex = codeCacheTotalArgIndex;1430ccTotalOption = xccOption;1431}1432UDATA ccTotalSize;1433IDATA returnCode = GET_MEMORY_VALUE(argIndex, ccTotalOption, ccTotalSize);1434if (OPTION_OK == returnCode)1435{1436ccTotalSize >>= 10; // convert to KB14371438// Impose a minimum value of 2 MB1439if (ccTotalSize < 2048)1440ccTotalSize = 2048;14411442// Restriction: total size must be a multiple of the size of one code cache1443UDATA fragmentSize = ccTotalSize % jitConfig->codeCacheKB;1444if (fragmentSize > 0) // TODO: do we want a message here?1445ccTotalSize += jitConfig->codeCacheKB - fragmentSize; // round-up14461447// Proportionally increase the data cache as well1448// Use 'double' to avoid truncation/overflow1449UDATA dcTotalSize = (double)ccTotalSize / (double)(jitConfig->codeCacheTotalKB) *1450(double)(jitConfig->dataCacheTotalKB);14511452// Round up to a multiple of the data cache size1453fragmentSize = dcTotalSize % jitConfig->dataCacheKB;1454if (fragmentSize > 0)1455dcTotalSize += jitConfig->dataCacheKB - fragmentSize;1456// Now write the values in jitConfig1457jitConfig->codeCacheTotalKB = ccTotalSize;1458// Make sure that the new value for dataCacheTotal doesn't shrink the default1459if (dcTotalSize > jitConfig->dataCacheTotalKB)1460jitConfig->dataCacheTotalKB = dcTotalSize;1461}1462else // Error with the option1463{1464// TODO: do we want a message here?1465j9nls_printf(PORTLIB, J9NLS_WARNING, J9NLS_JIT_OPTIONS_INCORRECT_MEMORY_SIZE, ccTotalOption);1466}1467}1468}1469}14701471void J9::Options::preProcessCodeCachePrintCodeCache(J9JavaVM *vm)1472{1473// -XX:+PrintCodeCache will be parsed twice into both AOT and JIT options here.1474const char *xxPrintCodeCacheOption = "-XX:+PrintCodeCache";1475const char *xxDisablePrintCodeCacheOption = "-XX:-PrintCodeCache";1476int32_t xxPrintCodeCacheArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxPrintCodeCacheOption, 0);1477int32_t xxDisablePrintCodeCacheArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisablePrintCodeCacheOption, 0);14781479if (xxPrintCodeCacheArgIndex > xxDisablePrintCodeCacheArgIndex)1480{1481self()->setOption(TR_PrintCodeCacheUsage);1482}1483}14841485bool J9::Options::preProcessCodeCacheXlpCodeCache(J9JavaVM *vm, J9JITConfig *jitConfig)1486{1487PORT_ACCESS_FROM_JAVAVM(vm);1488OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);14891490// Enable on X and Z, also on P.1491// PPC supports -Xlp:codecache option.. since it's set via environment variables. JVM should always request 4k pages.1492// fePreProcess is called twice - for AOT and JIT options parsing, which is redundant in terms of1493// processing the -Xlp:codecache options.1494// We should parse the -Xlp:codecache options only once though to avoid duplicate NLS messages.1495static bool parsedXlpCodeCacheOptions = false;14961497if (!parsedXlpCodeCacheOptions)1498{1499parsedXlpCodeCacheOptions = true;15001501UDATA requestedLargeCodePageSize = 0;1502UDATA requestedLargeCodePageFlags = J9PORT_VMEM_PAGE_FLAG_NOT_USED;1503UDATA largePageSize = 0;1504UDATA largePageFlags = 0;1505int32_t xlpCodeCacheIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, "-Xlp:codecache:", NULL);1506int32_t xlpIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, "-Xlp", NULL);15071508// Parse -Xlp:codecache:pagesize=<size> as the right most option1509if (xlpCodeCacheIndex > xlpIndex)1510{1511TR_XlpCodeCacheOptions parsingState = XLPCC_PARSING_FIRST_OPTION;1512UDATA optionNumber = 1;1513bool extraCommaWarning = false;1514char *previousOption = NULL;1515char *errorString = NULL;15161517UDATA pageSizeHowMany = 0;1518UDATA pageSizeOptionNumber = 0;1519UDATA pageableHowMany = 0;1520UDATA pageableOptionNumber = 0;1521UDATA nonPageableHowMany = 0;1522UDATA nonPageableOptionNumber = 0;15231524char *optionsString = NULL;15251526// Get Pointer to entire "-Xlp:codecache:" options string1527GET_OPTION_OPTION(xlpCodeCacheIndex, ':', ':', &optionsString);15281529// optionsString can not be NULL here, though it may point to null ('\0') character1530char *scanLimit = optionsString + strlen(optionsString);15311532// Parse -Xlp:codecache:pagesize=<size> option.1533// The proper formed -Xlp:codecache: options include1534// For X and zLinux platforms:1535// -Xlp:codecache:pagesize=<size> or1536// -Xlp:codecache:pagesize=<size>,pageable or1537// -Xlp:codecache:pagesize=<size>,nonpageable1538// For zOS platforms1539// -Xlp:codecache:pagesize=<size>,pageable or1540// -Xlp:codecache:pagesize=<size>,nonpageable1541while (optionsString < scanLimit)1542{1543if (try_scan(&optionsString, ","))1544{1545// Comma separator is discovered1546switch (parsingState)1547{1548case XLPCC_PARSING_FIRST_OPTION:1549// leading comma - ignored but warning required1550extraCommaWarning = true;1551parsingState = XLPCC_PARSING_OPTION;1552break;1553case XLPCC_PARSING_OPTION:1554// more then one comma - ignored but warning required1555extraCommaWarning = true;1556break;1557case XLPCC_PARSING_COMMA:1558// expecting for comma here, next should be an option1559parsingState = XLPCC_PARSING_OPTION;1560// next option number1561optionNumber += 1;1562break;1563case XLPCC_PARSING_ERROR:1564default:1565return false;1566}1567}1568else1569{1570// Comma separator has not been found. so1571switch (parsingState)1572{1573case XLPCC_PARSING_FIRST_OPTION:1574// still looking for parsing of first option - nothing to do1575parsingState = XLPCC_PARSING_OPTION;1576break;1577case XLPCC_PARSING_OPTION:1578// Can not recognize an option case1579errorString = optionsString;1580parsingState = XLPCC_PARSING_ERROR;1581break;1582case XLPCC_PARSING_COMMA:1583// can not find comma after option - so this is something unrecognizable at the end of known option1584errorString = previousOption;1585parsingState = XLPCC_PARSING_ERROR;1586break;1587case XLPCC_PARSING_ERROR:1588default:1589// must be unreachable states1590return false;1591}1592}15931594if (XLPCC_PARSING_ERROR == parsingState)1595{1596char *xlpOptionErrorString = errorString;1597int32_t xlpOptionErrorStringSize = 0;15981599// try to find comma to isolate unrecognized option1600char *commaLocation = strchr(errorString,',');16011602if (NULL != commaLocation)1603{1604// Comma found1605xlpOptionErrorStringSize = (size_t)(commaLocation - errorString);1606}1607else1608{1609// comma not found - print to end of string1610xlpOptionErrorStringSize = strlen(errorString);1611}1612j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_XLP_UNRECOGNIZED_OPTION, xlpOptionErrorStringSize, xlpOptionErrorString);1613return false;1614}16151616previousOption = optionsString;16171618if (try_scan(&optionsString, "pagesize="))1619{1620// Try to get memory value.1621// Given substring, we can't use GET_MEMORY_VALUE.1622// Scan for UDATA and M/m,G/g,K/k manually.1623UDATA scanResult = scan_udata(&optionsString, &requestedLargeCodePageSize);16241625// First scan for the integer string.1626if (0 != scanResult)1627{1628if (1 == scanResult)1629j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_MUST_BE_NUMBER, "pagesize=");1630else1631j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_VALUE_OVERFLOWED, "pagesize=");1632j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_INCORRECT_MEMORY_SIZE, "-Xlp:codecache:pagesize=<size>");1633return false;1634}16351636// Check for size qualifiers (G/M/K)1637UDATA qualifierShiftAmount = 0;1638if(try_scan(&optionsString, "G") || try_scan(&optionsString, "g"))1639qualifierShiftAmount = 30;1640else if(try_scan(&optionsString, "M") || try_scan(&optionsString, "m"))1641qualifierShiftAmount = 20;1642else if(try_scan(&optionsString, "K") || try_scan(&optionsString, "k"))1643qualifierShiftAmount = 10;16441645if (0 != qualifierShiftAmount)1646{1647// Check for overflow1648if (requestedLargeCodePageSize <= (((UDATA)-1) >> qualifierShiftAmount))1649{1650requestedLargeCodePageSize <<= qualifierShiftAmount;1651}1652else1653{1654j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_VALUE_OVERFLOWED, "pagesize=");1655j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_INCORRECT_MEMORY_SIZE, "-Xlp:codecache:pagesize=<size>");1656return false;1657}1658}16591660pageSizeHowMany += 1;1661pageSizeOptionNumber = optionNumber;16621663parsingState = XLPCC_PARSING_COMMA;1664}1665else if (try_scan(&optionsString, "pageable"))1666{1667pageableHowMany += 1;1668pageableOptionNumber = optionNumber;16691670parsingState = XLPCC_PARSING_COMMA;1671}1672else if (try_scan(&optionsString, "nonpageable"))1673{1674nonPageableHowMany += 1;1675nonPageableOptionNumber = optionNumber;16761677parsingState = XLPCC_PARSING_COMMA;1678}1679}16801681// post-parse check for trailing comma(s)1682switch (parsingState)1683{1684// if loop ended in one of these two states extra comma warning required1685case XLPCC_PARSING_FIRST_OPTION:1686case XLPCC_PARSING_OPTION:1687// trailing comma(s) or comma(s) alone1688extraCommaWarning = true;1689break;1690case XLPCC_PARSING_COMMA:1691// loop ended at comma search state - do nothing1692break;1693case XLPCC_PARSING_ERROR:1694default:1695// must be unreachable states1696return false;1697}16981699// Verify "pagesize=<size>" option.1700// This option must be specified for all platforms.1701if (0 == pageSizeHowMany)1702{1703j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_XLP_INCOMPLETE_OPTION, "-Xlp:codecache:", "pagesize=");1704return false;1705}17061707#if defined(J9ZOS390)1708// [non]pageable option must be specified for Z platforms1709if ((0 == pageableHowMany) && (0 == nonPageableHowMany))1710{1711// [non]pageable not found1712char *xlpOptionErrorString = "-Xlp:codecache:";1713char *xlpMissingOptionString = "[non]pageable";17141715j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_JIT_OPTIONS_XLP_INCOMPLETE_OPTION, xlpOptionErrorString, xlpMissingOptionString);1716return false;1717}17181719// Check for the right most option is most right1720if (pageableOptionNumber > nonPageableOptionNumber)1721requestedLargeCodePageFlags = J9PORT_VMEM_PAGE_FLAG_PAGEABLE;1722else1723requestedLargeCodePageFlags = J9PORT_VMEM_PAGE_FLAG_FIXED;17241725#endif // defined(J9ZOS390)17261727// print extra comma ignored warning1728if (extraCommaWarning)1729j9nls_printf(PORTLIB, J9NLS_INFO, J9NLS_JIT_OPTIONS_XLP_EXTRA_COMMA);1730}1731// Parse Size -Xlp<size>1732else if (xlpIndex >= 0)1733{1734// GET_MEMORY_VALUE macro casts it's second parameter to (char**)&, so a pointer to the option string is passed rather than the string literal.1735char *lpOption = "-Xlp";1736GET_MEMORY_VALUE(xlpIndex, lpOption, requestedLargeCodePageSize);1737}17381739if (requestedLargeCodePageSize != 0)1740{1741// Check to see if requested size is valid1742BOOLEAN isRequestedSizeSupported = FALSE;1743largePageSize = requestedLargeCodePageSize;1744largePageFlags = requestedLargeCodePageFlags;174517461747// j9vmem_find_valid_page_size happened to be changed to always return 01748// However formally the function type still be IDATA so assert if it returns anything else1749j9vmem_find_valid_page_size(J9PORT_VMEM_MEMORY_MODE_EXECUTE, &largePageSize, &largePageFlags, &isRequestedSizeSupported);17501751if (!isRequestedSizeSupported)1752{1753// Generate warning message for user that requested page sizes / type is not supported.1754char *oldQualifier, *newQualifier;1755char *oldPageType = NULL;1756char *newPageType = NULL;1757UDATA oldSize = requestedLargeCodePageSize;1758UDATA newSize = largePageSize;17591760// Convert size to K,M,G qualifiers.1761qualifiedSize(&oldSize, &oldQualifier);1762qualifiedSize(&newSize, &newQualifier);17631764if (0 == (J9PORT_VMEM_PAGE_FLAG_NOT_USED & requestedLargeCodePageFlags))1765oldPageType = getLargePageTypeString(requestedLargeCodePageFlags);17661767if (0 == (J9PORT_VMEM_PAGE_FLAG_NOT_USED & largePageFlags))1768newPageType = getLargePageTypeString(largePageFlags);17691770if (NULL == oldPageType)1771{1772if (NULL == newPageType)1773j9nls_printf(PORTLIB, J9NLS_INFO, J9NLS_JIT_OPTIONS_LARGE_PAGE_SIZE_NOT_SUPPORTED, oldSize, oldQualifier, newSize, newQualifier);1774else1775j9nls_printf(PORTLIB, J9NLS_INFO, J9NLS_JIT_OPTIONS_LARGE_PAGE_SIZE_NOT_SUPPORTED_WITH_NEW_PAGETYPE, oldSize, oldQualifier, newSize, newQualifier, newPageType);1776}1777else1778{1779if (NULL == newPageType)1780j9nls_printf(PORTLIB, J9NLS_INFO, J9NLS_JIT_OPTIONS_LARGE_PAGE_SIZE_NOT_SUPPORTED_WITH_REQUESTED_PAGETYPE, oldSize, oldQualifier, oldPageType, newSize, newQualifier);1781else1782j9nls_printf(PORTLIB, J9NLS_INFO, J9NLS_JIT_OPTIONS_LARGE_PAGE_SIZE_NOT_SUPPORTED_WITH_PAGETYPE, oldSize, oldQualifier, oldPageType, newSize, newQualifier, newPageType);1783}1784}1785}1786// When no -Xlp arguments are passed, we should use preferred page sizes1787else1788{1789UDATA *pageSizes = j9vmem_supported_page_sizes();1790UDATA *pageFlags = j9vmem_supported_page_flags();1791largePageSize = pageSizes[0]; // Default page size is always the first element1792largePageFlags = pageFlags[0];17931794UDATA preferredPageSize = 0;1795UDATA hugePreferredPageSize = 0;1796#if defined(TR_TARGET_POWER)1797preferredPageSize = 65536;1798#elif (defined(LINUX) && defined(TR_TARGET_X86))1799preferredPageSize = 2097152;1800hugePreferredPageSize = 0x40000000;1801#elif (defined(TR_TARGET_S390))1802preferredPageSize = 1048576;1803#endif1804if (0 != preferredPageSize)1805{1806for (UDATA pageIndex = 0; 0 != pageSizes[pageIndex]; ++pageIndex)1807{1808if ( (preferredPageSize == pageSizes[pageIndex] || hugePreferredPageSize == pageSizes[pageIndex])1809#if defined(J9ZOS390)1810/* zOS doesn't support non-pageable large pages for JIT code cache. */1811&& (0 != (J9PORT_VMEM_PAGE_FLAG_PAGEABLE & pageFlags[pageIndex]))1812#endif1813)1814{1815largePageSize = pageSizes[pageIndex];1816largePageFlags = pageFlags[pageIndex];1817}1818}1819}1820}18211822if (largePageSize > (0) && isNonNegativePowerOf2((int32_t)largePageSize))1823{1824jitConfig->largeCodePageSize = (int32_t)largePageSize;1825jitConfig->largeCodePageFlags = (int32_t)largePageFlags;1826}1827}18281829return true;1830}18311832bool J9::Options::preProcessCodeCache(J9JavaVM *vm, J9JITConfig *jitConfig)1833{1834PORT_ACCESS_FROM_JAVAVM(vm);1835OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);18361837char *ccOption = "-Xcodecache";1838int32_t argIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, ccOption, 0);1839if (argIndex >= 0)1840{1841UDATA ccSize;1842GET_MEMORY_VALUE(argIndex, ccOption, ccSize);1843ccSize >>= 10;1844jitConfig->codeCacheKB = ccSize;1845}18461847self()->preProcessCodeCacheIncreaseTotalSize(vm, jitConfig);18481849self()->preProcessCodeCachePrintCodeCache(vm);18501851if (!self()->preProcessCodeCacheXlpCodeCache(vm, jitConfig))1852{1853return false;1854}18551856return true;1857}18581859void J9::Options::preProcessSamplingExpirationTime(J9JavaVM *vm)1860{1861char *samplingOption = "-XsamplingExpirationTime";1862int32_t argIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, samplingOption, 0);1863if (argIndex >= 0)1864{1865UDATA expirationTime;1866IDATA ret = GET_INTEGER_VALUE(argIndex, samplingOption, expirationTime);1867if (ret == OPTION_OK)1868_samplingThreadExpirationTime = expirationTime;1869}1870}18711872void J9::Options::preProcessCompilationThreads(J9JavaVM *vm, J9JITConfig *jitConfig)1873{1874TR::CompilationInfo *compInfo = getCompilationInfo(jitConfig);1875char *compThreadsOption = "-XcompilationThreads";1876int32_t argIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, compThreadsOption, 0);1877if (argIndex >= 0)1878{1879UDATA numCompThreads;1880IDATA ret = GET_INTEGER_VALUE(argIndex, compThreadsOption, numCompThreads);18811882if (ret == OPTION_OK && numCompThreads > 0)1883{1884_numUsableCompilationThreads = numCompThreads;1885compInfo->updateNumUsableCompThreads(_numUsableCompilationThreads);1886}1887}1888}18891890void J9::Options::preProcessTLHPrefetch(J9JavaVM *vm)1891{1892#if defined(TR_HOST_X86) || defined(TR_HOST_POWER) || defined(TR_HOST_S390) || defined(TR_HOST_ARM64)1893bool preferTLHPrefetch;1894#if defined(TR_HOST_POWER)1895preferTLHPrefetch = TR::Compiler->target.cpu.isAtLeast(OMR_PROCESSOR_PPC_P6) && TR::Compiler->target.cpu.isAtMost(OMR_PROCESSOR_PPC_P7);1896#elif defined(TR_HOST_S390)1897preferTLHPrefetch = true;1898#elif defined(TR_HOST_ARM64)1899preferTLHPrefetch = true;1900#else // TR_HOST_X861901preferTLHPrefetch = true;1902// Disable TM on x86 because we cannot tell whether a Haswell chip supports TM or not, plus it's killing the performance on dayTrader31903self()->setOption(TR_DisableTM);1904#endif19051906IDATA notlhPrefetch = FIND_ARG_IN_VMARGS(EXACT_MATCH, "-XnotlhPrefetch", 0);1907IDATA tlhPrefetch = FIND_ARG_IN_VMARGS(EXACT_MATCH, "-XtlhPrefetch", 0);1908if (preferTLHPrefetch)1909{1910if (notlhPrefetch <= tlhPrefetch)1911{1912self()->setOption(TR_TLHPrefetch);1913}1914}1915else1916{1917if (notlhPrefetch < tlhPrefetch)1918{1919self()->setOption(TR_TLHPrefetch);1920}1921}1922#endif // defined(TR_HOST_X86) || defined(TR_HOST_POWER) || defined(TR_HOST_S390)1923}19241925void J9::Options::preProcessHwProfiler(J9JavaVM *vm)1926{1927// If the user didn't specifically ask for RI, let's enable it on some well defined platforms1928if (TR::Options::_hwProfilerEnabled == TR_maybe)1929{1930#if defined (TR_HOST_S390)1931if (vm->runtimeFlags & J9_RUNTIME_TUNE_VIRTUALIZED)1932{1933TR::Options::_hwProfilerEnabled = TR_yes;1934}1935else1936{1937TR::Options::_hwProfilerEnabled = TR_no;1938}1939#else1940TR::Options::_hwProfilerEnabled = TR_no;1941#endif1942}19431944// If RI is to be enabled, set other defaults as well1945if (TR::Options::_hwProfilerEnabled == TR_yes)1946{1947// Enable RI Based Recompilation by default1948self()->setOption(TR_EnableHardwareProfileRecompilation);19491950// Disable the RI Reduced Warm Heuristic1951self()->setOption(TR_DisableHardwareProfilerReducedWarm);19521953#if (defined(TR_HOST_POWER) && defined(TR_HOST_64BIT))1954#if defined(LINUX)1955// On Linux on Power downgrade compilations only when the compilation queue grows large1956self()->setOption(TR_UseRIOnlyForLargeQSZ);1957#endif1958self()->setOption(TR_DisableHardwareProfilerDuringStartup);1959#elif defined (TR_HOST_S390)1960self()->setOption(TR_DisableDynamicRIBufferProcessing);1961#endif1962}1963}19641965void J9::Options::preProcessDeterministicMode(J9JavaVM *vm)1966{1967// Process the deterministic mode1968if (TR::Options::_deterministicMode == -1) // not yet set1969{1970char *deterministicOption = "-XX:deterministic=";1971const UDATA MAX_DETERMINISTIC_MODE = 9; // only levels 0-9 are allowed1972int32_t argIndex = FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, deterministicOption, 0);1973if (argIndex >= 0)1974{1975UDATA deterministicMode;1976IDATA ret = GET_INTEGER_VALUE(argIndex, deterministicOption, deterministicMode);1977if (ret == OPTION_OK && deterministicMode <= MAX_DETERMINISTIC_MODE)1978{1979TR::Options::_deterministicMode = deterministicMode;1980}1981}1982}1983}19841985bool J9::Options::preProcessJitServer(J9JavaVM *vm, J9JITConfig *jitConfig)1986{1987#if defined(J9VM_OPT_JITSERVER)1988PORT_ACCESS_FROM_JAVAVM(vm);1989OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);19901991static bool JITServerAlreadyParsed = false;1992TR::CompilationInfo *compInfo = getCompilationInfo(jitConfig);1993if (!JITServerAlreadyParsed) // Avoid processing twice for AOT and JIT and produce duplicate messages1994{1995JITServerAlreadyParsed = true;1996bool disabledShareROMClasses = false;1997if (vm->internalVMFunctions->isJITServerEnabled(vm))1998{1999J9::PersistentInfo::_remoteCompilationMode = JITServer::SERVER;2000// Increase the default timeout value for JITServer.2001// It can be overridden with -XX:JITServerTimeout= option in JITServerParseCommonOptions().2002compInfo->getPersistentInfo()->setSocketTimeout(DEFAULT_JITSERVER_TIMEOUT);20032004// Check if cached ROM classes should be shared between clients2005const char *xxJITServerShareROMClassesOption = "-XX:+JITServerShareROMClasses";2006const char *xxDisableJITServerShareROMClassesOption = "-XX:-JITServerShareROMClasses";20072008int32_t xxJITServerShareROMClassesArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxJITServerShareROMClassesOption, 0);2009int32_t xxDisableJITServerShareROMClassesArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableJITServerShareROMClassesOption, 0);2010if (xxJITServerShareROMClassesArgIndex > xxDisableJITServerShareROMClassesArgIndex)2011{2012_shareROMClasses = true;2013}2014else if (xxDisableJITServerShareROMClassesArgIndex > xxJITServerShareROMClassesArgIndex)2015{2016disabledShareROMClasses = true;2017}2018}2019else2020{2021// Check option -XX:+UseJITServer2022// -XX:-UseJITServer disables JITServer at the client2023const char *xxUseJITServerOption = "-XX:+UseJITServer";2024const char *xxDisableUseJITServerOption = "-XX:-UseJITServer";20252026int32_t xxUseJITServerArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxUseJITServerOption, 0);2027int32_t xxDisableUseJITServerArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableUseJITServerOption, 0);20282029// Check if option is at all specified2030if (xxUseJITServerArgIndex > xxDisableUseJITServerArgIndex)2031{2032J9::PersistentInfo::_remoteCompilationMode = JITServer::CLIENT;2033compInfo->getPersistentInfo()->setSocketTimeout(DEFAULT_JITCLIENT_TIMEOUT);20342035// Check if the technology preview message should be displayed.2036const char *xxJITServerTechPreviewMessageOption = "-XX:+JITServerTechPreviewMessage";2037const char *xxDisableJITServerTechPreviewMessageOption = "-XX:-JITServerTechPreviewMessage";20382039int32_t xxJITServerTechPreviewMessageArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxJITServerTechPreviewMessageOption, 0);2040int32_t xxDisableJITServerTechPreviewMessageArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableJITServerTechPreviewMessageOption, 0);20412042// Only display tech preview message for Z2043if (xxJITServerTechPreviewMessageArgIndex > xxDisableJITServerTechPreviewMessageArgIndex ||2044TR::Compiler->target.cpu.isZ() && xxJITServerTechPreviewMessageArgIndex == xxDisableJITServerTechPreviewMessageArgIndex)2045{2046j9tty_printf(PORTLIB, "JITServer is currently a technology preview. Its use is not yet supported\n");2047}20482049const char *xxJITServerAddressOption = "-XX:JITServerAddress=";2050int32_t xxJITServerAddressArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerAddressOption, 0);20512052if (xxJITServerAddressArgIndex >= 0)2053{2054char *address = NULL;2055GET_OPTION_VALUE(xxJITServerAddressArgIndex, '=', &address);2056compInfo->getPersistentInfo()->setJITServerAddress(address);2057}20582059const char *xxJITServerLocalSyncCompilesOption = "-XX:+JITServerLocalSyncCompiles";2060const char *xxDisableJITServerLocalSyncCompilesOption = "-XX:-JITServerLocalSyncCompiles";20612062int32_t xxJITServerLocalSyncCompilesArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxJITServerLocalSyncCompilesOption, 0);2063int32_t xxDisableJITServerLocalSyncCompilesArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableJITServerLocalSyncCompilesOption, 0);20642065if (xxJITServerLocalSyncCompilesArgIndex > xxDisableJITServerLocalSyncCompilesArgIndex)2066{2067compInfo->getPersistentInfo()->setLocalSyncCompiles(true);2068}20692070const char *xxJITServerAOTCacheNameOption = "-XX:JITServerAOTCacheName=";2071int32_t xxJITServerAOTCacheNameArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerAOTCacheNameOption, 0);20722073if (xxJITServerAOTCacheNameArgIndex >= 0)2074{2075char *name = NULL;2076GET_OPTION_VALUE(xxJITServerAOTCacheNameArgIndex, '=', &name);2077compInfo->getPersistentInfo()->setJITServerAOTCacheName(name);2078}2079}2080}2081if (!JITServerParseCommonOptions(vm, compInfo))2082{2083// Could not parse JITServer options successfully2084return false;2085}20862087if (compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::CLIENT ||2088compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::SERVER)2089{2090// Generate a random identifier for this JITServer instance.2091// Collisions are possible, but very unlikely.2092// Using more bits for the client UID can reduce the probability of a collision further.2093std::random_device rd;2094std::mt19937_64 rng(rd());2095std::uniform_int_distribution<uint64_t> dist;2096// Generated uid must not be 02097uint64_t uid = dist(rng);2098while (0 == uid)2099uid = dist(rng);21002101if (compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::CLIENT)2102{2103compInfo->getPersistentInfo()->setClientUID(uid);2104compInfo->getPersistentInfo()->setServerUID(0);2105jitConfig->clientUID = uid;2106jitConfig->serverUID = 0;21072108// _safeReservePhysicalMemoryValue is set as 0 for the JITClient because compilations2109// are done remotely. The user can still override it with a command line option2110J9::Options::_safeReservePhysicalMemoryValue = 0;2111}2112else2113{2114compInfo->getPersistentInfo()->setClientUID(0);2115compInfo->getPersistentInfo()->setServerUID(uid);2116jitConfig->clientUID = 0;2117jitConfig->serverUID = uid;2118}21192120}2121else2122{2123// clientUID/serverUID == 0 when running a regular JVM2124compInfo->getPersistentInfo()->setClientUID(0);2125compInfo->getPersistentInfo()->setServerUID(0);2126jitConfig->clientUID = 0;2127jitConfig->serverUID = 0;2128}21292130if ((compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::SERVER) &&2131compInfo->getPersistentInfo()->getJITServerUseAOTCache() && !disabledShareROMClasses)2132{2133// Enable ROMClass sharing at the server by default (unless explicitly disabled) if using AOT cache2134_shareROMClasses = true;2135}2136if ((compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::CLIENT) &&2137compInfo->getPersistentInfo()->getJITServerUseAOTCache())2138{2139// With JITServer AOT cache, the client generates a lot of AOT compilations2140// that have GCR IL trees in them. Due to the negative affect of GCR counting2141// we want to limit the amount of time counting takes place.2142TR::Options::_GCRQueuedThresholdForCounting = 200;2143}2144}2145#endif /* defined(J9VM_OPT_JITSERVER) */2146return true;2147}21482149bool2150J9::Options::fePreProcess(void * base)2151{2152J9JITConfig * jitConfig = (J9JITConfig*)base;2153J9JavaVM * vm = jitConfig->javaVM;21542155PORT_ACCESS_FROM_JAVAVM(vm);2156OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);21572158#if defined(DEBUG) || defined(PROD_WITH_ASSUMES)2159bool forceSuffixLogs = false;2160#else2161bool forceSuffixLogs = true;2162#endif216321642165/* Using traps on z/OS for NullPointerException and ArrayIndexOutOfBound checks instead of the2166* old way of using explicit compare and branching off to a helper is causing several issues on z/OS:2167*2168* 1. When a trap fires because an exception needs to be thrown, the OS signal has to go through z/OS RTM2169* (Recovery Termination Management) and in doing so it gets serialized and has to acquire this CML lock.2170* When many concurrent exceptions are thrown, this lock gets contention.2171*2172* 2. on z/OS Management Facility, disabling traps gave performance boost because of fewer exceptions from the JCL.2173* The path length on z/OS for a trap is longer than on other operating systems so the trade-off and2174* penalty for using traps on z/OS is significantly worse than other platforms. This gives the potential2175* for significant performance loss caused by traps.2176*2177* 3. Depending on sysadmin settings, every time a trap fires, the system may get a "system dump"2178* message which shows a 0C7 abend and with lots of exceptions being thrown this clutters up the syslog.2179*2180* 4. Certain products can get in the way of the JIT signal handler so the JIT doesn't2181* receive the 0C7 signal causing the product process to get killed2182*2183* Therefore, the recommendation is to disable traps on z/OS by default.2184* Users can choose to enable traps using the "enableTraps" option.2185*/2186#if defined(J9ZOS390)2187self()->setOption(TR_DisableTraps);2188#endif21892190if (forceSuffixLogs)2191self()->setOption(TR_EnablePIDExtension);21922193if (jitConfig->runtimeFlags & J9JIT_CG_REGISTER_MAPS)2194self()->setOption(TR_RegisterMaps);21952196jitConfig->tLogFile = -1;2197jitConfig->tLogFileTemp = -1;21982199TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);2200uint32_t numProc = compInfo->getNumTargetCPUs();2201TR::Compiler->host.setNumberOfProcessors(numProc);2202TR::Compiler->target.setNumberOfProcessors(numProc);2203TR::Compiler->relocatableTarget.setNumberOfProcessors(numProc);22042205self()->preProcessMmf(vm, jitConfig);22062207if (FIND_ARG_IN_VMARGS(EXACT_MATCH, "-Xnoclassgc", 0) >= 0)2208self()->setOption(TR_NoClassGC);22092210self()->preProcessMode(vm, jitConfig);22112212self()->preProcessJniAccelerator(vm);22132214if (!self()->preProcessCodeCache(vm, jitConfig))2215{2216return false;2217}22182219self()->preProcessSamplingExpirationTime(vm);22202221self()->preProcessCompilationThreads(vm, jitConfig);22222223self()->preProcessTLHPrefetch(vm);22242225#if defined(TR_HOST_X86) || defined(TR_TARGET_POWER) || defined (TR_HOST_S390)2226self()->setOption(TR_ReservingLocks);2227#endif22282229self()->preProcessHwProfiler(vm);22302231#if defined (TR_HOST_S390)2232// On z Systems inlining very large compiled bodies proved to be worth a significant amount in terms of throughput2233// on benchmarks that we track. As such the throughput-compile-time tradeoff was significant enough to warrant the2234// inlining of very large compiled bodies on z Systems by default.2235if (vm->runtimeFlags & J9_RUNTIME_TUNE_VIRTUALIZED)2236{2237// Disable inlining of very large compiled methods only under -Xtune:virtualized2238self()->setOption(TR_InlineVeryLargeCompiledMethods, false);2239}2240else2241{2242self()->setOption(TR_InlineVeryLargeCompiledMethods);2243}2244#endif22452246// On big machines we can afford to spend more time compiling2247// (but not on zOS where customers care about CPU or on Xquickstart2248// which should be skimpy on compilation resources).2249// TR_SuspendEarly is set on zOS because test results indicate that2250// it does not benefit much by spending more time compiling.2251#if !defined(J9ZOS390)2252if (!self()->isQuickstartDetected())2253{2254// Power uses a larger SMT than X or Z2255uint32_t largeNumberOfCPUs = TR::Compiler->target.cpu.isPower() ? 64 : 32;2256if (compInfo->getNumTargetCPUs() >= largeNumberOfCPUs)2257{2258self()->setOption(TR_ConcurrentLPQ);2259self()->setOption(TR_EarlyLPQ);2260TR::Options::_expensiveCompWeight = 99; // default 202261TR::Options::_invocationThresholdToTriggerLowPriComp = 50; // default is 2502262TR::Options::_numIProfiledCallsToTriggerLowPriComp = 100; // default is 2502263TR::Options::_numDLTBufferMatchesToEagerlyIssueCompReq = 1;2264}2265}2266#else2267self()->setOption(TR_SuspendEarly);2268#endif22692270// samplingJProfiling is disabled globally. It will be enabled on a method by2271// method basis based on selected heuristic2272self()->setDisabled(OMR::samplingJProfiling, true);22732274#if defined (TR_HOST_S390)2275// Disable lock reservation due to a functional problem causing a deadlock situation in an ODM workload in Java 82276// SR5. In addition several performance issues on SPARK workloads have been reported which seem to concurrently2277// access StringBuffer objects from multiple threads.2278self()->setOption(TR_DisableLockResevation);2279// Setting number of onsite cache slots for instanceOf node to 4 on IBM Z2280self()->setMaxOnsiteCacheSlotForInstanceOf(4);2281#endif2282// Set a value for _safeReservePhysicalMemoryValue that is proportional2283// to the amount of free physical memory at boot time2284// The user can still override it with a command line option2285bool incomplete = false;2286uint64_t phMemAvail = compInfo->computeAndCacheFreePhysicalMemory(incomplete);2287if (phMemAvail != OMRPORT_MEMINFO_NOT_AVAILABLE && !incomplete)2288{2289const uint64_t reserveLimit = 32 * 1024 * 1024;2290uint64_t proposed = phMemAvail >> 6; // 64 times less2291if (proposed > reserveLimit)2292proposed = reserveLimit;2293J9::Options::_safeReservePhysicalMemoryValue = (int32_t)proposed;2294}22952296// enable TR_SelfTuningScratchMemoryUsageBeforeCompile if there is no swap memory2297J9MemoryInfo memInfo;2298if ((omrsysinfo_get_memory_info(&memInfo) == 0) && (0 == memInfo.totalSwap))2299{2300self()->setOption(TR_EnableSelfTuningScratchMemoryUsageBeforeCompile);2301}23022303self()->preProcessDeterministicMode(vm);23042305if (!TR::Compiler->target.cpu.isZ())2306self()->setOption(TR_DisableAOTBytesCompression);23072308if (!self()->preProcessJitServer(vm, jitConfig))2309{2310return false;2311}23122313#if (defined(TR_HOST_X86) || defined(TR_HOST_S390) || defined(TR_HOST_POWER)) && defined(TR_TARGET_64BIT)2314self()->setOption(TR_EnableSymbolValidationManager);2315#endif23162317return true;2318}23192320void2321J9::Options::openLogFiles(J9JITConfig *jitConfig)2322{2323char *vLogFileName = ((TR_JitPrivateConfig*)jitConfig->privateConfig)->vLogFileName;2324if (vLogFileName)2325((TR_JitPrivateConfig*)jitConfig->privateConfig)->vLogFile = fileOpen(self(), jitConfig, vLogFileName, "wb", true);23262327char *rtLogFileName = ((TR_JitPrivateConfig*)jitConfig->privateConfig)->rtLogFileName;2328if (rtLogFileName)2329((TR_JitPrivateConfig*)jitConfig->privateConfig)->rtLogFile = fileOpen(self(), jitConfig, rtLogFileName, "wb", true);2330}23312332#if defined(J9VM_OPT_JITSERVER)2333void2334J9::Options::setupJITServerOptions()2335{2336TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);23372338if (compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::SERVER ||2339compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::CLIENT)2340{2341self()->setOption(TR_DisableSamplingJProfiling);2342self()->setOption(TR_DisableProfiling); // JITServer limitation, JIT profiling data is not available to remote compiles yet2343self()->setOption(TR_DisableEDO); // JITServer limitation, EDO counters are not relocatable yet2344self()->setOption(TR_DisableMethodIsCold); // Shady heuristic; better to disable to reduce client/server traffic2345self()->setOption(TR_DisableJProfilerThread);2346self()->setOption(TR_EnableJProfiling, false);23472348if (compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::SERVER)2349{2350// The server can compile with VM access in hand because GC is not a factor here2351// For the same reason we don't have to use TR_EnableYieldVMAccess2352self()->setOption(TR_DisableNoVMAccess);23532354// IProfiler thread is not needed at JITServer because2355// no IProfiler info is collected at the server itself2356self()->setOption(TR_DisableIProfilerThread);2357J9::Compilation::setOutOfProcessCompilation();2358}23592360// In the JITServer world, expensive compilations are performed remotely so there is no risk of blowing the footprint limit on the JVM2361// Setting _expensiveCompWeight to a large value so that JSR292/hot/scorching compilation are allowed to be executed concurrently2362TR::Options::_expensiveCompWeight = TR::CompilationInfo::MAX_WEIGHT;2363}23642365if (TR::Options::getVerboseOption(TR_VerboseJITServer))2366{2367TR::PersistentInfo *persistentInfo = compInfo->getPersistentInfo();2368if (persistentInfo->getRemoteCompilationMode() == JITServer::SERVER)2369{2370JITServer::CommunicationStream::printJITServerVersion();2371TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "JITServer Server Mode. Port: %d. Connection Timeout %ums",2372persistentInfo->getJITServerPort(), persistentInfo->getSocketTimeout());2373}2374else if (persistentInfo->getRemoteCompilationMode() == JITServer::CLIENT)2375{2376JITServer::CommunicationStream::printJITServerVersion();2377TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "JITServer Client Mode. Server address: %s port: %d. Connection Timeout %ums",2378persistentInfo->getJITServerAddress().c_str(), persistentInfo->getJITServerPort(),2379persistentInfo->getSocketTimeout());2380TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "Identifier for current client JVM: %llu\n",2381(unsigned long long) compInfo->getPersistentInfo()->getClientUID());2382}2383}2384}2385#endif /* defined(J9VM_OPT_JITSERVER) */23862387bool2388J9::Options::fePostProcessJIT(void * base)2389{2390// vmPostProcess is called indirectly from the JIT_INITIALIZED phase2391// vmLatePostProcess is called indirectly from the aboutToBootstrap hook2392//2393J9JITConfig * jitConfig = (J9JITConfig*)base;2394J9JavaVM * javaVM = jitConfig->javaVM;2395PORT_ACCESS_FROM_JAVAVM(javaVM);23962397TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);2398// If user has not specified a value for compilation threads, do it now.2399// This code does not have to stay in the fePostProcessAOT because in an AOT only2400// scenario we don't need more than one compilation thread to load code.2401//2402if (_numUsableCompilationThreads <= 0)2403{2404_useCPUsToDetermineMaxNumberOfCompThreadsToActivate = true;2405if (TR::Compiler->target.isLinux())2406{2407// For linux we may want to create more threads to overcome thread2408// starvation due to lack of priorities2409//2410if (!TR::Options::getCmdLineOptions()->getOption(TR_DisableRampupImprovements) &&2411!TR::Options::getAOTCmdLineOptions()->getOption(TR_DisableRampupImprovements))2412{2413compInfo->updateNumUsableCompThreads(_numUsableCompilationThreads);2414}2415}2416if (_numUsableCompilationThreads <= 0)2417{2418// Determine the number of compilation threads based on number of online processors2419// Do not create more than numProc-1 compilation threads, but at least one2420//2421uint32_t numOnlineCPUs = j9sysinfo_get_number_CPUs_by_type(J9PORT_CPU_ONLINE);2422compInfo->updateNumUsableCompThreads(_numUsableCompilationThreads);2423_numUsableCompilationThreads = numOnlineCPUs > 1 ? std::min((numOnlineCPUs - 1), static_cast<uint32_t>(_numUsableCompilationThreads)) : 1;2424}2425}24262427// patch Lock OR if mfence is not being used2428//2429if (!self()->getOption(TR_X86UseMFENCE) && (jitConfig->runtimeFlags & J9JIT_PATCHING_FENCE_TYPE))2430jitConfig->runtimeFlags ^= J9JIT_PATCHING_FENCE_TYPE; // clear the bit24312432// Main options2433//2434// Before we do anything, hack the flag field into place2435uint32_t flags = *(uint32_t *)(&jitConfig->runtimeFlags);2436jitConfig->runtimeFlags |= flags;24372438if (jitConfig->runtimeFlags & J9JIT_TOSS_CODE)2439self()->setOption(TR_DisableAsyncCompilation, true);24402441if (jitConfig->runtimeFlags & J9JIT_RUNTIME_RESOLVE)2442jitConfig->gcOnResolveThreshold = 0;24432444if (_samplingFrequency > MAX_SAMPLING_FREQUENCY/10000) // Cap the user specified sampling frequency to "max"/100002445_samplingFrequency = MAX_SAMPLING_FREQUENCY/10000; // Too large a value can make samplingPeriod2446// negative when we multiply by loadFactor2447jitConfig->samplingFrequency = _samplingFrequency;24482449// grab vLogFileName from jitConfig and put into jitPrivateConfig, where it will be found henceforth2450TR_JitPrivateConfig *privateConfig = (TR_JitPrivateConfig*)jitConfig->privateConfig;2451privateConfig->vLogFileName = jitConfig->vLogFileName;2452self()->openLogFiles(jitConfig);24532454// Copy verbose flags from jitConfig into TR::Options static fields2455//2456TR::Options::setVerboseOptions(privateConfig->verboseFlags);24572458if (TR::Options::getVerboseOption(TR_VerboseFilters))2459{2460if (TR::Options::getDebug() && TR::Options::getDebug()->getCompilationFilters())2461{2462TR_VerboseLog::writeLine(TR_Vlog_INFO,"JIT limit filters:");2463TR::Options::getDebug()->printFilters();2464}2465}24662467#if defined(J9VM_OPT_JITSERVER)2468self()->setupJITServerOptions();2469#endif /* defined(J9VM_OPT_JITSERVER) */24702471return true;2472}24732474bool2475J9::Options::fePostProcessAOT(void * base)2476{2477J9JITConfig * jitConfig = (J9JITConfig*)base;2478J9JavaVM * javaVM = jitConfig->javaVM;2479PORT_ACCESS_FROM_JAVAVM(javaVM);24802481self()->openLogFiles(jitConfig);24822483if (TR::Options::getVerboseOption(TR_VerboseFilters))2484{2485if (TR::Options::getDebug() && TR::Options::getDebug()->getCompilationFilters())2486{2487TR_VerboseLog::writeLine(TR_Vlog_INFO,"AOT limit filters:");2488TR::Options::getDebug()->printFilters();2489}2490}24912492#if defined(J9VM_OPT_JITSERVER)2493self()->setupJITServerOptions();2494#endif /* defined(J9VM_OPT_JITSERVER) */24952496return true;2497}24982499bool J9::Options::feLatePostProcess(void * base, TR::OptionSet * optionSet)2500{2501// vmPostProcess is called indirectly from the JIT_INITIALIZED phase2502// vmLatePostProcess is called indirectly from the aboutToBootstrap hook2503//2504bool doAOT = true;2505if (optionSet)2506{2507// nothing option set specific to do2508return true;2509}25102511J9JITConfig * jitConfig = (J9JITConfig*)base;2512J9JavaVM * javaVM = jitConfig->javaVM;2513J9HookInterface * * vmHooks = javaVM->internalVMFunctions->getVMHookInterface(javaVM);25142515TR_J9VMBase * vm = TR_J9VMBase::get(jitConfig, 0);2516TR::CompilationInfo * compInfo = TR::CompilationInfo::get(jitConfig);25172518// runtimeFlags are properly setup only in fePostProcessJit,2519// so for AOT we can properly set dependent options only here2520if (jitConfig->runtimeFlags & J9JIT_TOSS_CODE)2521self()->setOption(TR_DisableAsyncCompilation, true);25222523PORT_ACCESS_FROM_JAVAVM(jitConfig->javaVM);2524if (vm->isAOT_DEPRECATED_DO_NOT_USE() || (jitConfig->runtimeFlags & J9JIT_TOSS_CODE))2525return true;25262527#if defined(J9VM_INTERP_ATOMIC_FREE_JNI) && !defined(TR_HOST_S390) && !defined(TR_HOST_POWER) && !defined(TR_HOST_X86) && !defined(TR_HOST_ARM64)2528// Atomic-free JNI dispatch needs codegen support, currently only prototyped on a few platforms2529setOption(TR_DisableDirectToJNI);2530#endif25312532#if defined(J9VM_ZOS_3164_INTEROPERABILITY)2533// 31-64 Interop currently lacks codegen DirectToJNI support to invoke cross AMODE calls.2534// This is a temporarily measure to ensure functional correctness. At the least, we can2535// enable DirectToJNI for resolved JNI calls to 64-bit targets.2536if (J9_ARE_ALL_BITS_SET(javaVM->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_3164_INTEROPERABILITY)) {2537setOption(TR_DisableDirectToJNI);2538}2539#endif25402541// Determine whether or not to call the hooked helpers2542//2543if (2544#if defined(J9VM_JIT_FULL_SPEED_DEBUG)2545(javaVM->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_CAN_ACCESS_LOCALS) ||2546#endif2547#if defined (J9VM_INTERP_HOT_CODE_REPLACEMENT)2548(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_POP_FRAMES_INTERRUPT) ||2549#endif2550(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_BREAKPOINT) ||2551(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_FRAME_POPPED) ||2552(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_FRAME_POP) ||2553(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_GET_FIELD) ||2554(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_PUT_FIELD) ||2555(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_GET_STATIC_FIELD) ||2556(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_PUT_STATIC_FIELD) ||2557(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_SINGLE_STEP))2558{2559static bool TR_DisableFullSpeedDebug = (feGetEnv("TR_DisableFullSpeedDebug") != NULL);2560static bool TR_DisableFullSpeedDebugAOT = (feGetEnv("TR_DisableFullSpeedDebugAOT") != NULL);2561#if defined(J9VM_JIT_FULL_SPEED_DEBUG)2562if (TR_DisableFullSpeedDebug)2563{2564return false;2565}2566else if (TR_DisableFullSpeedDebugAOT)2567{2568doAOT = false;2569}25702571self()->setOption(TR_FullSpeedDebug);2572self()->setOption(TR_DisableDirectToJNI);2573//setOption(TR_DisableNoVMAccess);2574//setOption(TR_DisableAsyncCompilation);2575//setOption(TR_DisableInterpreterProfiling, true);25762577initializeFSD(javaVM);2578#else2579return false;2580#endif2581}25822583bool exceptionEventHooked = false;2584if ((*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_EXCEPTION_CATCH))2585{2586jitConfig->jitExceptionCaught = jitExceptionCaught;2587exceptionEventHooked = true;2588}2589if ((*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_EXCEPTION_THROW))2590{2591exceptionEventHooked = true;2592}2593if (exceptionEventHooked)2594{2595self()->setOption(TR_DisableThrowToGoto);2596self()->setReportByteCodeInfoAtCatchBlock();2597}25982599// Determine whether or not to generate method enter and exit hooks2600//2601if ((*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_METHOD_ENTER))2602{2603self()->setOption(TR_ReportMethodEnter);2604#if !defined(TR_HOST_S390) && !defined(TR_HOST_POWER) && !defined(TR_HOST_X86)2605doAOT = false;2606#endif2607}2608if ((*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_METHOD_RETURN))2609{2610self()->setOption(TR_ReportMethodExit);2611#if !defined(TR_HOST_S390) && !defined(TR_HOST_POWER) && !defined(TR_HOST_X86)2612doAOT = false;2613#endif2614}26152616// Determine whether or not to disable allocation inlining2617//2618J9MemoryManagerFunctions * mmf = javaVM->memoryManagerFunctions;26192620if (!mmf->j9gc_jit_isInlineAllocationSupported(javaVM))2621{2622self()->setOption(TR_DisableAllocationInlining);2623doAOT = false;2624}26252626#if 02627// Determine whether or not to disable inlining2628//2629if ((TR::Options::getCmdLineOptions()->getOption(TR_ReportMethodEnter) ||2630TR::Options::getCmdLineOptions()->getOption(TR_ReportMethodExit)))2631{2632self()->setDisabled(inlining, true);2633printf("disabling inlining due to trace setting\n");2634doAOT = false;2635}2636#endif26372638#if defined(J9VM_OPT_JITSERVER)2639// Change the values of the two thresholds if the user didn't2640// input values to the options.2641if (_veryHighActiveThreadThreshold == -1)2642_veryHighActiveThreadThreshold = getNumUsableCompilationThreads() * 0.9;26432644if (_highActiveThreadThreshold == -1)2645_highActiveThreadThreshold = getNumUsableCompilationThreads() * 0.8;26462647// Check if the user inputted the correct values.2648// If the thresholds are bigger than the usableCompilationThreads, Then set them to be equal to the number of compilation threads.2649if (_veryHighActiveThreadThreshold > getNumUsableCompilationThreads())2650_veryHighActiveThreadThreshold = getNumUsableCompilationThreads();2651if (_highActiveThreadThreshold > getNumUsableCompilationThreads())2652_highActiveThreadThreshold = getNumUsableCompilationThreads();2653if (_highActiveThreadThreshold > _veryHighActiveThreadThreshold)2654_highActiveThreadThreshold = _veryHighActiveThreadThreshold;26552656#endif /* defined(J9VM_OPT_JITSERVER) */26572658// Determine whether or not to inline monitor enter/exit2659//2660if (self()->getOption(TR_DisableLiveMonitorMetadata))2661{2662self()->setOption(TR_DisableInlineMonEnt);2663self()->setOption(TR_DisableInlineMonExit);2664doAOT = false;2665}26662667// If the VM -Xrs or -Xrs:sync option has been specified the user is requesting2668// that we remove signals. Set the noResumableTrapHandler option to note this2669// request.2670// Also disable the packed decimal part of DAA because some PD instructions2671// trigger hardware exceptions. A new option has been added to disable traps2672// Which allows the disabling of DAA and traps to be decoupled from the handler2673// Multiple variants of -Xrs option are available now:2674// -Xrs Ignore all signals (J9_SIG_XRS_SYNC, J9_SIG_XRS_ASYNC)2675// -Xrs:sync Ignore synchronous signals (J9_SIG_XRS_SYNC)2676// -Xrs:async Ignore asynchronous signals (J9_SIG_XRS_ASYNC)2677if (J9_ARE_ALL_BITS_SET(javaVM->sigFlags, J9_SIG_XRS_SYNC))2678{2679self()->setOption(TR_NoResumableTrapHandler);2680self()->setOption(TR_DisablePackedDecimalIntrinsics);2681self()->setOption(TR_DisableTraps);26822683// Call initialize again to reset the flag as it will have been set on2684// in an earlier call2685vm->initializeHasResumableTrapHandler();2686}26872688// The trap handler currently is working (jitt fails) on Ottawa's IA32 Hardhat machine.2689// The platform isn't shipping so the priority of fixing the problem is currently low.2690//2691#if defined(HARDHAT) && defined(TR_TARGET_X86)2692self()->setOption(TR_NoResumableTrapHandler);2693#endif26942695// Determine whether or not to inline meta data maps have to represent every inline transition point2696//2697// The J9VM_DEBUG_ATTRIBUTE_MAINTAIN_FULL_INLINE_MAP is currently undefined in the Real Time builds. Once2698// the real time VM line has been merged back into the dev line then these 3 preprocessor statements can2699// be removed2700//2701#ifndef J9VM_DEBUG_ATTRIBUTE_MAINTAIN_FULL_INLINE_MAP2702#define J9VM_DEBUG_ATTRIBUTE_MAINTAIN_FULL_INLINE_MAP 02703#endif2704if (javaVM->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_MAINTAIN_FULL_INLINE_MAP)2705{2706self()->setOption(TR_GenerateCompleteInlineRanges);2707doAOT = false;2708}27092710// If class redefinition is the only debug capability - FSD off, HCR on2711// If other capabilities are specified, such as break points - FSD on, HCR off2712static char *disableHCR = feGetEnv("TR_DisableHCR");2713if ((javaVM->requiredDebugAttributes & J9VM_DEBUG_ATTRIBUTE_CAN_REDEFINE_CLASSES) && !self()->getOption(TR_FullSpeedDebug))2714if (!self()->getOption(TR_EnableHCR) && !disableHCR)2715{2716self()->setOption(TR_EnableHCR);2717}27182719// Check NextGenHCR is supported by the VM2720if (!(javaVM->extendedRuntimeFlags & J9_EXTENDED_RUNTIME_OSR_SAFE_POINT) ||2721(*vmHooks)->J9HookDisable(vmHooks, J9HOOK_VM_OBJECT_ALLOCATE_INSTRUMENTABLE) || disableHCR)2722{2723self()->setOption(TR_DisableNextGenHCR);2724}27252726#if !defined(TR_HOST_X86) && !defined(TR_HOST_S390) && !defined(TR_HOST_POWER) && !defined(TR_HOST_ARM64)2727//The bit is set when -XX:+JITInlineWatches is specified2728if (J9_ARE_ANY_BITS_SET(javaVM->extendedRuntimeFlags, J9_EXTENDED_RUNTIME_JIT_INLINE_WATCHES))2729TR_ASSERT_FATAL(false, "this platform doesn't support JIT inline field watch");2730#endif27312732// GCR and JProfiling are disabled under FSD for a number of reasons2733// First, there is confusion between the VM and the JIT as to whether a call to jitRetranslateCallerWithPreparation is a decompilation point.2734// Having the JIT agree with the VM could not be done by simply marking the symbol canGCandReturn, as this would affect other parts of the JIT2735// Second, in a sync method this call will occur before the temporary sync object has been stored to its temp2736// This results in the sync object not being available when the VM calls the buffer filling code2737//2738if (self()->getOption(TR_FullSpeedDebug))2739{2740self()->setReportByteCodeInfoAtCatchBlock();2741self()->setOption(TR_DisableGuardedCountingRecompilations);2742self()->setOption(TR_EnableJProfiling, false);2743//might move around asyn checks and clone the OSRBlock which are not safe under the current OSR infrastructure2744self()->setOption(TR_DisableProfiling);2745//the VM side doesn't support fsd for this event yet2746self()->setOption(TR_DisableNewInstanceImplOpt);2747//the following 2 opts might insert async checks at new bytecode index where the OSR infrastructures doesn't exist2748self()->setDisabled(OMR::redundantGotoElimination, true);2749self()->setDisabled(OMR::loopReplicator, true);2750}27512752#if defined(J9VM_OPT_SHARED_CLASSES)2753if (TR::Options::sharedClassCache())2754{2755if (!doAOT)2756{2757if (this == TR::Options::getAOTCmdLineOptions())2758{2759TR::Options::getAOTCmdLineOptions()->setOption(TR_NoLoadAOT);2760TR::Options::getAOTCmdLineOptions()->setOption(TR_NoStoreAOT);2761TR::Options::setSharedClassCache(false);2762if (javaVM->sharedClassConfig->verboseFlags & J9SHR_VERBOSEFLAG_ENABLE_VERBOSE)2763j9nls_printf( PORTLIB, J9NLS_WARNING, J9NLS_RELOCATABLE_CODE_NOT_AVAILABLE_WITH_FSD_JVMPI);2764}2765}2766else // do AOT2767{2768if (!self()->getOption(TR_DisablePersistIProfile))2769{2770// Turn off Iprofiler for the warm runs, but not if we cache only bootstrap classes2771// This is because we may be missing IProfiler information for non-bootstrap classes2772// that could not be stored in SCC2773if (J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES))2774{2775TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);2776static char * dnipdsp = feGetEnv("TR_DisableNoIProfilerDuringStartupPhase");2777if (compInfo->isWarmSCC() == TR_yes && !dnipdsp)2778{2779self()->setOption(TR_NoIProfilerDuringStartupPhase);2780}2781}2782}2783}2784}2785#endif27862787// Divide by 0 checks2788if (TR::Options::_LoopyMethodDivisionFactor == 0)2789TR::Options::_LoopyMethodDivisionFactor = 16; // Reset it back to the default value2790if (TR::Options::_IprofilerOffDivisionFactor == 0)2791TR::Options::_IprofilerOffDivisionFactor = 16; // Reset it back to the default value27922793// Some options consistency fixes for 2 options objects2794//2795if ((TR::Options::getAOTCmdLineOptions()->getFixedOptLevel() != -1) && (TR::Options::getJITCmdLineOptions()->getFixedOptLevel() == -1))2796TR::Options::getJITCmdLineOptions()->setFixedOptLevel(TR::Options::getAOTCmdLineOptions()->getFixedOptLevel());2797if ((TR::Options::getJITCmdLineOptions()->getFixedOptLevel() != -1) && (TR::Options::getAOTCmdLineOptions()->getFixedOptLevel() == -1))2798TR::Options::getAOTCmdLineOptions()->setFixedOptLevel(TR::Options::getJITCmdLineOptions()->getFixedOptLevel());27992800if (compInfo->getPersistentInfo()->isRuntimeInstrumentationRecompilationEnabled())2801{2802if (!TR::Options::getCmdLineOptions()->getOption(TR_EnableJitSamplingUpgradesDuringHWProfiling))2803{2804TR::Options::getCmdLineOptions()->setOption(TR_DisableUpgrades);2805}28062807// Under RI based recompilation, disable GCR recompilation2808TR::Options::getCmdLineOptions()->setOption(TR_DisableGuardedCountingRecompilations);2809TR::Options::getAOTCmdLineOptions()->setOption(TR_DisableGuardedCountingRecompilations);28102811// If someone enabled the mechanism to turn off RI during steady state,2812// we must disable the mechanism that toggle RI on/off dynamically2813if (self()->getOption(TR_InhibitRIBufferProcessingDuringDeepSteady))2814self()->setOption(TR_DisableDynamicRIBufferProcessing);2815}28162817// If the user or JIT heuristics (Xquickstart) want us to restrict the inlining during startup2818// now it's time to set the flag that enables the feature2819if (self()->getOption(TR_RestrictInlinerDuringStartup))2820{2821compInfo->getPersistentInfo()->setInlinerTemporarilyRestricted(true);2822}28232824// If we don't want to collect any type of information from samplingJProfiling2825// the disable the opt completely2826if (!TR::Options::getCmdLineOptions()->isAnySamplingJProfilingOptionSet())2827self()->setOption(TR_DisableSamplingJProfiling);28282829#if defined(J9VM_JIT_DYNAMIC_LOOP_TRANSFER)2830if (!compInfo->getDLT_HT() && TR::Options::_numDLTBufferMatchesToEagerlyIssueCompReq > 1)2831compInfo->setDLT_HT(new (PERSISTENT_NEW) DLTTracking(compInfo->getPersistentInfo()));2832#endif2833// The exploitation of idle time is done by a tracking mechanism done2834// on the IProfiler thread. If this thread does not exist, then we2835// must turn this feature off to avoid allocating a useless hashtable2836TR_IProfiler *iProfiler = vm->getIProfiler();2837if (!iProfiler || !iProfiler->getIProfilerThread())2838self()->setOption(TR_UseIdleTime, false);28392840// If NoResumableTrapHandler is set, disable packed decimal intrinsics inlining because2841// PD instructions exceptions can't be handled without the handler.2842// Add a new option to disable traps explicitly so DAA and trap instructions can be disabled separately2843// but are both covered by the NoResumableTrapHandler option2844if (self()->getOption(TR_NoResumableTrapHandler))2845{2846self()->setOption(TR_DisablePackedDecimalIntrinsics);2847self()->setOption(TR_DisableTraps);2848}28492850// Take care of the main option TR_DisableIntrinsics and the two sub-options2851if (self()->getOption(TR_DisableIntrinsics))2852{2853self()->setOption(TR_DisableMarshallingIntrinsics);2854self()->setOption(TR_DisablePackedDecimalIntrinsics);2855}2856else if (self()->getOption(TR_DisableMarshallingIntrinsics) &&2857self()->getOption(TR_DisablePackedDecimalIntrinsics))2858{2859self()->setOption(TR_DisableIntrinsics);2860}28612862/* Temporary (until SVM is the default)2863*2864* If the SVM is not enabled, use the old _coldUpgradeSampleThreshold2865* for AGGRESSIVE_AOT2866*/2867if (!self()->getOption(TR_EnableSymbolValidationManager)2868&& TR::Options::_aggressivenessLevel == TR::Options::AGGRESSIVE_AOT)2869{2870TR::Options::_coldUpgradeSampleThreshold = 10;2871}28722873#if defined(TR_HOST_ARM64)2874// ArraySet support is not available in AArch64 yet.2875// OpenJ9 issue #6443 tracks the work to enable.2876//2877self()->setOption(TR_DisableArraySetOpts);28782879// EDO catch block profiling support is not available in AArch64 yet.2880// OpenJ9 issue #6538 tracks the work to enable.2881//2882self()->setOption(TR_DisableEDO);2883#endif28842885return true;2886}288728882889void2890J9::Options::printPID()2891{2892((TR_J9VMBase *)_fe)->printPID();2893}28942895#if defined(J9VM_OPT_JITSERVER)2896void getTRPID(char *buf, size_t size);28972898static void2899appendRegex(TR::SimpleRegex *®exPtr, uint8_t *&curPos)2900{2901if (!regexPtr)2902return;2903size_t len = regexPtr->regexStrLen();2904memcpy(curPos, regexPtr->regexStr(), len);2905TR_ASSERT(curPos[len - 1], "not expecting null terminator");2906// Replace the regex pointer with self-referring-pointer which is the offset of regex data2907// with respect to the regex pointer2908regexPtr = (TR::SimpleRegex*) ((uint8_t*)curPos - (uint8_t *)®exPtr);2909curPos[len] = '\0';2910curPos += len + 1;2911}29122913static void2914unpackRegex(TR::SimpleRegex *®exPtr)2915{2916if (!regexPtr)2917return;2918char *str = (char*)((uintptr_t)®exPtr + (uintptr_t)regexPtr);2919regexPtr = TR::SimpleRegex::create(str);2920}29212922static void2923addRegexStringSize(TR::SimpleRegex *regexPtr, size_t &len)2924{2925if (regexPtr)2926len += regexPtr->regexStrLen() + 1;2927}29282929static uint8_t *2930appendContent(char * &charPtr, uint8_t * curPos, size_t length)2931{2932if (charPtr == NULL)2933return curPos;2934// Copy charPtr's content to the location pointed by curPos2935memcpy(curPos, charPtr, length);2936// Compute the offset from the address of charPtr to curPos and store it to charPtr2937charPtr = (char *)(curPos - (uint8_t *)&(charPtr));2938// Update current position2939return curPos += length;2940}29412942// Pack a TR::Options object into a std::string to be transfered to the server2943std::string2944J9::Options::packOptions(const TR::Options *origOptions)2945{2946size_t logFileNameLength = 0;2947size_t suffixLogsFormatLength = 0;2948size_t blockShufflingSequenceLength = 0;2949size_t induceOSRLength = 0;29502951char buf[JITSERVER_LOG_FILENAME_MAX_SIZE];2952char *origLogFileName = NULL;2953if (origOptions->_logFileName)2954{2955origLogFileName = origOptions->_logFileName;2956char pidBuf[20];2957memset(pidBuf, 0, sizeof(pidBuf));2958getTRPID(pidBuf, sizeof(pidBuf));2959logFileNameLength = strlen(origOptions->_logFileName) + strlen(".") + strlen(pidBuf) + strlen(".server") + 1;2960// If logFileNameLength is greater than JITSERVER_LOG_FILENAME_MAX_SIZE, PID might not be appended to the log file name2961// and the log file name could be truncated as well.2962if (logFileNameLength > JITSERVER_LOG_FILENAME_MAX_SIZE)2963logFileNameLength = JITSERVER_LOG_FILENAME_MAX_SIZE;2964snprintf(buf, logFileNameLength, "%s.%s.server", origOptions->_logFileName, pidBuf);2965}2966if (origOptions->_suffixLogsFormat)2967suffixLogsFormatLength = strlen(origOptions->_suffixLogsFormat) + 1;2968if (origOptions->_blockShufflingSequence)2969blockShufflingSequenceLength = strlen(origOptions->_blockShufflingSequence) + 1;2970if (origOptions->_induceOSR)2971induceOSRLength = strlen(origOptions->_induceOSR) + 1;29722973// sizeof(bool) is reserved to pack J9JIT_RUNTIME_RESOLVE2974size_t totalSize = sizeof(TR::Options) + logFileNameLength + suffixLogsFormatLength + blockShufflingSequenceLength + induceOSRLength + sizeof(bool);29752976addRegexStringSize(origOptions->_disabledOptTransformations, totalSize);2977addRegexStringSize(origOptions->_disabledInlineSites, totalSize);2978addRegexStringSize(origOptions->_disabledOpts, totalSize);2979addRegexStringSize(origOptions->_optsToTrace, totalSize);2980addRegexStringSize(origOptions->_dontInline, totalSize);2981addRegexStringSize(origOptions->_onlyInline, totalSize);2982addRegexStringSize(origOptions->_tryToInline, totalSize);2983addRegexStringSize(origOptions->_slipTrap, totalSize);2984addRegexStringSize(origOptions->_lockReserveClass, totalSize);2985addRegexStringSize(origOptions->_breakOnOpts, totalSize);2986addRegexStringSize(origOptions->_breakOnCreate, totalSize);2987addRegexStringSize(origOptions->_debugOnCreate, totalSize);2988addRegexStringSize(origOptions->_breakOnThrow, totalSize);2989addRegexStringSize(origOptions->_breakOnPrint, totalSize);2990addRegexStringSize(origOptions->_enabledStaticCounterNames, totalSize);2991addRegexStringSize(origOptions->_enabledDynamicCounterNames, totalSize);2992addRegexStringSize(origOptions->_counterHistogramNames, totalSize);2993addRegexStringSize(origOptions->_verboseOptTransformationsRegex, totalSize);2994addRegexStringSize(origOptions->_packedTest, totalSize);2995addRegexStringSize(origOptions->_memUsage, totalSize);2996addRegexStringSize(origOptions->_classesWithFolableFinalFields, totalSize);2997addRegexStringSize(origOptions->_disabledIdiomPatterns, totalSize);29982999std::string optionsStr(totalSize, '\0');3000TR::Options * options = (TR::Options *)optionsStr.data();3001memcpy(options, origOptions, sizeof(TR::Options));30023003if (origOptions->_logFileName)3004options->_logFileName = buf;30053006uint8_t *curPos = ((uint8_t *)options) + sizeof(TR::Options);30073008options->_optionSets = NULL;3009options->_startOptions = NULL;3010options->_envOptions = NULL;3011options->_logFile = NULL;3012options->_optFileName = NULL;3013options->_customStrategy = NULL;3014options->_customStrategySize = 0;3015options->_countString = NULL;3016appendRegex(options->_disabledOptTransformations, curPos);3017appendRegex(options->_disabledInlineSites, curPos);3018appendRegex(options->_disabledOpts, curPos);3019appendRegex(options->_optsToTrace, curPos);3020appendRegex(options->_dontInline, curPos);3021appendRegex(options->_onlyInline, curPos);3022appendRegex(options->_tryToInline, curPos);3023appendRegex(options->_slipTrap, curPos);3024appendRegex(options->_lockReserveClass, curPos);3025appendRegex(options->_breakOnOpts, curPos);3026appendRegex(options->_breakOnCreate, curPos);3027appendRegex(options->_debugOnCreate, curPos);3028appendRegex(options->_breakOnThrow, curPos);3029appendRegex(options->_breakOnPrint, curPos);3030appendRegex(options->_enabledStaticCounterNames, curPos);3031appendRegex(options->_enabledDynamicCounterNames, curPos);3032appendRegex(options->_counterHistogramNames, curPos);3033appendRegex(options->_verboseOptTransformationsRegex, curPos);3034appendRegex(options->_packedTest, curPos);3035appendRegex(options->_memUsage, curPos);3036appendRegex(options->_classesWithFolableFinalFields, curPos);3037appendRegex(options->_disabledIdiomPatterns, curPos);3038options->_osVersionString = NULL;3039options->_logListForOtherCompThreads = NULL;3040options->_objectFileName = NULL;30413042// Append the data pointed by a pointer to the content and patch the pointer3043// as a self-referring-pointer, or a relative pointer, which is3044// the offset of the data with respect to the pointer.3045curPos = appendContent(options->_logFileName, curPos, logFileNameLength);3046curPos = appendContent(options->_suffixLogsFormat, curPos, suffixLogsFormatLength);3047curPos = appendContent(options->_blockShufflingSequence, curPos, blockShufflingSequenceLength);3048curPos = appendContent(options->_induceOSR, curPos, induceOSRLength);30493050// Send rtResolve option to the server:3051// Temporary solution until we can send jitConfig->runtimeFlags to the server3052// or make rtResolve part of TR::Options instead of runtime flags3053auto *jitConfig = (J9JITConfig *) _feBase;3054bool rtResolve = jitConfig->runtimeFlags & J9JIT_RUNTIME_RESOLVE;3055char *rtResolveStr = (char *) &rtResolve;3056curPos = appendContent(rtResolveStr, curPos, sizeof(bool));30573058return optionsStr;3059}30603061TR::Options *3062J9::Options::unpackOptions(char *clientOptions, size_t clientOptionsSize, TR::CompilationInfoPerThreadBase* compInfoPT, TR_J9VMBase *fe, TR_Memory *trMemory)3063{3064TR::Options *options = (TR::Options *)trMemory->allocateHeapMemory(clientOptionsSize);3065memcpy(options, clientOptions, clientOptionsSize);30663067// Convert relative pointers to absolute pointers3068// pointer = address of field + offset3069if (options->_logFileName)3070options->_logFileName = (char *)((uint8_t *)&(options->_logFileName) + (ptrdiff_t)options->_logFileName);3071if (options->_suffixLogsFormat)3072options->_suffixLogsFormat = (char *)((uint8_t *)&(options->_suffixLogsFormat) + (ptrdiff_t)options->_suffixLogsFormat);3073if (options->_blockShufflingSequence)3074options->_blockShufflingSequence = (char *)((uint8_t *)&(options->_blockShufflingSequence) + (ptrdiff_t)options->_blockShufflingSequence);3075if (options->_induceOSR)3076options->_induceOSR = (char *)((uint8_t *)&(options->_induceOSR) + (ptrdiff_t)options->_induceOSR);30773078// Receive rtResolve: J9JIT_RUNTIME_RESOLVE3079// NOTE: This relies on rtResolve being the last option in clientOptions3080// the J9JIT_RUNTIME_RESOLVE flag from JITClient3081// On JITServer, we store this value for each client in ClientSessionData3082bool rtResolve = (bool) *((uint8_t *) options + clientOptionsSize - sizeof(bool));3083compInfoPT->getClientData()->setRtResolve(rtResolve);3084unpackRegex(options->_disabledOptTransformations);3085unpackRegex(options->_disabledInlineSites);3086unpackRegex(options->_disabledOpts);3087unpackRegex(options->_optsToTrace);3088unpackRegex(options->_dontInline);3089unpackRegex(options->_onlyInline);3090unpackRegex(options->_tryToInline);3091unpackRegex(options->_slipTrap);3092unpackRegex(options->_lockReserveClass);3093unpackRegex(options->_breakOnOpts);3094unpackRegex(options->_breakOnCreate);3095unpackRegex(options->_debugOnCreate);3096unpackRegex(options->_breakOnThrow);3097unpackRegex(options->_breakOnPrint);3098unpackRegex(options->_enabledStaticCounterNames);3099unpackRegex(options->_enabledDynamicCounterNames);3100unpackRegex(options->_counterHistogramNames);3101unpackRegex(options->_verboseOptTransformationsRegex);3102unpackRegex(options->_packedTest);3103unpackRegex(options->_memUsage);3104unpackRegex(options->_classesWithFolableFinalFields);3105unpackRegex(options->_disabledIdiomPatterns);31063107return options;3108}31093110// Pack the log file generated at the server to be sent to the client3111std::string3112J9::Options::packLogFile(TR::FILE *fp)3113{3114if (fp == NULL)3115return "";3116const size_t BUFFER_SIZE = 4096; // 4KB3117char buf[BUFFER_SIZE + 1];3118std::string logFileStr("");3119int readSize = 0;3120::rewind(fp->_stream);3121do {3122readSize = ::fread(buf, 1, BUFFER_SIZE, fp->_stream);3123buf[readSize] = '\0';3124logFileStr.append(buf);3125} while (readSize == BUFFER_SIZE);31263127logFileStr.append("</jitlog>\n");3128return logFileStr;3129}31303131// Create a log file at the client based on the log file string sent from the server3132int3133J9::Options::writeLogFileFromServer(const std::string& logFileContent)3134{3135if (logFileContent.empty() || !_logFileName)3136return 0;31373138char buf[JITSERVER_LOG_FILENAME_MAX_SIZE];3139_fe->acquireLogMonitor();3140snprintf(buf, sizeof(buf), "%s.%d.REMOTE", _logFileName, ++_compilationSequenceNumber);3141int sequenceNumber = _compilationSequenceNumber;3142_fe->releaseLogMonitor();31433144int32_t len = strlen(buf);3145// maximum length for suffix (dot + 8-digit date + dot + 6-digit time + dot + 5-digit pid + null terminator)3146int32_t MAX_SUFFIX_LENGTH = 23;3147if (len + MAX_SUFFIX_LENGTH > JITSERVER_LOG_FILENAME_MAX_SIZE)3148{3149if (TR::Options::getVerboseOption(TR_VerboseJITServer))3150{3151TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "Trace log not generated due to filename being too long");3152}3153return 0; // may overflow the buffer3154}3155char tmp[JITSERVER_LOG_FILENAME_MAX_SIZE];3156char * filename = _fe->getFormattedName(tmp, JITSERVER_LOG_FILENAME_MAX_SIZE, buf, _suffixLogsFormat, true);31573158TR::FILE *logFile = trfopen(filename, "wb", false);3159::fputs(logFileContent.c_str(), logFile->_stream);3160trfflush(logFile);3161trfclose(logFile);31623163return sequenceNumber;3164}31653166TR_Debug *createDebugObject(TR::Compilation *);31673168// JITServer: Create a log file for each client compilation request3169// Side effect: set _logFile3170// At the client: Triggered when a remote compilation is followed by a local compilation.3171// suffixNumber is the compilationSequenceNumber used for the remote compilation.3172// At the server: suffixNumber is set as 0.3173void3174J9::Options::setLogFileForClientOptions(int suffixNumber)3175{3176if (_logFileName)3177{3178_fe->acquireLogMonitor();3179if (suffixNumber)3180{3181self()->setOption(TR_EnablePIDExtension, true);3182self()->openLogFile(suffixNumber);3183}3184else3185{3186_compilationSequenceNumber++;3187self()->setOption(TR_EnablePIDExtension, false);3188self()->openLogFile(_compilationSequenceNumber);3189}31903191if (_logFile)3192{3193J9JITConfig *jitConfig = (J9JITConfig*)_feBase;3194if (!jitConfig->tracingHook)3195{3196jitConfig->tracingHook = (void*) (TR_CreateDebug_t)createDebugObject;3197suppressLogFileBecauseDebugObjectNotCreated(false);3198_hasLogFile = true;3199}3200}3201_fe->releaseLogMonitor();3202}3203}32043205void3206J9::Options::closeLogFileForClientOptions()3207{3208if (_logFile)3209{3210TR::Options::closeLogFile(_fe, _logFile);3211_logFile = NULL;3212}3213}3214#endif /* defined(J9VM_OPT_JITSERVER) */321532163217