inference: add error/throwness checks for setfield!#43603
Merged
Conversation
Member
|
Seems sensible to me, but I am not intimately familiar with this part of inference |
e06a1ee to
ee72a2b
Compare
aviatesk
commented
Jan 4, 2022
| end | ||
| if fld < 1 || fld > nf | ||
| return Bottom | ||
| elseif setfield && isconst(s, fld) |
Member
Author
There was a problem hiding this comment.
Also added a support for new const declaration for mutable struct field.
vtjnash
reviewed
Jan 7, 2022
| setfield!_tfunc(o, f, v) = (@nospecialize; v) | ||
| function setfield!_tfunc(o, f, v, order) | ||
| @nospecialize | ||
| if !isvarargtype(order) |
Member
There was a problem hiding this comment.
I thought we only ever call tfuncs with real types
Member
Author
There was a problem hiding this comment.
Unfortunately argtypes[end] can sometimes be varargtype:
Line 1682 in ee72a2b
Member
Author
There was a problem hiding this comment.
Maybe we want to try to make sure that most tfuncs deal with real types?
vtjnash
reviewed
Jan 7, 2022
vtjnash
approved these changes
Jan 7, 2022
98bd221 to
e814d9c
Compare
In a similar spirit to #43587, this commit introduces error check for `setfield!`. We can bail out from inference if we can prove either of: - the object is not mutable type - the object is `Module` object - the value being assigned is incompatible with the declared type of object field This commit also adds the throwness check for `setfield!` (i.e. `setfield!_nothrow`). This throwness check won't be used in the current native compilation pipeline since `setfield!` call can't be eliminated even if we can prove that it never throws. But this throwness check would be used by EscapeAnalysis.jl integration and so I'd like to include it in Base.
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
e814d9c to
f7a1767
Compare
aviatesk
added a commit
to aviatesk/EscapeAnalysis.jl
that referenced
this pull request
Jan 8, 2022
aviatesk
added a commit
that referenced
this pull request
Jan 8, 2022
aviatesk
added a commit
that referenced
this pull request
Jan 9, 2022
LilithHafner
pushed a commit
to LilithHafner/julia
that referenced
this pull request
Feb 22, 2022
In a similar spirit to JuliaLang#43587, this commit introduces error check for `setfield!`. We can bail out from inference if we can prove either of: - the object is not mutable type - the object is `Module` object - the value being assigned is incompatible with the declared type of object field This commit also adds the throwness check for `setfield!` (i.e. `setfield!_nothrow`). This throwness check won't be used in the current native compilation pipeline since `setfield!` call can't be eliminated even if we can prove that it never throws. But this throwness check would be used by EscapeAnalysis.jl integration and so I'd like to include it in Base.
LilithHafner
pushed a commit
to LilithHafner/julia
that referenced
this pull request
Feb 22, 2022
LilithHafner
pushed a commit
to LilithHafner/julia
that referenced
this pull request
Mar 8, 2022
In a similar spirit to JuliaLang#43587, this commit introduces error check for `setfield!`. We can bail out from inference if we can prove either of: - the object is not mutable type - the object is `Module` object - the value being assigned is incompatible with the declared type of object field This commit also adds the throwness check for `setfield!` (i.e. `setfield!_nothrow`). This throwness check won't be used in the current native compilation pipeline since `setfield!` call can't be eliminated even if we can prove that it never throws. But this throwness check would be used by EscapeAnalysis.jl integration and so I'd like to include it in Base.
LilithHafner
pushed a commit
to LilithHafner/julia
that referenced
this pull request
Mar 8, 2022
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.
In a similar spirit to #43587, this commit introduces error check for
setfield!. We can bail out from inference if we can prove either of:Moduleobjectobject field
This commit also adds throwness check implementation for
setfield!(i.e.setfield!_nothrow).This throwness check won't be used in the current native compilation
pipeline since
setfield!call can't be eliminated anyway even if we can provethat it never throws. But this throwness check would be used by
EscapeAnalysis.jl integration and so I'd like to include it in Base.