Skip to content

Commit

Permalink
JVMImage Shutdown Behaviour is now Implemented (eclipse-openj9#25)
Browse files Browse the repository at this point in the history
* Updated the writing options

* Added base functionality for teardown

* Teardown is now called on JVM shutdown

* Changed where teardown is called, also fixed a crashing issue when not using our feature

* Missed macro

* Removed unused variables and code cleanup

* Removed function from internalFunctions array

Signed-off-by: Brady Jessup <brady.jessup@ibm.com>
  • Loading branch information
Ershany-IBM committed Jul 3, 2019
1 parent b91808d commit bb2d8d1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
10 changes: 9 additions & 1 deletion runtime/oti/jvmimage_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,18 @@ void deregisterCPEntry(J9JavaVM *javaVM, J9ClassPathEntry *cpEntry);
* Shut down sequence of JVMImage
* Frees memory of heap variables and jvmimage instance
*
* @param javaVM[in] the java vm
* @param javaVM[in] the java vm
*/
void shutdownJVMImage(J9JavaVM *vm);

/*
* Frees the memory associated with the JVMImage
* If it is a cold run it will perform fixup and write the image to file
*
* @param javaVM[in] the java vm
*/
void teardownJVMImage(J9JavaVM *javaVM);

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 9 additions & 1 deletion runtime/vm/JVMImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ JVMImage::JVMImage(J9JavaVM *javaVM) :
_heap(NULL)
{
_dumpFileName = javaVM->ramStateFilePath;
_isWarmRun = J9_ARE_ALL_BITS_SET(javaVM->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_RAMSTATE_WARM_RUN);
}

JVMImage::~JVMImage()
Expand Down Expand Up @@ -497,6 +496,15 @@ shutdownJVMImage(J9JavaVM *javaVM)
}
}

extern "C" void
teardownJVMImage(J9JavaVM *javaVM)
{
if (IS_COLD_RUN(javaVM)) {
IMAGE_ACCESS_FROM_JAVAVM(javaVM);
jvmImage->writeImageToFile();
}
}

extern "C" void *
image_mem_allocate_memory(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount, const char *callSite, uint32_t category)
{
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/JVMImage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class JVMImage
omrthread_monitor_t _jvmImageMonitor;

char *_dumpFileName;
bool _isWarmRun;
protected:
public:
static const UDATA INITIAL_IMAGE_SIZE;
Expand All @@ -68,7 +67,6 @@ class JVMImage
void* reallocateTable(ImageTableHeader *table, uintptr_t tableSize);

bool readImageFromFile(void);
bool writeImageToFile(void);
protected:
void *operator new(size_t size, void *memoryPointer) { return memoryPointer; }
public:
Expand All @@ -80,6 +78,8 @@ class JVMImage
ImageRC setupWarmRun(void);
ImageRC setupColdRun(void);

bool writeImageToFile(void);

void* subAllocateMemory(uintptr_t byteAmount);
void* reallocateMemory(void *address, uintptr_t byteAmount); /* TODO: Extension functions for heap (not used currently) */
void freeSubAllocatedMemory(void *memStart); /* TODO: Extension functions for heap (not used currently) */
Expand Down
4 changes: 4 additions & 0 deletions runtime/vm/jvminit.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ freeJavaVM(J9JavaVM * vm)
runShutdownStage(vm, INTERPRETER_SHUTDOWN, NULL, 0);
}

if (IS_COLD_RUN(vm) || IS_WARM_RUN(vm)) {
teardownJVMImage(vm);
}

if (NULL != vm->classMemorySegments) {
J9ClassWalkState classWalkState;
J9Class * clazz;
Expand Down

0 comments on commit bb2d8d1

Please sign in to comment.