mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
adjust alignment, size of tag variant id and make it easy to
adjust in the future
This commit is contained in:
parent
cb9675259f
commit
5aaafa704f
@ -223,7 +223,7 @@ size_of::compute_tag_size(tag_info &tinfo) {
|
||||
tinfo.tag_sa.set(1, 1);
|
||||
} else {
|
||||
// Add in space for the tag.
|
||||
tinfo.tag_sa.add(sizeof(uint32_t), alignof<uint32_t>());
|
||||
tinfo.tag_sa.add(sizeof(tag_variant_t), alignof<tag_align_t>());
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,12 +357,12 @@ public:
|
||||
void walk_fn() { return cmp_two_pointers(); }
|
||||
void walk_obj() { return cmp_two_pointers(); }
|
||||
|
||||
void walk_tag(tag_info &tinfo, const data_pair<uint32_t> &tag_variants);
|
||||
void walk_tag(tag_info &tinfo, const data_pair<tag_variant_t> &tag_variants);
|
||||
void walk_struct(const uint8_t *end_sp);
|
||||
void walk_res(const rust_fn *dtor, uint16_t n_ty_params,
|
||||
const type_param *ty_params_sp, const uint8_t *end_sp,
|
||||
const data_pair<uintptr_t> &live);
|
||||
void walk_variant(tag_info &tinfo, uint32_t variant_id,
|
||||
void walk_variant(tag_info &tinfo, tag_variant_t variant_id,
|
||||
const std::pair<const uint8_t *,const uint8_t *>
|
||||
variant_ptr_and_end);
|
||||
|
||||
@ -394,7 +394,7 @@ cmp::walk_vec(bool is_pod, const std::pair<ptr_pair,ptr_pair> &data_range) {
|
||||
}
|
||||
|
||||
void
|
||||
cmp::walk_tag(tag_info &tinfo, const data_pair<uint32_t> &tag_variants) {
|
||||
cmp::walk_tag(tag_info &tinfo, const data_pair<tag_variant_t> &tag_variants) {
|
||||
cmp_number(tag_variants);
|
||||
if (result != 0)
|
||||
return;
|
||||
@ -417,7 +417,7 @@ cmp::walk_res(const rust_fn *dtor, uint16_t n_ty_params,
|
||||
}
|
||||
|
||||
void
|
||||
cmp::walk_variant(tag_info &tinfo, uint32_t variant_id,
|
||||
cmp::walk_variant(tag_info &tinfo, tag_variant_t variant_id,
|
||||
const std::pair<const uint8_t *,const uint8_t *>
|
||||
variant_ptr_and_end) {
|
||||
cmp sub(*this, variant_ptr_and_end.first, tinfo.params);
|
||||
@ -489,7 +489,7 @@ log::walk_vec(bool is_pod, const std::pair<ptr,ptr> &data) {
|
||||
}
|
||||
|
||||
void
|
||||
log::walk_variant(tag_info &tinfo, uint32_t variant_id,
|
||||
log::walk_variant(tag_info &tinfo, tag_variant_t variant_id,
|
||||
const std::pair<const uint8_t *,const uint8_t *>
|
||||
variant_ptr_and_end) {
|
||||
log sub(*this, variant_ptr_and_end.first, tinfo.params);
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
namespace shape {
|
||||
|
||||
typedef unsigned long tag_variant_t;
|
||||
typedef unsigned long tag_align_t;
|
||||
|
||||
// Constants
|
||||
|
||||
@ -234,7 +236,7 @@ public:
|
||||
void walk_reset();
|
||||
|
||||
std::pair<const uint8_t *,const uint8_t *>
|
||||
get_variant_sp(tag_info &info, uint32_t variant_id);
|
||||
get_variant_sp(tag_info &info, tag_variant_t variant_id);
|
||||
|
||||
protected:
|
||||
inline uint8_t peek() { return *sp; }
|
||||
@ -406,7 +408,7 @@ ctxt<T>::get_size_align(const uint8_t *&addr) {
|
||||
// the tag variant with the given ID.
|
||||
template<typename T>
|
||||
std::pair<const uint8_t *,const uint8_t *>
|
||||
ctxt<T>::get_variant_sp(tag_info &tinfo, uint32_t variant_id) {
|
||||
ctxt<T>::get_variant_sp(tag_info &tinfo, tag_variant_t variant_id) {
|
||||
uint16_t variant_offset = get_u16(tinfo.info_ptr +
|
||||
variant_id * sizeof(uint16_t));
|
||||
const uint8_t *variant_ptr = tables->tags + variant_offset;
|
||||
@ -816,7 +818,7 @@ protected:
|
||||
void walk_uniq_contents();
|
||||
void walk_fn_contents(ptr &dp);
|
||||
void walk_obj_contents(ptr &dp);
|
||||
void walk_variant(tag_info &tinfo, uint32_t variant);
|
||||
void walk_variant(tag_info &tinfo, tag_variant_t variant);
|
||||
|
||||
static std::pair<uint8_t *,uint8_t *> get_vec_data_range(ptr dp);
|
||||
static std::pair<ptr_pair,ptr_pair> get_vec_data_range(ptr_pair &dp);
|
||||
@ -901,7 +903,7 @@ data<T,U>::walk_uniq_contents() {
|
||||
|
||||
template<typename T,typename U>
|
||||
void
|
||||
data<T,U>::walk_variant(tag_info &tinfo, uint32_t variant_id) {
|
||||
data<T,U>::walk_variant(tag_info &tinfo, tag_variant_t variant_id) {
|
||||
std::pair<const uint8_t *,const uint8_t *> variant_ptr_and_end =
|
||||
this->get_variant_sp(tinfo, variant_id);
|
||||
static_cast<T *>(this)->walk_variant(tinfo, variant_id,
|
||||
@ -932,13 +934,13 @@ data<T,U>::walk_tag(tag_info &tinfo) {
|
||||
size_of::compute_tag_size(*this, tinfo);
|
||||
|
||||
if (tinfo.variant_count > 1)
|
||||
ALIGN_TO(alignof<uint32_t>());
|
||||
ALIGN_TO(alignof<tag_align_t>());
|
||||
|
||||
U end_dp = dp + tinfo.tag_sa.size;
|
||||
|
||||
typename U::template data<uint32_t>::t tag_variant;
|
||||
typename U::template data<tag_variant_t>::t tag_variant;
|
||||
if (tinfo.variant_count > 1)
|
||||
tag_variant = bump_dp<uint32_t>(dp);
|
||||
tag_variant = bump_dp<tag_variant_t>(dp);
|
||||
else
|
||||
tag_variant = 0;
|
||||
|
||||
@ -1047,7 +1049,7 @@ private:
|
||||
walk_vec(is_pod, get_vec_data_range(dp));
|
||||
}
|
||||
|
||||
void walk_tag(tag_info &tinfo, uint32_t tag_variant) {
|
||||
void walk_tag(tag_info &tinfo, tag_variant_t tag_variant) {
|
||||
out << prefix << "tag" << tag_variant;
|
||||
data<log,ptr>::walk_variant(tinfo, tag_variant);
|
||||
}
|
||||
@ -1096,7 +1098,7 @@ private:
|
||||
|
||||
void walk_struct(const uint8_t *end_sp);
|
||||
void walk_vec(bool is_pod, const std::pair<ptr,ptr> &data);
|
||||
void walk_variant(tag_info &tinfo, uint32_t variant_id,
|
||||
void walk_variant(tag_info &tinfo, tag_variant_t variant_id,
|
||||
const std::pair<const uint8_t *,const uint8_t *>
|
||||
variant_ptr_and_end);
|
||||
void walk_string(const std::pair<ptr,ptr> &data);
|
||||
|
Loading…
Reference in New Issue
Block a user