From 35bfaf50b096457dfc7d9a3728108b6a9324aa10 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 9 Jul 2012 14:54:49 -0700 Subject: [PATCH 01/10] Switch to use snapshot libraries, to prepare for some changes. --- mk/target.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mk/target.mk b/mk/target.mk index 5ddc825d335b..b53a8ca80109 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -8,9 +8,9 @@ # (resp. corelib), set this flag to 1. It will cause stage1 to use # the snapshot runtime (resp. corelib) rather than the runtime # (resp. corelib) from the working directory. -USE_SNAPSHOT_RUNTIME=0 -USE_SNAPSHOT_CORELIB=0 -USE_SNAPSHOT_STDLIB=0 +USE_SNAPSHOT_RUNTIME=1 +USE_SNAPSHOT_CORELIB=1 +USE_SNAPSHOT_STDLIB=1 define TARGET_STAGE_N From 260f73ed85cdf1421ee1b1d241b3cca438a4ac44 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 9 Jul 2012 14:56:11 -0700 Subject: [PATCH 02/10] Get rid of unused fields in tydescs. Closes #2351. --- src/libcore/sys.rs | 1 - src/rt/rust_shape.cpp | 3 +-- src/rt/rust_type.h | 9 --------- src/rt/rust_upcall.cpp | 11 ++++------- src/rt/rust_util.cpp | 7 ------- src/rustc/back/abi.rs | 25 +++++++++---------------- src/rustc/back/upcall.rs | 2 +- src/rustc/middle/trans/base.rs | 29 ++++++++++------------------- src/rustc/middle/trans/common.rs | 7 +++---- 9 files changed, 28 insertions(+), 66 deletions(-) diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index a24c41338c48..92913c3e28de 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -10,7 +10,6 @@ export log_str; export lock_and_signal, condition, methods; enum type_desc = { - first_param: **libc::c_int, size: libc::size_t, align: libc::size_t // Remaining fields not listed diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index 979a93415b3f..cb4afa904c90 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -484,8 +484,7 @@ log::walk_res2(const rust_fn *dtor, const uint8_t *end_sp) { extern "C" void shape_cmp_type(int8_t *result, const type_desc *tydesc, - const type_desc **subtydescs, uint8_t *data_0, - uint8_t *data_1, uint8_t cmp_type) { + uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) { rust_task *task = rust_get_current_task(); shape::arena arena; diff --git a/src/rt/rust_type.h b/src/rt/rust_type.h index fec61e5e9064..036485825f1d 100644 --- a/src/rt/rust_type.h +++ b/src/rt/rust_type.h @@ -45,24 +45,15 @@ static inline void *box_body(rust_opaque_box *box) { return (void*)(box + 1); } -// N.B. If you want to add a field to tydesc, please use one of the -// unused fields! struct type_desc { - uintptr_t UNUSED_1; size_t size; size_t align; glue_fn *take_glue; glue_fn *drop_glue; glue_fn *free_glue; glue_fn *visit_glue; - uintptr_t UNUSED_2; - uintptr_t UNUSED_3; - uintptr_t UNUSED_4; - uintptr_t UNUSED_5; const uint8_t *shape; const rust_shape_tables *shape_tables; - uintptr_t UNUSED_6; - uintptr_t UNUSED_7; }; extern "C" type_desc *rust_clone_type_desc(type_desc*); diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 1ce7c1217dcf..63b190b0a252 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -444,13 +444,11 @@ upcall_rust_personality(int version, extern "C" void shape_cmp_type(int8_t *result, const type_desc *tydesc, - const type_desc **subtydescs, uint8_t *data_0, - uint8_t *data_1, uint8_t cmp_type); + uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type); struct s_cmp_type_args { int8_t *result; const type_desc *tydesc; - const type_desc **subtydescs; uint8_t *data_0; uint8_t *data_1; uint8_t cmp_type; @@ -458,16 +456,15 @@ struct s_cmp_type_args { extern "C" void upcall_s_cmp_type(s_cmp_type_args *args) { - shape_cmp_type(args->result, args->tydesc, args->subtydescs, + shape_cmp_type(args->result, args->tydesc, args->data_0, args->data_1, args->cmp_type); } extern "C" void upcall_cmp_type(int8_t *result, const type_desc *tydesc, - const type_desc **subtydescs, uint8_t *data_0, - uint8_t *data_1, uint8_t cmp_type) { + uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) { rust_task *task = rust_get_current_task(); - s_cmp_type_args args = {result, tydesc, subtydescs, + s_cmp_type_args args = {result, tydesc, data_0, data_1, cmp_type}; UPCALL_SWITCH_STACK(task, &args, upcall_s_cmp_type); } diff --git a/src/rt/rust_util.cpp b/src/rt/rust_util.cpp index 07f89ece6621..cd765184c1eb 100644 --- a/src/rt/rust_util.cpp +++ b/src/rt/rust_util.cpp @@ -15,21 +15,14 @@ uint8_t str_body_shape[] = { }; struct type_desc str_body_tydesc = { - 0, // unused 1, // size 1, // align NULL, // take_glue NULL, // drop_glue NULL, // free_glue NULL, // visit_glue - 0, // unused - 0, // unused - 0, // unused - 0, // unused str_body_shape, // shape &empty_shape_tables, // shape_tables - 0, // unused - 0, // unused }; // diff --git a/src/rustc/back/abi.rs b/src/rustc/back/abi.rs index 385d3c7cb316..d6c0c5fa2dd7 100644 --- a/src/rustc/back/abi.rs +++ b/src/rustc/back/abi.rs @@ -33,22 +33,15 @@ const box_field_body: uint = 4u; const general_code_alignment: uint = 16u; -const tydesc_field_first_param: uint = 0u; -const tydesc_field_size: uint = 1u; -const tydesc_field_align: uint = 2u; -const tydesc_field_take_glue: uint = 3u; -const tydesc_field_drop_glue: uint = 4u; -const tydesc_field_free_glue: uint = 5u; -const tydesc_field_visit_glue: uint = 6u; -const tydesc_field_sever_glue: uint = 7u; -const tydesc_field_mark_glue: uint = 8u; -const tydesc_field_unused2: uint = 9u; -const tydesc_field_unused_2: uint = 10u; -const tydesc_field_shape: uint = 11u; -const tydesc_field_shape_tables: uint = 12u; -const tydesc_field_n_params: uint = 13u; -const tydesc_field_obj_params: uint = 14u; // FIXME unused (#2351) -const n_tydesc_fields: uint = 15u; +const tydesc_field_size: uint = 0u; +const tydesc_field_align: uint = 1u; +const tydesc_field_take_glue: uint = 2u; +const tydesc_field_drop_glue: uint = 3u; +const tydesc_field_free_glue: uint = 4u; +const tydesc_field_visit_glue: uint = 5u; +const tydesc_field_shape: uint = 6u; +const tydesc_field_shape_tables: uint = 7u; +const n_tydesc_fields: uint = 8u; const cmp_glue_op_eq: uint = 0u; diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index b7ee7008d2f5..7e9ba91058af 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -86,7 +86,7 @@ fn declare_upcalls(targ_cfg: @session::config, cmp_type: dv("cmp_type", ~[T_ptr(T_i1()), T_ptr(tydesc_type), - T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), + T_ptr(T_i8()), T_ptr(T_i8()), T_i8()]), log_type: diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 54dc6bb7c6dd..05b17d1fbe7a 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -596,21 +596,14 @@ fn emit_tydescs(ccx: @crate_ctxt) { let tydesc = C_named_struct(ccx.tydesc_type, - ~[C_null(T_ptr(T_ptr(ccx.tydesc_type))), - ti.size, // size - ti.align, // align - take_glue, // take_glue - drop_glue, // drop_glue - free_glue, // free_glue - visit_glue, // visit_glue - C_int(ccx, 0), // unused - C_int(ccx, 0), // unused - C_int(ccx, 0), // unused - C_int(ccx, 0), // unused - C_shape(ccx, shape), // shape - shape_tables, // shape_tables - C_int(ccx, 0), // unused - C_int(ccx, 0)]); // unused + ~[ti.size, // size + ti.align, // align + take_glue, // take_glue + drop_glue, // drop_glue + free_glue, // free_glue + visit_glue, // visit_glue + C_shape(ccx, shape), // shape + shape_tables]); // shape_tables let gvar = ti.tydesc; llvm::LLVMSetInitializer(gvar, tydesc); @@ -1213,14 +1206,12 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, let llrawlhsptr = BitCast(bcx, lllhs, T_ptr(T_i8())); let llrawrhsptr = BitCast(bcx, llrhs, T_ptr(T_i8())); let lltydesc = get_tydesc_simple(bcx.ccx(), t); - let lltydescs = - Load(bcx, GEPi(bcx, lltydesc, ~[0u, abi::tydesc_field_first_param])); let llfn = bcx.ccx().upcalls.cmp_type; let llcmpresultptr = alloca(bcx, T_i1()); - Call(bcx, llfn, ~[llcmpresultptr, lltydesc, lltydescs, - llrawlhsptr, llrawrhsptr, llop]); + Call(bcx, llfn, ~[llcmpresultptr, lltydesc, + llrawlhsptr, llrawrhsptr, llop]); ret Load(bcx, llcmpresultptr); } diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index cd1161e055c9..b72d219e8248 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -660,10 +660,9 @@ fn T_tydesc(targ_cfg: @session::config) -> TypeRef { let int_type = T_int(targ_cfg); let elems = - ~[tydescpp, int_type, int_type, - glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, - int_type, int_type, int_type, int_type, - T_ptr(T_i8()), T_ptr(T_i8()), int_type, int_type]; + ~[int_type, int_type, + glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, + T_ptr(T_i8()), T_ptr(T_i8())]; set_struct_body(tydesc, elems); ret tydesc; } From a7897b3ef3a75852f0494d45887c45587317ed8c Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 9 Jul 2012 14:58:02 -0700 Subject: [PATCH 03/10] Eliminate some obsolete upcalls. --- src/rt/rust_upcall.cpp | 53 ---------------------------------------- src/rt/rustrt.def.in | 3 --- src/rustc/back/upcall.rs | 8 ------ 3 files changed, 64 deletions(-) diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 63b190b0a252..cae5ce45b549 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -335,59 +335,6 @@ upcall_str_new_shared(const char *cstr, size_t len) { } -struct s_vec_grow_args { - rust_task *task; - rust_vec_box** vp; - size_t new_sz; -}; - -extern "C" CDECL void -upcall_s_vec_grow(s_vec_grow_args *args) { - rust_task *task = args->task; - LOG_UPCALL_ENTRY(task); - reserve_vec(task, args->vp, args->new_sz); - (*args->vp)->body.fill = args->new_sz; -} - -extern "C" CDECL void -upcall_vec_grow(rust_vec_box** vp, size_t new_sz) { - rust_task *task = rust_get_current_task(); - s_vec_grow_args args = {task, vp, new_sz}; - UPCALL_SWITCH_STACK(task, &args, upcall_s_vec_grow); -} - -struct s_str_concat_args { - rust_task *task; - rust_vec_box* lhs; - rust_vec_box* rhs; - rust_vec_box* retval; -}; - -extern "C" CDECL void -upcall_s_str_concat(s_str_concat_args *args) { - rust_vec *lhs = &args->lhs->body; - rust_vec *rhs = &args->rhs->body; - rust_task *task = args->task; - size_t fill = lhs->fill + rhs->fill - 1; - rust_vec_box* v = (rust_vec_box*) - task->kernel->malloc(fill + sizeof(rust_vec_box), - "str_concat"); - v->header.td = args->lhs->header.td; - v->body.fill = v->body.alloc = fill; - memmove(&v->body.data[0], &lhs->data[0], lhs->fill - 1); - memmove(&v->body.data[lhs->fill - 1], &rhs->data[0], rhs->fill); - args->retval = v; -} - -extern "C" CDECL rust_vec_box* -upcall_str_concat(rust_vec_box* lhs, rust_vec_box* rhs) { - rust_task *task = rust_get_current_task(); - s_str_concat_args args = {task, lhs, rhs, 0}; - UPCALL_SWITCH_STACK(task, &args, upcall_s_str_concat); - return args.retval; -} - - extern "C" _Unwind_Reason_Code __gxx_personality_v0(int version, _Unwind_Action actions, diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index e674d6fa1977..c413628c82ab 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -76,11 +76,8 @@ upcall_validate_box upcall_log_type upcall_malloc upcall_rust_personality -upcall_vec_grow -upcall_str_new upcall_str_new_uniq upcall_str_new_shared -upcall_str_concat upcall_call_shim_on_c_stack upcall_call_shim_on_rust_stack upcall_new_stack diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index 7e9ba91058af..e95f7e39af46 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -16,10 +16,8 @@ type upcalls = exchange_free: ValueRef, validate_box: ValueRef, mark: ValueRef, - vec_grow: ValueRef, str_new_uniq: ValueRef, str_new_shared: ValueRef, - str_concat: ValueRef, cmp_type: ValueRef, log_type: ValueRef, alloc_c_stack: ValueRef, @@ -71,18 +69,12 @@ fn declare_upcalls(targ_cfg: @session::config, nothrow(dv("validate_box", ~[T_ptr(T_i8())])), mark: d("mark", ~[T_ptr(T_i8())], int_t), - vec_grow: - nothrow(dv("vec_grow", ~[T_ptr(T_ptr(T_i8())), int_t])), str_new_uniq: nothrow(d("str_new_uniq", ~[T_ptr(T_i8()), int_t], T_ptr(T_i8()))), str_new_shared: nothrow(d("str_new_shared", ~[T_ptr(T_i8()), int_t], T_ptr(T_i8()))), - str_concat: - nothrow(d("str_concat", ~[T_ptr(T_i8()), - T_ptr(T_i8())], - T_ptr(T_i8()))), cmp_type: dv("cmp_type", ~[T_ptr(T_i1()), T_ptr(tydesc_type), From 120773b2a7b6a1ca8ba859528f3e3cd9e574bf3d Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 9 Jul 2012 17:23:13 -0700 Subject: [PATCH 04/10] Change the interface of placement new to take a tydesc as part of Issue #2831. --- src/libcore/sys.rs | 4 +-- src/libstd/arena.rs | 12 +++++++-- src/rustc/middle/trans/base.rs | 25 ++++++++----------- src/rustc/middle/typeck/check.rs | 10 +++----- .../placement-new-bad-method-type.rs | 2 +- src/test/run-pass/placement-new-leaky.rs | 8 +++++- src/test/run-pass/regions-mock-trans-impls.rs | 8 +++++- 7 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 92913c3e28de..7f3e49de5510 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -10,8 +10,8 @@ export log_str; export lock_and_signal, condition, methods; enum type_desc = { - size: libc::size_t, - align: libc::size_t + size: uint, + align: uint // Remaining fields not listed }; diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index fed358d93881..65fcd0a59ca0 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -31,11 +31,11 @@ impl arena for arena { head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u)); self.chunks = @cons(head, self.chunks); - ret self.alloc(n_bytes, align); + ret self.alloc_inner(n_bytes, align); } #[inline(always)] - fn alloc(n_bytes: uint, align: uint) -> *() { + fn alloc_inner(n_bytes: uint, align: uint) -> *() { let alignm1 = align - 1u; let mut head = list::head(self.chunks); @@ -52,5 +52,13 @@ impl arena for arena { ret unsafe::reinterpret_cast(p); } } + + #[inline(always)] + fn alloc(tydesc: *()) -> *() { + unsafe { + let tydesc = tydesc as *sys::type_desc; + self.alloc_inner((*tydesc).size, (*tydesc).align) + } + } } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 05b17d1fbe7a..823795d9155c 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -3693,9 +3693,9 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { ret trans_assign_op(bcx, e, op, dst, src); } ast::expr_new(pool, alloc_id, val) { - // First, call pool->alloc(sz, align) to get back a void*. Then, - // cast this memory to the required type and evaluate value into - // it. + // First, call pool->alloc(tydesc) to get back a void*. + // Then, cast this memory to the required type and evaluate value + // into it. let ccx = bcx.ccx(); // Allocate space for the ptr that will be returned from @@ -3706,24 +3706,21 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { #debug["ptr_ty = %s", ppaux::ty_to_str(tcx, ptr_ty)]; #debug["ptr_ptr_val = %s", val_str(ccx.tn, ptr_ptr_val)]; - let void_ty = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), - mutbl: ast::m_imm}); - let voidval = { - let llvoid_ty = type_of(ccx, void_ty); - PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_ty)) - }; - + let void_ty = ty::mk_nil_ptr(tcx); + let llvoid_ty = type_of(ccx, void_ty); + let voidval = PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_ty)); #debug["voidval = %s", val_str(ccx.tn, voidval)]; - let llval_ty = type_of(ccx, expr_ty(bcx, val)); - let args = - ~[llsize_of(ccx, llval_ty), llalign_of(ccx, llval_ty)]; + let static_ti = get_tydesc(ccx, expr_ty(bcx, val)); + lazily_emit_all_tydesc_glue(ccx, static_ti); + let lltydesc = PointerCast(bcx, static_ti.tydesc, llvoid_ty); + let origin = bcx.ccx().maps.method_map.get(alloc_id); let bcx = trans_call_inner( bcx, e.info(), node_id_type(bcx, alloc_id), void_ty, |bcx| impl::trans_method_callee(bcx, alloc_id, pool, origin), - arg_vals(args), + arg_vals(~[lltydesc]), save_in(voidval)); #debug["dest = %s", dest_str(ccx, dest)]; diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index bd9230613d31..504023687dd6 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -1631,17 +1631,15 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, some(entry) { fcx.ccx.method_map.insert(alloc_id, entry); - // Check that the alloc() method has the expected type, which - // should be fn(sz: uint, align: uint) -> *(). + // Check that the alloc() method has the expected + // type, which should be fn(tydesc: *()) -> *(). let expected_ty = { - let ty_uint = ty::mk_uint(tcx); let ty_nilp = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm}); - let m = ast::expl(ty::default_arg_mode_for_ty(ty_uint)); + let m = ast::expl(ty::default_arg_mode_for_ty(ty_nilp)); ty::mk_fn(tcx, {purity: ast::impure_fn, proto: ast::proto_any, - inputs: ~[{mode: m, ty: ty_uint}, - {mode: m, ty: ty_uint}], + inputs: ~[{mode: m, ty: ty_nilp}], output: ty_nilp, ret_style: ast::return_val, constraints: ~[]}) diff --git a/src/test/compile-fail/placement-new-bad-method-type.rs b/src/test/compile-fail/placement-new-bad-method-type.rs index 10db67161d18..2126a6bddc6b 100644 --- a/src/test/compile-fail/placement-new-bad-method-type.rs +++ b/src/test/compile-fail/placement-new-bad-method-type.rs @@ -11,5 +11,5 @@ impl methods for malloc_pool { fn main() { let p = &malloc_pool(()); let x = new(*p) 4u; - //~^ ERROR mismatched types: expected `fn(uint, uint) -> *()` + //~^ ERROR mismatched types: expected `fn(*()) -> *()` } diff --git a/src/test/run-pass/placement-new-leaky.rs b/src/test/run-pass/placement-new-leaky.rs index d33e9311a291..85363c432e0d 100644 --- a/src/test/run-pass/placement-new-leaky.rs +++ b/src/test/run-pass/placement-new-leaky.rs @@ -3,11 +3,17 @@ import libc, unsafe; enum malloc_pool = (); impl methods for malloc_pool { - fn alloc(sz: uint, align: uint) -> *() { + fn alloc_inner(sz: uint, align: uint) -> *() { unsafe { unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t)) } } + fn alloc(tydesc: *()) -> *() { + unsafe { + let tydesc = tydesc as *sys::type_desc; + self.alloc_inner((*tydesc).size, (*tydesc).align) + } + } } fn main() { diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index 077ca3d51ed3..cdd8033a1d19 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -16,9 +16,15 @@ type ccx = { }; impl arena for arena { - fn alloc(sz: uint, _align: uint) -> *() unsafe { + fn alloc_inner(sz: uint, _align: uint) -> *() unsafe { ret unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t)); } + fn alloc(tydesc: *()) -> *() { + unsafe { + let tydesc = tydesc as *sys::type_desc; + self.alloc_inner((*tydesc).size, (*tydesc).align) + } + } } fn h(bcx : &bcx) -> &bcx { From 62e9ae04e26f60124f6760df26b517bce450ae41 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 9 Jul 2012 17:39:22 -0700 Subject: [PATCH 05/10] Remove obsolete type param field from shape information. --- src/rt/rust_shape.h | 8 -------- src/rustc/middle/trans/shape.rs | 8 -------- 2 files changed, 16 deletions(-) diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index 26f775c9fac1..b0f021287c06 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -407,10 +407,6 @@ ctxt::walk_tag0() { // Determine the size and alignment. tinfo.tag_sa = get_size_align(tinfo.info_ptr); - // 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); } @@ -489,10 +485,6 @@ ctxt::walk_res0() { reinterpret_cast(tables->resources); const rust_fn *dtor = resources[dtor_offset]; - // 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 && "resource has type parameters on it"); - uint16_t sp_size = get_u16_bump(sp); const uint8_t *end_sp = sp + sp_size; diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index da37a59dc093..f6be67b1512b 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -250,10 +250,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { } add_u16(s, id as u16); - // Hack: always encode 0 tps, since the shape glue format - // hasn't changed since we started monomorphizing. - add_u16(s, 0_u16); - s } } @@ -342,10 +338,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { let ri = @{did: dtor_did, parent_id: some(did), tps: tps}; let id = interner::intern(ccx.shape_cx.resources, ri); add_u16(s, id as u16); - - // Hack: always encode 0 tps, since the shape glue format - // hasn't changed since we started monomorphizing. - add_u16(s, 0_u16); }; for ty::class_items_as_mutable_fields(ccx.tcx, did, substs).each |f| { sub += shape_of(ccx, f.mt.ty); From b569bdec9fc6637ae35148caad4823906a7829b4 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Wed, 11 Jul 2012 20:04:42 -0700 Subject: [PATCH 06/10] Refactor how we convert vstore ast types to ty types. --- src/rustc/middle/typeck/astconv.rs | 41 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index b171f9fc0414..6376d7d882ac 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -161,31 +161,30 @@ fn ast_ty_to_ty( self: AC, rscope: RS, a_seq_ty: @ast::ty, vst: ty::vstore) -> ty::t { let tcx = self.tcx(); - let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty); - alt ty::get(seq_ty).struct { - ty::ty_vec(mt) { - ret ty::mk_evec(tcx, mt, vst); + alt a_seq_ty.node { + ast::ty_vec(mt) { + ret ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst); } - - // HACK: if we get a ~[], we assume that it was actually a - // [] that got written down, and we throw away the /~... - ty::ty_evec(mt, vstore_uniq) { - ret ty::mk_evec(tcx, mt, vst); - } - - ty::ty_str { - ret ty::mk_estr(tcx, vst); - } - - _ { - tcx.sess.span_err( - a_seq_ty.span, - #fmt["bound not allowed on a %s", - ty::ty_sort_str(tcx, seq_ty)]); - ret seq_ty; + ast::ty_path(path, id) { + alt tcx.def_map.find(id) { + some(ast::def_prim_ty(ast::ty_str)) { + check_path_args(tcx, path, NO_TPS | NO_REGIONS); + ret ty::mk_estr(tcx, vst); + } + _ {} + } } + _ {} } + + // Get the type, just for the error message + let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty); + tcx.sess.span_err( + a_seq_ty.span, + #fmt["bound not allowed on a %s", + ty::ty_sort_str(tcx, seq_ty)]); + ret seq_ty; } fn check_path_args(tcx: ty::ctxt, From 7b265035661daefd7d30f05896a748e55bb561b0 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Wed, 11 Jul 2012 19:31:15 -0700 Subject: [PATCH 07/10] Make str be treated as str/~. --- src/rustc/middle/ty.rs | 2 +- src/rustc/middle/typeck.rs | 2 +- src/test/compile-fail/bad-const-type.rs | 2 +- src/test/compile-fail/binop-bitxor-str.rs | 2 +- src/test/compile-fail/fail-type-err.rs | 2 +- src/test/compile-fail/map-types.rs | 2 +- src/test/compile-fail/minus-string.rs | 2 +- src/test/compile-fail/missing-do.rs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index f4febfa05120..f24c382eb9e3 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -652,7 +652,7 @@ fn mk_mach_float(cx: ctxt, tm: ast::float_ty) -> t { mk_t(cx, ty_float(tm)) } fn mk_char(cx: ctxt) -> t { mk_t(cx, ty_int(ast::ty_char)) } -fn mk_str(cx: ctxt) -> t { mk_t(cx, ty_str) } +fn mk_str(cx: ctxt) -> t { mk_estr(cx, vstore_uniq) } fn mk_estr(cx: ctxt, t: vstore) -> t { mk_t(cx, ty_estr(t)) diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 1e198f0f82e2..4f74da96b77c 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -223,7 +223,7 @@ fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool { ty::ty_evec(mt, vstore_uniq) { if mt.mutbl != ast::m_imm { ret false; } alt ty::get(mt.ty).struct { - ty::ty_str { ret true; } + ty::ty_estr(vstore_uniq) { ret true; } _ { ret false; } } } diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs index f5f788a2458a..8b86db098e51 100644 --- a/src/test/compile-fail/bad-const-type.rs +++ b/src/test/compile-fail/bad-const-type.rs @@ -1,4 +1,4 @@ -// error-pattern:expected `str` but found `int` +// error-pattern:expected `str/~` but found `int` const i: str = 10i; fn main() { log(debug, i); } diff --git a/src/test/compile-fail/binop-bitxor-str.rs b/src/test/compile-fail/binop-bitxor-str.rs index 65e0996fa627..53bb7d8f53d9 100644 --- a/src/test/compile-fail/binop-bitxor-str.rs +++ b/src/test/compile-fail/binop-bitxor-str.rs @@ -1,3 +1,3 @@ -// error-pattern:^ cannot be applied to type `str` +// error-pattern:^ cannot be applied to type `str/~` fn main() { let x = "a" ^ "b"; } diff --git a/src/test/compile-fail/fail-type-err.rs b/src/test/compile-fail/fail-type-err.rs index eb44ccf413c0..3f9bda61c80e 100644 --- a/src/test/compile-fail/fail-type-err.rs +++ b/src/test/compile-fail/fail-type-err.rs @@ -1,2 +1,2 @@ -// error-pattern:expected `str` but found `~[int]` +// error-pattern:expected `str/~` but found `~[int]` fn main() { fail ~[0i]; } diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index 084cbf9529c0..9386c1526484 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -8,5 +8,5 @@ import std::map::map; fn main() { let x: map = map::str_hash::() as map::; let y: map = x; - //~^ ERROR mismatched types: expected `std::map::map` + //~^ ERROR mismatched types: expected `std::map::map` } diff --git a/src/test/compile-fail/minus-string.rs b/src/test/compile-fail/minus-string.rs index 27ed51852a4d..043d46f121b5 100644 --- a/src/test/compile-fail/minus-string.rs +++ b/src/test/compile-fail/minus-string.rs @@ -1,3 +1,3 @@ -// error-pattern:cannot apply unary operator `-` to type `str` +// error-pattern:cannot apply unary operator `-` to type `str/~` fn main() { -"foo"; } diff --git a/src/test/compile-fail/missing-do.rs b/src/test/compile-fail/missing-do.rs index 23905d14ffa0..31595875058e 100644 --- a/src/test/compile-fail/missing-do.rs +++ b/src/test/compile-fail/missing-do.rs @@ -3,7 +3,7 @@ fn foo(f: fn()) { f() } fn main() { - "" || 42; //~ ERROR binary operation || cannot be applied to type `str` + "" || 42; //~ ERROR binary operation || cannot be applied to type `str/~` foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn())` //~^ NOTE did you forget the 'do' keyword for the call? } From 8ad4e92c2bf1b40f88c4bad4b8c1243c13d16af6 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Thu, 12 Jul 2012 00:01:41 -0700 Subject: [PATCH 08/10] Handle autoserializing of str/~. --- src/libsyntax/ext/auto_serialize.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 64da3a7dcbdb..0ad0b2dc64d1 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -459,7 +459,6 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, ~[] } - ast::ty_vstore(@{node: ast::ty_vec(mt),_}, ast::vstore_uniq) | ast::ty_vec(mt) { let ser_e = cx.expr( @@ -477,6 +476,11 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, }] } + // For unique vstores, just pass through to the underlying vec or str + ast::ty_vstore(ty, ast::vstore_uniq) { + ser_ty(cx, tps, ty, s, v) + } + ast::ty_vstore(_, _) { cx.span_unimpl(ty.span, "serialization for vstore types"); } @@ -685,12 +689,16 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, #ast{ fail } } - ast::ty_vstore(@{node: ast::ty_vec(mt),_}, ast::vstore_uniq) | ast::ty_vec(mt) { let l = deser_lambda(cx, tps, mt.ty, cx.clone(d)); #ast{ std::serialization::read_to_vec($(d), $(l)) } } + // For unique vstores, just pass through to the underlying vec or str + ast::ty_vstore(ty, ast::vstore_uniq) { + deser_ty(cx, tps, ty, d) + } + ast::ty_vstore(_, _) { cx.span_unimpl(ty.span, "deserialization for vstore types"); } From f219d978b0fb7fe29c7e1bf3500d64df428f3b05 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Thu, 12 Jul 2012 10:10:14 -0700 Subject: [PATCH 09/10] Register snapshots. --- src/snapshots.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/snapshots.txt b/src/snapshots.txt index a6cc6181880d..a99a9f39a814 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +S 2012-07-12 8ad4e92 + macos-i386 b31efba34f0af7ce527adc49cd345548da528ccf + macos-x86_64 ef82309eb8ba269091fbe5f41a1e28fa3c6da90e + freebsd-x86_64 2a6471cf27a9d03637b96aa12f39736f663312e3 + linux-i386 94f77c50d753816df8c42608054a8cc3112ef34c + linux-x86_64 6d95183ceace8ae009b0d43a8df3a9cf13ad85a2 + winnt-i386 90edcaf74134a12d656898605c67551931830fcd + S 2012-07-06 b5f5676 macos-i386 c0f36f05f84696b98243046d0ebcb0fcc84995e7 macos-x86_64 b2bc7ba068de0ca426dfe7ae018ae3c6442fc0a5 From a8db1bd4ef3d2464b3a13c049491f25e6a4aaa32 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Thu, 12 Jul 2012 10:10:54 -0700 Subject: [PATCH 10/10] Switch back to not using snapshot libs. --- mk/target.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mk/target.mk b/mk/target.mk index b53a8ca80109..5ddc825d335b 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -8,9 +8,9 @@ # (resp. corelib), set this flag to 1. It will cause stage1 to use # the snapshot runtime (resp. corelib) rather than the runtime # (resp. corelib) from the working directory. -USE_SNAPSHOT_RUNTIME=1 -USE_SNAPSHOT_CORELIB=1 -USE_SNAPSHOT_STDLIB=1 +USE_SNAPSHOT_RUNTIME=0 +USE_SNAPSHOT_CORELIB=0 +USE_SNAPSHOT_STDLIB=0 define TARGET_STAGE_N