Skip to content

Commit d6a2afc

Browse files
committed
---
yaml --- r: 11862 b: refs/heads/master c: 4511f93 h: refs/heads/master v: v3
1 parent bd85f79 commit d6a2afc

File tree

9 files changed

+137
-322
lines changed

9 files changed

+137
-322
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 168398bb3dc01f8efecf734342af60a959a74b8d
2+
refs/heads/master: 4511f936b1b4766962d01a80f6887eecb30e89f9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/metadata/astencode.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,14 @@ fn encode_dict_origin(ecx: @e::encode_ctxt,
548548
}
549549
}
550550
}
551-
typeck::dict_iface(def_id) {
551+
typeck::dict_iface(def_id, tys) {
552552
ebml_w.emit_enum_variant("dict_iface", 1u, 3u) {||
553553
ebml_w.emit_enum_variant_arg(0u) {||
554554
ebml_w.emit_def_id(def_id)
555555
}
556+
ebml_w.emit_enum_variant_arg(1u) {||
557+
ebml_w.emit_tys(ecx, tys);
558+
}
556559
}
557560
}
558561
}
@@ -596,6 +599,9 @@ impl helpers for ebml::ebml_deserializer {
596599
typeck::dict_iface(
597600
self.read_enum_variant_arg(0u) {||
598601
self.read_def_id(xcx)
602+
},
603+
self.read_enum_variant_arg(1u) {||
604+
self.read_tys(xcx)
599605
}
600606
)
601607
}

trunk/src/rustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ fn get_impl_iface(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
258258
}
259259

260260
fn get_impl_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
261-
let items = ebml::get_doc(ebml::new_doc(cdata.data), tag_items);
261+
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
262262
let found = none;
263263
ebml::tagged_docs(find_item(id, items), tag_item_method) {|mid|
264264
let m_did = parse_def_id(ebml::doc_data(mid));

trunk/src/rustc/middle/trans/base.rs

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,7 +2070,6 @@ enum callee_env {
20702070
null_env,
20712071
is_closure,
20722072
self_env(ValueRef, ty::t),
2073-
dict_env(ValueRef, ValueRef),
20742073
}
20752074
type lval_maybe_callee = {bcx: block,
20762075
val: ValueRef,
@@ -2117,8 +2116,8 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, substs: [ty::t],
21172116
}
21182117
});
21192118
let hash_id = @{def: fn_id, substs: substs, dicts: alt dicts {
2120-
some(os) { vec::map(*os, {|o| impl::dict_id(ccx.tcx, o)}) }
2121-
none { [] }
2119+
some(os) { some_dicts(vec::map(*os, impl::vtable_id)) }
2120+
none { no_dicts }
21222121
}};
21232122
alt ccx.monomorphized.find(hash_id) {
21242123
some(val) { ret some(val); }
@@ -2258,10 +2257,8 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id,
22582257
none {
22592258
alt ccx.maps.dict_map.find(id) {
22602259
some(dicts) {
2261-
alt impl::resolve_dicts_in_fn_ctxt(bcx.fcx, dicts) {
2262-
some(dicts) { monomorphic_fn(ccx, fn_id, tys, some(dicts)) }
2263-
none { none }
2264-
}
2260+
let rdicts = impl::resolve_vtables_in_fn_ctxt(bcx.fcx, dicts);
2261+
monomorphic_fn(ccx, fn_id, tys, some(rdicts))
22652262
}
22662263
none { monomorphic_fn(ccx, fn_id, tys, none) }
22672264
}
@@ -2567,7 +2564,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
25672564

25682565
fn lval_maybe_callee_to_lval(c: lval_maybe_callee, ty: ty::t) -> lval_result {
25692566
let must_bind = alt c.generic { generic_full(_) { true } _ { false } } ||
2570-
alt c.env { self_env(_, _) | dict_env(_, _) { true } _ { false } };
2567+
alt c.env { self_env(_, _) { true } _ { false } };
25712568
if must_bind {
25722569
let n_args = ty::ty_fn_args(ty).len();
25732570
let args = vec::from_elem(n_args, none);
@@ -2779,28 +2776,7 @@ fn trans_args(cx: block, llenv: ValueRef,
27792776

27802777
let retty = ty::ty_fn_ret(fn_ty), full_retty = retty;
27812778
alt gen {
2782-
generic_full(g) {
2783-
lazily_emit_all_generic_info_tydesc_glues(ccx, g);
2784-
let i = 0u, n_orig = 0u;
2785-
for param in *g.param_bounds {
2786-
lltydescs += [g.tydescs[i]];
2787-
for bound in *param {
2788-
alt bound {
2789-
ty::bound_iface(_) {
2790-
let res = impl::get_dict(
2791-
bcx, option::get(g.origins)[n_orig]);
2792-
lltydescs += [res.val];
2793-
bcx = res.bcx;
2794-
n_orig += 1u;
2795-
}
2796-
_ {}
2797-
}
2798-
}
2799-
i += 1u;
2800-
}
2801-
args = ty::ty_fn_args(g.item_type);
2802-
retty = ty::ty_fn_ret(g.item_type);
2803-
}
2779+
generic_full(g) { fail; }
28042780
generic_mono(t) {
28052781
args = ty::ty_fn_args(t);
28062782
retty = ty::ty_fn_ret(t);
@@ -2884,17 +2860,12 @@ fn trans_call_inner(in_cx: block, fn_expr_ty: ty::t,
28842860
let bcx = f_res.bcx, ccx = cx.ccx();
28852861

28862862
let faddr = f_res.val;
2887-
let llenv, dict_param = none;
2888-
alt f_res.env {
2863+
let llenv = alt f_res.env {
28892864
null_env {
2890-
llenv = llvm::LLVMGetUndef(T_opaque_box_ptr(ccx));
2865+
llvm::LLVMGetUndef(T_opaque_box_ptr(ccx))
28912866
}
28922867
self_env(e, _) {
2893-
llenv = PointerCast(bcx, e, T_opaque_box_ptr(ccx));
2894-
}
2895-
dict_env(dict, e) {
2896-
llenv = PointerCast(bcx, e, T_opaque_box_ptr(ccx));
2897-
dict_param = some(dict);
2868+
PointerCast(bcx, e, T_opaque_box_ptr(ccx))
28982869
}
28992870
is_closure {
29002871
// It's a closure. Have to fetch the elements
@@ -2905,16 +2876,15 @@ fn trans_call_inner(in_cx: block, fn_expr_ty: ty::t,
29052876
faddr = GEPi(bcx, pair, [0, abi::fn_field_code]);
29062877
faddr = Load(bcx, faddr);
29072878
let llclosure = GEPi(bcx, pair, [0, abi::fn_field_box]);
2908-
llenv = Load(bcx, llclosure);
2879+
Load(bcx, llclosure)
29092880
}
2910-
}
2881+
};
29112882

29122883
let ret_ty = node_id_type(bcx, id);
29132884
let args_res =
29142885
trans_args(bcx, llenv, f_res.generic, args, fn_expr_ty, dest);
29152886
bcx = args_res.bcx;
29162887
let llargs = args_res.args;
2917-
option::may(dict_param) {|dict| llargs = [dict] + llargs}
29182888
let llretslot = args_res.retslot;
29192889

29202890
/* If the block is terminated,
@@ -2955,6 +2925,10 @@ fn invoke_(bcx: block, llfn: ValueRef, llargs: [ValueRef],
29552925
// cleanups to run
29562926
if bcx.unreachable { ret bcx; }
29572927
let normal_bcx = sub_block(bcx, "normal return");
2928+
/*std::io::println("fn: " + lib::llvm::type_to_str(bcx.ccx().tn, val_ty(llfn)));
2929+
for a in llargs {
2930+
std::io::println(" a: " + lib::llvm::type_to_str(bcx.ccx().tn, val_ty(a)));
2931+
}*/
29582932
invoker(bcx, llfn, llargs, normal_bcx.llbb, get_landing_pad(bcx));
29592933
ret normal_bcx;
29602934
}
@@ -4791,16 +4765,6 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
47914765
i += 1;
47924766
}
47934767
}
4794-
ast::item_impl(tps, some(@{node: ast::ty_path(_, id), _}), _, ms) {
4795-
let i_did = ast_util::def_id_of_def(ccx.tcx.def_map.get(id));
4796-
impl::trans_impl_vtable(ccx, item_path(ccx, it), i_did, ms, tps, it);
4797-
}
4798-
ast::item_iface(_, _) {
4799-
if !vec::any(*ty::iface_methods(ccx.tcx, local_def(it.id)), {|m|
4800-
ty::type_has_vars(ty::mk_fn(ccx.tcx, m.fty))}) {
4801-
impl::trans_iface_vtable(ccx, item_path(ccx, it), it);
4802-
}
4803-
}
48044768
_ { }
48054769
}
48064770
}
@@ -5032,9 +4996,9 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
50324996
discrims: ast_util::new_def_id_hash::<ValueRef>(),
50334997
discrim_symbols: int_hash::<str>(),
50344998
tydescs: ty::new_ty_hash(),
5035-
dicts: map::hashmap(hash_dict_id, {|a, b| a == b}),
50364999
external: util::common::new_def_hash(),
50375000
monomorphized: map::hashmap(hash_mono_id, {|a, b| a == b}),
5001+
vtables: map::hashmap(hash_mono_id, {|a, b| a == b}),
50385002
module_data: str_hash::<ValueRef>(),
50395003
lltypes: ty::new_ty_hash(),
50405004
names: new_namegen(),

trunk/src/rustc/middle/trans/closure.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -515,26 +515,7 @@ fn trans_bind_1(cx: block, outgoing_fty: ty::t,
515515

516516
// Figure out which tydescs we need to pass, if any.
517517
let (outgoing_fty_real, lltydescs, param_bounds) = alt f_res.generic {
518-
generic_full(ginfo) {
519-
let tds = [], orig = 0u;
520-
vec::iter2(ginfo.tydescs, *ginfo.param_bounds) {|td, bounds|
521-
tds += [td];
522-
for bound in *bounds {
523-
alt bound {
524-
ty::bound_iface(_) {
525-
let dict = impl::get_dict(
526-
bcx, option::get(ginfo.origins)[orig]);
527-
tds += [PointerCast(bcx, dict.val, val_ty(td))];
528-
orig += 1u;
529-
bcx = dict.bcx;
530-
}
531-
_ {}
532-
}
533-
}
534-
}
535-
lazily_emit_all_generic_info_tydesc_glues(ccx, ginfo);
536-
(ginfo.item_type, tds, ginfo.param_bounds)
537-
}
518+
generic_full(ginfo) { fail; }
538519
_ { (outgoing_fty, [], @[]) }
539520
};
540521

@@ -560,9 +541,6 @@ fn trans_bind_1(cx: block, outgoing_fty: ty::t,
560541
self_env(slf, slf_t) {
561542
([env_copy(slf, slf_t, owned)], target_self(f_res.val))
562543
}
563-
dict_env(_, _) {
564-
ccx.sess.unimpl("binding of dynamic method calls");
565-
}
566544
};
567545

568546
// Actually construct the closure

trunk/src/rustc/middle/trans/common.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ type crate_ctxt = {
9090
discrims: hashmap<ast::def_id, ValueRef>,
9191
discrim_symbols: hashmap<ast::node_id, str>,
9292
tydescs: hashmap<ty::t, @tydesc_info>,
93-
dicts: hashmap<dict_id, ValueRef>,
9493
// Track mapping of external ids to local items imported for inlining
9594
external: hashmap<ast::def_id, option<ast::node_id>>,
9695
// Cache instances of monomorphized functions
9796
monomorphized: hashmap<mono_id, {llfn: ValueRef, fty: ty::t}>,
97+
// Cache generated vtables
98+
vtables: hashmap<mono_id, ValueRef>,
9899
module_data: hashmap<str, ValueRef>,
99100
lltypes: hashmap<ty::t, TypeRef>,
100101
names: namegen,
@@ -846,30 +847,16 @@ pure fn type_has_static_size(cx: @crate_ctxt, t: ty::t) -> bool {
846847
!ty::type_has_dynamic_size(cx.tcx, t)
847848
}
848849

849-
// Used to identify cached dictionaries
850-
enum dict_param {
851-
dict_param_dict(dict_id),
852-
dict_param_ty(ty::t),
853-
}
854-
type dict_id = @{def: ast::def_id, params: [dict_param]};
855-
fn hash_dict_id(&&dp: dict_id) -> uint {
856-
let h = syntax::ast_util::hash_def_id(dp.def);
857-
for param in dp.params {
858-
h = h << 2u;
859-
alt param {
860-
dict_param_dict(d) { h += hash_dict_id(d); }
861-
dict_param_ty(t) { h += ty::type_id(t); }
862-
}
863-
}
864-
h
865-
}
866-
867850
// Used to identify cached monomorphized functions
868-
type mono_id = @{def: ast::def_id, substs: [ty::t], dicts: [dict_id]};
851+
enum mono_dicts { some_dicts([mono_id]), no_dicts }
852+
type mono_id = @{def: ast::def_id, substs: [ty::t], dicts: mono_dicts};
869853
fn hash_mono_id(&&mi: mono_id) -> uint {
870854
let h = syntax::ast_util::hash_def_id(mi.def);
871855
for ty in mi.substs { h = (h << 2u) + ty::type_id(ty); }
872-
for dict in mi.dicts { h = (h << 2u) + hash_dict_id(dict); }
856+
alt mi.dicts {
857+
some_dicts(ds) { for d in ds { h = (h << 2u) + hash_mono_id(d); } }
858+
_ {}
859+
}
873860
h
874861
}
875862

0 commit comments

Comments
 (0)