-
Notifications
You must be signed in to change notification settings - Fork 728
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
Change J9Module::moduleName from a j9object_t to a J9UTF8 pointer #20740
Change J9Module::moduleName from a j9object_t to a J9UTF8 pointer #20740
Conversation
743ca0a
to
f653682
Compare
f653682
to
35d786e
Compare
runtime/vm/lookupmethod.c
Outdated
J9UTF8 *moduleName = module->moduleName; | ||
U_8 *nameData = J9UTF8_DATA(moduleName); | ||
UDATA nameLength = J9UTF8_LENGTH(moduleName); | ||
nameBuffer = (char *)j9mem_allocate_memory(nameLength + 1, OMRMEM_CATEGORY_VM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
malloc
's failure case needs to be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can introduce copyJ9UTF8ToUTF8WithMemAlloc
, similar to copyStringToUTF8WithMemAlloc
, which could be used in most places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that when we add the rest of the support for snapshotting modules, we need to allcocate the moduleName
J9UTF8
s with the snapshot sub-allocator.
The API could just take a function pointer to the allocator to get around that, or we could have a snapshot specific function for when snapshots are enabled.
Note: my above description doesn't apply to where this comment is, but to other paths in this patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API could just take a function pointer to the allocator to get around that
This one seems better (less code). Instead of a function pointer, we can also use a boolean to toggle between the allocators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also use a boolean to toggle between the allocators
To keep it general/reusable beyond snapshotting, I think it is better to have the allocator as a parameter rather than a boolean to switch between the two.
But here, I will use the functions that we already have, and add a copyJ9UTF8ToUTF8WithMemAlloc
function as if we were ignorant of the future module snapshotting support. Then in the PR that adds modules to the snapshots, I will add a variant that takes an allocator pointer and use that anywhere we need.
@dmitripivkine Please review the GC code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC part of the change looks good to me
b10cc6b
to
2cd0300
Compare
2cd0300
to
4898374
Compare
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/ModularityHelper.java
Outdated
Show resolved
Hide resolved
4898374
to
7a386c3
Compare
I've addressed the comments. |
public static String getModuleName(J9ModulePointer modulePtr) throws CorruptDataException { | ||
String moduleName = null; | ||
if (modulePtr != null) { | ||
Object mn = modulePtr.moduleName(); | ||
if (mn instanceof J9ObjectPointer) { | ||
moduleName = J9ObjectHelper.stringValue((J9ObjectPointer)mn); | ||
} else if (mn instanceof J9UTF8Pointer) { | ||
moduleName = J9UTF8Helper.stringValue((J9UTF8Pointer)mn); | ||
} else { | ||
throw new CorruptDataException("Invalid module name data type encountered: " + mn.toString()); | ||
} | ||
} | ||
return moduleName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs will need to be used here. We should perform a brief sanity check using jdmpview + core file
to confirm that this helper is functioning correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something wrong with my auto indent functionality between vim/VSCode; really need to nail that down. Thanks for catching that. I'll test it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function won't work on older core files because J9ModulePointer::moduleName()
is generated for the build of jdmpview
based on they moduleName
type in the JDK build. i.e. the signature is (and from now on will be):
@com.ibm.j9ddr.GeneratedFieldAccessor(offsetFieldName="_moduleNameOffset_", declaredType="J9UTF8*")
public J9UTF8Pointer moduleName() throws CorruptDataException {...}
Using an older core file doesn't change the fact that this function returns a J9UTF8Pointer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the contrary, the blob in an old core records the fact that moduleName
was J9Object*
.
$ omr_blob_reader jdk-21/lib/default/j9ddr.dat
...
Struct name: J9Module
no superName
sizeOf: 64
fieldCount: 9
constCount: 0
Field declaredName: moduleName
declaredType: struct J9Object*
offset: 0
Also, the indentation is a mix of tabs and spaces; here, the indentation should be exclusively tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there is precedent for changing the type of a field used in DDR code. We may need to use a new name for the J9UTF8 flavour. Of course, that means that neither can be a "required" field in the sense used in AuxFieldInfo29.dat
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the contrary, the blob in an old core records the fact that moduleName was J9Object*
I understand that this is the case. My point was that using a newer jdmpview
with the changed type to examine an older core, results in the J9ModulePointer::moduleName()
to cause a:
java.lang.NoSuchMethodError: com/ibm/j9ddr/vm29/pointer/generated/J9ModulePointer.moduleName()Lcom/ibm/j9ddr/vm29/pointer/generated/J9UTF8Pointer; (loaded from <Unknown> by J9DDRClassloader for com.ibm.j9ddr.vm29.) called from class com.ibm.j9ddr.vm29.tools.ddrinteractive.ModularityHelper (loaded from <Unknown> by J9DDRClassloader for com.ibm.j9ddr.vm29.).
because of this difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the signature of the reference is baked into ModularityHelper.class
.
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/ModularityHelper.java
Outdated
Show resolved
Hide resolved
vmFuncs->setNativeOutOfMemoryError(currentThread, 0, 0); | ||
J9UTF8 *moduleName = fromModule->moduleName; | ||
if (NULL != moduleName) { | ||
Trc_MODULE_createPackage(currentThread, package, (const char *)J9UTF8_DATA(moduleName), fromModule); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J9UTF8 data isn't necessarily null-terminated: this may need to specify the length. This issues is present multiple places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured these could be skirted since we enforce null-termination of the moduleName
J9UTF8
on J9Module
creation.
04d5610
to
e22d2d6
Compare
Signed-off-by: Nathan Henderson <[email protected]>
e22d2d6
to
4ae925f
Compare
Jenkins test sanity alinux jdk21 |
Also tested locally with new system dump and one from 0.48.0. |
Signed-off-by: Nathan Henderson [email protected]