Skip to content

Commit 93a88ab

Browse files
committed
---
yaml --- r: 5071 b: refs/heads/master c: dfcbfa6 h: refs/heads/master i: 5069: 23c9f9c 5067: 56856ad 5063: c779c37 5055: 749fb47 v: v3
1 parent 5e65ad1 commit 93a88ab

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 143569fce4e9c394496e8bac357511229255ed6a
2+
refs/heads/master: dfcbfa61f3cbc331f4ab0ecf7fdd71b5faea773a

trunk/src/rt/rust_shape.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class cmp : public data<cmp,ptr_pair> {
280280
}
281281

282282
inline void cmp_two_pointers() {
283-
if (align) dp = align_to(dp, alignof<uint8_t *>() * 2);
283+
ALIGN_TO(alignof<void *>() * 2);
284284
data_pair<uint8_t *> fst = bump_dp<uint8_t *>(dp);
285285
data_pair<uint8_t *> snd = bump_dp<uint8_t *>(dp);
286286
cmp_number(fst);
@@ -289,7 +289,7 @@ class cmp : public data<cmp,ptr_pair> {
289289
}
290290

291291
inline void cmp_pointer() {
292-
if (align) dp = align_to(dp, alignof<uint8_t *>());
292+
ALIGN_TO(alignof<void *>());
293293
cmp_number(bump_dp<uint8_t *>(dp));
294294
}
295295

@@ -369,7 +369,7 @@ void cmp::cmp_number<int32_t>(const data_pair<int32_t> &nums) {
369369
void
370370
cmp::walk_vec(bool is_pod, const std::pair<ptr_pair,ptr_pair> &data_range) {
371371
cmp sub(*this, data_range.first);
372-
ptr_pair data_end = data_range.second;
372+
ptr_pair data_end = sub.end_dp = data_range.second;
373373
while (!result && sub.dp < data_end) {
374374
sub.walk_reset();
375375
result = sub.result;
@@ -467,6 +467,7 @@ log::walk_vec(bool is_pod, const std::pair<ptr,ptr> &data) {
467467
out << "[";
468468

469469
log sub(*this, data.first);
470+
sub.end_dp = data.second;
470471

471472
bool first = true;
472473
while (sub.dp < data.second) {

trunk/src/rt/rust_shape.h

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,9 @@ class ptr {
622622
template<typename T>
623623
struct data { typedef T t; };
624624

625-
ptr(uint8_t *in_p)
626-
: p(in_p) {}
627-
628-
ptr(uintptr_t in_p)
629-
: p((uint8_t *)in_p) {}
625+
ptr() : p(NULL) {}
626+
ptr(uint8_t *in_p) : p(in_p) {}
627+
ptr(uintptr_t in_p) : p((uint8_t *)in_p) {}
630628

631629
inline ptr operator+(const size_t amount) const {
632630
return make(p + amount);
@@ -639,7 +637,8 @@ class ptr {
639637
template<typename T>
640638
inline operator T *() { return (T *)p; }
641639

642-
inline operator uintptr_t() { return (uintptr_t)p; }
640+
inline operator bool() const { return p != NULL; }
641+
inline operator uintptr_t() const { return (uintptr_t)p; }
643642

644643
static inline ptr make(uint8_t *in_p) {
645644
ptr self(in_p);
@@ -687,12 +686,14 @@ class ptr_pair {
687686
template<typename T>
688687
struct data { typedef data_pair<T> t; };
689688

689+
ptr_pair() : fst(NULL), snd(NULL) {}
690690
ptr_pair(uint8_t *in_fst, uint8_t *in_snd) : fst(in_fst), snd(in_snd) {}
691-
692691
ptr_pair(data_pair<uint8_t *> &other) : fst(other.fst), snd(other.snd) {}
693692

694693
inline void operator=(uint8_t *rhs) { fst = snd = rhs; }
695694

695+
inline operator bool() const { return fst != NULL && snd != NULL; }
696+
696697
inline ptr_pair operator+(size_t n) const {
697698
return make(fst + n, snd + n);
698699
}
@@ -754,15 +755,27 @@ namespace shape {
754755
// An abstract class (again using the curiously recurring template pattern)
755756
// for methods that actually manipulate the data involved.
756757

758+
#define ALIGN_TO(alignment) \
759+
if (this->align) { \
760+
dp = align_to(dp, (alignment)); \
761+
if (this->end_dp && !(dp < this->end_dp)) \
762+
return; \
763+
}
764+
757765
#define DATA_SIMPLE(ty, call) \
758-
if (this->align) dp = align_to(dp, alignof<ty>()); \
766+
ALIGN_TO(alignof<ty>()); \
759767
U end_dp = dp + sizeof(ty); \
760768
static_cast<T *>(this)->call; \
761769
dp = end_dp;
762770

763771
template<typename T,typename U>
764772
class data : public ctxt< data<T,U> > {
773+
public:
774+
U dp;
775+
765776
protected:
777+
U end_dp;
778+
766779
void walk_box_contents();
767780
void walk_fn_contents(ptr &dp);
768781
void walk_obj_contents(ptr &dp);
@@ -774,16 +787,15 @@ class data : public ctxt< data<T,U> > {
774787
static std::pair<ptr_pair,ptr_pair> get_vec_data_range(ptr_pair &dp);
775788

776789
public:
777-
U dp;
778-
779790
data(rust_task *in_task,
780791
bool in_align,
781792
const uint8_t *in_sp,
782793
const type_param *in_params,
783794
const rust_shape_tables *in_tables,
784795
U const &in_dp)
785796
: ctxt< data<T,U> >(in_task, in_align, in_sp, in_params, in_tables),
786-
dp(in_dp) {}
797+
dp(in_dp),
798+
end_dp() {}
787799

788800
void walk_tag(tag_info &tinfo);
789801

@@ -801,14 +813,14 @@ class data : public ctxt< data<T,U> > {
801813
void walk_box() { DATA_SIMPLE(void *, walk_box()); }
802814

803815
void walk_fn() {
804-
if (this->align) dp = align_to(dp, sizeof(void *));
816+
ALIGN_TO(alignof<void *>());
805817
U next_dp = dp + sizeof(void *) * 2;
806818
static_cast<T *>(this)->walk_fn();
807819
dp = next_dp;
808820
}
809821

810822
void walk_obj() {
811-
if (this->align) dp = align_to(dp, sizeof(void *));
823+
ALIGN_TO(alignof<void *>());
812824
U next_dp = dp + sizeof(void *) * 2;
813825
static_cast<T *>(this)->walk_obj();
814826
dp = next_dp;
@@ -893,8 +905,8 @@ void
893905
data<T,U>::walk_tag(tag_info &tinfo) {
894906
size_of::compute_tag_size(*this, tinfo);
895907

896-
if (tinfo.variant_count > 1 && this->align)
897-
dp = align_to(dp, alignof<uint32_t>());
908+
if (tinfo.variant_count > 1)
909+
ALIGN_TO(alignof<uint32_t>());
898910

899911
U end_dp = dp + tinfo.tag_sa.size;
900912

@@ -1029,7 +1041,7 @@ class log : public data<log,ptr> {
10291041
void walk_subcontext(log &sub) { sub.walk(); }
10301042

10311043
void walk_box_contents(log &sub, ptr &ref_count_dp) {
1032-
if (ref_count_dp == 0) {
1044+
if (!ref_count_dp) {
10331045
out << "(null)";
10341046
} else {
10351047
sub.align = true;

0 commit comments

Comments
 (0)