Skip to content

Commit 6e5c8a7

Browse files
committed
More shape fixes for evecs.
1 parent 11a5d10 commit 6e5c8a7

File tree

7 files changed

+103
-27
lines changed

7 files changed

+103
-27
lines changed

src/rt/rust_box_annihilator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class annihilator : public shape::data<annihilator,shape::ptr> {
4949
task->kernel->free(vec);
5050
}
5151

52-
void walk_fixedvec2(uint16_t sz, bool is_pod) {
53-
walk_vec2(is_pod, get_fixedvec_data_range(sz, dp));
52+
void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) {
53+
walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp));
5454
}
5555

5656
void walk_vec2(bool is_pod,

src/rt/rust_cc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class irc : public shape::data<irc,shape::ptr> {
100100
walk_vec2(is_pod, get_slice_data_range(is_str, dp));
101101
}
102102

103-
void walk_fixedvec2(uint16_t sz, bool is_pod) {
104-
walk_vec2(is_pod, get_fixedvec_data_range(sz, dp));
103+
void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) {
104+
walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp));
105105
}
106106

107107
void walk_tag2(shape::tag_info &tinfo, uint32_t tag_variant) {
@@ -356,8 +356,8 @@ class mark : public shape::data<mark,shape::ptr> {
356356
walk_vec2(is_pod, get_slice_data_range(is_str, dp));
357357
}
358358

359-
void walk_fixedvec2(uint16_t sz, bool is_pod) {
360-
walk_vec2(is_pod, get_fixedvec_data_range(sz, dp));
359+
void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) {
360+
walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp));
361361
}
362362

363363
void walk_tag2(shape::tag_info &tinfo, uint32_t tag_variant) {

src/rt/rust_shape.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ class cmp : public data<cmp,ptr_pair> {
355355
walk_vec2(is_pod, get_slice_data_range(is_str, dp));
356356
}
357357

358-
void walk_fixedvec2(uint16_t sz, bool is_pod) {
358+
void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) {
359359
// Fixedvecs compare just like vecs.
360-
walk_vec2(is_pod, get_fixedvec_data_range(sz, dp));
360+
walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp));
361361
}
362362

363363
void walk_box2() {

src/rt/rust_shape.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@ ctxt<T>::walk_rptr0() {
524524
template<typename T>
525525
void
526526
ctxt<T>::walk_fixedvec0() {
527-
uint16_t vec_size = get_u16_bump(sp);
527+
uint16_t n_elts = get_u16_bump(sp);
528528
bool is_pod = *sp++;
529529
uint16_t sp_size = get_u16_bump(sp);
530530
const uint8_t *end_sp = sp + sp_size;
531531

532-
static_cast<T *>(this)->walk_fixedvec1(vec_size, is_pod);
532+
static_cast<T *>(this)->walk_fixedvec1(n_elts, is_pod);
533533

534534
sp = end_sp;
535535
}
@@ -629,8 +629,8 @@ class print : public ctxt<print> {
629629
void walk_rptr1() {
630630
DPRINT("&<"); walk(); DPRINT(">");
631631
}
632-
void walk_fixedvec1(uint16_t sz, bool is_pod) {
633-
DPRINT("fixedvec<%u, ", sz); walk(); DPRINT(">");
632+
void walk_fixedvec1(uint16_t n_elts, bool is_pod) {
633+
DPRINT("fixedvec<%u, ", n_elts); walk(); DPRINT(">");
634634
}
635635
void walk_slice1(bool is_pod, bool is_str) {
636636
DPRINT("slice<"); walk(); DPRINT(">");
@@ -721,10 +721,10 @@ class size_of : public ctxt<size_of> {
721721
abort(); // TODO
722722
}
723723

724-
void walk_fixedvec1(uint16_t sz, bool is_pod) {
724+
void walk_fixedvec1(uint16_t n_elts, bool is_pod) {
725725
size_of sub(*this);
726726
sub.walk();
727-
sa.set(sub.sa.size * sz, sub.sa.alignment);
727+
sa.set(sub.sa.size * n_elts, sub.sa.alignment);
728728
}
729729

730730
template<typename T>
@@ -959,9 +959,9 @@ class data : public ctxt< data<T,U> > {
959959
ptr_pair &dp);
960960

961961
static std::pair<uint8_t *,uint8_t *>
962-
get_fixedvec_data_range(uint16_t sz, ptr dp);
962+
get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, ptr dp);
963963
static std::pair<ptr_pair,ptr_pair>
964-
get_fixedvec_data_range(uint16_t sz, ptr_pair &dp);
964+
get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, ptr_pair &dp);
965965

966966
public:
967967
data(rust_task *in_task,
@@ -989,10 +989,10 @@ class data : public ctxt< data<T,U> > {
989989
DATA_SIMPLE(void *, walk_slice2(is_pod, is_str));
990990
}
991991

992-
void walk_fixedvec1(uint16_t sz, bool is_pod) {
992+
void walk_fixedvec1(uint16_t n_elts, bool is_pod) {
993993
size_align sa = size_of::get(*this);
994994
ALIGN_TO(sa.alignment);
995-
static_cast<T *>(this)->walk_fixedvec2(sz, is_pod);
995+
static_cast<T *>(this)->walk_fixedvec2(n_elts, sa.size, is_pod);
996996
}
997997

998998
void walk_box1() { DATA_SIMPLE(void *, walk_box2()); }
@@ -1132,16 +1132,19 @@ data<T,U>::get_slice_data_range(bool is_str, ptr_pair &dp) {
11321132

11331133
template<typename T,typename U>
11341134
std::pair<uint8_t *,uint8_t *>
1135-
data<T,U>::get_fixedvec_data_range(uint16_t sz, ptr dp) {
1135+
data<T,U>::get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, ptr dp) {
11361136
uint8_t* ptr = (uint8_t*)(dp);
1137-
return std::make_pair(ptr, ptr + sz);
1137+
return std::make_pair(ptr, ptr + (((size_t)n_elts) * elt_sz));
11381138
}
11391139

11401140
template<typename T,typename U>
11411141
std::pair<ptr_pair,ptr_pair>
1142-
data<T,U>::get_fixedvec_data_range(uint16_t sz, ptr_pair &dp) {
1143-
std::pair<uint8_t *,uint8_t *> fst = get_fixedvec_data_range(sz, dp.fst);
1144-
std::pair<uint8_t *,uint8_t *> snd = get_fixedvec_data_range(sz, dp.snd);
1142+
data<T,U>::get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz,
1143+
ptr_pair &dp) {
1144+
std::pair<uint8_t *,uint8_t *> fst =
1145+
get_fixedvec_data_range(n_elts, elt_sz, dp.fst);
1146+
std::pair<uint8_t *,uint8_t *> snd =
1147+
get_fixedvec_data_range(n_elts, elt_sz, dp.snd);
11451148
ptr_pair start(fst.first, snd.first);
11461149
ptr_pair end(fst.second, snd.second);
11471150
return std::make_pair(start, end);
@@ -1248,13 +1251,13 @@ class log : public data<log,ptr> {
12481251
}
12491252

12501253
void walk_slice2(bool is_pod, bool is_str) {
1251-
walk_vec2(is_pod, get_slice_data_range(dp, is_str));
1254+
walk_vec2(is_pod, get_slice_data_range(is_str, dp));
12521255
out << "/&";
12531256
}
12541257

1255-
void walk_fixedvec2(uint16_t sz, bool is_pod) {
1256-
walk_vec2(is_pod, get_fixedvec_data_range(sz, dp));
1257-
out << "/" << sz;
1258+
void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) {
1259+
walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp));
1260+
out << "/" << n_elts;
12581261
}
12591262

12601263
void walk_tag2(tag_info &tinfo, tag_variant_t tag_variant) {

src/test/run-pass/estr-internal.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ fn main() {
2020

2121
log(debug, b);
2222

23+
assert b < c;
24+
assert b <= c;
25+
assert b != c;
26+
assert c >= b;
27+
assert c > b;
28+
2329
assert a < c;
2430
assert a <= c;
2531
assert a != c;

src/test/run-pass/evec-internal.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,34 @@ fn main() {
55
z = x;
66
assert z[0] == 1;
77
assert z[4] == 5;
8+
9+
let a : [int]/5 = [1,1,1,1,1]/_;
10+
let b : [int]/5 = [2,2,2,2,2]/_;
11+
let c : [int]/5 = [2,2,2,2,3]/_;
12+
13+
log(debug, a);
14+
15+
assert a < b;
16+
assert a <= b;
17+
assert a != b;
18+
assert b >= a;
19+
assert b > a;
20+
21+
log(debug, b);
22+
23+
assert b < c;
24+
assert b <= c;
25+
assert b != c;
26+
assert c >= b;
27+
assert c > b;
28+
29+
assert a < c;
30+
assert a <= c;
31+
assert a != c;
32+
assert c >= a;
33+
assert c > a;
34+
35+
log(debug, c);
36+
37+
838
}

src/test/run-pass/evec-slice.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,41 @@ fn main() {
44
z = x;
55
assert z[0] == 1;
66
assert z[4] == 5;
7+
8+
let a : [int]/& = [1,1,1,1,1]/&;
9+
let b : [int]/& = [2,2,2,2,2]/&;
10+
let c : [int]/& = [2,2,2,2,3]/&;
11+
let cc : [int]/& = [2,2,2,2,2,2]/&;
12+
13+
log(debug, a);
14+
15+
assert a < b;
16+
assert a <= b;
17+
assert a != b;
18+
assert b >= a;
19+
assert b > a;
20+
21+
log(debug, b);
22+
23+
assert b < c;
24+
assert b <= c;
25+
assert b != c;
26+
assert c >= b;
27+
assert c > b;
28+
29+
assert a < c;
30+
assert a <= c;
31+
assert a != c;
32+
assert c >= a;
33+
assert c > a;
34+
35+
log(debug, c);
36+
37+
assert a < cc;
38+
assert a <= cc;
39+
assert a != cc;
40+
assert cc >= a;
41+
assert cc > a;
42+
43+
log(debug, cc);
744
}

0 commit comments

Comments
 (0)