The getResolvedMethods frond end query generates unnecessary MethodFromClassRecord SVM validation records; it creates a validation record for each method in a class. The reason is because the front end can't tell which of those resolved methods the compiler is going to use, and the SVM needs every (used) resolved method accounted for. I found a way to sidestep this (#23587). This PR and this bit of code for the MethodFromClassRecord
|
SVM_ASSERT_ALREADY_VALIDATED(this, beholder); |
|
return addVanillaRecord(method, new (_region) MethodFromClassRecord(method, beholder, index)); |
though highlights a characteristic that was overlooked right from the beginning: its only real purpose is to associate an ID to a method in a class; it doesn't actually help with any additional validation
1. This is because it requires its defining class to have been validated, which involves a class chain validation; therefore, the method's index is guaranteed to be the same by virtue of the class chain validation.
Thus, the SVM needs to be updated to only generate IDs for methods of classes and not actually create validation records for them. However, this requires having some way of linking the ID associated with a class with the IDs that will be associated with its methods, such that it does not require a validation record; otherwise, there is no benefit as every class with require 2 or 3 validation records (Class and/or ClassChain, and MethodsFromClass). Essentially, there has to be a way on the load run for the SVM to generate IDs for methods of a class such that they are exactly the same as those generated in the compile run.
The only way (I can think of thus far) to do so is to generate the method IDs immediately after the class ID. This has the effect of moving a method ID association from a later point in a compilation to an earlier point, which changes which record was the first to generate the ID, but does not change consistency between records with the same ID2. This turns out to be fairly non-trivial. The reason is related to constraints associated with the Well Known Classes, Array Classes, and possibly others.
For example, with the WKC, the IDs for the methods must be generated using the guaranteed ID generator, since the WKC ID generated after the previous WKC's methods must be consistent across runs. However, for other classes, the ID cannot be generated with the guaranteed ID generator since on a load run, the SVM does not increment IDs during validation (except for the guaranteed ones) and instead acquires them from the validation records loaded out of the SCC; thus, the method IDs must use their defining class's ID as a starting point.
All this gets complicated and sticky really quickly. After a failed attempt at what I thought was going to be a simple extension of the getResolvedMethods improvement above, I'm opening this issue to track this since this probably does have a decent amount of benefit.
The
getResolvedMethodsfrond end query generates unnecessaryMethodFromClassRecordSVM validation records; it creates a validation record for each method in a class. The reason is because the front end can't tell which of those resolved methods the compiler is going to use, and the SVM needs every (used) resolved method accounted for. I found a way to sidestep this (#23587). This PR and this bit of code for theMethodFromClassRecordopenj9/runtime/compiler/runtime/SymbolValidationManager.cpp
Lines 869 to 870 in 79f167d
though highlights a characteristic that was overlooked right from the beginning: its only real purpose is to associate an ID to a method in a class; it doesn't actually help with any additional validation1. This is because it requires its defining class to have been validated, which involves a class chain validation; therefore, the method's index is guaranteed to be the same by virtue of the class chain validation.
Thus, the SVM needs to be updated to only generate IDs for methods of classes and not actually create validation records for them. However, this requires having some way of linking the ID associated with a class with the IDs that will be associated with its methods, such that it does not require a validation record; otherwise, there is no benefit as every class with require 2 or 3 validation records (Class and/or ClassChain, and MethodsFromClass). Essentially, there has to be a way on the load run for the SVM to generate IDs for methods of a class such that they are exactly the same as those generated in the compile run.
The only way (I can think of thus far) to do so is to generate the method IDs immediately after the class ID. This has the effect of moving a method ID association from a later point in a compilation to an earlier point, which changes which record was the first to generate the ID, but does not change consistency between records with the same ID2. This turns out to be fairly non-trivial. The reason is related to constraints associated with the Well Known Classes, Array Classes, and possibly others.
For example, with the WKC, the IDs for the methods must be generated using the guaranteed ID generator, since the WKC ID generated after the previous WKC's methods must be consistent across runs. However, for other classes, the ID cannot be generated with the guaranteed ID generator since on a load run, the SVM does not increment IDs during validation (except for the guaranteed ones) and instead acquires them from the validation records loaded out of the SCC; thus, the method IDs must use their defining class's ID as a starting point.
All this gets complicated and sticky really quickly. After a failed attempt at what I thought was going to be a simple extension of the
getResolvedMethodsimprovement above, I'm opening this issue to track this since this probably does have a decent amount of benefit.Footnotes
Technically this statement isn't entirely accurate; if it were there would be no need to associate IDs to the methods at all (see https://github.com/eclipse-openj9/openj9/issues/23558#issuecomment-4099744672). ↩
I should note a very subtle point. Generating IDs immediately after generating an ID for a class means that Scenario 4 in https://github.com/eclipse-openj9/openj9/pull/23587 will never happen. ↩