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

Copy local signature from MethodHandleNatives.resolve #20700

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theresa-m
Copy link
Contributor

@theresa-m theresa-m commented Nov 28, 2024

For the case mentioned in #20189 (comment) sig1 in j9bcv_checkClassLoadingConstraintsForSignature should be copied but sig2 does not need to be copied. I added an additional boolean for each signature and it is only set to false if the signature is found in a class memory segment.

Related to: #20189

@@ -91,7 +91,7 @@ TraceExit=Trc_RTV_unlinkClassLoadingConstraints_Exit NoEnv Overhead=1 Level=1 Te

TraceEvent=Trc_RTV_checkClassLoadingConstraintForName Overhead=1 Level=3 Template="checkClassLoadingConstraintForName - Checking constraints between %p and %p for %.*s"

TraceAssert=Assert_RTV_validateClassLoadingConstraints Overhead=2 Level=5 NoEnv Assert="validateArgs(P1, P2, P3, P4, P5, P6), 1"
TraceAssert=Assert_RTV_validateClassLoadingConstraints Overhead=2 Level=5 NoEnv Assert="validateArgs(P1, P2, P3, P4, P5, P6, P7, P8), 1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trace point is level 5, which is not enabled by default.
We cannot change an existing trace point like this. It could cause problems parsing snap trace file generated by an older build that does not have this change.

Instead of changing this trace point, maybe you can add a new function like the following to set copyUTF1 and copyUTF2

static void 
findNamesInSegments(validateArgs (J9VMThread *vmThread, U_8 *name1, U_8 *name2, UDATA *name1Found, UDATA *name2Found) 
{
	J9MemorySegment *seg = vmThread->javaVM->classMemorySegments->nextSegment;
	while (seg) {
		if (!(*name1Found) 
                    && (seg->heapBase <= name1) 
                    && (seg->heapTop >= name1)
                  ) {
			*name1Found = TRUE;
		}
		/* same for name2 */
                 /* break if both names are found in the segment */
		seg = seg->nextSegment;
	}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed this trace point is level 2, so searching the classname is the class segment will have performance impact. There is a better way to fix this. Looking at the caller of j9bcv_checkClassLoadingConstraintsForSignature(), if the sig1 and sig2 are from the J9ROM** macro, then they are in the class segment and don't need to be copied.

The only case that needs to be copied is lookupSig here:

J9NameAndSignature * nas = (J9NameAndSignature *) nameAndSig;
lookupSig = nas->signature;

We could change j9bcv_checkClassLoadingConstraintsForSignature() to pass in additional parameters to whether copy the strings.

@theresa-m theresa-m changed the title Verify name is in class memory segment for copying Copy local signature from MethodHandleNatives.resolve Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants