Skip to content

Commit

Permalink
Change J9Module::moduleName from a j9object_t to a J9UTF8 pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Henderson <[email protected]>
  • Loading branch information
ThanHenderson committed Dec 10, 2024
1 parent 3f7abb5 commit 04d5610
Show file tree
Hide file tree
Showing 34 changed files with 280 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ J9Consts.J9_ITABLE_INDEX_UNRESOLVED = 0
J9Consts.J9_ITABLE_OFFSET_DIRECT = 0
J9Consts.J9_ITABLE_OFFSET_TAG_BITS = 0
J9Consts.J9_ITABLE_OFFSET_VIRTUAL = 0
J9Consts.J9_MODULE_NAME_IS_J9UTF8 = 0
J9Consts.PREVIEW_MINOR_VERSION = 0
J9Consts.VALUE_TYPES_MAJOR_VERSION = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9PackagePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ClassHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9UTF8Helper;
import com.ibm.j9ddr.vm29.structure.J9Consts;

public class ModularityHelper {
@FunctionalInterface
Expand Down Expand Up @@ -97,7 +100,7 @@ public static boolean moduleFilterMatchAll(J9ModulePointer modulePtr, String arg
* be outputted to.
*/
public static void printJ9Module(J9ModulePointer modulePtr, PrintStream out) throws CorruptDataException {
String moduleName = J9ObjectHelper.stringValue(modulePtr.moduleName());
String moduleName = getModuleName(modulePtr);
String hexAddress = modulePtr.getHexAddress();
out.printf("%-30s !j9module %s%n", moduleName, hexAddress);
}
Expand Down Expand Up @@ -340,4 +343,18 @@ public static int iterateClassLoaderClasses(PrintStream out, ClassIteratorFilter
return count;
}

public static String getModuleName(J9ModulePointer module) throws CorruptDataException {
String moduleName = null;
if ((module != null) && module.notNull()) {
if (0 != J9Consts.J9_MODULE_NAME_IS_J9UTF8) {
J9UTF8Pointer mn = module.moduleName();
moduleName = J9UTF8Helper.stringValue(mn);
} else {
/* moduleName used to be a J9ObjectPointer. */
J9ObjectPointer mn = J9ObjectPointer.cast(module.moduleNameEA().at(0));
moduleName = J9ObjectHelper.stringValue(mn);
}
}
return moduleName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9PackagePointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper;

/**
* DumpModuleDirectedExports command dumps all modules that the package is exported to
Expand Down Expand Up @@ -74,7 +74,7 @@ public void run(String command, String[] args, Context context, PrintStream out)
while (slotIterator.hasNext()) {
J9ModulePointer exportModulePtr = slotIterator.next();
hitCount++;
String moduleName = J9ObjectHelper.stringValue(exportModulePtr.moduleName());
String moduleName = ModularityHelper.getModuleName(exportModulePtr);
String hexAddress = exportModulePtr.getHexAddress();
out.printf("%-30s !j9module %s%n", moduleName, hexAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper;

/**
* DumpModuleReads command displays all modules that the target module reads
Expand Down Expand Up @@ -72,7 +72,7 @@ public void run(String command, String[] args, Context context, PrintStream out)
SlotIterator<J9ModulePointer> slotIterator = moduleHashTable.iterator();
while (slotIterator.hasNext()) {
J9ModulePointer readModulePtr = slotIterator.next();
String moduleName = J9ObjectHelper.stringValue(readModulePtr.moduleName());
String moduleName = ModularityHelper.getModuleName(readModulePtr);
String hexAddress = readModulePtr.getHexAddress();
out.printf("%-30s !j9module %s%n", moduleName, hexAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper;

/**
* FindAllModules command displays all the modules loaded by the runtime
Expand Down Expand Up @@ -70,7 +70,7 @@ public void run(String command, String[] args, Context context, PrintStream out)
SlotIterator<J9ModulePointer> slotIterator = moduleHashTable.iterator();
while (slotIterator.hasNext()) {
J9ModulePointer modulePtr = slotIterator.next();
String moduleName = J9ObjectHelper.stringValue(modulePtr.moduleName());
String moduleName = ModularityHelper.getModuleName(modulePtr);
String hexAddress = modulePtr.getHexAddress();
out.printf("%-30s !j9module %s%n", moduleName, hexAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper;

/**
* FindAllReads command displays all modules that read the target module
Expand Down Expand Up @@ -79,7 +79,7 @@ public void run(String command, String[] args, Context context, PrintStream out)
SlotIterator<J9ModulePointer> slotIterator = moduleHashTable.iterator();
while (slotIterator.hasNext()) {
J9ModulePointer modulePtr = slotIterator.next();
String moduleName = J9ObjectHelper.stringValue(modulePtr.moduleName());
String moduleName = ModularityHelper.getModuleName(modulePtr);
String hexAddress = modulePtr.getHexAddress();
J9HashTablePointer readTable = modulePtr.readAccessHashTable();
HashTable<J9ModulePointer> readModuleHashTable = ModuleHashTable.fromJ9HashTable(readTable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper;

/**
* FindModuleByName command find the modules corresponding to its module name
Expand Down Expand Up @@ -82,7 +82,7 @@ public void run(String command, String[] args, Context context, PrintStream out)
SlotIterator<J9ModulePointer> slotIterator = moduleHashTable.iterator();
while (slotIterator.hasNext()) {
J9ModulePointer modulePtr = slotIterator.next();
String moduleName = J9ObjectHelper.stringValue(modulePtr.moduleName());
String moduleName = ModularityHelper.getModuleName(modulePtr);
if (pattern.isMatch(moduleName)) {
hitCount++;
String hexAddress = modulePtr.getHexAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9PackagePointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9UTF8Helper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper;
Expand Down Expand Up @@ -157,7 +156,7 @@ private static void printModuleReads(J9ModulePointer modulePtr, PrintStream out)
* @return true if the names are equal, false otherwise.
*/
private static boolean filterModuleName(J9ModulePointer modulePtr, String targetName) throws CorruptDataException {
return J9ObjectHelper.stringValue(modulePtr.moduleName()).equals(targetName);
return ModularityHelper.getModuleName(modulePtr).equals(targetName);
}


Expand All @@ -168,7 +167,7 @@ private static boolean filterRequiresTargetModule(J9ModulePointer modulePtr, Str
SlotIterator<J9ModulePointer> slotIterator = moduleHashTable.iterator();
while (slotIterator.hasNext()) {
J9ModulePointer readModulePtr = slotIterator.next();
if (J9ObjectHelper.stringValue(readModulePtr.moduleName()).equals(targetModule)) {
if (ModularityHelper.getModuleName(readModulePtr).equals(targetModule)) {
result = true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.ibm.j9ddr.tools.ddrinteractive.FormatWalkResult;
import com.ibm.j9ddr.tools.ddrinteractive.IFieldFormatter;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModulePointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ObjectHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper;

/**
* Structure Formatter that adds a suffix to the command "!j9module $moduleAddress$" output
Expand All @@ -55,7 +55,7 @@ public FormatWalkResult postFormat(String type, long address,
J9ModulePointer modulePtr = J9ModulePointer.cast(address);
String moduleAddress = modulePtr.getHexAddress();
try {
out.println("Module name: " + J9ObjectHelper.stringValue(modulePtr.moduleName()));
out.println("Module name: " + ModularityHelper.getModuleName(modulePtr));
} catch (CorruptDataException e) {
// Do nothing
}
Expand Down
22 changes: 5 additions & 17 deletions runtime/bcutil/dynload.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,38 +207,26 @@ static IDATA
searchClassInModule(J9VMThread * vmThread, J9Module * j9module, U_8 * className, UDATA classNameLength, BOOLEAN verbose, J9TranslationLocalBuffer *localBuffer)
{
J9JavaVM *javaVM = vmThread->javaVM;
char moduleNameBuf[J9VM_PACKAGE_NAME_BUFFER_LENGTH];
char *moduleName = NULL;
BOOLEAN freeModuleName = FALSE;
U_8 *moduleName = NULL;
IDATA rc = 1;
PORT_ACCESS_FROM_JAVAVM(javaVM);

/* localBuffer should not be NULL */
Trc_BCU_Assert_True(NULL != localBuffer);

if (j9module == javaVM->javaBaseModule) {
moduleName = JAVA_BASE_MODULE;
moduleName = (U_8 *)JAVA_BASE_MODULE;
} else {
moduleName = J9_VM_FUNCTION(vmThread, copyStringToUTF8WithMemAlloc)(
vmThread, j9module->moduleName, J9_STR_NULL_TERMINATE_RESULT, "", 0, moduleNameBuf, J9VM_PACKAGE_NAME_BUFFER_LENGTH, NULL);
if (NULL == moduleName) {
rc = -1;
goto _end;
}
if (moduleNameBuf != moduleName) {
freeModuleName = TRUE;
if (NULL != j9module->moduleName) {
moduleName = J9UTF8_DATA(j9module->moduleName);
}
}

rc = searchClassInCPEntry(vmThread, javaVM->modulesPathEntry, j9module, (U_8*)moduleName, className, classNameLength, verbose);
rc = searchClassInCPEntry(vmThread, javaVM->modulesPathEntry, j9module, moduleName, className, classNameLength, verbose);
if (0 == rc) {
localBuffer->loadLocationType = LOAD_LOCATION_MODULE;
}

if (TRUE == freeModuleName) {
j9mem_free_memory(moduleName);
}
_end:
return rc;
}

Expand Down
3 changes: 0 additions & 3 deletions runtime/gc_base/RootScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ MM_RootScanner::scanModularityObjects(J9ClassLoader * classLoader)
J9Module * const module = *modulePtr;

doSlot(&module->moduleObject);
if (NULL != module->moduleName) {
doSlot(&module->moduleName);
}
if (NULL != module->version) {
doSlot(&module->version);
}
Expand Down
3 changes: 0 additions & 3 deletions runtime/gc_glue_java/ConcurrentMarkingDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,6 @@ MM_ConcurrentMarkingDelegate::concurrentClassMark(MM_EnvironmentBase *env, bool
J9Module * const module = *modulePtr;

_markingScheme->markObject(env, (j9object_t)module->moduleObject);
if (NULL != module->moduleName) {
_markingScheme->markObject(env, (j9object_t)module->moduleName);
}
if (NULL != module->version) {
_markingScheme->markObject(env, (j9object_t)module->version);
}
Expand Down
3 changes: 0 additions & 3 deletions runtime/gc_glue_java/MarkingDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,6 @@ MM_MarkingDelegate::completeMarking(MM_EnvironmentBase *env)
J9Module * const module = *modulePtr;

_markingScheme->markObjectNoCheck(env, (omrobjectptr_t )module->moduleObject);
if (NULL != module->moduleName) {
_markingScheme->markObjectNoCheck(env, (omrobjectptr_t )module->moduleName);
}
if (NULL != module->version) {
_markingScheme->markObjectNoCheck(env, (omrobjectptr_t )module->version);
}
Expand Down
1 change: 0 additions & 1 deletion runtime/gc_glue_java/MetronomeDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,6 @@ MM_MetronomeDelegate::doClassTracing(MM_EnvironmentRealtime *env)
J9Module * const module = *modulePtr;

didWork |= _markingScheme->markObject(env, module->moduleObject);
didWork |= _markingScheme->markObject(env, module->moduleName);
didWork |= _markingScheme->markObject(env, module->version);
modulePtr = (J9Module**)hashTableNextDo(&walkState);
}
Expand Down
10 changes: 0 additions & 10 deletions runtime/gc_vlhgc/CopyForwardScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2697,11 +2697,6 @@ MM_CopyForwardScheme::scanClassLoaderObjectSlots(MM_EnvironmentVLHGC *env, MM_Al
while (success && (NULL != modulePtr)) {
J9Module * const module = *modulePtr;
success = copyAndForward(env, reservingContext, classLoaderObject, (J9Object **)&(module->moduleObject));
if (success) {
if (NULL != module->moduleName) {
success = copyAndForward(env, reservingContext, classLoaderObject, (J9Object **)&(module->moduleName));
}
}
if (success) {
if (NULL != module->version) {
success = copyAndForward(env, reservingContext, classLoaderObject, (J9Object **)&(module->version));
Expand Down Expand Up @@ -4459,11 +4454,6 @@ MM_CopyForwardScheme::scanRoots(MM_EnvironmentVLHGC* env)
while (success && (NULL != modulePtr)) {
J9Module * const module = *modulePtr;
success = copyAndForward(env, getContextForHeapAddress(module->moduleObject), (J9Object **)&(module->moduleObject));
if (success) {
if (NULL != module->moduleName) {
success = copyAndForward(env, getContextForHeapAddress(module->moduleName), (J9Object **)&(module->moduleName));
}
}
if (success) {
if (NULL != module->version) {
success = copyAndForward(env, getContextForHeapAddress(module->version), (J9Object **)&(module->version));
Expand Down
3 changes: 0 additions & 3 deletions runtime/gc_vlhgc/GlobalMarkCardScrubber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@ MM_GlobalMarkCardScrubber::scrubClassLoaderObject(MM_EnvironmentVLHGC *env, J9Ob
J9Module * const module = *modulePtr;
Assert_MM_true(NULL != module->moduleObject);
doScrub = mayScrubReference(env, classLoaderObject, module->moduleObject);
if (doScrub) {
doScrub = mayScrubReference(env, classLoaderObject, module->moduleName);
}
if (doScrub) {
doScrub = mayScrubReference(env, classLoaderObject, module->version);
}
Expand Down
4 changes: 0 additions & 4 deletions runtime/gc_vlhgc/GlobalMarkingScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,6 @@ MM_GlobalMarkingScheme::scanClassLoaderObject(MM_EnvironmentVLHGC *env, J9Object
Assert_MM_true(NULL != module->moduleObject);
markObject(env, module->moduleObject);
rememberReferenceIfRequired(env, classLoaderObject, module->moduleObject);
if (NULL != module->moduleName) {
markObject(env, module->moduleName);
rememberReferenceIfRequired(env, classLoaderObject, module->moduleName);
}
if (NULL != module->version) {
markObject(env, module->version);
rememberReferenceIfRequired(env, classLoaderObject, module->version);
Expand Down
9 changes: 0 additions & 9 deletions runtime/gc_vlhgc/WriteOnceCompactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,15 +1340,6 @@ MM_WriteOnceCompactor::fixupClassLoaderObject(MM_EnvironmentVLHGC* env, J9Object
*slotPtr = forwardedObject;
_interRegionRememberedSet->rememberReferenceForCompact(env, classLoaderObject, forwardedObject);

slotPtr = &module->moduleName;

originalObject = *slotPtr;
if (NULL != originalObject) {
J9Object* forwardedObject = getForwardWrapper(env, originalObject, cache);
*slotPtr = forwardedObject;
_interRegionRememberedSet->rememberReferenceForCompact(env, classLoaderObject, forwardedObject);
}

slotPtr = &module->version;

originalObject = *slotPtr;
Expand Down
Loading

0 comments on commit 04d5610

Please sign in to comment.