From b22620624cdc4c35a74fce7eca9f6f279a403f56 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Fri, 8 Jun 2012 15:21:32 -0700 Subject: [PATCH] Get rid of a bunch of dead shape code. Closes #2552. --- src/rt/rust_box_annihilator.cpp | 19 ++-- src/rt/rust_cc.cpp | 55 ++++------ src/rt/rust_shape.cpp | 123 +++------------------- src/rt/rust_shape.h | 181 ++++++-------------------------- src/rustc/middle/trans/shape.rs | 1 - 5 files changed, 69 insertions(+), 310 deletions(-) diff --git a/src/rt/rust_box_annihilator.cpp b/src/rt/rust_box_annihilator.cpp index 6f6a22213e9..7984fbd618e 100644 --- a/src/rt/rust_box_annihilator.cpp +++ b/src/rt/rust_box_annihilator.cpp @@ -8,40 +8,36 @@ class annihilator : public shape::data { annihilator(const annihilator &other, const shape::ptr &in_dp) : shape::data(other.task, other.align, - other.sp, other.params, + other.sp, other.tables, in_dp) {} annihilator(const annihilator &other, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables = NULL) : shape::data(other.task, other.align, in_sp, - in_params, in_tables ? in_tables : other.tables, other.dp) {} annihilator(const annihilator &other, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables, shape::ptr in_dp) : shape::data(other.task, other.align, in_sp, - in_params, in_tables, in_dp) {} annihilator(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables, uint8_t *in_data) : shape::data(in_task, in_align, in_sp, - in_params, in_tables, in_data) {} + in_tables, + shape::ptr(in_data)) {} void walk_vec2(bool is_pod) { void *vec = shape::get_dp(dp); @@ -145,8 +141,7 @@ class annihilator : public shape::data { f(NULL, args->dtor->env, args->data); } - void walk_res2(const shape::rust_fn *dtor, unsigned n_params, - const shape::type_param *params, const uint8_t *end_sp, + void walk_res2(const shape::rust_fn *dtor, const uint8_t *end_sp, bool live) { void *data = (void*)(uintptr_t)dp; // Switch back to the Rust stack to run the destructor @@ -173,7 +168,7 @@ class annihilator : public shape::data { void walk_variant2(shape::tag_info &tinfo, uint32_t variant_id, const std::pair variant_ptr_and_end) { - annihilator sub(*this, variant_ptr_and_end.first, tinfo.params); + annihilator sub(*this, variant_ptr_and_end.first); const uint8_t *variant_end = variant_ptr_and_end.second; while (sub.sp < variant_end) { @@ -194,11 +189,9 @@ annihilator::do_annihilate(rust_task *task, rust_opaque_box *box) { const type_desc *tydesc = box->td; uint8_t *p = (uint8_t*) box_body(box); shape::arena arena; - shape::type_param *params = - shape::type_param::from_tydesc_and_data(tydesc, p, arena); annihilator annihilator(task, true, tydesc->shape, - params, tydesc->shape_tables, p); + tydesc->shape_tables, p); annihilator.walk(); task->boxed.free(box); } diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp index 46fb08a1ff6..999e7d87c5a 100644 --- a/src/rt/rust_cc.cpp +++ b/src/rt/rust_cc.cpp @@ -34,30 +34,26 @@ class irc : public shape::data { irc(const irc &other, const shape::ptr &in_dp) : shape::data(other.task, other.align, other.sp, - other.params, other.tables, in_dp), + other.tables, in_dp), ircs(other.ircs) {} irc(const irc &other, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables = NULL) : shape::data(other.task, other.align, in_sp, - in_params, in_tables ? in_tables : other.tables, other.dp), ircs(other.ircs) {} irc(const irc &other, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables, shape::ptr in_dp) : shape::data(other.task, other.align, in_sp, - in_params, in_tables, in_dp), ircs(other.ircs) {} @@ -65,13 +61,12 @@ class irc : public shape::data { irc(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables, uint8_t *in_data, irc_map &in_ircs) - : shape::data(in_task, in_align, in_sp, in_params, - in_tables, in_data), - ircs(in_ircs) {} + : shape::data(in_task, in_align, in_sp, + in_tables, shape::ptr(in_data)), + ircs(in_ircs) {} void walk_vec2(bool is_pod, std::pair data_range) { @@ -80,8 +75,8 @@ class irc : public shape::data { if (is_pod) return; - irc sub(*this, data_range.first); - shape::ptr data_end = sub.end_dp = data_range.second; + irc sub(*this, shape::ptr(data_range.first)); + shape::ptr data_end = sub.end_dp = shape::ptr(data_range.second); while (sub.dp < data_end) { sub.walk_reset(); // FIXME: shouldn't this be 'sub.align = true;'? @@ -148,8 +143,7 @@ class irc : public shape::data { void walk_tydesc2(char) { } - void walk_res2(const shape::rust_fn *dtor, unsigned n_params, - const shape::type_param *params, const uint8_t *end_sp, + void walk_res2(const shape::rust_fn *dtor, const uint8_t *end_sp, bool live) { while (this->sp != end_sp) { this->walk(); @@ -214,7 +208,7 @@ void irc::walk_variant2(shape::tag_info &tinfo, uint32_t variant_id, const std::pair variant_ptr_and_end) { - irc sub(*this, variant_ptr_and_end.first, tinfo.params); + irc sub(*this, variant_ptr_and_end.first); assert(variant_id < 256); // FIXME: Temporary sanity check. @@ -240,10 +234,8 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) { box, tydesc, body); shape::arena arena; - shape::type_param *params = - shape::type_param::from_tydesc_and_data(tydesc, body, arena); - irc irc(task, true, tydesc->shape, params, tydesc->shape_tables, + irc irc(task, true, tydesc->shape, tydesc->shape_tables, body, ircs); irc.walk(); } @@ -292,30 +284,26 @@ class mark : public shape::data { mark(const mark &other, const shape::ptr &in_dp) : shape::data(other.task, other.align, other.sp, - other.params, other.tables, in_dp), + other.tables, in_dp), marked(other.marked) {} mark(const mark &other, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables = NULL) : shape::data(other.task, other.align, in_sp, - in_params, in_tables ? in_tables : other.tables, other.dp), marked(other.marked) {} mark(const mark &other, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables, shape::ptr in_dp) : shape::data(other.task, other.align, in_sp, - in_params, in_tables, in_dp), marked(other.marked) {} @@ -323,12 +311,11 @@ class mark : public shape::data { mark(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const shape::type_param *in_params, const rust_shape_tables *in_tables, uint8_t *in_data, std::set &in_marked) - : shape::data(in_task, in_align, in_sp, in_params, - in_tables, in_data), + : shape::data(in_task, in_align, in_sp, + in_tables, shape::ptr(in_data)), marked(in_marked) {} void walk_vec2(bool is_pod, std::pair data_range) { @@ -340,8 +327,8 @@ class mark : public shape::data { if (data_range.second - data_range.first > 100000) abort(); // FIXME: Temporary sanity check. - mark sub(*this, data_range.first); - shape::ptr data_end = sub.end_dp = data_range.second; + mark sub(*this, shape::ptr(data_range.first)); + shape::ptr data_end = sub.end_dp = shape::ptr(data_range.second); while (sub.dp < data_end) { sub.walk_reset(); align = true; @@ -399,9 +386,8 @@ class mark : public shape::data { } } - void walk_res2(const shape::rust_fn *dtor, unsigned n_params, - const shape::type_param *params, const uint8_t *end_sp, - bool live) { + void walk_res2(const shape::rust_fn *dtor, const uint8_t *end_sp, + bool live) { while (this->sp != end_sp) { this->walk(); align = true; @@ -458,7 +444,7 @@ void mark::walk_variant2(shape::tag_info &tinfo, uint32_t variant_id, const std::pair variant_ptr_and_end) { - mark sub(*this, variant_ptr_and_end.first, tinfo.params); + mark sub(*this, variant_ptr_and_end.first); assert(variant_id < 256); // FIXME: Temporary sanity check. @@ -487,10 +473,8 @@ mark::do_mark(rust_task *task, uint8_t *p = (uint8_t*) box_body(box); shape::arena arena; - shape::type_param *params = - shape::type_param::from_tydesc_and_data(tydesc, p, arena); - mark mark(task, true, tydesc->shape, params, tydesc->shape_tables, + mark mark(task, true, tydesc->shape, tydesc->shape_tables, p, marked); mark.walk(); } @@ -543,8 +527,7 @@ do_final_cc(rust_task *task) { cerr << "Unreclaimed object found at " << (void*) box << ": "; const type_desc *td = box->td; shape::arena arena; - shape::type_param *params = shape::type_param::from_tydesc(td, arena); - shape::log log(task, true, td->shape, params, td->shape_tables, + shape::log log(task, true, td->shape, td->shape_tables, (uint8_t*)box_body(box), cerr); log.walk(); cerr << "\n"; diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index 1374a380e8e..267cd6bfd98 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -21,66 +21,11 @@ const uint8_t CMP_EQ = 0u; const uint8_t CMP_LT = 1u; const uint8_t CMP_LE = 2u; -// Type parameters - -type_param * -type_param::make(const type_desc **tydescs, unsigned n_tydescs, - arena &arena) { - if (!n_tydescs) - return NULL; - - type_param *ptrs = arena.alloc(n_tydescs); - for (uint32_t i = 0; i < n_tydescs; i++) { - const type_desc *subtydesc = tydescs[i]; - ptrs[i].shape = subtydesc->shape; - ptrs[i].tables = subtydesc->shape_tables; - - // FIXME: Doesn't handle a type-parametric object closing over a - // type-parametric object type properly. - ptrs[i].params = from_tydesc(subtydesc, arena); - } - return ptrs; -} - -// Constructs type parameters from an object shape. This is a bit messy, -// because it requires that the object shape have a specific format. -type_param * -type_param::from_obj_shape(const uint8_t *sp, ptr dp, arena &arena) { - uint8_t shape = *sp++; assert(shape == SHAPE_STRUCT); - get_u16_bump(sp); // Skip over the size. - shape = *sp++; assert(shape == SHAPE_PTR); - shape = *sp++; assert(shape == SHAPE_STRUCT); - - unsigned n_tydescs = get_u16_bump(sp); - - // Type descriptors start right after the reference count. - const type_desc **descs = (const type_desc **)(dp + sizeof(uintptr_t)); - - return make(descs, n_tydescs, arena); -} - - // A shape printer, useful for debugging void print::walk_tag1(tag_info &tinfo) { DPRINT("tag%u", tinfo.tag_id); - if (!tinfo.n_params) - return; - - DPRINT("<"); - - bool first = true; - for (uint16_t i = 0; i < tinfo.n_params; i++) { - if (!first) - DPRINT(","); - first = false; - - ctxt sub(*this, tinfo.params[i].shape); - sub.walk(); - } - - DPRINT(">"); } void @@ -100,27 +45,9 @@ print::walk_struct1(const uint8_t *end_sp) { } void -print::walk_res1(const rust_fn *dtor, unsigned n_params, - const type_param *params, const uint8_t *end_sp) { +print::walk_res1(const rust_fn *dtor, const uint8_t *end_sp) { DPRINT("res@%p", dtor); - // Print type parameters. - if (n_params) { - DPRINT("<"); - - bool first = true; - for (uint16_t i = 0; i < n_params; i++) { - if (!first) - DPRINT(","); - first = false; - - ctxt sub(*this, params[i].shape); - sub.walk(); - } - - DPRINT(">"); - } - // Print arguments. if (sp == end_sp) @@ -140,15 +67,6 @@ print::walk_res1(const rust_fn *dtor, unsigned n_params, DPRINT(")"); } -void -print::walk_var1(uint8_t param_index) { - DPRINT("%c=", 'T' + param_index); - - const type_param *param = ¶ms[param_index]; - print sub(*this, param->shape, param->params, param->tables); - sub.walk(); -} - template<> void print::walk_number1() { DPRINT("u8"); } template<> @@ -186,7 +104,7 @@ size_of::compute_tag_size(tag_info &tinfo) { const uint8_t *variant_ptr = variant_ptr_and_end.first; const uint8_t *variant_end = variant_ptr_and_end.second; - size_of sub(*this, variant_ptr, tinfo.params, NULL); + size_of sub(*this, variant_ptr, NULL); sub.align = false; // Compute the size of this variant. @@ -308,31 +226,27 @@ public: cmp(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables, uint8_t *in_data_0, uint8_t *in_data_1) - : data(in_task, in_align, in_sp, in_params, in_tables, + : data(in_task, in_align, in_sp, in_tables, ptr_pair::make(in_data_0, in_data_1)), result(0) {} cmp(const cmp &other, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables, ptr_pair &in_dp) - : data(other.task, other.align, in_sp, in_params, in_tables, + : data(other.task, other.align, in_sp, in_tables, in_dp), result(0) {} cmp(const cmp &other, const uint8_t *in_sp = NULL, - const type_param *in_params = NULL, const rust_shape_tables *in_tables = NULL) : data(other.task, other.align, in_sp ? in_sp : other.sp, - in_params ? in_params : other.params, in_tables ? in_tables : other.tables, other.dp), result(0) {} @@ -341,7 +255,6 @@ public: : data(other.task, other.align, other.sp, - other.params, other.tables, in_dp), result(0) {} @@ -386,8 +299,7 @@ public: void walk_tag2(tag_info &tinfo, const data_pair &tag_variants); void walk_struct2(const uint8_t *end_sp); - void walk_res2(const rust_fn *dtor, uint16_t n_ty_params, - const type_param *ty_params_sp, const uint8_t *end_sp, + void walk_res2(const rust_fn *dtor, const uint8_t *end_sp, const data_pair &live); void walk_variant2(tag_info &tinfo, tag_variant_t variant_id, @@ -439,8 +351,7 @@ cmp::walk_struct2(const uint8_t *end_sp) { } void -cmp::walk_res2(const rust_fn *dtor, uint16_t n_ty_params, - const type_param *ty_params_sp, const uint8_t *end_sp, +cmp::walk_res2(const rust_fn *dtor, const uint8_t *end_sp, const data_pair &live) { abort(); // TODO } @@ -450,7 +361,7 @@ cmp::walk_variant2(tag_info &tinfo, tag_variant_t variant_id, const std::pair variant_ptr_and_end) { - cmp sub(*this, variant_ptr_and_end.first, tinfo.params); + cmp sub(*this, variant_ptr_and_end.first); const uint8_t *variant_end = variant_ptr_and_end.second; while (!result && sub.sp < variant_end) { @@ -532,7 +443,7 @@ log::walk_variant2(tag_info &tinfo, tag_variant_t variant_id, const std::pair variant_ptr_and_end) { - log sub(*this, variant_ptr_and_end.first, tinfo.params); + log sub(*this, variant_ptr_and_end.first); const uint8_t *variant_end = variant_ptr_and_end.second; bool first = true; @@ -547,8 +458,7 @@ log::walk_variant2(tag_info &tinfo, } void -log::walk_res2(const rust_fn *dtor, unsigned n_params, - const type_param *params, const uint8_t *end_sp, bool live) { +log::walk_res2(const rust_fn *dtor, const uint8_t *end_sp, bool live) { out << prefix << "res"; if (this->sp == end_sp) @@ -576,12 +486,7 @@ shape_cmp_type(int8_t *result, const type_desc *tydesc, rust_task *task = rust_get_current_task(); shape::arena arena; - // FIXME: This may well be broken when comparing two closures or objects - // that close over different sets of type parameters. - shape::type_param *params = - shape::type_param::from_tydesc_and_data(tydesc, data_0, arena); - - shape::cmp cmp(task, true, tydesc->shape, params, tydesc->shape_tables, + shape::cmp cmp(task, true, tydesc->shape, tydesc->shape_tables, data_0, data_1); cmp.walk(); @@ -597,11 +502,9 @@ shape_log_str(const type_desc *tydesc, uint8_t *data) { rust_task *task = rust_get_current_task(); shape::arena arena; - shape::type_param *params = - shape::type_param::from_tydesc_and_data(tydesc, data, arena); std::stringstream ss; - shape::log log(task, true, tydesc->shape, params, tydesc->shape_tables, + shape::log log(task, true, tydesc->shape, tydesc->shape_tables, data, ss); log.walk(); @@ -615,11 +518,9 @@ shape_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) { rust_task *task = rust_get_current_task(); shape::arena arena; - shape::type_param *params = - shape::type_param::from_tydesc_and_data(tydesc, data, arena); std::stringstream ss; - shape::log log(task, true, tydesc->shape, params, tydesc->shape_tables, + shape::log log(task, true, tydesc->shape, tydesc->shape_tables, data, ss); log.walk(); diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index 6552c594577..a957bd1621d 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -49,7 +49,6 @@ const uint8_t SHAPE_STRUCT = 17u; const uint8_t SHAPE_BOX_FN = 18u; const uint8_t SHAPE_OBJ = 19u; const uint8_t SHAPE_RES = 20u; -const uint8_t SHAPE_VAR = 21u; const uint8_t SHAPE_UNIQ = 22u; const uint8_t SHAPE_UNIQ_FN = 25u; const uint8_t SHAPE_STACK_FN = 26u; @@ -72,7 +71,6 @@ const uint8_t SHAPE_PTR = SHAPE_U32; struct rust_obj; struct size_align; class ptr; -class type_param; // Arenas; these functions must execute very quickly, so we use an arena @@ -183,8 +181,6 @@ struct tag_info { uint16_t variant_count; // Number of variants in the tag. const uint8_t *largest_variants_ptr; // Ptr to largest variants table. size_align tag_sa; // Size and align of this tag. - uint16_t n_params; // Number of type parameters. - const type_param *params; // Array of type parameters. }; @@ -229,7 +225,6 @@ template class ctxt { public: const uint8_t *sp; // shape pointer - const type_param *params; // shapes of type parameters const rust_shape_tables *tables; rust_task *task; bool align; @@ -237,10 +232,8 @@ public: ctxt(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables) : sp(in_sp), - params(in_params), tables(in_tables), task(in_task), align(in_align) {} @@ -248,10 +241,8 @@ public: template ctxt(const ctxt &other, const uint8_t *in_sp = NULL, - const type_param *in_params = NULL, const rust_shape_tables *in_tables = NULL) : sp(in_sp ? in_sp : other.sp), - params(in_params ? in_params : other.params), tables(in_tables ? in_tables : other.tables), task(other.task), align(other.align) {} @@ -278,7 +269,6 @@ private: void walk_uniq0(); void walk_struct0(); void walk_res0(); - void walk_var0(); void walk_rptr0(); void walk_fixedvec0(); void walk_slice0(); @@ -292,60 +282,6 @@ struct rust_fn { void *env; }; -// Type parameters - -class type_param { -private: - static type_param *make(const type_desc **tydescs, unsigned n_tydescs, - arena &arena); - -public: - const uint8_t *shape; - const rust_shape_tables *tables; - const type_param *params; // subparameters - - // Creates type parameters from an object shape description. - static type_param *from_obj_shape(const uint8_t *sp, ptr dp, - arena &arena); - - template - inline void set(ctxt *cx) { - shape = cx->sp; - tables = cx->tables; - params = cx->params; - } - - // Creates type parameters from a type descriptor. - static inline type_param *from_tydesc(const type_desc *tydesc, - arena &arena) { - // In order to find the type parameters of objects and functions, we - // have to actually have the data pointer, since we don't statically - // know from the type of an object or function which type parameters - // it closes over. - assert(!tydesc->n_obj_params && "Type-parametric objects " - "must go through from_tydesc_and_data() instead!"); - - return make(tydesc->first_param, tydesc->n_params, arena); - } - - static type_param *from_tydesc_and_data(const type_desc *tydesc, - uint8_t *dp, arena &arena) { - if (tydesc->n_obj_params) { - uintptr_t n_obj_params = tydesc->n_obj_params; - const type_desc **first_param; - // Object closure. - DPRINT("n_obj_params OBJ %lu, tydesc %p, starting at %p\n", - (unsigned long)n_obj_params, tydesc, - dp + sizeof(uintptr_t) * 2); - first_param = (const type_desc **)(dp + sizeof(uintptr_t) * 2); - return make(first_param, n_obj_params, arena); - } - - return make(tydesc->first_param, tydesc->n_params, arena); - } -}; - - // Traversals #define WALK_NUMBER(c_type) \ @@ -372,7 +308,6 @@ ctxt::walk() { case SHAPE_BOX: walk_box0(); break; case SHAPE_STRUCT: walk_struct0(); break; case SHAPE_RES: walk_res0(); break; - case SHAPE_VAR: walk_var0(); break; case SHAPE_UNIQ: walk_uniq0(); break; case SHAPE_BOX_FN: case SHAPE_UNIQ_FN: @@ -460,18 +395,9 @@ ctxt::walk_tag0() { // Determine the size and alignment. tinfo.tag_sa = get_size_align(tinfo.info_ptr); - // Determine the number of parameters. - tinfo.n_params = get_u16_bump(sp); - - // Read in the tag type parameters. - type_param params[tinfo.n_params]; - for (uint16_t i = 0; i < tinfo.n_params; i++) { - uint16_t len = get_u16_bump(sp); - params[i].set(this); - sp += len; - } - - tinfo.params = params; + // Read in a dummy value; this used to be the number of parameters + uint16_t number_of_params = get_u16_bump(sp); + assert(number_of_params == 0 && "tag has type parameters on it"); // Call to the implementation. static_cast(this)->walk_tag1(tinfo); @@ -551,32 +477,22 @@ ctxt::walk_res0() { reinterpret_cast(tables->resources); const rust_fn *dtor = resources[dtor_offset]; + // Read in the resource type parameters, but ignore them. + // TODO: remove after snapshot uint16_t n_ty_params = get_u16_bump(sp); - - // Read in the tag type parameters. - type_param params[n_ty_params]; for (uint16_t i = 0; i < n_ty_params; i++) { uint16_t ty_param_len = get_u16_bump(sp); - const uint8_t *next_sp = sp + ty_param_len; - params[i].set(this); - sp = next_sp; + sp += ty_param_len; } uint16_t sp_size = get_u16_bump(sp); const uint8_t *end_sp = sp + sp_size; - static_cast(this)->walk_res1(dtor, n_ty_params, params, end_sp); + static_cast(this)->walk_res1(dtor, end_sp); sp = end_sp; } -template -void -ctxt::walk_var0() { - uint8_t param = *sp++; - static_cast(this)->walk_var1(param); -} - // A shape printer, useful for debugging class print : public ctxt { @@ -584,22 +500,18 @@ public: template print(const ctxt &other, const uint8_t *in_sp = NULL, - const type_param *in_params = NULL, const rust_shape_tables *in_tables = NULL) - : ctxt(other, in_sp, in_params, in_tables) {} + : ctxt(other, in_sp, in_tables) {} print(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables) - : ctxt(in_task, in_align, in_sp, in_params, in_tables) {} + : ctxt(in_task, in_align, in_sp, in_tables) {} void walk_tag1(tag_info &tinfo); void walk_struct1(const uint8_t *end_sp); - void walk_res1(const rust_fn *dtor, unsigned n_params, - const type_param *params, const uint8_t *end_sp); - void walk_var1(uint8_t param); + void walk_res1(const rust_fn *dtor, const uint8_t *end_sp); void walk_vec1(bool is_pod) { DPRINT("vec<"); walk(); DPRINT(">"); @@ -665,16 +577,14 @@ private: public: size_of(const size_of &other, const uint8_t *in_sp = NULL, - const type_param *in_params = NULL, const rust_shape_tables *in_tables = NULL) - : ctxt(other, in_sp, in_params, in_tables) {} + : ctxt(other, in_sp, in_tables) {} template size_of(const ctxt &other, const uint8_t *in_sp = NULL, - const type_param *in_params = NULL, const rust_shape_tables *in_tables = NULL) - : ctxt(other, in_sp, in_params, in_tables) {} + : ctxt(other, in_sp, in_tables) {} void walk_tag1(tag_info &tinfo); void walk_struct1(const uint8_t *end_sp); @@ -693,15 +603,7 @@ public: sa.set(sizeof(void *), sizeof(void *)); } - void walk_var1(uint8_t param_index) { - const type_param *param = ¶ms[param_index]; - size_of sub(*this, param->shape, param->params, param->tables); - sub.walk(); - sa = sub.sa; - } - - void walk_res1(const rust_fn *dtor, unsigned n_params, - const type_param *params, const uint8_t *end_sp) { + void walk_res1(const rust_fn *dtor, const uint8_t *end_sp) { abort(); // TODO } @@ -744,8 +646,8 @@ public: struct data { typedef T t; }; ptr() : p(NULL) {} - ptr(uint8_t *in_p) : p(in_p) {} - ptr(uintptr_t in_p) : p((uint8_t *)in_p) {} + explicit ptr(uint8_t *in_p) : p(in_p) {} + explicit ptr(uintptr_t in_p) : p((uint8_t *)in_p) {} inline ptr operator+(const size_t amount) const { return make(p + amount); @@ -961,10 +863,9 @@ public: data(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables, U const &in_dp) - : ctxt< data >(in_task, in_align, in_sp, in_params, in_tables), + : ctxt< data >(in_task, in_align, in_sp, in_tables), dp(in_dp), end_dp() {} @@ -1016,20 +917,10 @@ public: dp = next_dp; } - void walk_res1(const rust_fn *dtor, unsigned n_params, - const type_param *params, const uint8_t *end_sp) { + void walk_res1(const rust_fn *dtor, const uint8_t *end_sp) { typename U::template data::t live = bump_dp(dp); // Delegate to the implementation. - static_cast(this)->walk_res2(dtor, n_params, params, end_sp, - live); - } - - void walk_var1(uint8_t param_index) { - const type_param *param = &this->params[param_index]; - T sub(*static_cast(this), param->shape, param->params, - param->tables); - static_cast(this)->walk_subcontext2(sub); - dp = sub.dp; + static_cast(this)->walk_res2(dtor, end_sp, live); } template @@ -1050,8 +941,7 @@ data::walk_box_contents1() { if (body_td) { U body_dp(dp.box_body()); arena arena; - type_param *params = type_param::from_tydesc(body_td, arena); - T sub(*static_cast(this), body_td->shape, params, + T sub(*static_cast(this), body_td->shape, body_td->shape_tables, body_dp); sub.align = true; static_cast(this)->walk_box_contents2(sub); @@ -1065,8 +955,7 @@ data::walk_uniq_contents1() { if (body_td) { U body_dp(dp.box_body()); arena arena; - type_param *params = type_param::from_tydesc(body_td, arena); - T sub(*static_cast(this), body_td->shape, params, + T sub(*static_cast(this), body_td->shape, body_td->shape_tables, body_dp); sub.align = true; static_cast(this)->walk_uniq_contents2(sub); @@ -1102,8 +991,10 @@ data::get_vec_data_range(ptr dp) { template std::pair data::get_vec_data_range(ptr_pair &dp) { - std::pair fst = get_vec_data_range(dp.fst); - std::pair snd = get_vec_data_range(dp.snd); + std::pair fst = + get_vec_data_range(shape::ptr(dp.fst)); + std::pair snd = + get_vec_data_range(shape::ptr(dp.snd)); ptr_pair start(fst.first, snd.first); ptr_pair end(fst.second, snd.second); return std::make_pair(start, end); @@ -1122,9 +1013,9 @@ template std::pair data::get_slice_data_range(bool is_str, ptr_pair &dp) { std::pair fst = - get_slice_data_range(is_str, dp.fst); + get_slice_data_range(is_str, shape::ptr(dp.fst)); std::pair snd = - get_slice_data_range(is_str, dp.snd); + get_slice_data_range(is_str, shape::ptr(dp.snd)); ptr_pair start(fst.first, snd.first); ptr_pair end(fst.second, snd.second); return std::make_pair(start, end); @@ -1142,9 +1033,9 @@ std::pair data::get_fixedvec_data_range(uint16_t n_elts, size_t elt_sz, ptr_pair &dp) { std::pair fst = - get_fixedvec_data_range(n_elts, elt_sz, dp.fst); + get_fixedvec_data_range(n_elts, elt_sz, shape::ptr(dp.fst)); std::pair snd = - get_fixedvec_data_range(n_elts, elt_sz, dp.snd); + get_fixedvec_data_range(n_elts, elt_sz, shape::ptr(dp.snd)); ptr_pair start(fst.first, snd.first); ptr_pair end(fst.second, snd.second); return std::make_pair(start, end); @@ -1181,9 +1072,8 @@ void arena arena; const type_desc *closure_td = pair.env->td; - type_param *params = type_param::from_tydesc(closure_td, arena); ptr closure_dp((uintptr_t)box_body(pair.env)); - T sub(*static_cast(this), closure_td->shape, params, + T sub(*static_cast(this), closure_td->shape, closure_td->shape_tables, closure_dp); sub.align = true; @@ -1208,12 +1098,10 @@ private: log(log &other, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables = NULL) : data(other.task, other.align, in_sp, - in_params, in_tables ? in_tables : other.tables, other.dp), out(other.out), @@ -1221,13 +1109,11 @@ private: log(log &other, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables, ptr in_dp) : data(other.task, other.align, in_sp, - in_params, in_tables, in_dp), out(other.out), @@ -1237,7 +1123,6 @@ private: : data(other.task, other.align, other.sp, - other.params, other.tables, in_dp), out(other.out), @@ -1334,9 +1219,7 @@ private: const std::pair variant_ptr_and_end); void walk_string2(const std::pair &data); - void walk_res2(const rust_fn *dtor, unsigned n_params, - const type_param *params, const uint8_t *end_sp, - bool live); + void walk_res2(const rust_fn *dtor, const uint8_t *end_sp, bool live); template inline void walk_number2() { @@ -1348,11 +1231,11 @@ public: log(rust_task *in_task, bool in_align, const uint8_t *in_sp, - const type_param *in_params, const rust_shape_tables *in_tables, uint8_t *in_data, std::ostream &in_out) - : data(in_task, in_align, in_sp, in_params, in_tables, in_data), + : data(in_task, in_align, in_sp, in_tables, + ptr(in_data)), out(in_out), prefix("") {} }; diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 7ac885422a1..c5404a40196 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -83,7 +83,6 @@ const shape_enum: u8 = 12u8; const shape_struct: u8 = 17u8; const shape_box_fn: u8 = 18u8; const shape_res: u8 = 20u8; -const shape_var: u8 = 21u8; const shape_uniq: u8 = 22u8; const shape_opaque_closure_ptr: u8 = 23u8; // the closure itself. const shape_uniq_fn: u8 = 25u8;