Skip to content

Commit

Permalink
Register Class into Table (eclipse-openj9#19) (eclipse-openj9#23)
Browse files Browse the repository at this point in the history
* Register Class into Table (eclipse-openj9#23)

- register performed in createramclass
- added register functions into internalfuncs
- changed naming scheme

Signed-off-by: akshayben <[email protected]>
  • Loading branch information
akshayben authored Jun 28, 2019
1 parent 00ff7ee commit 4b8af86
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
6 changes: 6 additions & 0 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -4784,6 +4784,12 @@ typedef struct J9InternalVMFunctions {
void ( *setNestmatesError)(struct J9VMThread *vmThread, struct J9Class *nestMember, struct J9Class *nestHost, IDATA errorCode);
#endif /* J9VM_OPT_VALHALLA_NESTMATES */
BOOLEAN ( *areValueTypesEnabled)(struct J9JavaVM *vm);
void ( *registerClassLoader)(struct J9JavaVM* javaVM, struct J9ClassLoader* classLoader);
void ( *registerClass)(struct J9JavaVM* javaVM, struct J9Class* clazz);
void ( *registerCPEntry)(struct J9JavaVM* javaVM, struct J9ClassPathEntry* cpEntry);
void ( *deregisterClassLoader)(struct J9JavaVM* javaVM, struct J9ClassLoader* classLoader);
void ( *deregisterClass)(struct J9JavaVM* javaVM, struct J9Class* clazz);
void ( *deregisterCPEntry)(struct J9JavaVM* javaVM, struct J9ClassPathEntry* cpEntry);
} J9InternalVMFunctions;

/* Jazz 99339: define a new structure to replace JavaVM so as to pass J9NativeLibrary to JVMTIEnv */
Expand Down
2 changes: 1 addition & 1 deletion runtime/oti/jvmimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef struct JVMImageHeader {
UDATA imageSize; /* image size in bytes */
uintptr_t imageAddress;
J9WSRP classLoaderTable;
J9WSRP classSegmentTable;
J9WSRP classTable;
J9WSRP classPathEntryTable;
} JVMImageHeader;

Expand Down
8 changes: 4 additions & 4 deletions runtime/oti/jvmimage_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ UDATA initializeJVMImage(J9JavaVM *javaVM);
void registerClassLoader(J9JavaVM *javaVM, J9ClassLoader *classLoader);

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

/*
* Registers class path entry in table
Expand All @@ -93,12 +93,12 @@ void registerCPEntry(J9JavaVM *javaVM, J9ClassPathEntry *cpEntry);
void deregisterClassLoader(J9JavaVM *javaVM, J9ClassLoader *classLoader);

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

/*
* Deregisters class path entry from table
Expand Down
14 changes: 7 additions & 7 deletions runtime/vm/JVMImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ JVMImage::setupColdRun(void)
}

if ((NULL == allocateTable(getClassLoaderTable(), INITIAL_CLASSLOADER_TABLE_SIZE))
|| (NULL == allocateTable(getClassSegmentTable(), INITIAL_CLASS_TABLE_SIZE))
|| (NULL == allocateTable(getClassTable(), INITIAL_CLASS_TABLE_SIZE))
|| (NULL == allocateTable(getClassPathEntryTable(), INITIAL_CLASSPATH_TABLE_SIZE))) {
return IMAGE_ERROR;
}
Expand Down Expand Up @@ -151,11 +151,11 @@ bool
JVMImage::allocateImageTableHeaders(void)
{
WSRP_SET(_jvmImageHeader->classLoaderTable, subAllocateMemory(sizeof(ImageTableHeader)));
WSRP_SET(_jvmImageHeader->classSegmentTable, subAllocateMemory(sizeof(ImageTableHeader)));
WSRP_SET(_jvmImageHeader->classTable, subAllocateMemory(sizeof(ImageTableHeader)));
WSRP_SET(_jvmImageHeader->classPathEntryTable, subAllocateMemory(sizeof(ImageTableHeader)));

if ((0 == _jvmImageHeader->classLoaderTable)
|| (0 == _jvmImageHeader->classSegmentTable)
|| (0 == _jvmImageHeader->classTable)
|| (0 == _jvmImageHeader->classPathEntryTable)
) {
return false;
Expand Down Expand Up @@ -432,13 +432,13 @@ registerClassLoader(J9JavaVM *javaVM, J9ClassLoader *classLoader)
}

extern "C" void
registerClassSegment(J9JavaVM *javaVM, J9Class *clazz)
registerClass(J9JavaVM *javaVM, J9Class *clazz)
{
IMAGE_ACCESS_FROM_JAVAVM(javaVM);

Assert_VM_notNull(jvmImage);

jvmImage->registerEntryInTable(jvmImage->getClassSegmentTable(), (UDATA)clazz);
jvmImage->registerEntryInTable(jvmImage->getClassTable(), (UDATA)clazz);
}

extern "C" void
Expand All @@ -462,13 +462,13 @@ deregisterClassLoader(J9JavaVM *javaVM, J9ClassLoader *classLoader)
}

extern "C" void
deregisterClassSegment(J9JavaVM *javaVM, J9Class *clazz)
deregisterClass(J9JavaVM *javaVM, J9Class *clazz)
{
IMAGE_ACCESS_FROM_JAVAVM(javaVM);

Assert_VM_notNull(jvmImage);

jvmImage->deregisterEntryInTable(jvmImage->getClassSegmentTable(), (UDATA)clazz);
jvmImage->deregisterEntryInTable(jvmImage->getClassTable(), (UDATA)clazz);
}

extern "C" void
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/JVMImage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class JVMImage
void destroyMonitor(void);

ImageTableHeader* getClassLoaderTable(void) { return WSRP_GET(_jvmImageHeader->classLoaderTable, ImageTableHeader*); }
ImageTableHeader* getClassSegmentTable(void) { return WSRP_GET(_jvmImageHeader->classSegmentTable, ImageTableHeader*); }
ImageTableHeader* getClassTable(void) { return WSRP_GET(_jvmImageHeader->classTable, ImageTableHeader*); }
ImageTableHeader* getClassPathEntryTable(void) { return WSRP_GET(_jvmImageHeader->classPathEntryTable, ImageTableHeader*); }
};

Expand Down
4 changes: 4 additions & 0 deletions runtime/vm/createramclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,7 @@ internalCreateRAMClassFromROMClass(J9VMThread *vmThread, J9ClassLoader *classLoa
J9FlattenedClassCache *flattenedClassCache = (J9FlattenedClassCache *) flattenedClassCacheBuffer;
PORT_ACCESS_FROM_VMC(vmThread);
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
J9InternalVMFunctions const * const vmFuncs = javaVM->internalVMFunctions;

/* if this is an anon class classLoader should be anonClassLoader */
if (J9_ARE_ALL_BITS_SET(options, J9_FINDCLASS_FLAG_ANON)) {
Expand Down Expand Up @@ -3127,6 +3128,9 @@ internalCreateRAMClassFromROMClass(J9VMThread *vmThread, J9ClassLoader *classLoa
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */

result->classFlags = classFlags;
if (IS_COLD_RUN(javaVM)) {
vmFuncs->registerClass(javaVM, result);
}
}

return result;
Expand Down
6 changes: 6 additions & 0 deletions runtime/vm/intfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,10 @@ J9InternalVMFunctions J9InternalFunctions = {
setNestmatesError,
#endif
areValueTypesEnabled,
registerClassLoader,
registerClass,
registerCPEntry,
deregisterClassLoader,
deregisterClass,
deregisterCPEntry,
};

0 comments on commit 4b8af86

Please sign in to comment.