Merge branch 'rt-changes' into incoming

This commit is contained in:
Michael Sullivan
2012-07-12 10:28:43 -07:00
28 changed files with 116 additions and 204 deletions

View File

@@ -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;

View File

@@ -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,22 +69,16 @@ 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),
T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()),
T_ptr(T_i8()),
T_ptr(T_i8()),
T_i8()]),
log_type:

View File

@@ -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);
}
@@ -3702,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
@@ -3715,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)];

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -658,7 +658,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))

View File

@@ -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; }
}
}

View File

@@ -164,31 +164,30 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
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,

View File

@@ -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: ~[]})