fix(kernel): manually align unboxed fields

This commit is contained in:
Sebastian Ullrich 2019-07-26 20:42:24 +02:00 committed by Leonardo de Moura
parent 8fb004f917
commit d45cc4cb7b
3 changed files with 11 additions and 11 deletions

View file

@ -136,18 +136,18 @@ inline constexpr unsigned reflected_offset(expr_kind k) {
inline constexpr unsigned hash_offset(expr_kind k) {
return
k == expr_kind::FVar ? scalar_offset(k) + sizeof(unsigned char) : // for binder_info, TODO(Leo): delete after we remove support for legacy code
k == expr_kind::Lambda ? scalar_offset(k) + sizeof(unsigned char) : // for binder_info
k == expr_kind::Pi ? scalar_offset(k) + sizeof(unsigned char) : // for binder_info
k == expr_kind::FVar ? scalar_offset(k) + sizeof(unsigned) : // for binder_info, TODO(Leo): delete after we remove support for legacy code
k == expr_kind::Lambda ? scalar_offset(k) + sizeof(unsigned) : // for binder_info
k == expr_kind::Pi ? scalar_offset(k) + sizeof(unsigned) : // for binder_info
scalar_offset(k);
}
inline constexpr size_t flags_offset(expr_kind k) { return hash_offset(k) + sizeof(unsigned); }
inline constexpr size_t weight_offset(expr_kind k) { return flags_offset(k) + sizeof(unsigned char); }
inline constexpr size_t weight_offset(expr_kind k) { return flags_offset(k) + sizeof(unsigned); }
inline constexpr size_t depth_offset(expr_kind k) { return weight_offset(k) + sizeof(unsigned); }
inline constexpr size_t loose_bvar_range_offset(expr_kind k) { return depth_offset(k) + sizeof(unsigned); }
/* Size for scalar value area for non recursive expression. */
inline constexpr size_t expr_scalar_size(expr_kind k) { return flags_offset(k) + sizeof(unsigned char); }
inline constexpr size_t expr_scalar_size(expr_kind k) { return flags_offset(k) + sizeof(unsigned); }
/* Size for scalar value area for recursive expression. */
inline constexpr size_t rec_expr_scalar_size(expr_kind k) { return loose_bvar_range_offset(k) + sizeof(unsigned); }

View file

@ -25,14 +25,14 @@ local_decl::local_decl():object_ref(*g_dummy_decl) {}
local_decl::local_decl(unsigned idx, name const & n, name const & un, expr const & t, expr const & v):
object_ref(mk_cnstr(0, n, un, t, v, sizeof(unsigned) + sizeof(unsigned char))) {
cnstr_set_scalar<unsigned char>(raw(), sizeof(object*)*4, 0);
cnstr_set_scalar<unsigned>(raw(), sizeof(object*)*4+sizeof(unsigned char), idx);
cnstr_set_scalar<unsigned>(raw(), sizeof(object*)*4, idx);
cnstr_set_scalar<unsigned char>(raw(), sizeof(object*)*4+sizeof(unsigned), 0);
}
local_decl::local_decl(unsigned idx, name const & n, name const & un, expr const & t, binder_info bi):
object_ref(mk_cnstr(0, n, un, t, object_ref(box(0)), sizeof(unsigned) + sizeof(unsigned char))) {
cnstr_set_scalar<unsigned char>(raw(), sizeof(object*)*4, static_cast<unsigned char>(bi));
cnstr_set_scalar<unsigned>(raw(), sizeof(object*)*4+sizeof(unsigned char), idx);
cnstr_set_scalar<unsigned>(raw(), sizeof(object*)*4, idx);
cnstr_set_scalar<unsigned char>(raw(), sizeof(object*)*4+sizeof(unsigned), static_cast<unsigned char>(bi));
}
local_decl::local_decl(local_decl const & d, expr const & t, expr const & v):

View file

@ -34,8 +34,8 @@ public:
if (is_scalar(cnstr_get(raw(), 3))) return none_expr();
else return some_expr(static_cast<expr const &>(cnstr_get_ref(raw(), 3)));
}
binder_info get_info() const { return static_cast<binder_info>(cnstr_get_scalar<unsigned char>(raw(), sizeof(object*)*4)); }
unsigned get_idx() const { return cnstr_get_scalar<unsigned>(raw(), sizeof(object*)*4+sizeof(unsigned char)); }
unsigned get_idx() const { return cnstr_get_scalar<unsigned>(raw(), sizeof(object*)*4); }
binder_info get_info() const { return static_cast<binder_info>(cnstr_get_scalar<unsigned char>(raw(), sizeof(object*)*4+sizeof(unsigned))); }
expr mk_ref() const;
};