Omit null checks on return values when they're known to be not null#60
Draft
raneashay wants to merge 1 commit intomicrosoft:mainfrom
Draft
Omit null checks on return values when they're known to be not null#60raneashay wants to merge 1 commit intomicrosoft:mainfrom
raneashay wants to merge 1 commit intomicrosoft:mainfrom
Conversation
This patch augments the C2 bytecode parser's call node emission to skip the null check on return values that are of reference type, if the analysis can prove that returned values are never null. To determine nullability, this patch makes use of the Byte Code Escape Analyzer, which exposes methods to determine whether (1) the return value is freshly allocated (and thus non-null) or (2) the return value is one of the arguments, in which case, the caller's analysis of the arguments can be extended to the callee's return value. Key to this patch is a modification to the Byte Code Escape Analyzer's logic for determining whether method's argument escapes. Prior to this patch, the analysis was too conservative, resulting in constrcutor (`<init>`) methods (which initialize freshy allocated objects) being marked as escaping. This patch updates the logic so that the object being initialized is not marked as escaping. All other arguments to `<init>` are treated identically as before. This patch also adds positive and negative checks on IR nodes in the final ideal graph to exercise changes in this patch.
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.
This patch augments the C2 bytecode parser's call node emission to skip
the null check on return values that are of reference type, if the
analysis can prove that returned values are never null. To determine
nullability, this patch makes use of the Byte Code Escape Analyzer,
which exposes methods to determine whether (1) the return value is
freshly allocated (and thus non-null) or (2) the return value is one of
the arguments, in which case, the caller's analysis of the arguments can
be extended to the callee's return value.
Key to this patch is a modification to the Byte Code Escape Analyzer's
logic for determining whether method's argument escapes. Prior to this
patch, the analysis was too conservative, resulting in constrcutor
(
<init>) methods (which initialize freshy allocated objects) beingmarked as escaping. This patch updates the logic so that the object
being initialized is not marked as escaping. All other arguments to
<init>are treated identically as before.This patch also adds positive and negative checks on IR nodes in the
final ideal graph to exercise changes in this patch.