Register allocator correctness verifier#13229
Draft
danocmx wants to merge 97 commits intooracle:masterfrom
Draft
Register allocator correctness verifier#13229danocmx wants to merge 97 commits intooracle:masterfrom
danocmx wants to merge 97 commits intooracle:masterfrom
Conversation
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Register allocation verifier, inspired by cranelift's regalloc checker. Works by saving symbols before allocation - variables, constants, registers and stack slots, then matches these to locations inserted by allocator(s) - registers and stack slots. Outputs of instructions then store these symbols to those locations in block's verification state. Spills, register moves and reloads move these around. Before any checking is done, initial allocation state (map of form location → symbol) is calculated for each block based on it's predecessors, when same location with different symbols meet, a conflict is created - can be resolved by writing to the location. Afterwards, checking is done for each block, we verify that symbols before allocation are stored at the locations inserted by allocator(s), taking into account reloads and spills that the allocator created.
Implemented as a phase (
RegAllocVerifierPhase) that wraps around both register and stack allocator, collects symbol information before allocation and matches this information to instructions after allocation to create verifier IR that it then uses to update state allocation maps and to verify operands.When a violation is detected by the verifier, a
RAVExceptionis thrown and if dumping is enabled a.rav.txtfile is created ingraal_dumpsdirectory with the exception details and verifier IR.Implemented as
jdk.graal.compiler.lir.alloc.verifierpackage, modifiesAllocationStageto insert the verification phase when enabled and also changes modifier to public forbuildmethod inLocationMarkerto access it in the verifier package. No other modification to existing was needed, variable locations stripped by the allocator from label/jump instructions are recovered by finding their first usage inFromUsageGlobalResolverclass to not mess with the existing register allocator code.Some functionality tested in
RegAllocVerifierTest, runs valid methods with the verifier, then injects faults and tests if the verifier can detect them. To be expanded.New compiler flags:
EnableRAVerifier- enables the verification for the compilationVerifyStackAllocator- verifies that stack allocator output together with register allocatorCollectReferences- usesLocationMarkerclass to collect GC reference sets before final code analysis stage to verify and invalidate old referencesOther functionality
alivelocation is not overwritten by the instruction astemporoutputJavaKindObject match