Path: blob/master/runtime/compiler/control/DLLMain.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#define J9_EXTERNAL_TO_VM2324#include "control/Options.hpp"25#include "env/ClassLoaderTable.hpp"26#include "env/annotations/AnnotationBase.hpp"27#include "env/ut_j9jit.h"28#include "control/CompilationRuntime.hpp"29#include "control/CompilationThread.hpp"30#include "env/VMJ9.h"31#include "runtime/IProfiler.hpp"32#include "runtime/J9Profiler.hpp"33#if defined(J9VM_OPT_JITSERVER)34#include "runtime/Listener.hpp"35#endif /* J9VM_OPT_JITSERVER */36#include "runtime/codertinit.hpp"37#include "rossa.h"3839#include "j9.h"40#include "jvminit.h"4142// NOTE: Any changes made to J9VMDllMain that relate to AOT compile time43// should be put instead in onLoadInternal().44//4546#ifdef AOT_COMPILE_TIME_VERSION47#define THIS_DLL_NAME J9_AOT_DLL_NAME48#else49#define THIS_DLL_NAME J9_JIT_DLL_NAME50#endif5152extern bool initializeJIT(J9JavaVM *vm);5354extern bool isQuickstart;5556IDATA J9VMDllMain(J9JavaVM* vm, IDATA stage, void * reserved)57{58J9JITConfig * jitConfig = 0;59UDATA initialFlags = 0;60J9VMDllLoadInfo* loadInfo = FIND_DLL_TABLE_ENTRY( THIS_DLL_NAME );61char* xjitCommandLineOptions = "";62char* xaotCommandLineOptions = "";63IDATA fullSpeedDebugSet = FALSE;64IDATA argIndex = 0;6566IDATA tlhPrefetch = 0;67IDATA notlhPrefetch = 0;68IDATA lockReservation = 0;69IDATA argIndexXjit = 0;70IDATA argIndexXaot = 0;71IDATA argIndexXnojit = 0;7273IDATA argIndexClient = 0;74IDATA argIndexServer = 0;75IDATA argIndexQuickstart = 0;7677IDATA argIndexRIEnabled = 0;78IDATA argIndexRIDisabled = 0;7980static bool isJIT = false;81static bool isAOT = false;8283static bool jitInitialized = false;84static bool aotrtInitialized = false;8586PORT_ACCESS_FROM_JAVAVM(vm);8788#define AOT_INIT_STAGE SYSTEM_CLASSLOADER_SET /* defined separately to ensure dependencies below */8990switch(stage)91{9293case DLL_LOAD_TABLE_FINALIZED :94{9596// Bootstrap JIT initialization97//98if (!initializeJIT(vm))99{100return J9VMDLLMAIN_FAILED;101}102103/* Find and consume these before the library might be unloaded */104FIND_AND_CONSUME_ARG(EXACT_MATCH, "-Xnodfpbd", 0);105if (FIND_ARG_IN_VMARGS(EXACT_MATCH, "-Xdfpbd", 0) >= 0)106{107FIND_AND_CONSUME_ARG( EXACT_MATCH, "-Xhysteresis", 0);108}109FIND_AND_CONSUME_ARG( EXACT_MATCH, "-Xnoquickstart", 0); // deprecated110FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, "-Xtune:elastic", 0);111argIndexQuickstart = FIND_AND_CONSUME_ARG( EXACT_MATCH, "-Xquickstart", 0);112tlhPrefetch = FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XtlhPrefetch", 0);113notlhPrefetch = FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XnotlhPrefetch", 0);114lockReservation = FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XlockReservation", 0);115FIND_AND_CONSUME_ARG(EXACT_MEMORY_MATCH, "-Xcodecache", 0);116FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, "-XjniAcc:", 0);117FIND_AND_CONSUME_ARG(EXACT_MEMORY_MATCH, "-Xcodecachetotal", 0);118FIND_AND_CONSUME_ARG(EXACT_MEMORY_MATCH, "-XX:codecachetotal=", 0);119120FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, "-Xlp:codecache:", 0);121122FIND_AND_CONSUME_ARG(EXACT_MEMORY_MATCH, "-XsamplingExpirationTime", 0);123FIND_AND_CONSUME_ARG(EXACT_MEMORY_MATCH, "-XcompilationThreads", 0);124FIND_AND_CONSUME_ARG(EXACT_MEMORY_MATCH, "-XaggressivenessLevel", 0);125argIndexXjit = FIND_AND_CONSUME_ARG(OPTIONAL_LIST_MATCH, "-Xjit", 0);126argIndexXaot = FIND_AND_CONSUME_ARG(OPTIONAL_LIST_MATCH, "-Xaot", 0);127argIndexXnojit = FIND_AND_CONSUME_ARG(OPTIONAL_LIST_MATCH, "-Xnojit", 0);128129argIndexRIEnabled = FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XX:+RuntimeInstrumentation", 0);130argIndexRIDisabled = FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XX:-RuntimeInstrumentation", 0);131132// Determine if user disabled Runtime Instrumentation133if (argIndexRIEnabled >= 0 || argIndexRIDisabled >= 0)134TR::Options::_hwProfilerEnabled = (argIndexRIDisabled > argIndexRIEnabled) ? TR_no : TR_yes;135136TR::Options::_doNotProcessEnvVars = (FIND_AND_CONSUME_ARG(EXACT_MATCH, "-XX:doNotProcessJitEnvVars", 0) >= 0);137138isQuickstart = J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_TUNE_QUICKSTART);139140#ifdef TR_HOST_X86141// By default, disallow reservation of objects' monitors for which a142// previous reservation has been cancelled (issue #1124). But allow it143// again if -XlockReservation was specified.144TR::Options::_aggressiveLockReservation = lockReservation >= 0;145#else146// Keep the always aggressive behaviour until codegen is adjusted.147TR::Options::_aggressiveLockReservation = true;148#endif149150/* setup field to indicate whether we will allow JIT compilation */151if (argIndexXjit >= argIndexXnojit)152{153isJIT = true;154}155156/* setup field to indicate whether we will allow AOT compilation and perform AOT runtime157* initializations to allow AOT code to be loaded from the shared cache as well as from JXEs */158if ((J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_ENABLE_AOT)))159{160isAOT = true;161}162163static char *disableAOT = feGetEnv2("TR_disableAOT", (void *)vm);164if (disableAOT)165isAOT = false;166167/* If debuginfoserver has been loaded and no FSD support, unload this library and aot */168#ifdef J9VM_JIT_FULL_SPEED_DEBUG169fullSpeedDebugSet = TRUE;170#endif171172static bool TR_DisableFullSpeedDebug = feGetEnv2("TR_DisableFullSpeedDebug", (void *)vm)?1:0;173if (!fullSpeedDebugSet || TR_DisableFullSpeedDebug)174{175loadInfo->loadFlags |= FORCE_UNLOAD;176break;177}178179#if defined(J9VM_GC_BATCH_CLEAR_TLH)180/* The order is important: we have to request it before the first TLH is created. */181/* Platform detection seems difficult at this point. */182{183#ifdef TR_HOST_X86184static char *enableBatchClear = feGetEnv2("TR_EnableBatchClear", (void *)vm);185186#else //ppc and s390187static char *disableBatchClear = feGetEnv2("TR_DisableBatchClear", (void *)vm);188#ifdef TR_HOST_POWER189static char *disableDualTLH = feGetEnv2("TR_DisableDualTLH", (void *)vm);190191//if disableDualTLH is specified, revert back to old semantics.192// Do not batch clear, JIT has to zeroinit all code on TLH.193//Non P6, P7 and up are allowed to batch clear however.194bool disableZeroedTLHPages = disableDualTLH && (((notlhPrefetch >= 0) || (!TR::Compiler->target.cpu.is(OMR_PROCESSOR_PPC_P6) && !TR::Compiler->target.cpu.is(OMR_PROCESSOR_PPC_P7))));195#endif//TR_HOST_POWER196#endif//TR_HOST_X86197/*in testmode, the JIT will be loaded by a native. At this point it's too late to change198* the TLH mode, and it won't matter anyway, since JIT'ed code won't be run.199* See CMVC 70078200*/201if (202#ifdef TR_HOST_X86203enableBatchClear204#else//ppc and s390205disableBatchClear==0206#ifdef TR_HOST_POWER207&&!disableZeroedTLHPages208#endif//TR_HOST_POWER209#endif//TR_HOST_X86210)211{212J9VMDllLoadInfo *gcLoadInfo = getGCDllLoadInfo(vm);213214if (!IS_STAGE_COMPLETED(gcLoadInfo->completedBits, JCL_INITIALIZED) )//&& vm->memoryManagerFunctions)215{216vm->memoryManagerFunctions->allocateZeroedTLHPages(vm, true);217}218}219}220#endif//J9VM_GC_BATCH_CLEAR_TLH221222break;223}224225case AOT_INIT_STAGE :226if (isAOT)227{228/* Perform initializations for AOT runtime */229#if defined(J9VM_INTERP_AOT_RUNTIME_SUPPORT)230// TODO: This now acts as a general "Is the jit shutting down" flag, should it be renamed / changed for something different?231if (vm->jitConfig)232vm->jitConfig->runtimeFlags |= J9JIT_AOT_ATTACHED;233#endif234aotrtInitialized = true;235}236break;237238// createThreadWithCategory compiling threads in this stage239case JIT_INITIALIZED :240if (isJIT || isAOT)241{242/* We need to initialize the following if we allow JIT compilation, AOT compilation or AOT relocation to be done */243try244{245/*246* Note that the option prefix we need to match includes the colon.247*/248argIndexXjit = FIND_ARG_IN_VMARGS( STARTSWITH_MATCH, "-Xjit:", 0);249argIndexXaot = FIND_ARG_IN_VMARGS( STARTSWITH_MATCH, "-Xaot:", 0);250251/* do initializations for -Xjit options */252if (isJIT && argIndexXjit >= 0)253{254IDATA returnVal = 0, size = 128;255xjitCommandLineOptions = 0;256do257{258size = size * 2;259if (xjitCommandLineOptions)260j9mem_free_memory(xjitCommandLineOptions);261if (!(xjitCommandLineOptions = (char*)j9mem_allocate_memory(size * sizeof(char), J9MEM_CATEGORY_JIT)))262return J9VMDLLMAIN_FAILED;263returnVal = GET_COMPOUND_VALUE(argIndexXjit, ':', &xjitCommandLineOptions, size);264} while (returnVal == OPTION_BUFFER_OVERFLOW);265266if (!* xjitCommandLineOptions)267{268j9mem_free_memory(xjitCommandLineOptions);269loadInfo->fatalErrorStr = "no arguments for -Xjit:";270return J9VMDLLMAIN_FAILED;271}272}273274codert_onload(vm);275276/* do initializations for -Xaot options */277if (isAOT && argIndexXaot >= 0)278{279IDATA returnVal = 0, size = 128;280xaotCommandLineOptions = 0;281do282{283size = size * 2;284if (xaotCommandLineOptions)285j9mem_free_memory(xaotCommandLineOptions);286if (!(xaotCommandLineOptions = (char*)j9mem_allocate_memory(size * sizeof(char), J9MEM_CATEGORY_JIT)))287return J9VMDLLMAIN_FAILED;288returnVal = GET_COMPOUND_VALUE(argIndexXaot, ':', &xaotCommandLineOptions, size);289} while (returnVal == OPTION_BUFFER_OVERFLOW);290291if (!* xaotCommandLineOptions)292{293j9mem_free_memory(xaotCommandLineOptions);294loadInfo->fatalErrorStr = "no arguments for -Xaot:";295return J9VMDLLMAIN_FAILED;296}297}298299jitConfig = vm->jitConfig;300301if (!jitConfig)302{303loadInfo->fatalErrorStr = "cannot initialize JIT: no jitconfig";304return J9VMDLLMAIN_FAILED;305}306307if (isQuickstart)308jitConfig->runtimeFlags |= J9JIT_QUICKSTART;309310if (aotrtInitialized)311jitConfig->runtimeFlags |= J9JIT_AOT_ATTACHED;312313if (jitConfig->runtimeFlags & J9JIT_JIT_ATTACHED)314goto _abort;315if (onLoadInternal(vm, jitConfig, xjitCommandLineOptions, xaotCommandLineOptions, initialFlags, reserved, isJIT?0:1))316goto _abort;317318if (isJIT)319jitConfig->runtimeFlags |= J9JIT_JIT_ATTACHED;320321// Option string is no longer needed322/* The following code causes problems on zLinux (only) when using a tracing option323The code is commented out until we can figure out the root cause324if (isJIT && argIndexXjit >= 0 && xjitCommandLineOptions)325{326j9mem_free_memory(xjitCommandLineOptions);327xjitCommandLineOptions = 0;328}329if (isAOT && argIndexXaot >= 0 && xaotCommandLineOptions)330{331j9mem_free_memory(xaotCommandLineOptions);332xaotCommandLineOptions = 0;333}334*/335jitInitialized = true;336return J9VMDLLMAIN_OK;337}338catch (const std::exception &e) {}339_abort:340freeJITConfig(jitConfig);341if (!loadInfo->fatalErrorStr || strlen(loadInfo->fatalErrorStr)==0)342loadInfo->fatalErrorStr = "cannot initialize JIT";343return J9VMDLLMAIN_FAILED;344}345break;346347// createThreadWithCategory sampling and profiling threads in this stage348case ABOUT_TO_BOOTSTRAP:349{350#if defined(J9VM_OPT_SHARED_CLASSES)351// ENABLE_AOT must be set AND the shared class must be properly initialized352UDATA aotFlags = J9SHR_RUNTIMEFLAG_CACHE_INITIALIZATION_COMPLETE;353if (vm->sharedClassConfig && ((vm->sharedClassConfig->runtimeFlags & aotFlags) == aotFlags))354{355TR::Options::setSharedClassCache(true); // Set to true as long as cache is present and initialized356357TR_J9VMBase *feWithoutThread = TR_J9VMBase::get(vm->jitConfig, 0);358TR_J9SharedCache *sharedCache = new (PERSISTENT_NEW) TR_J9SharedCache((TR_J9VMBase *)feWithoutThread);359if (sharedCache != NULL)360{361TR_PersistentMemory *persistentMemory = (TR_PersistentMemory *)(vm->jitConfig->scratchSegment);362TR_PersistentClassLoaderTable *loaderTable = persistentMemory->getPersistentInfo()->getPersistentClassLoaderTable();363sharedCache->setPersistentClassLoaderTable(loaderTable);364loaderTable->setSharedCache(sharedCache);365}366}367else368#endif /* defined(J9VM_OPT_SHARED_CLASSES) */369{370TR::Options::setSharedClassCache(false);371}372373if (!isAOT)374{375/* turn off internal flags if user specified AOT to be turned OFF */376#if defined(J9VM_OPT_SHARED_CLASSES)377if (vm->sharedClassConfig && (vm->sharedClassConfig->runtimeFlags & J9SHR_RUNTIMEFLAG_ENABLE_AOT))378{379// doesn't matter if J9SHR_RUNTIMEFLAG_CACHE_INITIALIZATION_COMPLETE is set or not380// we're only clearing the ENABLE_AOT flag381vm->sharedClassConfig->runtimeFlags &= ~J9SHR_RUNTIMEFLAG_ENABLE_AOT;382}383#endif384if ( TR::Options::getAOTCmdLineOptions() )385{386TR::Options::getAOTCmdLineOptions()->setOption(TR_NoLoadAOT);387TR::Options::getAOTCmdLineOptions()->setOption(TR_NoStoreAOT);388TR::Options::setSharedClassCache(false);389}390}391392if (TR::Options::sharedClassCache())393TR_J9SharedCache::setSharedCacheDisabledReason(TR_J9SharedCache::NOT_DISABLED);394else395TR_J9SharedCache::setSharedCacheDisabledReason(TR_J9SharedCache::AOT_DISABLED);396397if (isJIT || isAOT)398{399400/* Although we've initialized the compiler, we have to tell the compiler whether it can perform JIT compiles401* This is because the compiler can be configured to only AOT compile. */402TR::Options::setCanJITCompile(isJIT);403404int32_t rv = aboutToBootstrap(vm, vm->jitConfig);405406jitConfig = vm->jitConfig;407408if (isAOT && !isJIT && TR::Options::getAOTCmdLineOptions()->getOption(TR_NoStoreAOT))409TR::Options::getCmdLineOptions()->setOption(TR_DisableInterpreterProfiling, true);410411412if (!TR::Options::canJITCompile()) // -Xnojit, then recompilation is not supported413// Ensure JIT and AOT flags are set appropriately414{415TR::Options::getAOTCmdLineOptions()->setAllowRecompilation(false);416TR::Options::getAOTCmdLineOptions()->setOption(TR_DisableCHOpts);417418TR::Options::getJITCmdLineOptions()->setAllowRecompilation(false);419TR::Options::getJITCmdLineOptions()->setOption(TR_DisableCHOpts);420}421422if (!isJIT)423{424TR::Options::getAOTCmdLineOptions()->setOption(TR_DisableGuardedCountingRecompilations);425}426427if (isAOT428&& TR::Options::getAOTCmdLineOptions()->getOption(TR_EnableClassChainValidationCaching)429&& (TR::Options::getCmdLineOptions()->getOption(TR_DisableCHOpts)))430{431TR::Options::getAOTCmdLineOptions()->setOption(TR_EnableClassChainValidationCaching, false);432}433434if (rv == -1)435{436// cannot free JIT config because shutdown stage expects it to exist437vm->runtimeFlags &= ~J9_RUNTIME_JIT_ACTIVE;438if (!loadInfo->fatalErrorStr || strlen(loadInfo->fatalErrorStr)==0)439loadInfo->fatalErrorStr = "cannot initialize JIT";440return J9VMDLLMAIN_FAILED;441}442443if (rv == 1)444{445// cannot free JIT config because shutdown stage expects it to exist446vm->runtimeFlags &= ~J9_RUNTIME_JIT_ACTIVE;447printf("Non-Fatal Error: cannot initialize JIT: JVMTI with FSD disabled\n");448}449450/* If the return value is 0, then continue normally */451TR::Options::setIsFullyInitialized();452}453454break;455}456457case VM_INITIALIZATION_COMPLETE:458{459// When the compilation thread was created, it was too early to create an460// instance of java.lang.Thread (we need to be assume that JCL is ready)461// Its safe to do this now.462//463if (isJIT || isAOT)464{465J9VMThread *curThread = vm->internalVMFunctions->currentVMThread(vm);466TR::CompilationInfo *compInfo = getCompilationInfo(vm->jitConfig);467TR::CompilationInfoPerThread * const *arrayOfCompInfoPT = compInfo->getArrayOfCompilationInfoPerThread();468TR_ASSERT(arrayOfCompInfoPT, "TR::CompilationInfo::_arrayOfCompilationInfoPerThread is null\n");469470for (int32_t i = 0; i < compInfo->getNumTotalCompilationThreads(); i++)471{472TR::CompilationInfoPerThread *curCompThreadInfoPT = arrayOfCompInfoPT[i];473TR_ASSERT(curCompThreadInfoPT, "a thread's compinfo is missing\n");474475J9VMThread *compThread = curCompThreadInfoPT->getCompilationThread();476if (!compThread)477continue;478479//char threadName[32]; // make sure the name below does not exceed 32 chars480//sprintf(threadName, "JIT Compilation Thread-%d", curCompThreadInfoPT->getCompThreadId());481482char *threadName = (483curCompThreadInfoPT->compilationThreadIsActive() ?484curCompThreadInfoPT->getActiveThreadName() :485curCompThreadInfoPT->getSuspendedThreadName()486);487488vm->internalVMFunctions->initializeAttachedThread(489curThread,490threadName,491vm->systemThreadGroupRef,492((compThread->privateFlags & J9_PRIVATE_FLAGS_DAEMON_THREAD) != 0),493compThread494);495496if ((curThread->currentException != NULL) || (curThread->threadObject == NULL))497{498if (!loadInfo->fatalErrorStr || strlen(loadInfo->fatalErrorStr)==0)499loadInfo->fatalErrorStr = "cannot create the jit Thread object";500return J9VMDLLMAIN_FAILED;501}502503TRIGGER_J9HOOK_VM_THREAD_STARTED(vm->hookInterface, curThread, compThread);504} // end for505506// Give a name to the sampling thread as well507// The sampling thread (if any) has been created and attached in stage 13508// It cannot be stopped because that happens in stage 17 while here we are in stage 15509// In this case we can access the samplingThreadLifetimeState without a monitor because510// no other thread tries to read or write to it.511if (compInfo->getSamplerThread())512{513TR_ASSERT(compInfo->getSamplingThreadLifetimeState() == TR::CompilationInfo::SAMPLE_THR_ATTACHED,514"Sampling thread must be already attached in stage 15\n");515vm->internalVMFunctions->initializeAttachedThread(516curThread,517"JIT-SamplerThread",518vm->systemThreadGroupRef,519((compInfo->getSamplerThread()->privateFlags & J9_PRIVATE_FLAGS_DAEMON_THREAD) != 0),520compInfo->getSamplerThread()521);522if ((curThread->currentException != NULL) || (curThread->threadObject == NULL))523{524if (!loadInfo->fatalErrorStr || strlen(loadInfo->fatalErrorStr)==0)525loadInfo->fatalErrorStr = "cannot create the jit Sampler Thread object";526return J9VMDLLMAIN_FAILED;527}528compInfo->setSamplingThreadLifetimeState(TR::CompilationInfo::SAMPLE_THR_INITIALIZED);529TRIGGER_J9HOOK_VM_THREAD_STARTED(vm->hookInterface, curThread, compInfo->getSamplerThread());530}531532TR_J9VMBase *fe = TR_J9VMBase::get(vm->jitConfig, 0);533if (!fe->isAOT_DEPRECATED_DO_NOT_USE())534TR_AnnotationBase::loadExpectedAnnotationClasses(curThread);535536// Also set name for interpreter profiler thread if it exists537#if defined (J9VM_INTERP_PROFILING_BYTECODES)538TR_IProfiler *iProfiler = fe->getIProfiler();539if (iProfiler)540{541J9VMThread *iProfilerThread = iProfiler->getIProfilerThread();542if (iProfilerThread)543{544vm->internalVMFunctions->initializeAttachedThread545(curThread, "IProfiler", vm->systemThreadGroupRef,546((iProfilerThread->privateFlags & J9_PRIVATE_FLAGS_DAEMON_THREAD) != 0),547iProfilerThread);548if ((curThread->currentException != NULL) || (curThread->threadObject == NULL))549{550if (!loadInfo->fatalErrorStr || strlen(loadInfo->fatalErrorStr)==0)551loadInfo->fatalErrorStr = "cannot create the iProfiler Thread object";552return J9VMDLLMAIN_FAILED;553}554TRIGGER_J9HOOK_VM_THREAD_STARTED(vm->hookInterface, curThread, iProfilerThread);555}556}557#endif558559TR_JProfilerThread *jProfiler = ((TR_JitPrivateConfig*)(vm->jitConfig->privateConfig))->jProfiler;560if (jProfiler)561{562J9VMThread *jProfilerThread = jProfiler->getJProfilerThread();563if (jProfilerThread)564{565vm->internalVMFunctions->initializeAttachedThread566(curThread, "JProfiler", vm->systemThreadGroupRef,567((jProfilerThread->privateFlags & J9_PRIVATE_FLAGS_DAEMON_THREAD) != 0),568jProfilerThread);569if ((curThread->currentException != NULL) || (curThread->threadObject == NULL))570{571if (!loadInfo->fatalErrorStr || strlen(loadInfo->fatalErrorStr)==0)572loadInfo->fatalErrorStr = "cannot create the jProfiler Thread object";573return J9VMDLLMAIN_FAILED;574}575TRIGGER_J9HOOK_VM_THREAD_STARTED(vm->hookInterface, curThread, jProfilerThread);576}577}578}579}580break;581582case INTERPRETER_SHUTDOWN:583584if (isJIT || isAOT)585{586if (vm->jitConfig)587{588TR_J9VMBase *trvm = TR_J9VMBase::get(vm->jitConfig, 0);589if (!trvm->isAOT_DEPRECATED_DO_NOT_USE() && trvm->_compInfo)590{591#if defined(J9VM_OPT_JITSERVER)592if (trvm->_compInfo->getPersistentInfo()->getRemoteCompilationMode() == JITServer::SERVER)593{594TR_Listener *listener = ((TR_JitPrivateConfig*)(vm->jitConfig->privateConfig))->listener;595if (listener)596{597listener->stop();598}599}600#endif /* defined(J9VM_OPT_JITSERVER) */601trvm->_compInfo->stopCompilationThreads();602}603JitShutdown(vm->jitConfig);604}605}606break;607608case LIBRARIES_ONUNLOAD :609case JVM_EXIT_STAGE :610if (jitInitialized)611{612jitConfig = vm->jitConfig;613if (jitConfig && stage == JVM_EXIT_STAGE)614JitShutdown(jitConfig);615//TR_FrontEnd * vm = TR_J9VMBase::get(jitConfig, 0);616//TR::Compilation::shutdown(vm); // already done in JitShutdown617j9jit_fclose(((TR_JitPrivateConfig*)jitConfig->privateConfig)->vLogFile);618((TR_JitPrivateConfig*)jitConfig->privateConfig)->vLogFile = 0;619j9jit_fclose(((TR_JitPrivateConfig*)jitConfig->privateConfig)->rtLogFile);620((TR_JitPrivateConfig*)jitConfig->privateConfig)->rtLogFile = 0;621j9jit_fcloseId(jitConfig->tLogFile);622jitConfig->tLogFile = -1;623j9jit_fcloseId(jitConfig->tLogFileTemp);624jitConfig->tLogFileTemp = -1;625626static char * printIPFanInStats = feGetEnv("TR_PrintIPFanInStats");627if (printIPFanInStats)628((TR_JitPrivateConfig*)(jitConfig->privateConfig))->iProfiler->checkMethodHashTable();629630if ( stage != JVM_EXIT_STAGE ) /* If not shutdownDueToExit */631{632freeJITConfig(jitConfig);633}634jitInitialized = false;635}636637if (aotrtInitialized)638{639#if defined(J9VM_INTERP_AOT_RUNTIME_SUPPORT)640jitConfig = vm->jitConfig;641if (jitConfig)642jitConfig->runtimeFlags &= ~J9JIT_AOT_ATTACHED;643#endif644if ( stage != JVM_EXIT_STAGE )645codert_OnUnload(vm);646aotrtInitialized = false;647}648break;649}650return J9VMDLLMAIN_OK;651}652653654