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

Update iterate unwrap #2238

Merged
merged 5 commits into from
Dec 31, 2024
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
42 changes: 23 additions & 19 deletions src/rules/jitrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -817,31 +817,35 @@ function push_if_not_ref(
return darg
end

struct PushInnerStruct{reverse, Vals}
vals::Vals
end

@inline function (v::PushInnerStruct{reverse})(@nospecialize(arg), @nospecialize(darg)) where reverse
ty = Core.Typeof(arg)
actreg = active_reg_nothrow(ty, Val(nothing))
if actreg == AnyState
Const(arg)
elseif actreg == ActiveState
Active(arg)
elseif actreg == MixedState
darg = Base.inferencebarrier(darg)
MixedDuplicated(
arg,
push_if_not_ref(Val(reverse), v.vals, darg, ty)::Base.RefValue{ty},
)
else
Duplicated(arg, darg)
end
end

@inline function iterate_unwrap_augfwd_dup(
::Val{reverse},
vals,
args,
dargs,
) where {reverse}
ntuple(Val(length(args))) do i
Base.@_inline_meta
arg = args[i]
ty = Core.Typeof(arg)
actreg = active_reg_nothrow(ty, Val(nothing))
if actreg == AnyState
Const(arg)
elseif actreg == ActiveState
Active(arg)
elseif actreg == MixedState
darg = Base.inferencebarrier(dargs[i])
MixedDuplicated(
arg,
push_if_not_ref(Val(reverse), vals, darg, ty)::Base.RefValue{ty},
)
else
Duplicated(arg, dargs[i])
end
end
map(PushInnerStruct{reverse, typeof(vals)}(vals), args, dargs)
end

@inline function iterate_unwrap_augfwd_batchdup(
Expand Down
Loading