round up alignment to ptr_bytes

This commit is contained in:
Folkert 2020-11-19 22:10:02 +01:00
parent fd026ee9d8
commit e30893b66e
2 changed files with 3 additions and 3 deletions

View file

@ -1067,7 +1067,7 @@ pub fn allocate_with_refcount_help<'a, 'ctx, 'env>(
let value_type = basic_type_from_layout(env.arena, ctx, layout, env.ptr_bytes);
let len_type = env.ptr_int();
let extra_bytes = layout.alignment_bytes(env.ptr_bytes);
let extra_bytes = layout.alignment_bytes(env.ptr_bytes).max(env.ptr_bytes);
let ptr = {
// number of bytes we will allocated
@ -1097,7 +1097,7 @@ pub fn allocate_with_refcount_help<'a, 'ctx, 'env>(
let index = match extra_bytes {
n if n == env.ptr_bytes => 1,
n if n == 2 * env.ptr_bytes => 2,
_ => unreachable!("invalid extra_bytes"),
_ => unreachable!("invalid extra_bytes, {}", extra_bytes),
};
let index_intvalue = int_type.const_int(index, false);