Skip to content

Commit 97d9fe8

Browse files
committed
---
yaml --- r: 111511 b: refs/heads/master c: 938eaaa h: refs/heads/master i: 111509: 73f600d 111507: 16bc29f 111503: 12b3fdf v: v3
1 parent 51fcc2e commit 97d9fe8

File tree

11 files changed

+62
-60
lines changed

11 files changed

+62
-60
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: 344ce1703616dc329dc11f827d91f71ca25205fc
2+
refs/heads/master: 938eaaa304445101e2c516a9d339dcbc0a416d58
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b5dd3f05fe95168b5569d0f519636149479eb6ac
55
refs/heads/try: 38201d7c6bf0c32b0e5bdc8ecd63976ebc1b3a4c

trunk/src/librustc/middle/trans/_match.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ use util::ppaux::{Repr, vec_map_to_str};
225225

226226
use collections::HashMap;
227227
use std::cell::Cell;
228+
use std::rc::Rc;
228229
use syntax::ast;
229230
use syntax::ast::Ident;
230231
use syntax::ast_util::path_to_ident;
@@ -250,7 +251,7 @@ pub enum VecLenOpt {
250251
// range)
251252
enum Opt {
252253
lit(Lit),
253-
var(ty::Disr, @adt::Repr),
254+
var(ty::Disr, Rc<adt::Repr>),
254255
range(@ast::Expr, @ast::Expr),
255256
vec_len(/* length */ uint, VecLenOpt, /*range of matches*/(uint, uint))
256257
}
@@ -351,8 +352,8 @@ fn trans_opt<'a>(bcx: &'a Block<'a>, o: &Opt) -> opt_result<'a> {
351352
let (llval, _) = consts::get_const_val(bcx.ccx(), lit_id);
352353
return single_result(rslt(bcx, llval));
353354
}
354-
var(disr_val, repr) => {
355-
return adt::trans_case(bcx, repr, disr_val);
355+
var(disr_val, ref repr) => {
356+
return adt::trans_case(bcx, &**repr, disr_val);
356357
}
357358
range(l1, l2) => {
358359
let (l1, _) = consts::const_expr(ccx, l1, true);
@@ -1561,7 +1562,7 @@ fn compile_submatch_continue<'a, 'b>(
15611562
expr::with_field_tys(tcx, pat_ty, Some(pat_id), |discr, field_tys| {
15621563
let rec_vals = rec_fields.iter().map(|field_name| {
15631564
let ix = ty::field_idx_strict(tcx, field_name.name, field_tys);
1564-
adt::trans_field_ptr(bcx, pat_repr, val, discr, ix)
1565+
adt::trans_field_ptr(bcx, &*pat_repr, val, discr, ix)
15651566
}).collect::<Vec<_>>();
15661567
compile_submatch(
15671568
bcx,
@@ -1587,7 +1588,7 @@ fn compile_submatch_continue<'a, 'b>(
15871588
_ => ccx.sess().bug("non-tuple type in tuple pattern")
15881589
};
15891590
let tup_vals = Vec::from_fn(n_tup_elts, |i| {
1590-
adt::trans_field_ptr(bcx, tup_repr, val, 0, i)
1591+
adt::trans_field_ptr(bcx, &*tup_repr, val, 0, i)
15911592
});
15921593
compile_submatch(bcx,
15931594
enter_tup(bcx,
@@ -1616,7 +1617,7 @@ fn compile_submatch_continue<'a, 'b>(
16161617

16171618
let struct_repr = adt::represent_type(bcx.ccx(), struct_ty);
16181619
let llstructvals = Vec::from_fn(struct_element_count, |i| {
1619-
adt::trans_field_ptr(bcx, struct_repr, val, 0, i)
1620+
adt::trans_field_ptr(bcx, &*struct_repr, val, 0, i)
16201621
});
16211622
compile_submatch(bcx,
16221623
enter_tuple_struct(bcx, dm, m, col, val,
@@ -1652,8 +1653,8 @@ fn compile_submatch_continue<'a, 'b>(
16521653
debug!("test_val={}", bcx.val_to_str(test_val));
16531654
if opts.len() > 0u {
16541655
match *opts.get(0) {
1655-
var(_, repr) => {
1656-
let (the_kind, val_opt) = adt::trans_switch(bcx, repr, val);
1656+
var(_, ref repr) => {
1657+
let (the_kind, val_opt) = adt::trans_switch(bcx, &**repr, val);
16571658
kind = the_kind;
16581659
for &tval in val_opt.iter() { test_val = tval; }
16591660
}
@@ -1799,9 +1800,9 @@ fn compile_submatch_continue<'a, 'b>(
17991800
let mut size = 0u;
18001801
let mut unpacked = Vec::new();
18011802
match *opt {
1802-
var(disr_val, repr) => {
1803+
var(disr_val, ref repr) => {
18031804
let ExtractedBlock {vals: argvals, bcx: new_bcx} =
1804-
extract_variant_args(opt_cx, repr, disr_val, val);
1805+
extract_variant_args(opt_cx, &**repr, disr_val, val);
18051806
size = argvals.len();
18061807
unpacked = argvals;
18071808
opt_cx = new_bcx;
@@ -2219,7 +2220,7 @@ fn bind_irrefutable_pat<'a>(
22192220
enum_id,
22202221
var_id);
22212222
let args = extract_variant_args(bcx,
2222-
repr,
2223+
&*repr,
22232224
vinfo.disr_val,
22242225
val);
22252226
for sub_pat in sub_pats.iter() {
@@ -2240,7 +2241,7 @@ fn bind_irrefutable_pat<'a>(
22402241
// This is the tuple struct case.
22412242
let repr = adt::represent_node(bcx, pat.id);
22422243
for (i, elem) in elems.iter().enumerate() {
2243-
let fldptr = adt::trans_field_ptr(bcx, repr,
2244+
let fldptr = adt::trans_field_ptr(bcx, &*repr,
22442245
val, 0, i);
22452246
bcx = bind_irrefutable_pat(bcx, *elem,
22462247
fldptr, binding_mode,
@@ -2263,7 +2264,7 @@ fn bind_irrefutable_pat<'a>(
22632264
expr::with_field_tys(tcx, pat_ty, Some(pat.id), |discr, field_tys| {
22642265
for f in fields.iter() {
22652266
let ix = ty::field_idx_strict(tcx, f.ident.name, field_tys);
2266-
let fldptr = adt::trans_field_ptr(bcx, pat_repr, val,
2267+
let fldptr = adt::trans_field_ptr(bcx, &*pat_repr, val,
22672268
discr, ix);
22682269
bcx = bind_irrefutable_pat(bcx, f.pat, fldptr,
22692270
binding_mode, cleanup_scope);
@@ -2273,7 +2274,7 @@ fn bind_irrefutable_pat<'a>(
22732274
ast::PatTup(ref elems) => {
22742275
let repr = adt::represent_node(bcx, pat.id);
22752276
for (i, elem) in elems.iter().enumerate() {
2276-
let fldptr = adt::trans_field_ptr(bcx, repr, val, 0, i);
2277+
let fldptr = adt::trans_field_ptr(bcx, &*repr, val, 0, i);
22772278
bcx = bind_irrefutable_pat(bcx, *elem, fldptr,
22782279
binding_mode, cleanup_scope);
22792280
}

trunk/src/librustc/middle/trans/adt.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545

4646
use std::container::Map;
4747
use libc::c_ulonglong;
48-
use std::option::{Option, Some, None};
4948
use std::num::{Bitwise};
49+
use std::rc::Rc;
5050

5151
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
5252
use middle::trans::_match;
@@ -115,22 +115,22 @@ pub struct Struct {
115115
* these, for places in trans where the `ty::t` isn't directly
116116
* available.
117117
*/
118-
pub fn represent_node(bcx: &Block, node: ast::NodeId) -> @Repr {
118+
pub fn represent_node(bcx: &Block, node: ast::NodeId) -> Rc<Repr> {
119119
represent_type(bcx.ccx(), node_id_type(bcx, node))
120120
}
121121

122122
/// Decides how to represent a given type.
123-
pub fn represent_type(cx: &CrateContext, t: ty::t) -> @Repr {
123+
pub fn represent_type(cx: &CrateContext, t: ty::t) -> Rc<Repr> {
124124
debug!("Representing: {}", ty_to_str(cx.tcx(), t));
125125
match cx.adt_reprs.borrow().find(&t) {
126-
Some(repr) => return *repr,
126+
Some(repr) => return repr.clone(),
127127
None => {}
128128
}
129129

130-
let repr = @represent_type_uncached(cx, t);
130+
let repr = Rc::new(represent_type_uncached(cx, t));
131131
debug!("Represented as: {:?}", repr)
132-
cx.adt_reprs.borrow_mut().insert(t, repr);
133-
return repr;
132+
cx.adt_reprs.borrow_mut().insert(t, repr.clone());
133+
repr
134134
}
135135

136136
fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ pub fn iter_structural_ty<'r,
660660
let repr = adt::represent_type(cx.ccx(), t);
661661
expr::with_field_tys(cx.tcx(), t, None, |discr, field_tys| {
662662
for (i, field_ty) in field_tys.iter().enumerate() {
663-
let llfld_a = adt::trans_field_ptr(cx, repr, av, discr, i);
663+
let llfld_a = adt::trans_field_ptr(cx, &*repr, av, discr, i);
664664
cx = f(cx, llfld_a, field_ty.mt.ty);
665665
}
666666
})
@@ -678,7 +678,7 @@ pub fn iter_structural_ty<'r,
678678
ty::ty_tup(ref args) => {
679679
let repr = adt::represent_type(cx.ccx(), t);
680680
for (i, arg) in args.iter().enumerate() {
681-
let llfld_a = adt::trans_field_ptr(cx, repr, av, 0, i);
681+
let llfld_a = adt::trans_field_ptr(cx, &*repr, av, 0, i);
682682
cx = f(cx, llfld_a, *arg);
683683
}
684684
}
@@ -693,9 +693,9 @@ pub fn iter_structural_ty<'r,
693693
// NB: we must hit the discriminant first so that structural
694694
// comparison know not to proceed when the discriminants differ.
695695

696-
match adt::trans_switch(cx, repr, av) {
696+
match adt::trans_switch(cx, &*repr, av) {
697697
(_match::single, None) => {
698-
cx = iter_variant(cx, repr, av, &**variants.get(0),
698+
cx = iter_variant(cx, &*repr, av, &**variants.get(0),
699699
substs.tps.as_slice(), f);
700700
}
701701
(_match::switch, Some(lldiscrim_a)) => {
@@ -710,7 +710,7 @@ pub fn iter_structural_ty<'r,
710710
let variant_cx =
711711
fcx.new_temp_block("enum-iter-variant-".to_owned() +
712712
variant.disr_val.to_str());
713-
match adt::trans_case(cx, repr, variant.disr_val) {
713+
match adt::trans_case(cx, &*repr, variant.disr_val) {
714714
_match::single_result(r) => {
715715
AddCase(llswitch, r.val, variant_cx.llbb)
716716
}
@@ -719,7 +719,7 @@ pub fn iter_structural_ty<'r,
719719
}
720720
let variant_cx =
721721
iter_variant(variant_cx,
722-
repr,
722+
&*repr,
723723
av,
724724
&**variant,
725725
substs.tps.as_slice(),
@@ -1512,10 +1512,10 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
15121512

15131513
if !type_is_zero_size(fcx.ccx, result_ty) {
15141514
let repr = adt::represent_type(ccx, result_ty);
1515-
adt::trans_start_init(bcx, repr, fcx.llretptr.get().unwrap(), disr);
1515+
adt::trans_start_init(bcx, &*repr, fcx.llretptr.get().unwrap(), disr);
15161516
for (i, arg_datum) in arg_datums.move_iter().enumerate() {
15171517
let lldestptr = adt::trans_field_ptr(bcx,
1518-
repr,
1518+
&*repr,
15191519
fcx.llretptr.get().unwrap(),
15201520
disr,
15211521
i);

trunk/src/librustc/middle/trans/consts.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef {
130130
fn const_deref_newtype(cx: &CrateContext, v: ValueRef, t: ty::t)
131131
-> ValueRef {
132132
let repr = adt::represent_type(cx, t);
133-
adt::const_get_field(cx, repr, v, 0, 0)
133+
adt::const_get_field(cx, &*repr, v, 0, 0)
134134
}
135135

136136
fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
@@ -418,7 +418,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
418418
let (bv, inlineable) = const_expr(cx, base, is_local);
419419
expr::with_field_tys(cx.tcx(), bt, None, |discr, field_tys| {
420420
let ix = ty::field_idx_strict(cx.tcx(), field.name, field_tys);
421-
(adt::const_get_field(cx, brepr, bv, discr, ix), inlineable)
421+
(adt::const_get_field(cx, &*brepr, bv, discr, ix), inlineable)
422422
})
423423
}
424424

@@ -491,7 +491,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
491491
(expr::cast_enum, expr::cast_integral) |
492492
(expr::cast_enum, expr::cast_float) => {
493493
let repr = adt::represent_type(cx, basety);
494-
let discr = adt::const_get_discrim(cx, repr, v);
494+
let discr = adt::const_get_discrim(cx, &*repr, v);
495495
let iv = C_integral(cx.int_type, discr, false);
496496
let ety_cast = expr::cast_type_kind(ety);
497497
match ety_cast {
@@ -524,7 +524,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
524524
let ety = ty::expr_ty(cx.tcx(), e);
525525
let repr = adt::represent_type(cx, ety);
526526
let (vals, inlineable) = map_list(es.as_slice());
527-
(adt::trans_const(cx, repr, 0, vals.as_slice()), inlineable)
527+
(adt::trans_const(cx, &*repr, 0, vals.as_slice()), inlineable)
528528
}
529529
ast::ExprStruct(_, ref fs, ref base_opt) => {
530530
let ety = ty::expr_ty(cx.tcx(), e);
@@ -544,15 +544,15 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
544544
None => {
545545
match base_val {
546546
Some((bv, inlineable)) => {
547-
(adt::const_get_field(cx, repr, bv, discr, ix),
547+
(adt::const_get_field(cx, &*repr, bv, discr, ix),
548548
inlineable)
549549
}
550550
None => cx.sess().span_bug(e.span, "missing struct field")
551551
}
552552
}
553553
}
554554
}));
555-
(adt::trans_const(cx, repr, discr, cs),
555+
(adt::trans_const(cx, &*repr, discr, cs),
556556
inlineable.iter().fold(true, |a, &b| a && b))
557557
})
558558
}
@@ -632,7 +632,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
632632
let vinfo = ty::enum_variant_with_id(cx.tcx(),
633633
enum_did,
634634
variant_did);
635-
(adt::trans_const(cx, repr, vinfo.disr_val, []), true)
635+
(adt::trans_const(cx, &*repr, vinfo.disr_val, []), true)
636636
}
637637
Some(ast::DefStruct(_)) => {
638638
let ety = ty::expr_ty(cx.tcx(), e);
@@ -651,7 +651,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
651651
let ety = ty::expr_ty(cx.tcx(), e);
652652
let repr = adt::represent_type(cx, ety);
653653
let (arg_vals, inlineable) = map_list(args.as_slice());
654-
(adt::trans_const(cx, repr, 0, arg_vals.as_slice()),
654+
(adt::trans_const(cx, &*repr, 0, arg_vals.as_slice()),
655655
inlineable)
656656
}
657657
Some(ast::DefVariant(enum_did, variant_did, _)) => {
@@ -662,7 +662,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
662662
variant_did);
663663
let (arg_vals, inlineable) = map_list(args.as_slice());
664664
(adt::trans_const(cx,
665-
repr,
665+
&*repr,
666666
vinfo.disr_val,
667667
arg_vals.as_slice()), inlineable)
668668
}

trunk/src/librustc/middle/trans/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use util::nodemap::{NodeMap, NodeSet, DefIdMap};
3131
use std::cell::{Cell, RefCell};
3232
use std::c_str::ToCStr;
3333
use std::ptr;
34+
use std::rc::Rc;
3435
use collections::{HashMap, HashSet};
3536
use syntax::ast;
3637
use syntax::parse::token::InternedString;
@@ -92,7 +93,7 @@ pub struct CrateContext {
9293

9394
pub lltypes: RefCell<HashMap<ty::t, Type>>,
9495
pub llsizingtypes: RefCell<HashMap<ty::t, Type>>,
95-
pub adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>,
96+
pub adt_reprs: RefCell<HashMap<ty::t, Rc<adt::Repr>>>,
9697
pub symbol_hasher: RefCell<Sha256>,
9798
pub type_hashcodes: RefCell<HashMap<ty::t, ~str>>,
9899
pub all_llvm_symbols: RefCell<HashSet<~str>>,

trunk/src/librustc/middle/trans/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ fn prepare_tuple_metadata(cx: &CrateContext,
13891389
}
13901390

13911391
struct GeneralMemberDescriptionFactory {
1392-
type_rep: @adt::Repr,
1392+
type_rep: Rc<adt::Repr>,
13931393
variants: Rc<Vec<Rc<ty::VariantInfo>>>,
13941394
discriminant_type_metadata: ValueRef,
13951395
containing_scope: DIScope,
@@ -1662,7 +1662,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
16621662
llvm_type: enum_llvm_type,
16631663
file_metadata: file_metadata,
16641664
member_description_factory: GeneralMD(GeneralMemberDescriptionFactory {
1665-
type_rep: type_rep,
1665+
type_rep: type_rep.clone(),
16661666
variants: variants,
16671667
discriminant_type_metadata: discriminant_type_metadata,
16681668
containing_scope: containing_scope,

0 commit comments

Comments
 (0)