Skip to content

Commit

Permalink
Merge pull request JuliaLang#33724 from JuliaLang/jn/layout-reorg
Browse files Browse the repository at this point in the history
datatype: reorganize layout calculation code
  • Loading branch information
vtjnash authored Nov 18, 2019
2 parents 05a80e1 + 4e0d353 commit 1e39c69
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 297 deletions.
10 changes: 5 additions & 5 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ datatype_fieldtypes(x::DataType) = ccall(:jl_get_fieldtypes, Any, (Any,), x)

struct DataTypeLayout
nfields::UInt32
npointers::UInt32
alignment::UInt32
# alignment : 28;
# alignment : 9;
# haspadding : 1;
# pointerfree : 1;
# fielddesc_type : 2;
end

Expand Down Expand Up @@ -380,8 +380,8 @@ Can be called on any `isconcretetype`.
function datatype_pointerfree(dt::DataType)
@_pure_meta
dt.layout == C_NULL && throw(UndefRefError())
alignment = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment
return (alignment >> 10) & 0xFFFFF == 0
npointers = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).npointers
return npointers == 0
end

"""
Expand All @@ -397,7 +397,7 @@ function datatype_fielddesc_type(dt::DataType)
@_pure_meta
dt.layout == C_NULL && throw(UndefRefError())
alignment = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment
return (alignment >> 30) & 3
return (alignment >> 10) & 3
end

"""
Expand Down
Loading

0 comments on commit 1e39c69

Please sign in to comment.