-
-
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
call convert in Base.setfield! #16226
Conversation
this looks correct to me, although I think we also need to delete the corresponding lowering code that was inserting calls to convert. I also think we just need to check that it won't cause any performance regressions since now setfield is not handled by a special tfunc. |
I think this will definitely be a problem, since the index argument to |
Don't we just have to make sure it uses |
Yes I think lowering will need to be changed to call |
@JeffBezanson, when I replace |
Good news --- in the interim I've added a |
Is there a way restart Travis, or do I need a forced push? |
Log in to travis with github auth then you can restart. Travis overwrites logs on restarts, so please save failure logs to a gist before restarting. Note that this succeeded 3 weeks ago, but I restarted it this morning to see if the merge commit into latest master would still pass. It didn't, so if you rebase this branch I suspect you'll see the same failure locally. Probably a newly added test that this would break. |
b1ff106
to
83b09e2
Compare
@@ -2238,7 +2238,7 @@ f9534d(x) = (a=(1,2,4,6,7); a[x]) | |||
@test try; f9534d() catch ex; (ex::BoundsError).a === (1,2,4,6,7) && ex.i == 7; end | |||
@test try; f9534d(-1) catch ex; (ex::BoundsError).a === (1,2,4,6,7) && ex.i == -1; end | |||
f9534e(x) = (a=IOBuffer(); setfield!(a, x, 3)) | |||
@test try; f9534e(-2) catch ex; isa((ex::BoundsError).a,Base.IOBuffer) && ex.i == -2; end | |||
@test try; f9534e(-2) catch ex; (ex::BoundsError).a == Base.IOBuffer && ex.i == -2; end |
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'm not sure why I had to make this change to get the test to pass. @JeffBezanson, has the behavior of Core.setfield!
changed to store the type rather than the value in the a
field?
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.
No this should not have changed.
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 think this means inlining may have changed? I'm not certain that jl_f_getfield
and the codegen optimization for that getfield actually throw the same error.
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.
This is probably #16517 Actually probably not... that one is only applicable when the one following the catch is a literal.
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 think the issue is that Core.setfield!(x, i, convert(fieldtype(T, i), v))
is throwing a BoundsError from fieldtype
, not from Core.setfield!
.
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'm not sure if there is a clean way to fix this.
If we had an isfield(T, i)
intrinsic, I could check it explicitly and then throw an error, but we don't have such an intrinsic. I can replace fieldtype(T, i)
with try; fieldtype(T, i); catch; Any; end
— that works, but is mildly horrifying.
Suggestions?
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.
We could just call Core.setfield!
in the test
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.
We could, but do we care what kind of BoundsError
data is thrown by Base.setfield!
?
needs another rebase? |
Bump - as the underlying issue (#16195) here is related to a 0.5 deprecation, should this be added to the 0.5.x milestone? |
83b09e2
to
73808cf
Compare
Rebased. |
this may have to queue for a bit @nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
I'm skeptical that the performance regression here is real; |
The sort functions seem to generally be a bit noisy so nothing to worry about. |
The BoundsError change sounds like a bug and should be fixed before merging. |
I don't recall if we are or not, but we should be using a fixed random sequence since the randomization has a large impact on sort performance. Obviously, it evens out in the long term, but it's unnecessary noise that we're adding only to have to try to remove it with more runs. |
Pretty sure everything in BaseBenchmarks fixes the seed for all "random" data. |
This is the case. |
New functions `Base.getproperty` and `Base.setproperty!` can be overloaded to change the behavior of `x.p` and `x.p = v`, respectively. This forces inference constant propagation through get/setproperty, since it is very likely this method will yield better information after specializing on the field name (even if `convert` is too big to make us want to inline the generic version and trigger the heuristic normally). closes #16195 (and thus also closes #16226) fix #1974
New functions `Base.getproperty` and `Base.setproperty!` can be overloaded to change the behavior of `x.p` and `x.p = v`, respectively. This forces inference constant propagation through get/setproperty, since it is very likely this method will yield better information after specializing on the field name (even if `convert` is too big to make us want to inline the generic version and trigger the heuristic normally). closes #16195 (and thus also closes #16226) fix #1974
Fixes #16195, following the suggestion of @vtjnash.