Skip to content

Commit 149e77b

Browse files
committed
---
yaml --- r: 4407 b: refs/heads/master c: 2a3235b h: refs/heads/master i: 4405: df3899c 4403: 1163c13 4399: c7160f4 v: v3
1 parent b70903e commit 149e77b

File tree

4 files changed

+60
-52
lines changed

4 files changed

+60
-52
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 0e70332b295d72e9b70e5db59382e507a416b8e8
2+
refs/heads/master: 2a3235b58c86d289753691ee9fbe2af15d601e43

trunk/src/comp/back/abi.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,21 @@ const vec_elt_pad: int = 3;
4747
const vec_elt_data: int = 4;
4848

4949
const tydesc_field_first_param: int = 0;
50-
5150
const tydesc_field_size: int = 1;
52-
5351
const tydesc_field_align: int = 2;
54-
5552
const tydesc_field_copy_glue: int = 3;
56-
5753
const tydesc_field_drop_glue: int = 4;
58-
5954
const tydesc_field_free_glue: int = 5;
60-
6155
const tydesc_field_sever_glue: int = 6;
62-
6356
const tydesc_field_mark_glue: int = 7;
64-
65-
6657
// FIXME no longer used in rustc, drop when rustboot is gone
6758
const tydesc_field_obj_drop_glue: int = 8;
68-
6959
const tydesc_field_is_stateful: int = 9;
70-
7160
const tydesc_field_cmp_glue: int = 10;
72-
73-
const n_tydesc_fields: int = 11;
61+
const tydesc_field_shape: int = 11;
62+
const tydesc_field_shape_tables: int = 12;
63+
const tydesc_field_n_params: int = 13;
64+
const n_tydesc_fields: int = 14;
7465

7566
const cmp_glue_op_eq: uint = 0u;
7667

trunk/src/comp/middle/trans.rs

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,8 @@ fn linearize_ty_params(cx: &@block_ctxt, t: &ty::t) ->
895895

896896
fn trans_stack_local_derived_tydesc(cx: &@block_ctxt, llsz: ValueRef,
897897
llalign: ValueRef, llroottydesc: ValueRef,
898-
llparamtydescs: ValueRef) -> ValueRef {
898+
llparamtydescs: ValueRef,
899+
n_params: uint) -> ValueRef {
899900
let llmyroottydesc = alloca(cx, bcx_ccx(cx).tydesc_type);
900901
// By convention, desc 0 is the root descriptor.
901902

@@ -904,11 +905,14 @@ fn trans_stack_local_derived_tydesc(cx: &@block_ctxt, llsz: ValueRef,
904905
// Store a pointer to the rest of the descriptors.
905906

906907
let llfirstparam = cx.build.GEP(llparamtydescs, ~[C_int(0), C_int(0)]);
907-
cx.build.Store(llfirstparam,
908-
cx.build.GEP(llmyroottydesc, ~[C_int(0), C_int(0)]));
909-
cx.build.Store(llsz, cx.build.GEP(llmyroottydesc, ~[C_int(0), C_int(1)]));
910-
cx.build.Store(llalign,
911-
cx.build.GEP(llmyroottydesc, ~[C_int(0), C_int(2)]));
908+
store_inbounds(cx, llfirstparam, llmyroottydesc,
909+
~[C_int(0), C_int(abi::tydesc_field_first_param)]);
910+
store_inbounds(cx, C_uint(n_params), llmyroottydesc,
911+
~[C_int(0), C_int(abi::tydesc_field_n_params)]);
912+
store_inbounds(cx, llsz, llmyroottydesc,
913+
~[C_int(0), C_int(abi::tydesc_field_size)]);
914+
store_inbounds(cx, llalign, llmyroottydesc,
915+
~[C_int(0), C_int(abi::tydesc_field_align)]);
912916
ret llmyroottydesc;
913917
}
914918

@@ -964,7 +968,8 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool,
964968
v = td_val;
965969
} else {
966970
let llparamtydescs =
967-
alloca(bcx, T_array(T_ptr(bcx_ccx(bcx).tydesc_type), n_params));
971+
alloca(bcx, T_array(T_ptr(bcx_ccx(bcx).tydesc_type),
972+
n_params + 1u));
968973
let i = 0;
969974
for td: ValueRef in tys.descs {
970975
let tdp = bcx.build.GEP(llparamtydescs, ~[C_int(0), C_int(i)]);
@@ -973,7 +978,7 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool,
973978
}
974979
v =
975980
trans_stack_local_derived_tydesc(bcx, sz.val, align.val, root,
976-
llparamtydescs);
981+
llparamtydescs, n_params);
977982
}
978983
bcx.fcx.derived_tydescs.insert(t, {lltydesc: v, escapes: escapes});
979984
ret rslt(cx, v);
@@ -1191,20 +1196,28 @@ fn emit_tydescs(ccx: &@crate_ctxt) {
11911196
none. { ccx.stats.n_null_glues += 1u; C_null(cmp_fn_ty) }
11921197
some(v) { ccx.stats.n_real_glues += 1u; v }
11931198
};
1194-
let // copy_glue
1195-
// drop_glue
1196-
// free_glue
1197-
// sever_glue
1198-
// mark_glue
1199-
// obj_drop_glue
1200-
// is_stateful
1201-
tydesc =
1199+
1200+
let shape = shape::shape_of(ccx, pair.key);
1201+
let shape_tables =
1202+
llvm::LLVMConstPointerCast(ccx.shape_cx.llshapetables,
1203+
T_ptr(T_i8()));
1204+
1205+
let tydesc =
12021206
C_named_struct(ccx.tydesc_type,
1203-
~[C_null(T_ptr(T_ptr(ccx.tydesc_type))), ti.size,
1204-
ti.align, copy_glue, drop_glue, free_glue,
1205-
C_null(glue_fn_ty), C_null(glue_fn_ty),
1206-
C_null(glue_fn_ty), C_null(glue_fn_ty),
1207-
cmp_glue]); // cmp_glue
1207+
~[C_null(T_ptr(T_ptr(ccx.tydesc_type))),
1208+
ti.size, // size
1209+
ti.align, // align
1210+
copy_glue, // copy_glue
1211+
drop_glue, // drop_glue
1212+
free_glue, // free_glue
1213+
C_null(glue_fn_ty), // sever_glue
1214+
C_null(glue_fn_ty), // mark_glue
1215+
C_null(glue_fn_ty), // obj_drop_glue
1216+
C_null(glue_fn_ty), // is_stateful
1217+
cmp_glue, // cmp_glue
1218+
C_shape(ccx, shape), // shape
1219+
shape_tables, // shape_tables
1220+
C_int(0)]); // n_params
12081221

12091222
let gvar = ti.tydesc;
12101223
llvm::LLVMSetInitializer(gvar, tydesc);
@@ -2288,16 +2301,17 @@ fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t,
22882301
let ti = none[@tydesc_info];
22892302
let r = get_tydesc(cx, t, false, ti);
22902303
lazily_emit_tydesc_glue(cx, abi::tydesc_field_cmp_glue, ti);
2304+
let lltydesc = r.val;
22912305
let lltydescs =
2292-
r.bcx.build.GEP(r.val,
2306+
r.bcx.build.GEP(lltydesc,
22932307
~[C_int(0), C_int(abi::tydesc_field_first_param)]);
22942308
lltydescs = r.bcx.build.Load(lltydescs);
22952309

22962310
let llfn;
22972311
alt ti {
22982312
none. {
22992313
let llfnptr =
2300-
r.bcx.build.GEP(r.val,
2314+
r.bcx.build.GEP(lltydesc,
23012315
~[C_int(0), C_int(abi::tydesc_field_cmp_glue)]);
23022316
llfn = r.bcx.build.Load(llfnptr);
23032317
}
@@ -2306,7 +2320,7 @@ fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t,
23062320

23072321
let llcmpresultptr = alloca(r.bcx, T_i1());
23082322
let llargs: ValueRef[] =
2309-
~[llcmpresultptr, r.bcx.fcx.lltaskptr, C_null(T_ptr(T_nil())),
2323+
~[llcmpresultptr, r.bcx.fcx.lltaskptr, lltydesc,
23102324
lltydescs, llrawlhsptr, llrawrhsptr, llop];
23112325
r.bcx.build.Call(llfn, llargs);
23122326
ret rslt(r.bcx, r.bcx.build.Load(llcmpresultptr));
@@ -8000,8 +8014,9 @@ fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt,
80008014
trans_mod(cx, crate.node.module);
80018015
create_crate_map(ccx);
80028016
emit_tydescs(ccx);
8003-
// Translate the metadata:
8017+
shape::gen_shape_tables(ccx);
80048018

8019+
// Translate the metadata.
80058020
write_metadata(cx.ccx, crate);
80068021
if ccx.sess.get_opts().stats {
80078022
log_err "--- trans stats ---";

trunk/src/comp/middle/trans_common.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -597,22 +597,13 @@ fn T_tydesc(taskptr_type: TypeRef) -> TypeRef {
597597
T_ptr(T_fn(~[T_ptr(T_nil()), taskptr_type, T_ptr(T_nil()), tydescpp,
598598
pvoid], T_void()));
599599
let cmp_glue_fn_ty =
600-
T_ptr(T_fn(~[T_ptr(T_i1()), taskptr_type, T_ptr(T_nil()), tydescpp,
600+
T_ptr(T_fn(~[T_ptr(T_i1()), taskptr_type, T_ptr(tydesc), tydescpp,
601601
pvoid, pvoid, T_i8()], T_void()));
602602

603-
let // first_param
604-
// size
605-
// align
606-
// copy_glue
607-
// drop_glue
608-
// free_glue
609-
// sever_glue
610-
// mark_glue
611-
// obj_drop_glue
612-
// is_stateful
613-
elems =
603+
let elems =
614604
~[tydescpp, T_int(), T_int(), glue_fn_ty, glue_fn_ty, glue_fn_ty,
615-
glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, cmp_glue_fn_ty];
605+
glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, cmp_glue_fn_ty,
606+
T_ptr(T_i8()), T_ptr(T_i8()), T_int()];
616607
set_struct_body(tydesc, elems);
617608
ret tydesc;
618609
}
@@ -874,3 +865,14 @@ fn C_bytes(bytes : &u8[]) -> ValueRef {
874865
ivec::len(bytes), False);
875866
}
876867

868+
fn C_shape(ccx : &@crate_ctxt, bytes : &u8[]) -> ValueRef {
869+
let llshape = C_bytes(bytes);
870+
let llglobal = llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape),
871+
str::buf(ccx.names.next("shape")));
872+
llvm::LLVMSetInitializer(llglobal, llshape);
873+
llvm::LLVMSetGlobalConstant(llglobal, True);
874+
llvm::LLVMSetLinkage(llglobal,
875+
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
876+
ret llvm::LLVMConstPointerCast(llglobal, T_ptr(T_i8()));
877+
}
878+

0 commit comments

Comments
 (0)