Skip to content
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

Improve type stability of array_subpadding slightly #48136

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions base/reinterpretarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,18 @@ end
@assume_effects :total function array_subpadding(S, T)
lcm_size = lcm(sizeof(S), sizeof(T))
s, t = CyclePadding(S), CyclePadding(T)
isempty(t) && return true
isempty(s) && return false
checked_size = 0
ps, sstate = iterate(s) # use of Stateful harms inference and makes this vulnerable to invalidation
pad, tstate = iterate(t)
# use of Stateful harms inference and makes this vulnerable to invalidation
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to use Stateful, but just the normal iterate algorithm?

Suggested change
# use of Stateful harms inference and makes this vulnerable to invalidation

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it was written with Stateful before and got changed to not use it and this is here as a hint for future developers to not put that back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - it was changed some time before 1.9 by Tim Holy in hunt of invalidations. I left the comment.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(pad, tstate) = let
it = iterate(t)
it === nothing && return true
it
end
(ps, sstate) = let
it = iterate(s)
it === nothing && return false
it
end
while checked_size < lcm_size
while true
# See if there's corresponding padding in S
Expand Down