-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
inference: add error/throwness checks for setfield!
#43603
Conversation
Seems sensible to me, but I am not intimately familiar with this part of inference |
e06a1ee
to
ee72a2b
Compare
if s <: Tuple && fld >= nf && isvarargtype(ftypes[nf]) | ||
return rewrap_unionall(unwrapva(ftypes[nf]), s00) | ||
end | ||
if fld < 1 || fld > nf | ||
return Bottom | ||
elseif setfield && isconst(s, fld) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added a support for new const
declaration for mutable struct field.
setfield!_tfunc(o, f, v) = (@nospecialize; v) | ||
function setfield!_tfunc(o, f, v, order) | ||
@nospecialize | ||
if !isvarargtype(order) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we only ever call tfuncs with real types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately argtypes[end]
can sometimes be varargtype:
Line 1682 in ee72a2b
push!(argtypes, unconstrain_vararg_length(vatype)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to try to make sure that most tfuncs deal with real types?
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
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.
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.
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:Module
objectobject 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.