diff --git a/runtime/oti/j9consts.h b/runtime/oti/j9consts.h index 51e8cb7ca9f..59bb698aec0 100644 --- a/runtime/oti/j9consts.h +++ b/runtime/oti/j9consts.h @@ -327,6 +327,8 @@ extern "C" { #define J9_EXTENDED_RUNTIME2_ENABLE_VALHALLA 0x1 #define J9_EXTENDED_RUNTIME2_COMPRESS_OBJECT_REFERENCES 0x2 #define J9_EXTENDED_RUNTIME2_ENABLE_PREVIEW 0x4 +#define J9_EXTENDED_RUNTIME2_RAMSTATE_COLD_RUN 0x8 +#define J9_EXTENDED_RUNTIME2_RAMSTATE_WARM_RUN 0x10 /* TODO: Define this until the JIT removes it */ diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index c228e304f93..17c55490580 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -5029,6 +5029,7 @@ typedef struct J9JavaVM { struct J9PortLibrary * portLibrary; UDATA j2seVersion; void* zipCachePool; + char* ramStateFilePath; struct J9VMInterface vmInterface; struct HarmonyVMInterface harmonyVMInterface; UDATA dynamicLoadClassAllocationIncrement; diff --git a/runtime/oti/jvminit.h b/runtime/oti/jvminit.h index afcd8dc49bb..ee50aa486d5 100644 --- a/runtime/oti/jvminit.h +++ b/runtime/oti/jvminit.h @@ -253,6 +253,8 @@ enum INIT_STAGE { #define VMOPT_XFASTRESOLVE "-Xfastresolve" #define VMOPT_XSHARECLASSES "-Xshareclasses" #define VMOPT_XSHARECLASSES_COLON "-Xshareclasses:" +#define VMOPT_XSAVERAMSTATE "-Xsaveramstate=" +#define VMOPT_XRESTORERAMSTATE "-Xrestoreramstate=" #define VMOPT_XSERVICE_EQUALS "-Xservice=" #define VMOPT_XISS "-Xiss" #define VMOPT_XSSI "-Xssi" diff --git a/runtime/vm/JVMImage.hpp b/runtime/vm/JVMImage.hpp new file mode 100644 index 00000000000..8bf56782e46 --- /dev/null +++ b/runtime/vm/JVMImage.hpp @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2001, 2019 IBM Corp. and others + * + * 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] http://openjdk.java.net/legal/assembly-exception.html + * + * 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-exception + *******************************************************************************/ +/* +* JVMImage.hpp +*/ + +#ifndef JVMIMAGE_HPP_ +#define JVMIMAGE_HPP_ + +#include "j9_types.h" + +class JVMImage +{ +public: + JVMImage(); + ~JVMImage(); + void allocateImageMemory(UDATA size); + void subAllocateMemory(uintptr_t size); + void freeSubAllocatedMemory(); + +private: + UDATA _memoryStart; + UDATA _size; +}; + +#endif /* JVMIMAGE_H_ */ + diff --git a/runtime/vm/jvminit.c b/runtime/vm/jvminit.c index 5cf500847bd..5fab1c97744 100644 --- a/runtime/vm/jvminit.c +++ b/runtime/vm/jvminit.c @@ -1759,6 +1759,21 @@ IDATA VMInitStages(J9JavaVM *vm, IDATA stage, void* reserved) { } } #endif + { + IDATA restoreStateIndex = FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, VMOPT_XRESTORERAMSTATE, NULL); + IDATA saveStateIndex = FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, VMOPT_XSAVERAMSTATE, NULL); + char *optionValue = NULL; + // If both restore (warm run) and save (cold run) are specified save state takes precedence + if (saveStateIndex >= 0) { + GET_OPTION_VALUE(saveStateIndex, '=', &optionValue); + vm->extendedRuntimeFlags2 |= J9_EXTENDED_RUNTIME2_RAMSTATE_COLD_RUN; + } + else if (restoreStateIndex >= 0) { + GET_OPTION_VALUE(restoreStateIndex, '=', &optionValue); + vm->extendedRuntimeFlags2 |= J9_EXTENDED_RUNTIME2_RAMSTATE_WARM_RUN; + } + vm->ramStateFilePath = optionValue; + } if (FIND_AND_CONSUME_ARG(EXACT_MATCH, VMOPT_XDFPBD, NULL) >= 0) { vm->runtimeFlags |= J9_RUNTIME_DFPBD;