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 4, 2024
1 parent 249921b commit 35d786e
Show file tree
Hide file tree
Showing 29 changed files with 194 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,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 = J9UTF8Helper.stringValue(modulePtr.moduleName());
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 @@ -36,7 +36,7 @@
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.J9UTF8Helper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;

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 = J9UTF8Helper.stringValue(exportModulePtr.moduleName());
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,7 +35,7 @@
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.J9UTF8Helper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;

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 = J9UTF8Helper.stringValue(readModulePtr.moduleName());
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,7 +35,7 @@
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.J9UTF8Helper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;

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 = J9UTF8Helper.stringValue(modulePtr.moduleName());
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,7 +38,7 @@
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.J9UTF8Helper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;

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 = J9UTF8Helper.stringValue(modulePtr.moduleName());
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,7 +36,7 @@
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.J9UTF8Helper;
import com.ibm.j9ddr.vm29.pointer.helper.J9RASHelper;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.JavaVersionHelper;

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 = J9UTF8Helper.stringValue(modulePtr.moduleName());
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 J9UTF8Helper.stringValue(modulePtr.moduleName()).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 (J9UTF8Helper.stringValue(readModulePtr.moduleName()).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.pointer.helper.J9UTF8Helper;

/**
* 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: " + J9UTF8Helper.stringValue(modulePtr.moduleName()));
} catch (CorruptDataException e) {
// Do nothing
}
Expand Down
12 changes: 10 additions & 2 deletions runtime/bcutil/dynload.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,20 @@ searchClassInModule(J9VMThread * vmThread, J9Module * j9module, U_8 * className,
if (j9module == javaVM->javaBaseModule) {
moduleName = 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);
J9UTF8 *moduleNameJ9UTF8 = j9module->moduleName;
U_8 *nameData = J9UTF8_DATA(moduleNameJ9UTF8);
UDATA nameLength = J9UTF8_LENGTH(moduleNameJ9UTF8);
if (nameLength < J9VM_PACKAGE_NAME_BUFFER_LENGTH) {
moduleName = moduleNameBuf;
} else {
moduleName = (char *)j9mem_allocate_memory(nameLength + 1, OMRMEM_CATEGORY_VM); /* +1 for null-terminator. */
}
if (NULL == moduleName) {
rc = -1;
goto _end;
}
memcpy(moduleName, nameData, nameLength);
moduleName[nameLength] = '\0';
if (moduleNameBuf != moduleName) {
freeModuleName = TRUE;
}
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 @@ -92,9 +92,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 @@ -2691,11 +2691,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 @@ -4441,11 +4436,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 @@ -896,10 +896,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 @@ -1337,15 +1337,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 35d786e

Please sign in to comment.