diff --git a/runtime/makelib/targets.mk.ftl b/runtime/makelib/targets.mk.ftl index 839910dc0df..87f613efd8a 100644 --- a/runtime/makelib/targets.mk.ftl +++ b/runtime/makelib/targets.mk.ftl @@ -537,21 +537,13 @@ CLANG_CXXFLAGS+=-std=c++0x -D_CRT_SUPPRESS_RESTRICT -DVS12AndHigher CLANG_CXXFLAGS+=-D_M_X64 endif -# special handling MHInterpreterFull.cpp, MHInterpreterCompressed.cpp, BytecodeInterpreterFull.cpp, BytecodeInterpreterCompressed.cpp, CRIUBytecodeInterpreterFull.cpp, CRIUBytecodeInterpreterCompressed.cpp, DebugBytecodeInterpreterFull.cpp and DebugBytecodeInterpreterCompressed.cpp +# special handling MHInterpreterFull.cpp, MHInterpreterCompressed.cpp, BytecodeInterpreterFull.cpp, BytecodeInterpreterCompressed.cpp, DebugBytecodeInterpreterFull.cpp and DebugBytecodeInterpreterCompressed.cpp BytecodeInterpreterFull$(UMA_DOT_O):BytecodeInterpreterFull.cpp $(CLANG_CXX) $(CLANG_CXXFLAGS) -c $< -o $@ BytecodeInterpreterCompressed$(UMA_DOT_O):BytecodeInterpreterCompressed.cpp $(CLANG_CXX) $(CLANG_CXXFLAGS) -c $< -o $@ -ifneq ($(J9VM_OPT_CRIU_SUPPORT),) -CRIUBytecodeInterpreterFull$(UMA_DOT_O):CRIUBytecodeInterpreterFull.cpp - $(CLANG_CXX) $(CLANG_CXXFLAGS) -c $< -o $@ - -CRIUBytecodeInterpreterCompressed$(UMA_DOT_O):CRIUBytecodeInterpreterCompressed.cpp - $(CLANG_CXX) $(CLANG_CXXFLAGS) -c $< -o $@ -endif - DebugBytecodeInterpreterFull$(UMA_DOT_O):DebugBytecodeInterpreterFull.cpp $(CLANG_CXX) $(CLANG_CXXFLAGS) -c $< -o $@ @@ -582,7 +574,7 @@ SharedService$(UMA_DOT_O):SharedService.c <#if uma.spec.processor.ppc> ifndef USE_PPC_GCC -# special handling BytecodeInterpreterFull.cpp, BytecodeInterpreterCompressed.cpp, CRIUBytecodeInterpreterFull.cpp, CRIUBytecodeInterpreterCompressed.cpp, DebugBytecodeInterpreterFull.cpp and DebugBytecodeInterpreterCompressed.cpp +# special handling BytecodeInterpreterFull.cpp, BytecodeInterpreterCompressed.cpp, DebugBytecodeInterpreterFull.cpp and DebugBytecodeInterpreterCompressed.cpp FLAGS_TO_REMOVE += -O3 NEW_OPTIMIZATION_FLAG=-O2 -qdebug=lincomm:ptranl:tfbagg <#if uma.spec.type.linux> @@ -597,14 +589,6 @@ BytecodeInterpreterFull$(UMA_DOT_O):BytecodeInterpreterFull.cpp BytecodeInterpreterCompressed$(UMA_DOT_O):BytecodeInterpreterCompressed.cpp $(CXX) $(SPECIALCXXFLAGS) $(NEW_OPTIMIZATION_FLAG) -c $< -ifneq ($(J9VM_OPT_CRIU_SUPPORT),) -CRIUBytecodeInterpreterFull$(UMA_DOT_O):CRIUBytecodeInterpreterFull.cpp - $(CXX) $(SPECIALCXXFLAGS) $(NEW_OPTIMIZATION_FLAG) -c $< - -CRIUBytecodeInterpreterCompressed$(UMA_DOT_O):CRIUBytecodeInterpreterCompressed.cpp - $(CXX) $(SPECIALCXXFLAGS) $(NEW_OPTIMIZATION_FLAG) -c $< -endif - DebugBytecodeInterpreterFull$(UMA_DOT_O):DebugBytecodeInterpreterFull.cpp $(CXX) $(SPECIALCXXFLAGS) $(NEW_OPTIMIZATION_FLAG) -c $< diff --git a/runtime/makelib/targets.mk.linux.inc.ftl b/runtime/makelib/targets.mk.linux.inc.ftl index bbabc7e531f..81058cc20b3 100644 --- a/runtime/makelib/targets.mk.linux.inc.ftl +++ b/runtime/makelib/targets.mk.linux.inc.ftl @@ -532,7 +532,7 @@ bcverify$(UMA_DOT_O) : bcverify.c ifdef USE_PPC_GCC -# special handling MHInterpreterFull.cpp, MHInterpreterCompressed.cpp, BytecodeInterpreterFull.cpp, BytecodeInterpreterCompressed.cpp, CRIUBytecodeInterpreterFull.cpp, CRIUBytecodeInterpreterCompressed.cpp, DebugBytecodeInterpreterFull.cpp and DebugBytecodeInterpreterCompressed.cpp +# special handling MHInterpreterFull.cpp, MHInterpreterCompressed.cpp, BytecodeInterpreterFull.cpp, BytecodeInterpreterCompressed.cpp, DebugBytecodeInterpreterFull.cpp and DebugBytecodeInterpreterCompressed.cpp BytecodeInterpreterFull$(UMA_DOT_O) : BytecodeInterpreterFull.cpp $(PPC_GCC_CXX) $(PPC_GCC_CXXFLAGS) -c $< @@ -540,14 +540,6 @@ BytecodeInterpreterFull$(UMA_DOT_O) : BytecodeInterpreterFull.cpp BytecodeInterpreterCompressed$(UMA_DOT_O) : BytecodeInterpreterCompressed.cpp $(PPC_GCC_CXX) $(PPC_GCC_CXXFLAGS) -c $< -ifneq ($(J9VM_OPT_CRIU_SUPPORT),) -CRIUBytecodeInterpreterFull$(UMA_DOT_O) : CRIUBytecodeInterpreterFull.cpp - $(PPC_GCC_CXX) $(PPC_GCC_CXXFLAGS) -c $< - -CRIUBytecodeInterpreterCompressed$(UMA_DOT_O) : CRIUBytecodeInterpreterCompressed.cpp - $(PPC_GCC_CXX) $(PPC_GCC_CXXFLAGS) -c $< -endif - DebugBytecodeInterpreterFull$(UMA_DOT_O) : DebugBytecodeInterpreterFull.cpp $(PPC_GCC_CXX) $(PPC_GCC_CXXFLAGS) -c $< diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index a70d6891173..95a72f86613 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -4311,6 +4311,7 @@ typedef struct J9DelayedLockingOpertionsRecord { #define J9VM_CRIU_ENABLE_CRIU_SEC_PROVIDER 0x40 #define J9VM_CRAC_IS_CHECKPOINT_ENABLED 0x80 #define J9VM_CRIU_SUPPORT_DEBUG_ON_RESTORE 0x100 +#define J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER 0x200 /* matches maximum count defined by JDWP in threadControl.c */ #define J9VM_CRIU_MAX_DEBUG_THREADS_STORED 10 diff --git a/runtime/vm/CMakeLists.txt b/runtime/vm/CMakeLists.txt index 93e568deee3..780f3862ae6 100644 --- a/runtime/vm/CMakeLists.txt +++ b/runtime/vm/CMakeLists.txt @@ -217,13 +217,6 @@ set(interpreter_sources DebugBytecodeInterpreterFull.cpp ) -if(J9VM_OPT_CRIU_SUPPORT) - list(APPEND interpreter_sources - CRIUBytecodeInterpreterCompressed.cpp - CRIUBytecodeInterpreterFull.cpp - ) -endif() - if(J9VM_OPT_METHOD_HANDLE) list(APPEND interpreter_sources MHInterpreterCompressed.cpp diff --git a/runtime/vm/CRIUBytecodeInterpreterCompressed.cpp b/runtime/vm/CRIUBytecodeInterpreterCompressed.cpp deleted file mode 100644 index 5012e80e1f4..00000000000 --- a/runtime/vm/CRIUBytecodeInterpreterCompressed.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2023 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include "j9cfg.h" - -#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(J9VM_OPT_CRIU_SUPPORT) -#define DO_HOOKS -#define OMR_OVERRIDE_COMPRESS_OBJECT_REFERENCES 1 -#define LOOP_NAME criuBytecodeLoopCompressed -#define INTERPRETER_CLASS VM_CRIUBytecodeInterpreterCompressed -#include "BytecodeInterpreter.inc" -#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(J9VM_OPT_CRIU_SUPPORT) */ diff --git a/runtime/vm/CRIUBytecodeInterpreterFull.cpp b/runtime/vm/CRIUBytecodeInterpreterFull.cpp deleted file mode 100644 index 27b3a93f5fa..00000000000 --- a/runtime/vm/CRIUBytecodeInterpreterFull.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2023 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include "j9cfg.h" - -#if defined(OMR_GC_FULL_POINTERS) && defined(J9VM_OPT_CRIU_SUPPORT) -#define DO_HOOKS -#define OMR_OVERRIDE_COMPRESS_OBJECT_REFERENCES 0 -#define LOOP_NAME criuBytecodeLoopFull -#define INTERPRETER_CLASS VM_CRIUBytecodeInterpreterFull -#include "BytecodeInterpreter.inc" -#endif /* defined(OMR_GC_FULL_POINTERS) && defined(J9VM_OPT_CRIU_SUPPORT) */ diff --git a/runtime/vm/CRIUHelpers.cpp b/runtime/vm/CRIUHelpers.cpp index aa1de62e09e..2989246fdc1 100644 --- a/runtime/vm/CRIUHelpers.cpp +++ b/runtime/vm/CRIUHelpers.cpp @@ -58,6 +58,7 @@ static BOOLEAN criuRestoreInitializeTrace(J9VMThread *currentThread, void *userD static BOOLEAN criuRestoreInitializeXrs(J9VMThread *currentThread, void *userData, const char **nlsMsgFormat); static BOOLEAN criuRestoreDisableSharedClassCache(J9VMThread *currentThread, void *userData, const char **nlsMsgFormat); static BOOLEAN criuRestoreInitializeDump(J9VMThread *currentThread, void *userData, const char **nlsMsgFormat); +static BOOLEAN criuRestoreCheckForDebugInterpreterRequest(J9VMThread *currentThread, void *userData, const char **nlsMsgFormat); static jvmtiIterationControl objectIteratorCallback(J9JavaVM *vm, J9MM_IterateObjectDescriptor *objectDesc, void *userData); #if defined(OMR_GC_FULL_POINTERS) UDATA debugBytecodeLoopFull(J9VMThread *currentThread); @@ -185,6 +186,12 @@ isDebugOnRestoreEnabled(J9VMThread *currentThread) return J9_ARE_ALL_BITS_SET(currentThread->javaVM->checkpointState.flags, J9VM_CRIU_SUPPORT_DEBUG_ON_RESTORE) && isCRaCorCRIUSupportEnabled(currentThread); } +BOOLEAN +isTransitionToDebugInterpreterRequested(J9VMThread *currentThread) +{ + return J9_ARE_ALL_BITS_SET(currentThread->javaVM->checkpointState.flags, J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER) && isCRaCorCRIUSupportEnabled(currentThread); +} + void setRequiredGhostFileLimit(J9VMThread *currentThread, U_32 ghostFileLimit) { @@ -319,6 +326,8 @@ criuRestoreInitializeTrace(J9VMThread *currentThread, void *userData, const char *nlsMsgFormat = j9nls_lookup_message(J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE, J9NLS_VM_CRIU_RESTORE_INITIALIZE_TRACE_FAILED, NULL); result = FALSE; + } else { + vm->checkpointState.flags |= J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER; } } } @@ -425,12 +434,42 @@ criuRestoreInitializeDump(J9VMThread *currentThread, void *userData, const char *nlsMsgFormat = j9nls_lookup_message(J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE, J9NLS_VM_CRIU_RESTORE_INITIALIZE_DUMP_FAILED, NULL); result = FALSE; + } else { + vm->checkpointState.flags |= J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER; } } } return result; } +/** + * An internal JVM checkpoint hook to check for the debug interpreter VMOPT after restore. + * + * @param[in] currentThread vmThread token + * @param[in] userData J9InternalHookRecord pointer + * @param[in/out] nlsMsgFormat an NLS message + * + * @return BOOLEAN TRUE if no error, otherwise FALSE + */ +static BOOLEAN +criuRestoreCheckForDebugInterpreterRequest(J9VMThread *currentThread, void *userData, const char **nlsMsgFormat) +{ + BOOLEAN result = TRUE; + J9JavaVM *vm = currentThread->javaVM; + + if (NULL != vm->checkpointState.restoreArgsList) { + J9VMInitArgs *restoreArgsList = vm->checkpointState.restoreArgsList; + IDATA debugOn = FIND_AND_CONSUME_ARG(restoreArgsList, EXACT_MATCH, VMOPT_XXDEBUGINTERPRETER, NULL); + IDATA debugOff = FIND_AND_CONSUME_ARG(restoreArgsList, EXACT_MATCH, VMOPT_XXNODEBUGINTERPRETER, NULL); + if (debugOn > debugOff) { + vm->checkpointState.flags |= J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER; + } else { + vm->checkpointState.flags &= ~(UDATA)J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER; + } + } + return result; +} + /** * This cleans up the instanceObjects associated with each J9JavaVM->checkpointState.hookRecords, * the hookRecords and classIterationRestoreHookRecords as well if checkpointState.isNonPortableRestoreMode is TRUE. @@ -536,6 +575,7 @@ initializeCriuHooks(J9VMThread *currentThread) addInternalJVMCheckpointHook(currentThread, TRUE, NULL, FALSE, criuRestoreInitializeTrace); addInternalJVMCheckpointHook(currentThread, TRUE, NULL, FALSE, criuRestoreInitializeXrs); addInternalJVMCheckpointHook(currentThread, TRUE, NULL, FALSE, criuRestoreInitializeDump); + addInternalJVMCheckpointHook(currentThread, TRUE, NULL, FALSE, criuRestoreCheckForDebugInterpreterRequest); } addInternalJVMCheckpointHook(currentThread, TRUE, NULL, FALSE, criuRestoreDisableSharedClassCache); @@ -1488,22 +1528,19 @@ checkTransitionToDebugInterpreter(J9VMThread *currentThread) { BOOLEAN result = TRUE; J9JavaVM *vm = currentThread->javaVM; - if (NULL != vm->checkpointState.restoreArgsList) { - J9VMInitArgs *restoreArgsList = vm->checkpointState.restoreArgsList; - IDATA debugOn = FIND_AND_CONSUME_ARG(restoreArgsList, EXACT_MATCH, VMOPT_XXDEBUGINTERPRETER, NULL); - IDATA debugOff = FIND_AND_CONSUME_ARG(restoreArgsList, EXACT_MATCH, VMOPT_XXNODEBUGINTERPRETER, NULL); - if (debugOn > debugOff) { - /* - * The transition to the debug interpreter currently only works with -Xint, - * and the null check for vm->jitConfig will be removed when the jit changes are completed. - */ - if (isDebugOnRestoreEnabled(currentThread) && (NULL == vm->jitConfig)) { - transitionToDebugInterpreter(vm); - } else { - result = FALSE; - } + + if (isTransitionToDebugInterpreterRequested(currentThread)) { + if (NULL == vm->jitConfig) { + transitionToDebugInterpreter(vm); + } else if (isDebugOnRestoreEnabled(currentThread)) { + transitionToDebugInterpreter(vm); + } else { + result = FALSE; } + } else { + result = FALSE; } + return result; } @@ -1912,15 +1949,6 @@ criuCheckpointJVMImpl(JNIEnv *env, case RESTORE_ARGS_RETURN_OK: break; } - - if (!checkTransitionToDebugInterpreter(currentThread)) { - currentExceptionClass = vm->checkpointState.criuJVMRestoreExceptionClass; - nlsMsgFormat = j9nls_lookup_message( - J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE, - J9NLS_VM_CRIU_CHECK_TRANSITION_TO_DEBUG_INTERPRETER_FAILED, - NULL); - goto wakeJavaThreadsWithExclusiveVMAccess; - } } if (hasDumpSucceeded) { @@ -1934,6 +1962,14 @@ criuCheckpointJVMImpl(JNIEnv *env, currentExceptionClass = vm->checkpointState.criuJVMRestoreExceptionClass; goto wakeJavaThreadsWithExclusiveVMAccess; } + if (hasDumpSucceeded && !checkTransitionToDebugInterpreter(currentThread)) { + currentExceptionClass = vm->checkpointState.criuJVMRestoreExceptionClass; + nlsMsgFormat = j9nls_lookup_message( + J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE, + J9NLS_VM_CRIU_CHECK_TRANSITION_TO_DEBUG_INTERPRETER_FAILED, + NULL); + goto wakeJavaThreadsWithExclusiveVMAccess; + } if (J9_ARE_ANY_BITS_SET(vm->checkpointState.flags, J9VM_CRIU_IS_JDWP_ENABLED)) { /* Resuming the threads marked with J9_PRIVATE_FLAGS2_DELAY_HALT_FOR_CHECKPOINT * is only required for JDWP threads. diff --git a/runtime/vm/jvminit.c b/runtime/vm/jvminit.c index 044efbb20d7..2993bb3493f 100644 --- a/runtime/vm/jvminit.c +++ b/runtime/vm/jvminit.c @@ -326,17 +326,11 @@ J9_DECLARE_CONSTANT_UTF8(j9_dispatch, "dispatch"); /* The appropriate bytecodeLoop is selected based on interpreter mode */ #if defined(OMR_GC_FULL_POINTERS) UDATA bytecodeLoopFull(J9VMThread *currentThread); -#if defined(J9VM_OPT_CRIU_SUPPORT) -UDATA criuBytecodeLoopFull(J9VMThread *currentThread); -#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ UDATA debugBytecodeLoopFull(J9VMThread *currentThread); #endif /* defined(OMR_GC_FULL_POINTERS) */ #if defined(OMR_GC_COMPRESSED_POINTERS) UDATA bytecodeLoopCompressed(J9VMThread *currentThread); -#if defined(J9VM_OPT_CRIU_SUPPORT) -UDATA criuBytecodeLoopCompressed(J9VMThread *currentThread); -#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ UDATA debugBytecodeLoopCompressed(J9VMThread *currentThread); #endif /* defined(OMR_GC_COMPRESSED_POINTERS) */ @@ -2998,21 +2992,7 @@ VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) vm->bytecodeLoop = debugBytecodeLoopFull; #endif /* defined(OMR_GC_FULL_POINTERS) */ } - } else -#if defined(J9VM_OPT_CRIU_SUPPORT) - if (J9_ARE_ALL_BITS_SET(vm->checkpointState.flags, J9VM_CRIU_IS_CHECKPOINT_ALLOWED)) { - if (J9JAVAVM_COMPRESS_OBJECT_REFERENCES(vm)) { -#if defined(OMR_GC_COMPRESSED_POINTERS) - vm->bytecodeLoop = criuBytecodeLoopCompressed; -#endif /* defined(OMR_GC_COMPRESSED_POINTERS) */ - } else { -#if defined(OMR_GC_FULL_POINTERS) - vm->bytecodeLoop = criuBytecodeLoopFull; -#endif /* defined(OMR_GC_FULL_POINTERS) */ - } - } else -#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ - { + } else { if (J9JAVAVM_COMPRESS_OBJECT_REFERENCES(vm)) { #if defined(OMR_GC_COMPRESSED_POINTERS) vm->bytecodeLoop = bytecodeLoopCompressed; @@ -3823,8 +3803,14 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) IDATA noDebugInterpreter = FIND_AND_CONSUME_VMARG(EXACT_MATCH, VMOPT_XXNODEBUGINTERPRETER, NULL); if (debugInterpreter > noDebugInterpreter) { vm->extendedRuntimeFlags |= J9_EXTENDED_RUNTIME_DEBUG_MODE; +#if defined(J9VM_OPT_CRIU_SUPPORT) + vm->checkpointState.flags |= J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER; +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ } else if (debugInterpreter < noDebugInterpreter) { vm->extendedRuntimeFlags &= ~(UDATA)J9_EXTENDED_RUNTIME_DEBUG_MODE; +#if defined(J9VM_OPT_CRIU_SUPPORT) + vm->checkpointState.flags &= ~(UDATA)J9VM_CRIU_TRANSITION_TO_DEBUG_INTERPRETER; +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ } }