diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2012-05-03 14:11:54 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2012-05-03 14:11:54 -0700 |
| commit | 6e5c8a7fb86aa38d47d70f7390035cc426f91159 (patch) | |
| tree | e9b157de0a53e056ebd63db17557e4af1ac17ef1 | |
| parent | 11a5d10bf2958c642ae6a7c4afff8e181aa2167d (diff) | |
| download | rust-6e5c8a7fb86aa38d47d70f7390035cc426f91159.tar.gz rust-6e5c8a7fb86aa38d47d70f7390035cc426f91159.zip | |
More shape fixes for evecs.
| -rw-r--r-- | src/rt/rust_box_annihilator.cpp | 4 | ||||
| -rw-r--r-- | src/rt/rust_cc.cpp | 8 | ||||
| -rw-r--r-- | src/rt/rust_shape.cpp | 4 | ||||
| -rw-r--r-- | src/rt/rust_shape.h | 41 | ||||
| -rw-r--r-- | src/test/run-pass/estr-internal.rs | 6 | ||||
| -rw-r--r-- | src/test/run-pass/evec-internal.rs | 30 | ||||
| -rw-r--r-- | src/test/run-pass/evec-slice.rs | 37 |
7 files changed, 103 insertions, 27 deletions
diff --git a/src/rt/rust_box_annihilator.cpp b/src/rt/rust_box_annihilator.cpp index bc5e0dfdda5..15ec71eeb05 100644 --- a/src/rt/rust_box_annihilator.cpp +++ b/src/rt/rust_box_annihilator.cpp @@ -49,8 +49,8 @@ class annihilator : public shape::data<annihilator,shape::ptr> { task->kernel->free(vec); } - void walk_fixedvec2(uint16_t sz, bool is_pod) { - walk_vec2(is_pod, get_fixedvec_data_range(sz, dp)); + void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) { + walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp)); } void walk_vec2(bool is_pod, diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp index 4e3facd0413..66f044b8ce9 100644 --- a/src/rt/rust_cc.cpp +++ b/src/rt/rust_cc.cpp @@ -100,8 +100,8 @@ class irc : public shape::data<irc,shape::ptr> { walk_vec2(is_pod, get_slice_data_range(is_str, dp)); } - void walk_fixedvec2(uint16_t sz, bool is_pod) { - walk_vec2(is_pod, get_fixedvec_data_range(sz, dp)); + void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) { + walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp)); } void walk_tag2(shape::tag_info &tinfo, uint32_t tag_variant) { @@ -356,8 +356,8 @@ class mark : public shape::data<mark,shape::ptr> { walk_vec2(is_pod, get_slice_data_range(is_str, dp)); } - void walk_fixedvec2(uint16_t sz, bool is_pod) { - walk_vec2(is_pod, get_fixedvec_data_range(sz, dp)); + void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) { + walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp)); } void walk_tag2(shape::tag_info &tinfo, uint32_t tag_variant) { diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index 9f3fbbed89e..c5f6a39b6c8 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -355,9 +355,9 @@ public: walk_vec2(is_pod, get_slice_data_range(is_str, dp)); } - void walk_fixedvec2(uint16_t sz, bool is_pod) { + void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) { // Fixedvecs compare just like vecs. - walk_vec2(is_pod, get_fixedvec_data_range(sz, dp)); + walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp)); } void walk_box2() { diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index 112a61ee239..c6817b23a6e 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -524,12 +524,12 @@ ctxt<T>::walk_rptr0() { template<typename T> void ctxt<T>::walk_fixedvec0() { - uint16_t vec_size = get_u16_bump(sp); + uint16_t n_elts = get_u16_bump(sp); bool is_pod = *sp++; uint16_t sp_size = get_u16_bump(sp); const uint8_t *end_sp = sp + sp_size; - static_cast<T *>(this)->walk_fixedvec1(vec_size, is_pod); + static_cast<T *>(this)->walk_fixedvec1(n_elts, is_pod); sp = end_sp; } @@ -629,8 +629,8 @@ public: void walk_rptr1() { DPRINT("&<"); walk(); DPRINT(">"); } - void walk_fixedvec1(uint16_t sz, bool is_pod) { - DPRINT("fixedvec<%u, ", sz); walk(); DPRINT(">"); + void walk_fixedvec1(uint16_t n_elts, bool is_pod) { + DPRINT("fixedvec<%u, ", n_elts); walk(); DPRINT(">"); } void walk_slice1(bool is_pod, bool is_str) { DPRINT("slice<"); walk(); DPRINT(">"); @@ -721,10 +721,10 @@ public: abort(); // TODO } - void walk_fixedvec1(uint16_t sz, bool is_pod) { + void walk_fixedvec1(uint16_t n_elts, bool is_pod) { size_of sub(*this); sub.walk(); - sa.set(sub.sa.size * sz, sub.sa.alignment); + sa.set(sub.sa.size * n_elts, sub.sa.alignment); } template<typename T> @@ -959,9 +959,9 @@ protected: ptr_pair &dp); static std::pair<uint8_t *,uint8_t *> - get_fixedvec_data_range(uint16_t sz, ptr dp); + get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, ptr dp); static std::pair<ptr_pair,ptr_pair> - get_fixedvec_data_range(uint16_t sz, ptr_pair &dp); + get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, ptr_pair &dp); public: data(rust_task *in_task, @@ -989,10 +989,10 @@ public: DATA_SIMPLE(void *, walk_slice2(is_pod, is_str)); } - void walk_fixedvec1(uint16_t sz, bool is_pod) { + void walk_fixedvec1(uint16_t n_elts, bool is_pod) { size_align sa = size_of::get(*this); ALIGN_TO(sa.alignment); - static_cast<T *>(this)->walk_fixedvec2(sz, is_pod); + static_cast<T *>(this)->walk_fixedvec2(n_elts, sa.size, is_pod); } 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) { template<typename T,typename U> std::pair<uint8_t *,uint8_t *> -data<T,U>::get_fixedvec_data_range(uint16_t sz, ptr dp) { +data<T,U>::get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, ptr dp) { uint8_t* ptr = (uint8_t*)(dp); - return std::make_pair(ptr, ptr + sz); + return std::make_pair(ptr, ptr + (((size_t)n_elts) * elt_sz)); } template<typename T,typename U> std::pair<ptr_pair,ptr_pair> -data<T,U>::get_fixedvec_data_range(uint16_t sz, ptr_pair &dp) { - std::pair<uint8_t *,uint8_t *> fst = get_fixedvec_data_range(sz, dp.fst); - std::pair<uint8_t *,uint8_t *> snd = get_fixedvec_data_range(sz, dp.snd); +data<T,U>::get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, + ptr_pair &dp) { + std::pair<uint8_t *,uint8_t *> fst = + get_fixedvec_data_range(n_elts, elt_sz, dp.fst); + std::pair<uint8_t *,uint8_t *> snd = + get_fixedvec_data_range(n_elts, elt_sz, dp.snd); ptr_pair start(fst.first, snd.first); ptr_pair end(fst.second, snd.second); return std::make_pair(start, end); @@ -1248,13 +1251,13 @@ private: } void walk_slice2(bool is_pod, bool is_str) { - walk_vec2(is_pod, get_slice_data_range(dp, is_str)); + walk_vec2(is_pod, get_slice_data_range(is_str, dp)); out << "/&"; } - void walk_fixedvec2(uint16_t sz, bool is_pod) { - walk_vec2(is_pod, get_fixedvec_data_range(sz, dp)); - out << "/" << sz; + void walk_fixedvec2(uint16_t n_elts, size_t elt_sz, bool is_pod) { + walk_vec2(is_pod, get_fixedvec_data_range(n_elts, elt_sz, dp)); + out << "/" << n_elts; } void walk_tag2(tag_info &tinfo, tag_variant_t tag_variant) { diff --git a/src/test/run-pass/estr-internal.rs b/src/test/run-pass/estr-internal.rs index b5290f3c0ab..1dc99b082cd 100644 --- a/src/test/run-pass/estr-internal.rs +++ b/src/test/run-pass/estr-internal.rs @@ -20,6 +20,12 @@ fn main() { log(debug, b); + assert b < c; + assert b <= c; + assert b != c; + assert c >= b; + assert c > b; + assert a < c; assert a <= c; assert a != c; diff --git a/src/test/run-pass/evec-internal.rs b/src/test/run-pass/evec-internal.rs index d402a7b8bb8..4f3bd10e4de 100644 --- a/src/test/run-pass/evec-internal.rs +++ b/src/test/run-pass/evec-internal.rs @@ -5,4 +5,34 @@ fn main() { z = x; assert z[0] == 1; assert z[4] == 5; + + let a : [int]/5 = [1,1,1,1,1]/_; + let b : [int]/5 = [2,2,2,2,2]/_; + let c : [int]/5 = [2,2,2,2,3]/_; + + log(debug, a); + + assert a < b; + assert a <= b; + assert a != b; + assert b >= a; + assert b > a; + + log(debug, b); + + assert b < c; + assert b <= c; + assert b != c; + assert c >= b; + assert c > b; + + assert a < c; + assert a <= c; + assert a != c; + assert c >= a; + assert c > a; + + log(debug, c); + + } diff --git a/src/test/run-pass/evec-slice.rs b/src/test/run-pass/evec-slice.rs index 1c7799ce2c3..8073a9be95f 100644 --- a/src/test/run-pass/evec-slice.rs +++ b/src/test/run-pass/evec-slice.rs @@ -4,4 +4,41 @@ fn main() { z = x; assert z[0] == 1; assert z[4] == 5; + + let a : [int]/& = [1,1,1,1,1]/&; + let b : [int]/& = [2,2,2,2,2]/&; + let c : [int]/& = [2,2,2,2,3]/&; + let cc : [int]/& = [2,2,2,2,2,2]/&; + + log(debug, a); + + assert a < b; + assert a <= b; + assert a != b; + assert b >= a; + assert b > a; + + log(debug, b); + + assert b < c; + assert b <= c; + assert b != c; + assert c >= b; + assert c > b; + + assert a < c; + assert a <= c; + assert a != c; + assert c >= a; + assert c > a; + + log(debug, c); + + assert a < cc; + assert a <= cc; + assert a != cc; + assert cc >= a; + assert cc > a; + + log(debug, cc); } |
