-
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
Add J9Modules and J9Packages to the VM snapshot #20830
base: master
Are you sure you want to change the base?
Conversation
@babsingh Here is the rest of the preliminary modularity support for the VM snapshot. There are a few areas (in particular) that need improvement (the I've tested on Java 11, and it works (can create a snapshot and restore) provided it is run with |
UDATA packageNameJ9UTF8Size = packageNameLength + sizeof(J9UTF8) + 1; /* +1 for null-terminator. */ | ||
#if defined(J9VM_OPT_SNAPSHOTS) | ||
if (IS_SNAPSHOTTING_ENABLED(vm)) { | ||
packageName = (J9UTF8 *)vmsnapshot_allocate_memory(packageNameJ9UTF8Size, OMRMEM_CATEGORY_VM); | ||
} else | ||
#endif /* defined(J9VM_OPT_SNAPSHOTS) */ | ||
{ | ||
packageName = (J9UTF8 *)j9mem_allocate_memory(packageNameJ9UTF8Size, OMRMEM_CATEGORY_VM); | ||
} | ||
if (NULL == packageName) { | ||
vmFuncs->setNativeOutOfMemoryError(currentThread, 0, 0); | ||
return retval; | ||
} | ||
memcpy(J9UTF8_DATA(packageName), (void *)package, packageNameLength); | ||
J9UTF8_DATA(packageName)[packageNameLength] = '\0'; | ||
J9UTF8_SET_LENGTH(packageName, (U_16)packageNameLength); |
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.
Why don't we use addUTFNameToPackage
over here? We can rewrite addUTFNameToPackage
to return packageName
, and J9Package->packageName
can be set outside the scope this method wherever needed.
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 main other use of addUTFNameToPackage
is for setting up queries to the package hash tables. Those names do not need to be persisted (nor properly free
'd when freeing a J9Package
) and thus they shouldn't be allocated with the vmsnapshot_allocate_memory
when snapshotting is enabled.
Given that it is only on creation where J9Package::packageName
needs to potentially be allocated in such a way that it can be persisted, and that is only done once in the code base, I figured that an inline version, like implemented here, was more appropriate.
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.
Ok, let's keep it as-is for now. My initial intent was to aim for a common allocation path to improve maintainability and code clarity, and rely upon the compiler to do the optimizations.
Related: eclipse-openj9#20612 Signed-off-by: Nathan Henderson <[email protected]>
23b8f07
to
8e9517e
Compare
jenkins test sanity.functional amac jdk21 |
jenkins test sanity.functional alinux jdk11 |
jenkins compile win jdk17 |
Related: #20612
Signed-off-by: Nathan Henderson [email protected]