summary refs log tree commit diff
path: root/src/rustc/middle
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-03-15 17:42:33 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-03-16 15:38:42 +0100
commit22bef74b550b2b08338ebb43363f3d09df6413b9 (patch)
tree1a96fdf8b865c54e4d0a64391451bb913d97ea50 /src/rustc/middle
parent140d194007bbb427ab694807782b3a41bb43b27d (diff)
downloadrust-22bef74b550b2b08338ebb43363f3d09df6413b9.tar.gz
rust-22bef74b550b2b08338ebb43363f3d09df6413b9.zip
Remove shared tydescs
All tydescs are static now, there's no need to worry about
marshalling them between threads anymore.
Diffstat (limited to 'src/rustc/middle')
-rw-r--r--src/rustc/middle/trans/base.rs18
-rw-r--r--src/rustc/middle/trans/closure.rs39
-rw-r--r--src/rustc/middle/trans/shape.rs1
-rw-r--r--src/rustc/middle/trans/type_of.rs2
-rw-r--r--src/rustc/middle/ty.rs19
5 files changed, 17 insertions, 62 deletions
diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs
index 221a9537045..23fc3f69e96 100644
--- a/src/rustc/middle/trans/base.rs
+++ b/src/rustc/middle/trans/base.rs
@@ -559,14 +559,6 @@ fn make_take_glue(cx: block, v: ValueRef, t: ty::t) {
         Store(r.bcx, r.val, v);
         r.bcx
       }
-      ty::ty_send_type {
-        // sendable type descriptors are basically unique pointers,
-        // they must be cloned when copied:
-        let r = Load(bcx, v);
-        let s = Call(bcx, bcx.ccx().upcalls.create_shared_type_desc, [r]);
-        Store(bcx, s, v);
-        bcx
-      }
       ty::ty_fn(_) {
         closure::make_fn_glue(bcx, v, t, take_ty)
       }
@@ -623,14 +615,6 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
       ty::ty_vec(_) | ty::ty_str {
         tvec::make_free_glue(bcx, PointerCast(bcx, v, type_of(ccx, t)), t)
       }
-      ty::ty_send_type {
-        // sendable type descriptors are basically unique pointers,
-        // they must be freed.
-        let ccx = bcx.ccx();
-        let v = PointerCast(bcx, v, T_ptr(ccx.tydesc_type));
-        Call(bcx, ccx.upcalls.free_shared_type_desc, [v]);
-        bcx
-      }
       ty::ty_fn(_) {
         closure::make_fn_glue(bcx, v, t, free_ty)
       }
@@ -649,7 +633,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
       ty::ty_box(_) | ty::ty_opaque_box {
         decr_refcnt_maybe_free(bcx, Load(bcx, v0), t)
       }
-      ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str | ty::ty_send_type {
+      ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str {
         free_ty(bcx, Load(bcx, v0), t)
       }
       ty::ty_res(did, inner, tps) {
diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs
index e2546717732..ad24195d901 100644
--- a/src/rustc/middle/trans/closure.rs
+++ b/src/rustc/middle/trans/closure.rs
@@ -114,16 +114,8 @@ fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str {
     }
 }
 
-fn mk_tydesc_ty(tcx: ty::ctxt, ck: ty::closure_kind) -> ty::t {
-    ret alt ck {
-      ty::ck_block | ty::ck_box { ty::mk_type(tcx) }
-      ty::ck_uniq { ty::mk_send_type(tcx) }
-    };
-}
-
 fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t {
-    let tydesc_ty = mk_tydesc_ty(tcx, ty::ck_uniq);
-    let cbox_ty = tuplify_cbox_ty(tcx, cdata_ty, tydesc_ty);
+    let cbox_ty = tuplify_cbox_ty(tcx, cdata_ty, ty::mk_type(tcx));
     ret ty::mk_imm_uniq(tcx, cbox_ty);
 }
 
@@ -166,14 +158,12 @@ fn allocate_cbox(bcx: block,
         Store(bcx, rc, ref_cnt);
     }
 
-    fn store_uniq_tydesc(bcx: block,
-                         cdata_ty: ty::t,
-                         box: ValueRef,
-                         &ti: option<@tydesc_info>) -> block {
-        let ccx = bcx.ccx();
+    fn store_tydesc(bcx: block,
+                    cdata_ty: ty::t,
+                    box: ValueRef,
+                    &ti: option<@tydesc_info>) -> block {
         let bound_tydesc = GEPi(bcx, box, [0, abi::box_field_tydesc]);
         let {bcx, val: td} = base::get_tydesc(bcx, cdata_ty, ti);
-        let td = Call(bcx, ccx.upcalls.create_shared_type_desc, [td]);
         Store(bcx, td, bound_tydesc);
         bcx
     }
@@ -190,7 +180,7 @@ fn allocate_cbox(bcx: block,
         let uniq_cbox_ty = mk_tuplified_uniq_cbox_ty(tcx, cdata_ty);
         let {bcx, val: box} = uniq::alloc_uniq(bcx, uniq_cbox_ty);
         nuke_ref_count(bcx, box);
-        let bcx = store_uniq_tydesc(bcx, cdata_ty, box, ti);
+        let bcx = store_tydesc(bcx, cdata_ty, box, ti);
         (bcx, box)
       }
       ty::ck_block {
@@ -222,19 +212,6 @@ fn store_environment(bcx: block,
                      bound_values: [environment_value],
                      ck: ty::closure_kind) -> closure_result {
 
-    fn maybe_clone_tydesc(bcx: block,
-                          ck: ty::closure_kind,
-                          td: ValueRef) -> ValueRef {
-        ret alt ck {
-          ty::ck_block | ty::ck_box {
-            td
-          }
-          ty::ck_uniq {
-            Call(bcx, bcx.ccx().upcalls.create_shared_type_desc, [td])
-          }
-        };
-    }
-
     let ccx = bcx.ccx(), tcx = ccx.tcx;
 
     // compute the shape of the closure
@@ -551,7 +528,7 @@ fn make_opaque_cbox_take_glue(
 
         // Take the (deeply cloned) type descriptor
         let tydesc_out = GEPi(bcx, cbox_out, [0, abi::box_field_tydesc]);
-        let bcx = take_ty(bcx, tydesc_out, mk_tydesc_ty(tcx, ty::ck_uniq));
+        let bcx = take_ty(bcx, tydesc_out, ty::mk_type(tcx));
 
         // Take the data in the tuple
         let ti = none;
@@ -612,7 +589,7 @@ fn make_opaque_cbox_free_glue(
             trans_free(bcx, cbox)
           }
           ty::ck_uniq {
-            let bcx = free_ty(bcx, tydesc, mk_tydesc_ty(tcx, ck));
+            let bcx = free_ty(bcx, tydesc, ty::mk_type(tcx));
             trans_shared_free(bcx, cbox)
           }
         }
diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs
index f632cf625c6..88860e2aeab 100644
--- a/src/rustc/middle/trans/shape.rs
+++ b/src/rustc/middle/trans/shape.rs
@@ -298,7 +298,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
       ty::ty_float(ast::ty_f) { [s_float(ccx.tcx)] }
       ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) { [s_uint(ccx.tcx)] }
       ty::ty_type { [s_tydesc(ccx.tcx)] }
-      ty::ty_send_type { [s_send_tydesc(ccx.tcx)] }
       ty::ty_int(ast::ty_i8) { [shape_i8] }
       ty::ty_uint(ast::ty_u16) { [shape_u16] }
       ty::ty_int(ast::ty_i16) { [shape_i16] }
diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs
index 7c19134faad..9d49c595fe5 100644
--- a/src/rustc/middle/trans/type_of.rs
+++ b/src/rustc/middle/trans/type_of.rs
@@ -71,7 +71,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
         ret T_struct([T_i8(), type_of(cx, sub1)]);
       }
       ty::ty_param(_, _) { T_typaram(cx.tn) }
-      ty::ty_send_type | ty::ty_type { T_ptr(cx.tydesc_type) }
+      ty::ty_type { T_ptr(cx.tydesc_type) }
       ty::ty_tup(elts) {
         let tys = [];
         for elt in elts {
diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs
index 32be4ee5518..e91ef230cd2 100644
--- a/src/rustc/middle/ty.rs
+++ b/src/rustc/middle/ty.rs
@@ -82,7 +82,6 @@ export ty_rptr, mk_rptr;
 export ty_rec, mk_rec;
 export ty_enum, mk_enum, type_is_enum;
 export ty_tup, mk_tup;
-export ty_send_type, mk_send_type;
 export ty_type, mk_type;
 export ty_uint, mk_uint, mk_mach_uint;
 export ty_uniq, mk_uniq, mk_imm_uniq, type_is_unique_box;
@@ -267,7 +266,6 @@ enum sty {
     ty_self([t]), // interface method self type
 
     ty_type, // type_desc*
-    ty_send_type, // type_desc* that has been cloned into exchange heap
     ty_opaque_box, // used by monomorphizer to represent any @ box
     ty_constr(t, [@type_constr]),
     ty_opaque_closure_ptr(closure_kind), // ptr to env for fn, fn@, fn~
@@ -392,7 +390,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
     }
     alt st {
       ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
-      ty_str | ty_type | ty_send_type | ty_opaque_closure_ptr(_) |
+      ty_str | ty_type | ty_opaque_closure_ptr(_) |
       ty_opaque_box {}
       ty_param(_, _) { has_params = true; }
       ty_var(_) | ty_self(_) { has_vars = true; }
@@ -518,8 +516,6 @@ fn mk_param(cx: ctxt, n: uint, k: def_id) -> t { mk_t(cx, ty_param(n, k)) }
 
 fn mk_type(cx: ctxt) -> t { mk_t(cx, ty_type) }
 
-fn mk_send_type(cx: ctxt) -> t { mk_t(cx, ty_send_type) }
-
 fn mk_opaque_closure_ptr(cx: ctxt, ck: closure_kind) -> t {
     mk_t(cx, ty_opaque_closure_ptr(ck))
 }
@@ -553,7 +549,7 @@ fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
     if !f(ty) { ret; }
     alt get(ty).struct {
       ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
-      ty_str | ty_send_type | ty_type | ty_opaque_box |
+      ty_str | ty_type | ty_opaque_box |
       ty_opaque_closure_ptr(_) | ty_var(_) | ty_param(_, _) {}
       ty_box(tm) | ty_vec(tm) | ty_ptr(tm) | ty_rptr(_, tm) {
         maybe_walk_ty(tm.ty, f);
@@ -599,7 +595,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
 
     alt tb.struct {
       ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
-      ty_str | ty_type | ty_send_type | ty_opaque_closure_ptr(_) |
+      ty_str | ty_type | ty_opaque_closure_ptr(_) |
       ty_opaque_box {}
       ty_box(tm) {
         ty = mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mutbl: tm.mutbl});
@@ -780,7 +776,7 @@ pure fn type_is_unique(ty: t) -> bool {
 pure fn type_is_scalar(ty: t) -> bool {
     alt get(ty).struct {
       ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
-      ty_send_type | ty_type | ty_ptr(_) | ty_rptr(_, _) { true }
+      ty_type | ty_ptr(_) | ty_rptr(_, _) { true }
       _ { false }
     }
 }
@@ -884,7 +880,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
     let result = alt get(ty).struct {
       // Scalar and unique types are sendable
       ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
-      ty_ptr(_) | ty_send_type | ty_str { kind_sendable }
+      ty_ptr(_) | ty_str { kind_sendable }
       ty_type { kind_copyable }
       ty_fn(f) { proto_kind(f.proto) }
       ty_opaque_closure_ptr(ck_block) { kind_noncopyable }
@@ -1034,7 +1030,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
     alt get(ty).struct {
       // Scalar types
       ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
-      ty_send_type | ty_type | ty_ptr(_) { result = true; }
+      ty_type | ty_ptr(_) { result = true; }
       // Boxed types
       ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
       ty_iface(_, _) | ty_rptr(_,_) | ty_opaque_box { result = false; }
@@ -1223,7 +1219,6 @@ fn hash_type_structure(st: sty) -> uint {
         h
       }
       ty_uniq(mt) { hash_subty(37u, mt.ty) }
-      ty_send_type { 38u }
       ty_iface(did, tys) {
         let h = hash_def(40u, did);
         for typ: t in tys { h = hash_subty(h, typ); }
@@ -1984,7 +1979,7 @@ mod unify {
           (_, ty_bot) { nxt(expected) }
           (ty_bot, _) { nxt(actual) }
           (ty_nil, _) | (ty_bool, _) | (ty_int(_), _) | (ty_uint(_), _) |
-          (ty_float(_), _) | (ty_str, _) | (ty_send_type, _) {
+          (ty_float(_), _) | (ty_str, _) {
             struct_cmp(cx, expected, actual, nxt)
           }
           (ty_param(e_n, _), ty_param(a_n, _)) if e_n == a_n {