Skip to content

Commit

Permalink
Make jl_datatype_size reflect non-padded field size
Browse files Browse the repository at this point in the history
Padding is then added when creating the struct layout, but otherwise
the memory layout should be unchanged. This is an alternative to
the proposal in #46260. LLVM size and julia size should now be
aligned.
  • Loading branch information
Keno committed Aug 11, 2022
1 parent 61f58be commit 22fa0e4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/datatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static unsigned union_isinlinable(jl_value_t *ty, int pointerfree, size_t *nbyte
size_t sz = jl_datatype_size(ty);
size_t al = jl_datatype_align(ty);
// primitive types in struct slots need their sizes aligned. issue #37974
if (asfield && jl_is_primitivetype(ty))
if (asfield)
sz = LLT_ALIGN(sz, al);
if (*nbytes < sz)
*nbytes = sz;
Expand Down Expand Up @@ -525,9 +525,7 @@ void jl_compute_field_offsets(jl_datatype_t *st)
if (al > alignm)
alignm = al;
}
st->size = LLT_ALIGN(sz, alignm);
if (st->size > sz)
haspadding = 1;
st->size = sz;
if (should_malloc && npointers)
pointers = (uint32_t*)malloc_s(npointers * sizeof(uint32_t));
else
Expand Down Expand Up @@ -1470,6 +1468,7 @@ static inline void memassign_safe(int hasptr, jl_value_t *parent, char *dst, con
memmove_refs((void**)dst, (void**)src, nptr);
jl_gc_multi_wb(parent, src);
src = (jl_value_t*)((char*)src + nptr * sizeof(void*));
dst += nptr * sizeof(void*);
nb -= nptr * sizeof(void*);
}
else {
Expand Down

0 comments on commit 22fa0e4

Please sign in to comment.