Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure consistency in the ClassLoader hash table #12871

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions runtime/oti/vm_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,6 @@ resolveNativeAddress(J9VMThread *currentThread, J9Method *nativeMethod, UDATA ru

/* ---------------- classallocation.c ---------------- */

/**
* @brief Get Package ID for the ROM class. NOTE: You must own the class table mutex before calling this function.
* @param *classLoader Classloader for the class
* @param *romClass ROM class with package name
* @param *vmThread J9VMThread instance
* @param entryIndex classpath index
* @param locationType location type of class
* @return UDATA Package ID
*/
UDATA
initializePackageID(J9ClassLoader *classLoader, J9ROMClass *romClass, J9VMThread *vmThread, IDATA entryIndex, I_32 locationType);

/**
* @brief
* @param *javaVM
Expand Down Expand Up @@ -2132,6 +2120,7 @@ cacheObjectMonitorForLookup(J9JavaVM* vm, J9VMThread* vmStruct, J9ObjectMonitor*

/**
* @brief Find the package ID for the given name and length
* @note Must own the classTableMutex.
* @param *vmThread J9VMThread instance
* @param *classLoader Classloader for the class
* @param *romClass ROM class with the package name
Expand All @@ -2144,14 +2133,26 @@ hashPkgTableIDFor(J9VMThread *vmThread, J9ClassLoader *classLoader, J9ROMClass*

/**
* @brief Look up the package information given a ROM class.
* @note the ROM class may be a dummy with only the package name.
* @note Must own the classTableMutex.
* @note The ROM class may be a dummy with only the package name.
* @param *classLoader Classloader for the class
* @param *romClass ROM class with the package name
* @return J9PackageIDTableEntry* ROM class representing a package
*/
J9PackageIDTableEntry *
hashPkgTableAt(J9ClassLoader* classLoader, J9ROMClass* romClass);

/**
* @brief Delete the package ID for a ROM class.
* @note Must own the classTableMutex.
* @note The entry is only deleted if it came from the given ROM class.
* @param *classLoader Classloader for the class
* @param *romClass ROM class with the package name
*/
void
hashPkgTableDelete(J9ClassLoader* classLoader, J9ROMClass* romClass);


/**
* @brief Iterate over the package IDs used by the specified class loader
* @param *classLoader
Expand Down
18 changes: 13 additions & 5 deletions runtime/vm/KeyHashTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,6 @@ hashClassTableNextDo(J9HashTableState *walkState)
return (NULL == next) ? NULL : next->ramClass;
}

/**
* Find the package ID for the given name and length.
* NOTE: You must own the class table mutex before calling this function.
*/
UDATA
hashPkgTableIDFor(J9VMThread *vmThread, J9ClassLoader *classLoader, J9ROMClass *romClass, IDATA entryIndex, I_32 locationType)
{
Expand All @@ -553,7 +549,7 @@ hashPkgTableIDFor(J9VMThread *vmThread, J9ClassLoader *classLoader, J9ROMClass *
result = growClassHashTable(javaVM, classLoader, &key);
}
if (NULL != result) {
packageID = *(UDATA *)result;
packageID = result->packageID.taggedROMClass;
if (isSystemClassLoader && J9_ARE_ALL_BITS_SET(result->tag, TAG_GENERATED_PACKAGE)) {
if (J9_ARE_NO_BITS_SET(key.tag, TAG_GENERATED_PACKAGE)) {
/* Below function removes the TAG_GENERATED_PACKAGE bit from the hash table entry after adding
Expand Down Expand Up @@ -586,6 +582,18 @@ hashPkgTableAt(J9ClassLoader *classLoader, J9ROMClass *romClass)
return (NULL != result) ? &result->packageID : NULL;
}

void
hashPkgTableDelete(J9ClassLoader *classLoader, J9ROMClass *romClass)
{
J9PackageIDTableEntry *entry = hashPkgTableAt(classLoader, romClass);
if (NULL != entry) {
if ((entry->taggedROMClass & ~(UDATA)(TAG_ROM_CLASS | TAG_GENERATED_PACKAGE)) == (UDATA)romClass) {
uint32_t rc = hashTableRemove(classLoader->classHashTable, entry);
Assert_VM_true(0 == rc);
}
}
}

J9PackageIDTableEntry *
hashPkgTableStartDo(J9ClassLoader *classLoader, J9HashTableState *walkState)
{
Expand Down
10 changes: 1 addition & 9 deletions runtime/vm/classallocation.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2020 IBM Corp. and others
* Copyright (c) 1991, 2021 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
Expand Down Expand Up @@ -51,14 +51,6 @@

static void cleanPackage(J9Package *package);

UDATA
initializePackageID(J9ClassLoader *classLoader, J9ROMClass *romClass, J9VMThread *vmThread, IDATA entryIndex, I_32 locationType)
{
UDATA id = hashPkgTableIDFor(vmThread, classLoader, romClass, entryIndex, locationType);

return id;
}

#define CLASS_PROPAGATION_TABLE_SIZE 3

U_32 classPropagationTable[CLASS_PROPAGATION_TABLE_SIZE] = {
Expand Down
Loading