Skip to content
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
13 changes: 8 additions & 5 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,18 @@ LLT_ALIGN(x, sz) = (x + sz - 1) & -sz
# amount of total space taken by T when stored in a container
function aligned_sizeof(@nospecialize T::Type)
@_foldable_meta
if isbitsunion(T)
_, sz, al = uniontype_layout(T)
return LLT_ALIGN(sz, al)
if isa(T, Union)
if allocatedinline(T)
# NOTE this check is equivalent to `isbitsunion(T)`, we can improve type
# inference in the second branch with the outer `isa(T, Union)` check
_, sz, al = uniontype_layout(T)
return LLT_ALIGN(sz, al)
end
elseif allocatedinline(T)
al = datatype_alignment(T)
return LLT_ALIGN(Core.sizeof(T), al)
else
return Core.sizeof(Ptr{Cvoid})
end
return Core.sizeof(Ptr{Cvoid})
end

gc_alignment(sz::Integer) = Int(ccall(:jl_alignment, Cint, (Csize_t,), sz))
Expand Down