From 43e287f7a2cc09099ee36bd4d6d61af81b1c4620 Mon Sep 17 00:00:00 2001 From: "Keith W. Campbell" Date: Tue, 16 Nov 2021 12:38:10 -0500 Subject: [PATCH] Tidy up CRIU support * inline CRIU checkpoint state (only if needed) * add missing #endif comments * compile criuhelpers.cpp only if CRIU support is configured * only declare functions when they will be defined Signed-off-by: Keith W. Campbell --- runtime/compiler/control/HookedByTheJit.cpp | 13 +- runtime/compiler/control/J9Options.cpp | 2 +- runtime/compiler/control/rossa.cpp | 2 +- runtime/compiler/env/VMJ9.cpp | 4 +- runtime/criusupport/criusupport.cpp | 2 +- runtime/gc_modron_startup/mminit.cpp | 8 +- runtime/oti/j9nonbuilder.h | 43 +-- runtime/oti/vm_api.h | 8 +- runtime/vm/CMakeLists.txt | 11 +- runtime/vm/criuhelpers.cpp | 19 +- runtime/vm/jvminit.c | 308 ++++++++++++-------- runtime/vm/module.xml | 3 + 12 files changed, 242 insertions(+), 181 deletions(-) diff --git a/runtime/compiler/control/HookedByTheJit.cpp b/runtime/compiler/control/HookedByTheJit.cpp index fa712dd2050..92fc5432e37 100644 --- a/runtime/compiler/control/HookedByTheJit.cpp +++ b/runtime/compiler/control/HookedByTheJit.cpp @@ -1816,7 +1816,7 @@ static void jitHookPrepareRestore(J9HookInterface * * hookInterface, UDATA event jitConfig->targetProcessor = TR::Compiler->target.cpu.getProcessorDescription(); } } -#endif +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ #if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING) static void jitHookClassesUnload(J9HookInterface * * hookInterface, UDATA eventNum, void * eventData, void * userData) @@ -2119,7 +2119,7 @@ static void jitHookClassUnload(J9HookInterface * * hookInterface, UDATA eventNum compInfo->getUnloadedClassesTempList()->push_back(clazz); // Loop through the set to find the class that needs to be purged. // Once found erase from the set. - compInfo->getclassesCachedAtServer().erase(unloadedEvent->clazz); + compInfo->getclassesCachedAtServer().erase(unloadedEvent->clazz); if (auto deserializer = compInfo->getJITServerAOTDeserializer()) deserializer->invalidateClass(vmThread, j9clazz); } @@ -5152,7 +5152,7 @@ static void DoCalculateOverallCompCPUUtilization(TR::CompilationInfo *compInfo, const CpuSelfThreadUtilization& cpuUtil = arrayOfCompInfoPT[i]->getCompThreadCPU(); TR_VerboseLog::write(" compThr%d:%3d%% (%2d%%, %2d%%) ", i, cpuUtilizationValues[i], cpuUtil.getThreadLastCpuUtil(), cpuUtil.getThreadPrevCpuUtil()); if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCompilationThreadsDetails)) - TR_VerboseLog::write("(%dms, %dms, lastCheckpoint=%u) ", + TR_VerboseLog::write("(%dms, %dms, lastCheckpoint=%u) ", static_cast(cpuUtil.getLastMeasurementInterval()) / 1000000, static_cast(cpuUtil.getSecondLastMeasurementInterval()) / 1000000, cpuUtil.getLowResolutionClockAtLastUpdate()); @@ -5396,7 +5396,7 @@ static void iProfilerActivationLogic(J9JITConfig * jitConfig, TR::CompilationInf TR_J9VMBase *fej9 = (TR_J9VMBase *)(TR_J9VMBase::get(jitConfig, 0)); TR_IProfiler *iProfiler = fej9->getIProfiler(); TR::PersistentInfo *persistentInfo = compInfo->getPersistentInfo(); - if (iProfiler + if (iProfiler && iProfiler->getProfilerMemoryFootprint() < TR::Options::_iProfilerMemoryConsumptionLimit #if defined(J9VM_OPT_JITSERVER) && compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER @@ -6556,7 +6556,7 @@ int32_t setUpHooks(J9JavaVM * javaVM, J9JITConfig * jitConfig, TR_FrontEnd * vm) jitConfig->samplerMonitor = NULL; // initialize this field just in case compInfo->setSamplingThreadLifetimeState(TR::CompilationInfo::SAMPLE_THR_NOT_CREATED); // just in case - if (jitConfig->samplingFrequency + if (jitConfig->samplingFrequency && !vmj9->isAOT_DEPRECATED_DO_NOT_USE() #if defined(J9VM_OPT_JITSERVER) && compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER @@ -6571,7 +6571,6 @@ int32_t setUpHooks(J9JavaVM * javaVM, J9JITConfig * jitConfig, TR_FrontEnd * vm) j9thread_monitor_init_with_name(&(jitConfig->samplerMonitor), 0, "JIT sampling thread"); - if (jitConfig->samplerMonitor) { UDATA priority; @@ -6799,7 +6798,7 @@ int32_t setUpHooks(J9JavaVM * javaVM, J9JITConfig * jitConfig, TR_FrontEnd * vm) j9tty_printf(PORTLIB, "Error: Unable to register CRIU hook\n"); return -1; } -#endif +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ if (!vmj9->isAOT_DEPRECATED_DO_NOT_USE() #if defined(J9VM_OPT_JITSERVER) diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index 0ff259a5f9f..5b7557e8be6 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -1258,7 +1258,7 @@ void J9::Options::preProcessMmf(J9JavaVM *vm, J9JITConfig *jitConfig) if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_ENABLE_PORTABLE_SHARED_CACHE) #if defined(J9VM_OPT_CRIU_SUPPORT) || vm->internalVMFunctions->isCheckpointAllowed(vmThread) -#endif +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ ) { // Disable any fixed-size heap optimizations under portable shared cache mode diff --git a/runtime/compiler/control/rossa.cpp b/runtime/compiler/control/rossa.cpp index bf533bc2920..07bdf26e71e 100644 --- a/runtime/compiler/control/rossa.cpp +++ b/runtime/compiler/control/rossa.cpp @@ -2037,7 +2037,7 @@ aboutToBootstrap(J9JavaVM * javaVM, J9JITConfig * jitConfig) TR::Compiler->target.cpu = TR::CPU::detectRelocatable(TR::Compiler->omrPortLib); jitConfig->targetProcessor = TR::Compiler->target.cpu.getProcessorDescription(); } -#endif +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ #if defined(TR_TARGET_S390) uintptr_t * tocBase = (uintptr_t *)jitConfig->pseudoTOC; diff --git a/runtime/compiler/env/VMJ9.cpp b/runtime/compiler/env/VMJ9.cpp index e9504e5b395..871ee1ce30d 100644 --- a/runtime/compiler/env/VMJ9.cpp +++ b/runtime/compiler/env/VMJ9.cpp @@ -9453,9 +9453,9 @@ TR_J9VMBase::inSnapshotMode() { #if defined(J9VM_OPT_CRIU_SUPPORT) return getJ9JITConfig()->javaVM->internalVMFunctions->isCheckpointAllowed(vmThread()); -#else +#else /* defined(J9VM_OPT_CRIU_SUPPORT) */ return false; -#endif +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ } diff --git a/runtime/criusupport/criusupport.cpp b/runtime/criusupport/criusupport.cpp index cbbfb8e8ad4..64245e04c04 100644 --- a/runtime/criusupport/criusupport.cpp +++ b/runtime/criusupport/criusupport.cpp @@ -173,7 +173,7 @@ getNativeString(J9VMThread *currentThread, j9object_t javaString, char **nativeS } } - (localNativeString)[requiredConvertedStringSize - 1] = '\0'; + localNativeString[requiredConvertedStringSize - 1] = '\0'; /* convert the string */ requiredConvertedStringSize = omrstr_convert(J9STR_CODE_MUTF8, J9STR_CODE_PLATFORM_RAW, diff --git a/runtime/gc_modron_startup/mminit.cpp b/runtime/gc_modron_startup/mminit.cpp index 6a99d1ba7af..5773ab1af7d 100644 --- a/runtime/gc_modron_startup/mminit.cpp +++ b/runtime/gc_modron_startup/mminit.cpp @@ -1089,7 +1089,7 @@ gcInitializeXmxXmdxVerification(J9JavaVM *javaVM, IDATA* memoryParameters, bool /* Fail to initialize if assertions are off */ return JNI_ERR; } - + /* Adjust heap ceiling value if it is necessary */ if (extensions->heapCeiling > maxHeapForCR) { extensions->heapCeiling = maxHeapForCR; @@ -2918,11 +2918,11 @@ gcInitializeDefaults(J9JavaVM* vm) if (hwSupported) { /* Software Barrier request overwrites HW usage on supported HW */ - extensions->concurrentScavengerHWSupport = hwSupported - && !extensions->softwareRangeCheckReadBarrier + extensions->concurrentScavengerHWSupport = hwSupported + && !extensions->softwareRangeCheckReadBarrier #if defined(J9VM_OPT_CRIU_SUPPORT) && !vm->internalVMFunctions->isCRIUSupportEnabled(vm->internalVMFunctions->currentVMThread(vm)) -#endif +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ && !J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_ENABLE_PORTABLE_SHARED_CACHE); extensions->concurrentScavenger = hwSupported || extensions->softwareRangeCheckReadBarrier; } else { diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index 1792d094b5e..a57c1a1d9b4 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -621,19 +621,19 @@ typedef struct J9HotField { struct J9HotField* next; uint32_t hotness; uint16_t cpuUtil; - uint8_t hotFieldOffset; + uint8_t hotFieldOffset; } J9HotField; typedef struct J9ClassHotFieldsInfo { struct J9HotField* hotFieldListHead; struct J9ClassLoader* classLoader; - BOOLEAN isClassHotFieldListDirty; + BOOLEAN isClassHotFieldListDirty; uint8_t hotFieldOffset1; uint8_t hotFieldOffset2; uint8_t hotFieldOffset3; - uint8_t consecutiveHotFieldSelections; - uint8_t hotFieldListLength; - } J9ClassHotFieldsInfo; + uint8_t consecutiveHotFieldSelections; + uint8_t hotFieldListLength; +} J9ClassHotFieldsInfo; typedef struct J9ROMNameAndSignature { J9SRP name; @@ -2877,11 +2877,11 @@ typedef struct J9Object { /** * An aligned class pointer representing the type of the object. The low order bits must be masked off prior to * dereferencing this pointer. The bit values are described below. - * - * @details - * + * + * @details + * * The following diagram describes the metadata stored in the low order bit flags of an object class pointer: - * + * * Bit 31 23 15 7 6 5 4 3 2 1 0 * ┌─────────────────────────────────────────────────────────────────────┐ * Word │0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0│ @@ -2892,11 +2892,11 @@ typedef struct J9Object { * │ │ └──────► [3] Slot contains forwarded pointer * │ └────────► [4] Object has been hashed * └─────────────► [5] Nursery age (0 - 14) or various remembered states - * + * * [1] If bit is 0, the slot represents the start of object, ie object header, which depending of forwarded bit * could be class slot or forwarded pointer. * If bit is 1, the slot represents the start of a hole, in which case the value is the address of the next - * connected hole (as part of free memory pool). The address could be null, in which case it is a small + * connected hole (as part of free memory pool). The address could be null, in which case it is a small * stand-alone hole that is not part of the list, so called dark-matter. A hole will also have one more slot, * with info about its size/length. * This bit designation is needed when heap objects are iterated in address order - once an object is found, @@ -2904,18 +2904,18 @@ typedef struct J9Object { * [2] If object is hashed (hash bit 4 set), and object is moved by a GC, the object will grow by a hash slot * (position of hash slot is found in class struct), and this bit will be set. * This bit is used to find hash value (from object address if not moved or from hash slot if moved) and to - * find proper size of object (for example when heap objects are iterated, to find the position of the next + * find proper size of object (for example when heap objects are iterated, to find the position of the next * object). * [3] If the object has been moved on the heap and we encounter a stale reference, this bit tells us that the a * slot within the object contains a forwarding pointer (FP) to where we can find the moved object. FP * partially overlaps with class slot (it's not quite following it). In 32bit it exactly overlaps (both FP and * class slots are 32 bit). In 64bit non-CR, again it exactly overlaps (both FP and class slots are 64 bit ). - * In 64bit CR, 1/2 of FP overlaps with class slot, and the other 1/2 of FP follows the class slots (FP is + * In 64bit CR, 1/2 of FP overlaps with class slot, and the other 1/2 of FP follows the class slots (FP is * uncommpressed 64 bit, and class slot is 32 bit). * [4] Object has been hashed by application thread, for example by using the object as a key in a hash map * [5] If the object is in the nursery (gencon) these four bits count how many times the object has been flipped. * If the object is in tenure (gencon) these bits describe the various tenure states. These bits are not used - * under the balanced GC policy. + * under the balanced GC policy. */ j9objectclass_t clazz; } J9Object; @@ -3641,29 +3641,29 @@ typedef struct J9Method { /** * This field is overloaded and can have several meanings: - * + * * 1. If the J9_STARTPC_NOT_TRANSLATED bit is set, this method is interpreted * a. If the value is non-negative, then the field contains the invocation count which is decremented towards * zero. When the invocation count reaches zero, the method will be queued for JIT compilation. The invocation * count is represented as: - * + * * ``` * (invocationCount << 1) | J9_STARTPC_NOT_TRANSLATED * ``` - * + * * b. If the method is a default method which has conflicts then this field contains the RAM method to execute. * That is, the extra field will contain: - * + * * ``` * ((J9Method*)) | J9_STARTPC_NOT_TRANSLATED * ``` - * + * * c. If the value is negative, then it can be one of (see definition for documentation on these): * - J9_JIT_NEVER_TRANSLATE * The VM will not decrement the count and the method will stay interpreted * - J9_JIT_QUEUED_FOR_COMPILATION * The method has been queued for JIT compilation - * + * * 2. If the J9_STARTPC_NOT_TRANSLATED bit is not set, this method is JIT compiled * a. The field contains the address of the start PC of the JIT compiled method */ @@ -5101,6 +5101,7 @@ typedef struct J9VMThread { #define J9VMTHREAD_DISCONTIGUOUS_HEADER_SIZE(vmThread) (J9VMTHREAD_COMPRESS_OBJECT_REFERENCES(vmThread) ? sizeof(J9IndexableObjectDiscontiguousCompressed) : sizeof(J9IndexableObjectDiscontiguousFull)) typedef struct J9CRIUCheckpointState { + BOOLEAN isCheckPointEnabled; BOOLEAN isCheckPointAllowed; BOOLEAN isNonPortableRestoreMode; } J9CRIUCheckpointState; @@ -5558,8 +5559,8 @@ typedef struct J9JavaVM { jmethodID criuJVMCheckpointExceptionInit; jmethodID criuSystemCheckpointExceptionInit; jmethodID criuRestoreExceptionInit; + J9CRIUCheckpointState checkpointState; #endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ - J9CRIUCheckpointState *checkpointState; #if JAVA_SPEC_VERSION >= 16 struct J9Pool *cifNativeCalloutDataCache; omrthread_monitor_t cifNativeCalloutDataCacheMutex; diff --git a/runtime/oti/vm_api.h b/runtime/oti/vm_api.h index 260e0c2f12b..0dbfe00414b 100644 --- a/runtime/oti/vm_api.h +++ b/runtime/oti/vm_api.h @@ -488,12 +488,13 @@ internalCreateRAMClassFromROMClass(J9VMThread *vmThread, J9ClassLoader *classLoa IDATA entryIndex, I_32 locationType, J9Class *classBeingRedefined, J9Class *hostClass); +#if defined(J9VM_OPT_CRIU_SUPPORT) + /* ---------------- criuhelpers.cpp ---------------- */ /** * @brief Queries if CRIU support is enabled. By default support * is not enabled, it can be enabled with `-XX:+EnableCRIUSupport` * - * * @param currentThread vmthread token * @return TRUE if enabled, FALSE otherwise */ @@ -506,7 +507,6 @@ isCRIUSupportEnabled(J9VMThread *currentThread); * will not be permitted after the JVM has been restored from a checkpoint * (checkpoint once mode). * - * * @param currentThread vmthread token * @return TRUE if permitted, FALSE otherwise */ @@ -532,6 +532,8 @@ jvmCheckpointHooks(J9VMThread *currentThread); BOOLEAN jvmRestoreHooks(J9VMThread *currentThread); +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ + /* ---------------- classloadersearch.c ---------------- */ /** @@ -4712,7 +4714,7 @@ void throwNewJavaIoIOException(JNIEnv *env, const char *message); #ifdef __cplusplus -} +} /* extern "C" */ #endif #endif /* vm_api_h */ diff --git a/runtime/vm/CMakeLists.txt b/runtime/vm/CMakeLists.txt index 363f3fd0c5b..db861e65352 100644 --- a/runtime/vm/CMakeLists.txt +++ b/runtime/vm/CMakeLists.txt @@ -52,7 +52,7 @@ if(OMR_ARCH_POWER AND OMR_OS_AIX) ]] endif() elseif(OMR_OS_ZOS) - #TODO need to handle optimized debug info + # TODO need to handle optimized debug info list(APPEND interp_flags_to_remove "-O3" "-g" "-qdebug=nohook") list(APPEND interp_new_flags @@ -91,7 +91,6 @@ set(main_sources classseg.c classsupport.c createramclass.cpp - criuhelpers.cpp description.c dllsup.c drophelp.c @@ -182,6 +181,13 @@ set(main_sources ${CMAKE_CURRENT_BINARY_DIR}/ut_j9vm.c ) + +if(J9VM_OPT_CRIU_SUPPORT) + list(APPEND main_sources + criuhelpers.cpp + ) +endif() + set(interpreter_sources BytecodeInterpreterCompressed.cpp BytecodeInterpreterFull.cpp @@ -219,7 +225,6 @@ if(interp_new_flags) set_property(SOURCE ${interpreter_sources} APPEND_STRING PROPERTY COMPILE_FLAGS " ${flags_str}") endif() - if(OMR_OS_WINDOWS AND (OMR_TOOLCONFIG STREQUAL "msvc")) # JIT helper methods require us to disable buffer security checks on Windows # See https://github.com/eclipse-openj9/openj9/pull/1494 for rationale diff --git a/runtime/vm/criuhelpers.cpp b/runtime/vm/criuhelpers.cpp index 22f3320ede5..69f27e9c4bd 100644 --- a/runtime/vm/criuhelpers.cpp +++ b/runtime/vm/criuhelpers.cpp @@ -67,10 +67,10 @@ jvmRestoreHooks(J9VMThread *currentThread) nas.name = (J9UTF8 *)&runPostRestoreHooks_name; nas.signature = (J9UTF8 *)&runPostRestoreHooks_sig; - Assert_VM_notNull(vm->checkpointState); + Assert_VM_true(vm->checkpointState.isCheckPointEnabled); - if (vm->checkpointState->isNonPortableRestoreMode) { - vm->checkpointState->isCheckPointAllowed = FALSE; + if (vm->checkpointState.isNonPortableRestoreMode) { + vm->checkpointState.isCheckPointAllowed = FALSE; } TRIGGER_J9HOOK_VM_PREPARING_FOR_RESTORE(vm->hookInterface, currentThread); @@ -88,22 +88,19 @@ jvmRestoreHooks(J9VMThread *currentThread) BOOLEAN isCRIUSupportEnabled(J9VMThread *currentThread) { - return NULL != currentThread->javaVM->checkpointState; + return currentThread->javaVM->checkpointState.isCheckPointEnabled; } BOOLEAN isCheckpointAllowed(J9VMThread *currentThread) { - J9JavaVM *vm = currentThread->javaVM; - BOOLEAN res = FALSE; + BOOLEAN result = FALSE; if (isCRIUSupportEnabled(currentThread)) { - res = vm->checkpointState->isCheckPointAllowed; + result = currentThread->javaVM->checkpointState.isCheckPointAllowed; } - return res; + return result; } - - -}/* extern "C" */ +} /* extern "C" */ diff --git a/runtime/vm/jvminit.c b/runtime/vm/jvminit.c index 17144277610..8e06aca5def 100644 --- a/runtime/vm/jvminit.c +++ b/runtime/vm/jvminit.c @@ -42,10 +42,7 @@ #include #include "util_api.h" -#if !defined(stdout) -#ifdef stdout -#undef stdout -#endif +#if !defined(stdout) #define stdout NULL #endif @@ -185,7 +182,7 @@ static const struct J9VMIgnoredOption ignoredOptionTable[] = { { VMOPT_CLIENT, EXACT_MATCH }, { VMOPT_SERVER, EXACT_MATCH }, { VMOPT_X142BOOSTGCTHRPRIO, EXACT_MATCH }, - + { MAPOPT_XSIGCATCH, EXACT_MATCH }, { MAPOPT_XNOSIGCATCH, EXACT_MATCH }, { MAPOPT_XINITACSH, EXACT_MEMORY_MATCH }, @@ -387,7 +384,9 @@ freeBytecodePairs(J9JavaVM *vm) } #endif /* COUNT_BYTECODE_PAIRS */ -static void print_verbose_stackusage_of_nonsystem_threads(J9VMThread* vmThread) { +static void +print_verbose_stackusage_of_nonsystem_threads(J9VMThread* vmThread) +{ J9VMThread * currentThread; J9JavaVM * vm = vmThread->javaVM; if ((vm->runtimeFlags & J9_RUNTIME_REPORT_STACK_USE) && vmThread->stackObject && (vm->verboseLevel & VERBOSE_STACK)) { @@ -419,7 +418,9 @@ static void print_verbose_stackusage_of_nonsystem_threads(J9VMThread* vmThread) } } -void print_verbose_stackUsage(J9VMThread* vmThread, UDATA stillRunning){ +void +print_verbose_stackUsage(J9VMThread* vmThread, UDATA stillRunning) +{ UDATA *stackSlot = J9_LOWEST_STACK_SLOT(vmThread); UDATA nbyteUsed = (vmThread->stackObject->end - stackSlot) * sizeof(UDATA); UDATA cbyteUsed = omrthread_get_stack_usage(vmThread->osThread); @@ -453,7 +454,9 @@ void print_verbose_stackUsage(J9VMThread* vmThread, UDATA stillRunning){ * * @return 0 if success, 1 otherwise */ -static UDATA setGlobalConvertersAware(J9JavaVM *vm) { +static UDATA +setGlobalConvertersAware(J9JavaVM *vm) +{ UDATA rc = 0; if ((FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XIPT, NULL)) >= 0) { @@ -469,7 +472,8 @@ static UDATA setGlobalConvertersAware(J9JavaVM *vm) { return rc; } -void OMRNORETURN exitJavaVM(J9VMThread * vmThread, IDATA rc) +void OMRNORETURN +exitJavaVM(J9VMThread * vmThread, IDATA rc) { J9JavaVM *vm = NULL; @@ -778,12 +782,12 @@ freeJavaVM(J9JavaVM * vm) } runShutdownStage(vm, GC_SHUTDOWN_COMPLETE, NULL, 0); - /* zOS: Do not close any of the DLLs. This is necessary - * because we do not know for sure whether all the threads + /* zOS: Do not close any of the DLLs. This is necessary + * because we do not know for sure whether all the threads * that may depend on these DLLs have terminated. * - * Note that this solution is also suggested in the - * 'z/OS XL C/C++ Programming Guide' V1R13 (Chapter 21 + * Note that this solution is also suggested in the + * 'z/OS XL C/C++ Programming Guide' V1R13 (Chapter 21 * under the heading 'DLL Restrictions'). */ #if !defined(J9ZOS390) @@ -798,13 +802,6 @@ freeJavaVM(J9JavaVM * vm) vm->dllLoadTable = NULL; } -#if defined(J9VM_OPT_CRIU_SUPPORT) - if (NULL != vm->checkpointState) { - j9mem_free_memory(vm->checkpointState); - vm->checkpointState = NULL; - } -#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ - /* Detach the VM from OMR */ detachVMFromOMR(vm); @@ -894,7 +891,7 @@ freeJavaVM(J9JavaVM * vm) j9mem_free_memory(vm->originalSIGPIPESignalAction); vm->originalSIGPIPESignalAction = NULL; } -#endif +#endif #if defined(J9VM_INTERP_CUSTOM_SPIN_OPTIONS) /* Free custom spin options */ @@ -1088,7 +1085,8 @@ initializeJavaVM(void * osMainThread, J9JavaVM ** vmPtr, J9CreateJavaVMParams *c } #if (defined(J9VM_PROF_COUNT_ARGS_TEMPS)) -static void report(J9JavaVM * vm) +static void +report(J9JavaVM * vm) { UDATA ** counts = (UDATA **) vm->reserved2; UDATA count; @@ -1161,11 +1159,10 @@ static void report(J9JavaVM * vm) printf("\n\n"); } - #endif /* J9VM_PROF_COUNT_ARGS_TEMPS */ - -static void vfprintfHook(struct OMRPortLibrary *portLib, const char *format, ...) +static void +vfprintfHook(struct OMRPortLibrary *portLib, const char *format, ...) { va_list args; jint (JNICALL * * vprintfHookFunctionPtr)(FILE *fp, const char *format, va_list args) = GLOBAL_DATA(vprintfHookFunction); @@ -1188,7 +1185,9 @@ static IDATA vfprintfHook_file_write_text(struct OMRPortLibrary *portLibrary, ID /* Run using a pool_do, this method loads all libraries that match the flags given. */ -static void loadDLL(void* dllLoadInfo, void* userDataTemp) { +static void +loadDLL(void* dllLoadInfo, void* userDataTemp) +{ J9VMDllLoadInfo* entry = (J9VMDllLoadInfo*) dllLoadInfo; LoadInitData* userData = (LoadInitData*) userDataTemp; @@ -1204,15 +1203,15 @@ static void loadDLL(void* dllLoadInfo, void* userDataTemp) { /* this function will enter information, such as the descriptor, into the dllLoadInfo */ loadDllSuccess = loadJ9DLL(userData->vm, entry); - - end = j9time_nano_time(); - + + end = j9time_nano_time(); + if (loadDllSuccess) { JVMINIT_VERBOSE_INIT_VM_TRACE1(userData->vm, "\tLoaded library %s\n", dllName); } else { JVMINIT_VERBOSE_INIT_VM_TRACE1(userData->vm, "\tFailed to load library %s\n", dllName); } - + JVMINIT_VERBOSE_INIT_VM_TRACE2(userData->vm, "\t\tcompleted with rc=%d in %lld nano sec.\n", loadDllSuccess, (end-start)); JVMINIT_VERBOSE_INIT_TRACE_WORKING_SET(userData->vm); } @@ -1572,7 +1571,8 @@ initializeModulesPathEntry(J9JavaVM * javaVM, J9ClassPathEntry *cpEntry) * /modules - should be a directory containing modules in exploded form */ IDATA -initializeModulesPath(J9JavaVM *vm) { +initializeModulesPath(J9JavaVM *vm) +{ UDATA rc = 0; IDATA modulesPathLen = 0; U_8 *modulesPath = NULL; @@ -1621,7 +1621,6 @@ initializeModulesPath(J9JavaVM *vm) { return -1; } - BOOLEAN setBootLoaderModulePatchPaths(J9JavaVM * javaVM, J9Module * j9module, const char * moduleName) { @@ -1685,7 +1684,8 @@ setBootLoaderModulePatchPaths(J9JavaVM * javaVM, J9Module * j9module, const char } static VMINLINE void -processMemoryInterleaveOptions(J9JavaVM * vm) { +processMemoryInterleaveOptions(J9JavaVM * vm) +{ PORT_ACCESS_FROM_JAVAVM(vm); BOOLEAN enabled = FALSE; IDATA argIndex = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_OPT_XXINTERLEAVEMEMORY, NULL); @@ -1698,8 +1698,9 @@ processMemoryInterleaveOptions(J9JavaVM * vm) { j9port_control(J9PORT_CTLDATA_VMEM_NUMA_INTERLEAVE_MEM, enabled? 1 : 0); } -static VMINLINE void -dumpClassLoader(J9JavaVM *vm, J9ClassLoader *loader, IDATA fd){ +static VMINLINE void +dumpClassLoader(J9JavaVM *vm, J9ClassLoader *loader, IDATA fd) +{ J9HashTableState walkState = {0}; PORT_ACCESS_FROM_JAVAVM(vm); J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions; @@ -1713,7 +1714,8 @@ dumpClassLoader(J9JavaVM *vm, J9ClassLoader *loader, IDATA fd){ } void -dumpLoadedClassList(J9HookInterface **hookInterface, uintptr_t eventNum, void *eventData, void *userData) { +dumpLoadedClassList(J9HookInterface **hookInterface, uintptr_t eventNum, void *eventData, void *userData) +{ J9VMShutdownEvent *event = eventData; J9JavaVM *vm = event->vmThread->javaVM; PORT_ACCESS_FROM_JAVAVM(vm); @@ -1735,7 +1737,8 @@ dumpLoadedClassList(J9HookInterface **hookInterface, uintptr_t eventNum, void *e /* Print out the internal version information for openj9 */ static void -j9print_internal_version(J9PortLibrary *portLib) { +j9print_internal_version(J9PortLibrary *portLib) +{ PORT_ACCESS_FROM_PORT(portLib); #if defined(OPENJ9_BUILD) @@ -1755,7 +1758,9 @@ j9print_internal_version(J9PortLibrary *portLib) { /* The equivalent of a J9VMDllMain for the VM init module */ -IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { +IDATA +VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) +{ J9VMDllLoadInfo *loadInfo; IDATA returnVal = J9VMDLLMAIN_OK; IDATA argIndex = -1; @@ -1980,13 +1985,13 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { #if defined(AIXPPC) || defined(J9ZOS390) if (argIndex > argIndex2) { - vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_FLAG_JSCRATCH_ADV_ON_FREE; - } + vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_FLAG_JSCRATCH_ADV_ON_FREE; + } #else /* make +DisclaimJitScratch the default behavior for non AIX platforms*/ if (argIndex2 < 0 || (argIndex > argIndex2)) { - vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_FLAG_JSCRATCH_ADV_ON_FREE; - } + vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_FLAG_JSCRATCH_ADV_ON_FREE; + } #endif /* -Xtune:virtualized was added so that consumers could start adding it to their command lines */ @@ -2002,9 +2007,9 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { /* if -Xsoftmx is a parameter, +DisclaimVirtualMemory is set */ if (argIndex3 >= 0) { j9port_control(J9PORT_CTLDATA_VMEM_ADVISE_OS_ONFREE, 1); - } - /* last instance of +/- DisclaimVirtualMemory found on the command line wins and - * overrules -Xsoftmx +DisclaimVirtualMemory setting */ + } + /* last instance of +/- DisclaimVirtualMemory found on the command line wins and + * overrules -Xsoftmx +DisclaimVirtualMemory setting */ if (argIndex2 > argIndex) { j9port_control(J9PORT_CTLDATA_VMEM_ADVISE_OS_ONFREE, 1); } else if (argIndex > argIndex2) { @@ -2031,12 +2036,12 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { argIndex2 = FIND_ARG_IN_VMARGS(EXACT_MATCH, VMOPT_XXNONLSMESSAGES, NULL); if (argIndex2 > argIndex) { j9port_control(OMRPORT_CTLDATA_NLS_DISABLE, 1); - } + } if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags, J9_EXTENDED_RUNTIME_PAGE_ALIGN_DIRECT_MEMORY)) { J9VMSystemProperty* prop = NULL; - if ((J9SYSPROP_ERROR_NONE != getSystemProperty(vm, "sun.nio.PageAlignDirectMemory", &prop)) + if ((J9SYSPROP_ERROR_NONE != getSystemProperty(vm, "sun.nio.PageAlignDirectMemory", &prop)) || (J9SYSPROP_ERROR_NONE != setSystemProperty(vm, prop, "true")) ) { loadInfo = FIND_DLL_TABLE_ENTRY( FUNCTION_VM_INIT ); @@ -2085,7 +2090,7 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { BOOLEAN enableGcOnIdle = FALSE; BOOLEAN inContainer = omrsysinfo_is_running_in_container(); - /* + /* * GcOnIdle is enabled only if: * 1. -XX:+IdleTuningGcOnIdle is set, or * 2. running in container, or @@ -2103,12 +2108,12 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { if (TRUE == enableGcOnIdle) { vm->vmRuntimeStateListener.idleTuningFlags |= (UDATA)J9_IDLE_TUNING_GC_ON_IDLE; /* - * - * CompactOnIdle is enabled only if XX:+IdleTuningGcOnIdle is set and - * -XX:+IdleTuningCompactOnIdle is set - * - * Setting Xtune:virtualized on java versions 9 or above does not enable CompactOnIdle. - */ + * + * CompactOnIdle is enabled only if XX:+IdleTuningGcOnIdle is set and + * -XX:+IdleTuningCompactOnIdle is set + * + * Setting Xtune:virtualized on java versions 9 or above does not enable CompactOnIdle. + */ if (argIndexCompactOnIdleEnable > argIndexCompactOnIdleDisable) { vm->vmRuntimeStateListener.idleTuningFlags |= (UDATA)J9_IDLE_TUNING_COMPACT_ON_IDLE; } else { @@ -2650,7 +2655,7 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { Trc_VM_VMInitStages_InvariantInterningDisabled(); } Trc_VM_classloaderLocking(J9_ARE_NO_BITS_SET(vm->extendedRuntimeFlags,J9_EXTENDED_RUNTIME_CLASSLOADER_LOCKING_ENABLED)? "disabled": "enabled" ); - + if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags, J9_EXTENDED_RUNTIME_REDUCE_CPU_MONITOR_OVERHEAD)) { Trc_VM_VMInitStages_ReduceCPUMonitorOverhead("enabled", "false"); } else { @@ -2751,7 +2756,9 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { /* Run after all command-line args should have been consumed. Returns TRUE or FALSE. */ -static UDATA checkArgsConsumed(J9JavaVM * vm, J9PortLibrary* portLibrary, J9VMInitArgs* j9vm_args) { +static UDATA +checkArgsConsumed(J9JavaVM * vm, J9PortLibrary* portLibrary, J9VMInitArgs* j9vm_args) +{ UDATA i = 0; PORT_ACCESS_FROM_PORT(portLibrary); jboolean ignoreUnrecognized = j9vm_args->actualVMArgs->ignoreUnrecognized; @@ -2796,8 +2803,8 @@ static UDATA checkArgsConsumed(J9JavaVM * vm, J9PortLibrary* portLibrary, J9VMIn if (IS_CONSUMABLE( j9vm_args, i ) && !IS_CONSUMED( j9vm_args, i )) { char* optString = j9vm_args->actualVMArgs->options[i].optionString; char* envVar = j9vm_args->j9Options[i].fromEnvVar; - - /* If ignoreUnrecognized is set to JNI_TRUE, we should not reject any options that are: + + /* If ignoreUnrecognized is set to JNI_TRUE, we should not reject any options that are: empty or contain only whitespace, or unrecognized options beginning with -X or _ */ if (ignoreUnrecognized && (NULL != optString) && (isEmpty(optString) || !strncmp(optString, "-X", 2) || *optString=='_')) { continue; @@ -2827,7 +2834,9 @@ static UDATA checkArgsConsumed(J9JavaVM * vm, J9PortLibrary* portLibrary, J9VMIn } /* Returns TRUE if a string is empty or if it contains only whitespace characters. */ -static BOOLEAN isEmpty(const char * str) { +static BOOLEAN +isEmpty(const char * str) +{ BOOLEAN isEmpty = TRUE; while('\0' != *str) { if (0 == isspace((unsigned char) *str)) { @@ -2842,7 +2851,9 @@ static BOOLEAN isEmpty(const char * str) { /* Run using a pool_do after each initialization stage. If any errors were reported by libraries, a flag is set to FALSE and the error is printed. See checkPostStage. */ -static void checkDllInfo(void* dllLoadInfo, void* userDataTemp) { +static void +checkDllInfo(void* dllLoadInfo, void* userDataTemp) +{ J9VMDllLoadInfo* entry = (J9VMDllLoadInfo*)dllLoadInfo; CheckPostStageData* userData = (CheckPostStageData*)userDataTemp; int isInitialization = userData->stage < INTERPRETER_SHUTDOWN; @@ -2891,7 +2902,9 @@ static void checkDllInfo(void* dllLoadInfo, void* userDataTemp) { Eg. -Xint - the JIT library is not loaded and therefore cannot consume the option. Do not consume any arguments here unless absolutely necessary. */ -static void consumeVMArgs(J9JavaVM* vm, J9VMInitArgs* j9vm_args) { +static void +consumeVMArgs(J9JavaVM* vm, J9VMInitArgs* j9vm_args) +{ PORT_ACCESS_FROM_JAVAVM(vm); BOOLEAN assertOptionFound = FALSE; @@ -2994,7 +3007,7 @@ modifyDllLoadTable(J9JavaVM * vm, J9Pool* loadTable, J9VMInitArgs* j9vm_args) #define SET_FLAG_AT_INDEX(flag, index) j9vm_args->j9Options[index].flags = flag | (j9vm_args->j9Options[index].flags & ARG_MEMORY_ALLOCATION) xverify = ((xverifyIndex = findArgInVMArgs( PORTLIB, j9vm_args, OPTIONAL_LIST_MATCH, VMOPT_XVERIFY, NULL, FALSE))>=0); - + xxverboseverificationIndex = findArgInVMArgs( PORTLIB, j9vm_args, EXACT_MATCH, VMOPT_XXVERBOSEVERIFICATION, NULL, FALSE); xxnoverboseverificationIndex = findArgInVMArgs( PORTLIB, j9vm_args, EXACT_MATCH, VMOPT_XXNOVERBOSEVERIFICATION, NULL, FALSE); xxverboseverification = (xxverboseverificationIndex > xxnoverboseverificationIndex); @@ -3163,7 +3176,7 @@ modifyDllLoadTable(J9JavaVM * vm, J9Pool* loadTable, J9VMInitArgs* j9vm_args) UDATA zlibDllLength = 0; UDATA zlibFileHandle = 0; UDATA zlibRC = 0; - + zlibDllLength = strlen(vm->j9libvmDirectory); expectedZlibPathLength = zlibDllLength + (sizeof(DIR_SEPARATOR_STR) - 1) + strlen(J9_ZIP_DLL_NAME) + 1; if (expectedZlibPathLength > EsMaxPath) { @@ -3188,7 +3201,7 @@ modifyDllLoadTable(J9JavaVM * vm, J9Pool* loadTable, J9VMInitArgs* j9vm_args) } } #endif /* defined(S390) && defined(LINUX) */ - + optionValueOperations(PORTLIB, j9vm_args, xxjitdirectoryIndex, GET_OPTION, &jitdirectoryValue, 0, '=', 0, NULL); /* get option value for xxjitdirectory= */ jitDirectoryLength = strlen(jitdirectoryValue); /* Test that the alternate JIT Directory contains a valid JIT library for this release */ @@ -3402,7 +3415,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA alwaysCopyJNICritical = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXALWAYSCOPYJNICRITICAL, NULL); IDATA noAlwaysCopyJNICritical = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXNOALWAYSCOPYJNICRITICAL, NULL); if (alwaysCopyJNICritical > noAlwaysCopyJNICritical) { - vm->runtimeFlags |= J9_RUNTIME_ALWAYS_COPY_JNI_CRITICAL; + vm->runtimeFlags |= J9_RUNTIME_ALWAYS_COPY_JNI_CRITICAL; } else if (alwaysCopyJNICritical < noAlwaysCopyJNICritical) { vm->runtimeFlags &= ~(UDATA)J9_RUNTIME_ALWAYS_COPY_JNI_CRITICAL; } @@ -3412,7 +3425,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA alwaysUseJNICritical = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXALWAYSUSEJNICRITICAL, NULL); IDATA noAlwaysUseJNICritical = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXNOALWAYSUSEJNICRITICAL, NULL); if (alwaysUseJNICritical > noAlwaysUseJNICritical) { - vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_ALWAYS_USE_JNI_CRITICAL; + vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_ALWAYS_USE_JNI_CRITICAL; } else if (alwaysUseJNICritical < noAlwaysUseJNICritical) { vm->extendedRuntimeFlags &= ~(UDATA)J9_EXTENDED_RUNTIME_ALWAYS_USE_JNI_CRITICAL; } @@ -3422,7 +3435,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA debugVmAccess = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXDEBUGVMACCESS, NULL); IDATA noDebugVmAccess = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXNODEBUGVMACCESS, NULL); if (debugVmAccess > noDebugVmAccess) { - vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_DEBUG_VM_ACCESS; + vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_DEBUG_VM_ACCESS; } else if (debugVmAccess < noDebugVmAccess) { vm->extendedRuntimeFlags &= ~(UDATA)J9_EXTENDED_RUNTIME_DEBUG_VM_ACCESS; } @@ -3432,7 +3445,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA mhAllowI2J = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXMHALLOWI2J, NULL); IDATA nomhAllowI2J = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXNOMHALLOWI2J, NULL); if (mhAllowI2J > nomhAllowI2J) { - vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_I2J_MH_TRANSITION_ENABLED; + vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_I2J_MH_TRANSITION_ENABLED; } else if (mhAllowI2J < nomhAllowI2J) { vm->extendedRuntimeFlags &= ~(UDATA)J9_EXTENDED_RUNTIME_I2J_MH_TRANSITION_ENABLED; } @@ -3442,7 +3455,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA lazySymbolResolution = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXLAZYSYMBOLRESOLUTION, NULL); IDATA nolazySymbolResolution = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXNOLAZYSYMBOLRESOLUTION, NULL); if (lazySymbolResolution > nolazySymbolResolution) { - vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_LAZY_SYMBOL_RESOLUTION; + vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_LAZY_SYMBOL_RESOLUTION; } else if (lazySymbolResolution < nolazySymbolResolution) { vm->extendedRuntimeFlags &= ~(UDATA)J9_EXTENDED_RUNTIME_LAZY_SYMBOL_RESOLUTION; } @@ -3452,7 +3465,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA vmLockClassLoaderEnable = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXVMLOCKCLASSLOADERENABLE, NULL); IDATA vmLockClassLoaderDisable = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXVMLOCKCLASSLOADERDISABLE, NULL); if (vmLockClassLoaderEnable > vmLockClassLoaderDisable) { - vm->extendedRuntimeFlags |= (UDATA)J9_EXTENDED_RUNTIME_CLASSLOADER_LOCKING_ENABLED; + vm->extendedRuntimeFlags |= (UDATA)J9_EXTENDED_RUNTIME_CLASSLOADER_LOCKING_ENABLED; } else if (vmLockClassLoaderEnable < vmLockClassLoaderDisable) { vm->extendedRuntimeFlags &= ~(UDATA)J9_EXTENDED_RUNTIME_CLASSLOADER_LOCKING_ENABLED; } @@ -3595,7 +3608,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) vm->extendedRuntimeFlags &= ~(UDATA)(J9_EXTENDED_RUNTIME_OSR_SAFE_POINT| J9_EXTENDED_RUNTIME_OSR_SAFE_POINT_FV); } } - + { IDATA enableOSRSafePointFV = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXENABLEOSRSAFEPOINTFV, NULL); IDATA disableOSRSafePointFV = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXDISABLEOSRSAFEPOINTFV, NULL); @@ -3605,7 +3618,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) vm->extendedRuntimeFlags &= ~(UDATA)J9_EXTENDED_RUNTIME_OSR_SAFE_POINT_FV; } } - + { IDATA enableJITWatch = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXENABLEJITWATCH, NULL); IDATA disableJITWatch = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXDISABLEJITWATCH, NULL); @@ -3633,13 +3646,8 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA enableCRIU = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXENABLECRIU, NULL); IDATA disableCRIU = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXDISABLECRIU, NULL); if (enableCRIU > disableCRIU) { - PORT_ACCESS_FROM_JAVAVM(vm); - vm->checkpointState = (J9CRIUCheckpointState*) j9mem_allocate_memory(sizeof(J9CRIUCheckpointState), OMRMEM_CATEGORY_VM); - if (NULL == vm->checkpointState) { - return JNI_ENOMEM; - } - memset(vm->checkpointState, 0, sizeof(J9CRIUCheckpointState)); - vm->checkpointState->isCheckPointAllowed = TRUE; + vm->checkpointState.isCheckPointEnabled = TRUE; + vm->checkpointState.isCheckPointAllowed = TRUE; } } @@ -3647,8 +3655,8 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA enableCRIUNonPortableMode = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXENABLECRIUNONPORTABLEMODE, NULL); IDATA disableCRIUNonPortableMode = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXDISABLECRIUNONPORTABLEMODE, NULL); if (enableCRIUNonPortableMode > disableCRIUNonPortableMode) { - if (NULL != vm->checkpointState) { - vm->checkpointState->isNonPortableRestoreMode = TRUE; + if (vm->checkpointState.isCheckPointEnabled) { + vm->checkpointState.isNonPortableRestoreMode = TRUE; } } } @@ -3663,7 +3671,7 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) vm->runtimeFlags &= ~(UDATA)J9_RUNTIME_ALWAYS_SPLIT_BYTECODES; } } - + { IDATA enablePositiveHashCode = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXENABLEPOSITIVEHASHCODE, NULL); IDATA disablePositiveHashCode = FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XXDISABLEPOSITIVEHASHCODE, NULL); @@ -3759,7 +3767,9 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) /* Called for each stage. Runs J9VMDllMain for every library in the table. */ -static jint runInitializationStage(J9JavaVM* vm, IDATA stage) { +static jint +runInitializationStage(J9JavaVM* vm, IDATA stage) +{ RunDllMainData userData; J9VMThread *mainThread = vm->mainThread; @@ -3795,7 +3805,9 @@ static jint runInitializationStage(J9JavaVM* vm, IDATA stage) { /* Run from a pool_do for each library. Invokes the J9VMDllMain method. Errors are reported in the entry->fatalErrorStr. */ -static void runJ9VMDllMain(void* dllLoadInfo, void* userDataTemp) { +static void +runJ9VMDllMain(void* dllLoadInfo, void* userDataTemp) +{ J9VMDllLoadInfo* entry = (J9VMDllLoadInfo*) dllLoadInfo; RunDllMainData* userData = (RunDllMainData*) userDataTemp; IDATA (*J9VMDllMainFunc)(J9JavaVM*, IDATA, void*); @@ -3863,7 +3875,9 @@ static void runJ9VMDllMain(void* dllLoadInfo, void* userDataTemp) { /* Loads libraries based on flags. */ -static jint runLoadStage(J9JavaVM *vm, IDATA flags) { +static jint +runLoadStage(J9JavaVM *vm, IDATA flags) +{ struct LoadInitData userData; userData.vm = vm; @@ -3879,23 +3893,23 @@ static jint runLoadStage(J9JavaVM *vm, IDATA flags) { -/** +/** * \brief Run the specified shutdown stage with JVMTI first in the list - * + * * @param[in] vm VM Structure * @param[in] userData RunDllMainData structure describing the stage and filter flags * @return none - * + * * Run the specified shutdown stage, with JVMTI first in the list. This is done mainly to avoid * the JIT going away before TI can deallocate things via vm->jitConfig while freeing environments. */ static void runShutdownStageJvmtiFirst(J9JavaVM * vm, RunDllMainData * userData) { - J9VMDllLoadInfo* jvmtiLoadInfo; + J9VMDllLoadInfo* jvmtiLoadInfo; void *anElement; pool_state aState; - + jvmtiLoadInfo = FIND_DLL_TABLE_ENTRY(J9_JVMTI_DLL_NAME); if (jvmtiLoadInfo) { @@ -3913,12 +3927,11 @@ runShutdownStageJvmtiFirst(J9JavaVM * vm, RunDllMainData * userData) return; } - - - /* Called for each stage. Runs J9VMDllMain for every library in the table. */ -static jint runShutdownStage(J9JavaVM* vm, IDATA stage, void* reserved, UDATA filterFlags) { +static jint +runShutdownStage(J9JavaVM* vm, IDATA stage, void* reserved, UDATA filterFlags) +{ RunDllMainData userData; userData.vm = vm; @@ -3952,7 +3965,9 @@ static jint runShutdownStage(J9JavaVM* vm, IDATA stage, void* reserved, UDATA fi /* Runs after each stage. Returns FALSE if an error occurred. */ -static jint checkPostStage(J9JavaVM* vm, IDATA stage) { +static jint +checkPostStage(J9JavaVM* vm, IDATA stage) +{ CheckPostStageData userData; userData.vm = vm; @@ -3970,7 +3985,9 @@ static jint checkPostStage(J9JavaVM* vm, IDATA stage) { /* Unloads libraries being forced to unload. */ -static jint runForcedUnloadStage(J9JavaVM *vm) { +static jint +runForcedUnloadStage(J9JavaVM *vm) +{ struct LoadInitData userData; userData.vm = vm; @@ -3983,7 +4000,9 @@ static jint runForcedUnloadStage(J9JavaVM *vm) { /* Run using a pool_do, this method shuts down all libraries that match the flags given. */ -static void unloadDLL(void* dllLoadInfo, void* userDataTemp) { +static void +unloadDLL(void* dllLoadInfo, void* userDataTemp) +{ J9VMDllLoadInfo* entry = (J9VMDllLoadInfo*) dllLoadInfo; LoadInitData* userData = (LoadInitData*) userDataTemp; @@ -4003,7 +4022,9 @@ static void unloadDLL(void* dllLoadInfo, void* userDataTemp) { /* Marks all -Dfoo=bar java options as NOT_CONSUMABLE. Also walks the ignoredOptionTable and if it sees any of those options in the vm_args and marks them as ignored */ -static void registerIgnoredOptions(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args) { +static void +registerIgnoredOptions(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args) +{ UDATA i; char* option; const struct J9VMIgnoredOption *ignoredOptionTablePtr = (const struct J9VMIgnoredOption *)GLOBAL_TABLE(ignoredOptionTable); @@ -4053,7 +4074,7 @@ isGCPolicyMetronome(J9JavaVM *javaVM) } #endif /* (defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)) || (defined(LINUX) && defined(J9VM_GC_REALTIME)) */ -#if defined(LINUX) && defined(J9VM_GC_REALTIME) +#if defined(LINUX) && defined(J9VM_GC_REALTIME) /* Linux SRT only */ /** @@ -4136,7 +4157,7 @@ threadInitStages(J9JavaVM* vm, IDATA stage, void* reserved) } #endif -#if defined(LINUX) && defined(J9VM_GC_REALTIME) +#if defined(LINUX) && defined(J9VM_GC_REALTIME) /* Linux SRT only */ if (0 != setJ9ThreadSchedulingAlgorithm(vm)) { goto _error; @@ -4346,7 +4367,9 @@ zeroInitStages(J9JavaVM* vm, IDATA stage, void* reserved) } -static void* getOptionExtraInfo(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, IDATA match, char* optionName) { +static void * +getOptionExtraInfo(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, IDATA match, char* optionName) +{ PORT_ACCESS_FROM_PORT(portLibrary); IDATA element = findArgInVMArgs( PORTLIB, j9vm_args, match, optionName, NULL, FALSE); if (element >=0) @@ -4357,7 +4380,9 @@ static void* getOptionExtraInfo(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_a /* This function runs the JVM_OnLoad of a loaded library */ -UDATA runJVMOnLoad(J9JavaVM* vm, J9VMDllLoadInfo* loadInfo, char* options) { +UDATA +runJVMOnLoad(J9JavaVM* vm, J9VMDllLoadInfo* loadInfo, char* options) +{ jint (JNICALL * jvmOnLoadFunc)(JavaVM *, char *, void *); jint rc; @@ -4379,7 +4404,9 @@ UDATA runJVMOnLoad(J9JavaVM* vm, J9VMDllLoadInfo* loadInfo, char* options) { /* Close all loaded DLLs. All library shutdown code should have been run. */ -static void closeAllDLLs(J9JavaVM* vm) { +static void +closeAllDLLs(J9JavaVM* vm) +{ PORT_ACCESS_FROM_JAVAVM(vm); if (vm->dllLoadTable) { @@ -4430,7 +4457,9 @@ initializeXruns(J9JavaVM* vm) /* Runs UnOnload functions for libraries such as Xruns */ -static void runUnOnloads(J9JavaVM* vm, UDATA shutdownDueToExit) { +static void +runUnOnloads(J9JavaVM* vm, UDATA shutdownDueToExit) +{ PORT_ACCESS_FROM_JAVAVM(vm); if (vm->dllLoadTable) { @@ -4458,7 +4487,9 @@ static void runUnOnloads(J9JavaVM* vm, UDATA shutdownDueToExit) { This must be done at the earliest opportunity possible stage. */ -IDATA registerCmdLineMapping(J9JavaVM* vm, char* sov_option, char* j9_option, UDATA mapFlags) { +IDATA +registerCmdLineMapping(J9JavaVM* vm, char* sov_option, char* j9_option, UDATA mapFlags) +{ IDATA index = 0; UDATA match = 0; @@ -4607,15 +4638,15 @@ registerVMCmdLineMappings(J9JavaVM* vm) if (registerCmdLineMapping(vm, MAPOPT_XXINITIALHEAPSIZE_EQUALS, VMOPT_XMS, EXACT_MAP_WITH_OPTIONS) == RC_FAILED) { return RC_FAILED; } - /* Map -XX:OnOutOfMemoryError= to -Xdump:tool:events=systhrow,filter=java/lang/OutOfMemoryError,exec= */ + /* Map -XX:OnOutOfMemoryError= to -Xdump:tool:events=systhrow,filter=java/lang/OutOfMemoryError,exec= */ if (registerCmdLineMapping(vm, MAPOPT_XXONOUTOFMEMORYERROR_EQUALS, VMOPT_XDUMP_TOOL_OUTOFMEMORYERROR_EXEC_EQUALS, EXACT_MAP_WITH_OPTIONS) == RC_FAILED) { return RC_FAILED; } - /* Map -XX:+ExitOnOutOfMemoryError to -Xdump:exit:events=systhrow,filter=java/lang/OutOfMemoryError */ + /* Map -XX:+ExitOnOutOfMemoryError to -Xdump:exit:events=systhrow,filter=java/lang/OutOfMemoryError */ if (registerCmdLineMapping(vm, MAPOPT_XXENABLEEXITONOUTOFMEMORYERROR, VMOPT_XDUMP_EXIT_OUTOFMEMORYERROR, EXACT_MAP_NO_OPTIONS) == RC_FAILED) { return RC_FAILED; } - /* Map -XX:-ExitOnOutOfMemoryError to -Xdump:exit:none:events=systhrow,filter=java/lang/OutOfMemoryError */ + /* Map -XX:-ExitOnOutOfMemoryError to -Xdump:exit:none:events=systhrow,filter=java/lang/OutOfMemoryError */ if (registerCmdLineMapping(vm, MAPOPT_XXDISABLEEXITONOUTOFMEMORYERROR, VMOPT_XDUMP_EXIT_OUTOFMEMORYERROR_DISABLE, EXACT_MAP_NO_OPTIONS) == RC_FAILED) { return RC_FAILED; } @@ -4643,7 +4674,9 @@ registerVMCmdLineMappings(J9JavaVM* vm) #ifdef JVMINIT_UNIT_TEST -static void testFindArgs(J9JavaVM* vm) { +static void +testFindArgs(J9JavaVM* vm) +{ char* origOption0, *origOption1, *origOption2, *origOption3; #ifdef J9VM_OPT_SIDECAR J9CmdLineMapping* origMapping1, *origMapping2, *origMapping3; @@ -5061,7 +5094,9 @@ static void testFindArgs(J9JavaVM* vm) { } -static void testOptionValueOps(J9JavaVM* vm) { +static void +testOptionValueOps(J9JavaVM* vm) +{ char* result; char* origOption1, *origOption2, *origOption3, *origOption4, *origOption5, *origOption6; char* optName; @@ -5891,7 +5926,9 @@ static void testOptionValueOps(J9JavaVM* vm) { #if (defined(J9VM_OPT_SIDECAR)) /* Whine about -Djava.compiler if the option is not used correctly */ -static IDATA checkDjavacompiler(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args) { +static IDATA +checkDjavacompiler(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args) +{ IDATA index = 0; char* jitValue = NULL; PORT_ACCESS_FROM_PORT(portLibrary); @@ -5914,7 +5951,9 @@ static IDATA checkDjavacompiler(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_a #endif /* J9VM_OPT_SIDECAR */ -static IDATA setMemoryOptionToOptElse(J9JavaVM* vm, UDATA* thingToSet, char* optionName, UDATA defaultValue, UDATA doConsumeArg) { +static IDATA +setMemoryOptionToOptElse(J9JavaVM* vm, UDATA* thingToSet, char* optionName, UDATA defaultValue, UDATA doConsumeArg) +{ IDATA index, status; UDATA newValue; PORT_ACCESS_FROM_JAVAVM(vm); @@ -5931,7 +5970,9 @@ static IDATA setMemoryOptionToOptElse(J9JavaVM* vm, UDATA* thingToSet, char* opt return OPTION_OK; } -static IDATA setIntegerValueOptionToOptElse(J9JavaVM* vm, UDATA* thingToSet, char* optionName, UDATA defaultValue, UDATA doConsumeArg) { +static IDATA +setIntegerValueOptionToOptElse(J9JavaVM* vm, UDATA* thingToSet, char* optionName, UDATA defaultValue, UDATA doConsumeArg) +{ IDATA index, status; UDATA newValue; PORT_ACCESS_FROM_JAVAVM(vm); @@ -5951,7 +5992,9 @@ static IDATA setIntegerValueOptionToOptElse(J9JavaVM* vm, UDATA* thingToSet, cha #if (defined(J9VM_OPT_SIDECAR)) -static IDATA createMapping(J9JavaVM* vm, char* j9Name, char* mapName, UDATA flags, IDATA atIndex) { +static IDATA +createMapping(J9JavaVM* vm, char* j9Name, char* mapName, UDATA flags, IDATA atIndex) +{ J9CmdLineMapping* newMapping; IDATA j9NameLen = (j9Name) ? (strlen(j9Name) + 1) : 2; IDATA mapNameLen = (mapName) ? (strlen(mapName) + 1) : 2; @@ -5978,7 +6021,9 @@ static IDATA createMapping(J9JavaVM* vm, char* j9Name, char* mapName, UDATA flag } #endif /* J9VM_OPT_SIDECAR */ -static void generateMemoryOptionParseError(J9JavaVM* vm, J9VMDllLoadInfo* loadInfo, UDATA errorType, char* optionWithError) { +static void +generateMemoryOptionParseError(J9JavaVM* vm, J9VMDllLoadInfo* loadInfo, UDATA errorType, char* optionWithError) +{ char *errorBuffer; PORT_ACCESS_FROM_JAVAVM(vm); @@ -6141,7 +6186,7 @@ preloadUser32Dll(J9JavaVM *vm) * The -Xprotectcontiguous and -Xnoprotectcontiguous options specify whether * we should protect the largest contiguous free memory region while loading * user32.dll. - * + * * This is done to avoid fragmenting the address space (which would limit the * maximum size of the Java heap), if user32.dll will cause other DLLs to be * loaded via the LoadAppInit_DLLs mechanism. By default, we don't do this. @@ -6184,7 +6229,8 @@ preloadUser32Dll(J9JavaVM *vm) * @param vm pointer to the vm struct */ static void -processCompressionOptions(J9JavaVM *vm){ +processCompressionOptions(J9JavaVM *vm) +{ IDATA argIndex1; IDATA argIndex2; @@ -6586,11 +6632,11 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData) goto error; } #if !defined(WIN32) - vm->originalSIGPIPESignalAction = j9mem_allocate_memory(sizeof(struct sigaction), OMRMEM_CATEGORY_VM); + vm->originalSIGPIPESignalAction = j9mem_allocate_memory(sizeof(struct sigaction), OMRMEM_CATEGORY_VM); if (NULL == vm->originalSIGPIPESignalAction) { goto error; } - + /* Needed for JCL dependency on JVM to set SIGPIPE to SIG_IGN */ sigemptyset(&newSignalAction.sa_mask); #ifndef J9ZTPF @@ -6974,7 +7020,7 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData) } #endif /* Create the global hot field class info pool and global hot field class info pool monitor if scavenger dynamicBreadthFirstScanOrdering is enabled - * + * * The global hot field class info pool and global hot field class info pool monitor will be used to store hot * field information for all classes containing hot fields. In addition to this, the globalHotFieldPoolMutex that is created * is used when a new hot field pool for a classLoader is to be dynamically created. @@ -6986,7 +7032,7 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData) || (0 != omrthread_monitor_init_with_name(&vm->globalHotFieldPoolMutex, 0, "globalHotFieldPoolMutex")) ) { goto error; - } + } } } else { @@ -7017,7 +7063,7 @@ protectedInitializeJavaVM(J9PortLibrary* portLibrary, void * userData) } } #endif - + initializeInitialMethods(vm); if (JNI_OK != (stageRC = runInitializationStage(vm, ABOUT_TO_BOOTSTRAP))) { @@ -7120,7 +7166,9 @@ sigxfszHandler(struct J9PortLibrary* portLibrary, U_32 gpType, void* gpInfo, voi #endif #if (defined(J9VM_OPT_SIDECAR)) /* priv. proto (autogen) */ -void sidecarInit(J9VMThread *mainThread) { +void +sidecarInit(J9VMThread *mainThread) +{ /* we load java.lang.Shutdown so that it is already loaded when sidecarShutdown is called. * This prevents memory allocations that will occur after an OutOfMemoryError or * a StackOverflowError has occurred. @@ -7321,7 +7369,9 @@ setSignalOptions(J9JavaVM *vm, J9PortLibrary *portLibrary) #if (defined(J9VM_INTERP_VERBOSE)) /* Runs after each stage. Returns FALSE if an error occurred. */ -static const char* getNameForStage(IDATA stage) { +static const char * +getNameForStage(IDATA stage) +{ switch (stage) { case PORT_LIBRARY_GUARANTEED : return "PORT_LIBRARY_GUARANTEED"; @@ -7383,7 +7433,9 @@ static const char* getNameForStage(IDATA stage) { #if (defined(J9VM_INTERP_VERBOSE)) /* Runs after each stage. Returns FALSE if an error occurred. */ -static const char* getNameForLoadStage(IDATA stage) { +static const char * +getNameForLoadStage(IDATA stage) +{ switch (stage) { case EARLY_LOAD : return "EARLY_LOAD"; @@ -7765,7 +7817,8 @@ handleSIGILLForSSE(int signal, struct sigcontext context) BOOLEAN -isSSE2SupportedOnX86() { +isSSE2SupportedOnX86() +{ BOOLEAN result = FALSE; if ((J9SSE2cpuidFeatures() & SSE2_FLAG) == SSE2_FLAG) { @@ -7800,7 +7853,8 @@ isSSE2SupportedOnX86() { #if (defined(AIXPPC) || defined(LINUXPPC)) && !defined(J9OS_I5) BOOLEAN -isPPC64bit() { +isPPC64bit() +{ #if defined(AIXPPC) if (J9_ADDRMODE_64 != sysconf(_SC_AIX_KERNEL_BITMODE)) { return FALSE; diff --git a/runtime/vm/module.xml b/runtime/vm/module.xml index f41cd9e7c52..979dad22433 100644 --- a/runtime/vm/module.xml +++ b/runtime/vm/module.xml @@ -102,6 +102,9 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-excepti + + +