Skip to content

Commit

Permalink
Place JVMImage instance into JVMImagePortLibrary (eclipse-openj9#16)
Browse files Browse the repository at this point in the history
* Place JVMImage instance into JVMImagePortLibrary
- created wrapper around omr port library and added jvmimage
- placed pointer to wrapper in J9JavaVM
- changed all functions to rely on vm reference or jvmimageportlibrary

Signed-off-by: akshayben [email protected]
  • Loading branch information
akshayben authored Jun 21, 2019
1 parent 8f10b2d commit f6bd7be
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 112 deletions.
1 change: 1 addition & 0 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -5056,6 +5056,7 @@ typedef struct J9JavaVM {
struct J9PortLibrary * portLibrary;
UDATA j2seVersion;
void* zipCachePool;
void* jvmImagePortLibrary;
char* ramStateFilePath;
struct J9VMInterface vmInterface;
struct HarmonyVMInterface harmonyVMInterface;
Expand Down
18 changes: 17 additions & 1 deletion runtime/oti/jvmimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@

#define IS_WARM_RUN(javaVM) J9_ARE_ALL_BITS_SET(javaVM->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_RAMSTATE_WARM_RUN)
#define IS_COLD_RUN(javaVM) J9_ARE_ALL_BITS_SET(javaVM->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_RAMSTATE_COLD_RUN)
#define OMRPORT_FROM_IMAGE() getImagePortLibrary()

#define JVMIMAGEPORT_FROM_PORT(_portLibrary) ((JVMImagePortLibrary *)(_portLibrary))
#define JVMIMAGEPORT_FROM_JAVAVM(javaVM) ((JVMImagePortLibrary *)(javaVM->jvmImagePortLibrary))
#define IMAGEPORT_FROM_JAVAVM(javaVM) ((OMRPortLibrary *)(javaVM->jvmImagePortLibrary))

#define IMAGE_ACCESS_FROM_PORT(_portLibrary) JVMImage *jvmImage = (JVMImage *)(JVMIMAGEPORT_FROM_PORT(_portLibrary)->jvmImage)
#define IMAGE_ACCESS_FROM_JAVAVM(javaVM) JVMImage *jvmImage = (JVMImage *)(JVMIMAGEPORT_FROM_JAVAVM(javaVM)->jvmImage)

#define INITIAL_CLASSLOADER_TABLE_SIZE 3
#define INITIAL_CLASS_TABLE_SIZE 10
Expand All @@ -38,9 +44,19 @@ enum ImageRC {
};

/* forward struct declarations */
struct JVMImagePortLibrary;
struct ImageTableHeader;
struct JVMImageHeader;

/*
* OMR port library wrapper
* JVMImage instance to access image functions
*/
typedef struct JVMImagePortLibrary {
OMRPortLibrary portLibrary;
void *jvmImage;
} JVMImagePortLibrary;

/*
* allows us to dump this struct into file and reload easier
* allocated space for image data is longer than sizeof(JVMImageHeader)
Expand Down
37 changes: 18 additions & 19 deletions runtime/oti/jvmimage_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C" {
*
* @return pointer to allocated memory on success, NULL on failure
*/
void* mem_allocate_memory(uintptr_t byteAmount);
void* mem_allocate_memory(J9JavaVM *javaVM, uintptr_t byteAmount);

/*
* Allocate memory in heap image
Expand All @@ -55,9 +55,10 @@ void* image_mem_allocate_memory(struct OMRPortLibrary *portLibrary, uintptr_t by
/*
* Free memory in heap image
*
* @param javaVM[in] the java vm
* @param memoryPointer[in] pointer to address for free
*/
void mem_free_memory(void *memoryPointer);
void mem_free_memory(J9JavaVM *javaVM, void *memoryPointer);

/*
* Free memory in heap image
Expand All @@ -70,67 +71,65 @@ void image_mem_free_memory(struct OMRPortLibrary *portLibrary, void *memoryPoint
/*
* Creates and allocates the jvm image and its' heap
*
* @param vm[in] the java vm
* @param javaVM[in] the java vm
*
* @return 0 on fail, 1 on success
*/
UDATA initializeJVMImage(J9JavaVM *vm);
UDATA initializeJVMImage(J9JavaVM *javaVM);

/*
* Registers class loader in table
*
* @param javaVM[in] the java vm
* @param classLoader[in] J9ClassLoader to register
*/
void registerClassLoader(J9ClassLoader *classLoader);
void registerClassLoader(J9JavaVM *javaVM, J9ClassLoader *classLoader);

/*
* Registers class segment in table
*
* @param javaVM[in] the java vm
* @param clazz[in] J9Class to register
*/
void registerClassSegment(J9Class *clazz);
void registerClassSegment(J9JavaVM *javaVM, J9Class *clazz);

/*
* Registers class path entry in table
*
* @param javaVM[in] the java vm
* @param cpEntry[in] J9ClassPathEntry to register
*/
void registerCPEntry(J9ClassPathEntry *cpEntry);
void registerCPEntry(J9JavaVM *javaVM, J9ClassPathEntry *cpEntry);

/*
* Deregisters class loader from table
*
* @param javaVM[in] the java vm
* @param classLoader[in] J9ClassLoader to register
*/
void deregisterClassLoader(J9ClassLoader *classLoader);
void deregisterClassLoader(J9JavaVM *javaVM, J9ClassLoader *classLoader);

/*
* Deregisters class segment from table
*
* @param javaVM[in] the java vm
* @param clazz[in] J9Class to register
*/
void deregisterClassSegment(J9Class *clazz);
void deregisterClassSegment(J9JavaVM *javaVM, J9Class *clazz);

/*
* Deregisters class path entry from table
*
* @param javaVM[in] the java vm
* @param cpEntry[in] J9ClassPathEntry to register
*/
void deregisterCPEntry(J9ClassPathEntry *cpEntry);

/*
* Returns the port library used by the image
* Do not use directly but through macro defined in jvmimage.h
*
* @return pointer to port library of image on success, NULL on failure
*/
OMRPortLibrary* getImagePortLibrary(void);
void deregisterCPEntry(J9JavaVM *javaVM, J9ClassPathEntry *cpEntry);

/*
* Shut down sequence of JVMImage
* Frees memory of heap variables and jvmimage instance
*
* @param vm[in] the java vm
* @param javaVM[in] the java vm
*/
void shutdownJVMImage(J9JavaVM *vm);

Expand Down
Loading

0 comments on commit f6bd7be

Please sign in to comment.