about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Brüschweiler <blei42@gmail.com>2013-06-22 21:36:00 +0200
committerPhilipp Brüschweiler <blei42@gmail.com>2013-06-23 13:02:00 +0200
commite2f1049bd5f041f1f219d683e4e29e32ca30cd1c (patch)
tree509134d12c4aa0c9bdaee4fecebe95a39036fdb9
parent1b76bac41de9f52295a99db21abdd1ad5b0fc231 (diff)
downloadrust-e2f1049bd5f041f1f219d683e4e29e32ca30cd1c.tar.gz
rust-e2f1049bd5f041f1f219d683e4e29e32ca30cd1c.zip
Remove unused TyDesc parameter from the glue functions
To remove the environment pointer, support for function pointers without
an environment argument is needed (i.e. a fixed version of #6661).
-rw-r--r--src/libextra/arena.rs16
-rw-r--r--src/librustc/back/abi.rs13
-rw-r--r--src/librustc/middle/trans/glue.rs14
-rw-r--r--src/librustc/middle/trans/type_.rs11
-rw-r--r--src/libstd/cleanup.rs18
-rw-r--r--src/libstd/gc.rs15
-rw-r--r--src/libstd/unstable/intrinsics.rs4
-rw-r--r--src/rt/rust_task.cpp6
-rw-r--r--src/rt/rust_type.h6
9 files changed, 66 insertions, 37 deletions
diff --git a/src/libextra/arena.rs b/src/libextra/arena.rs
index 3766af04656..cec3a2c1e95 100644
--- a/src/libextra/arena.rs
+++ b/src/libextra/arena.rs
@@ -115,6 +115,19 @@ fn round_up_to(base: uint, align: uint) -> uint {
     (base + (align - 1)) & !(align - 1)
 }
 
+#[inline]
+#[cfg(not(stage0))]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    // This function should be inlined when stage0 is gone
+    ((*tydesc).drop_glue)(data);
+}
+
+#[inline]
+#[cfg(stage0)]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    ((*tydesc).drop_glue)(0 as **TyDesc, data);
+}
+
 // Walk down a chunk, running the destructors for any objects stored
 // in it.
 unsafe fn destroy_chunk(chunk: &Chunk) {
@@ -134,8 +147,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
         //debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
         //       start, size, align, is_done);
         if is_done {
-            ((*tydesc).drop_glue)(&tydesc as **TyDesc,
-                                  ptr::offset(buf, start) as *i8);
+            call_drop_glue(tydesc, ptr::offset(buf, start) as *i8);
         }
 
         // Find where the next tydesc lives
diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs
index 8f15c74ed0e..05b6e90c682 100644
--- a/src/librustc/back/abi.rs
+++ b/src/librustc/back/abi.rs
@@ -8,9 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
-
 pub static rc_base_field_refcnt: uint = 0u;
 
 pub static task_field_refcnt: uint = 0u;
@@ -69,14 +66,4 @@ pub static vec_elt_elems: uint = 2u;
 pub static slice_elt_base: uint = 0u;
 pub static slice_elt_len: uint = 1u;
 
-pub static worst_case_glue_call_args: uint = 7u;
-
 pub static abi_version: uint = 1u;
-
-pub fn memcpy_glue_name() -> ~str { return ~"rust_memcpy_glue"; }
-
-pub fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; }
-
-pub fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; }
-
-pub fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; }
diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs
index f9bffb4a36e..75a1221cca5 100644
--- a/src/librustc/middle/trans/glue.rs
+++ b/src/librustc/middle/trans/glue.rs
@@ -232,7 +232,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
                                field: uint,
                                ti: @mut tydesc_info) {
     let _icx = push_ctxt("lazily_emit_tydesc_glue");
-    let llfnty = type_of_glue_fn(ccx);
+    let llfnty = Type::glue_fn();
 
     if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
         return;
@@ -338,9 +338,7 @@ pub fn call_tydesc_glue_full(bcx: block,
         }
     };
 
-    Call(bcx, llfn, [C_null(Type::nil().ptr_to()),
-                        C_null(bcx.ccx().tydesc_type.ptr_to().ptr_to()),
-                        llrawptr]);
+    Call(bcx, llfn, [C_null(Type::nil().ptr_to()), llrawptr]);
 }
 
 // See [Note-arg-mode]
@@ -680,7 +678,7 @@ pub fn make_generic_glue_inner(ccx: @mut CrateContext,
 
     let bcx = top_scope_block(fcx, None);
     let lltop = bcx.llbb;
-    let rawptr0_arg = fcx.arg_pos(1u);
+    let rawptr0_arg = fcx.arg_pos(0u);
     let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, rawptr0_arg as c_uint) };
     let llty = type_of(ccx, t);
     let llrawptr0 = PointerCast(bcx, llrawptr0, llty.ptr_to());
@@ -715,7 +713,7 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
     let _icx = push_ctxt("emit_tydescs");
     // As of this point, allow no more tydescs to be created.
     ccx.finished_tydescs = true;
-    let glue_fn_ty = Type::generic_glue_fn(ccx);
+    let glue_fn_ty = Type::generic_glue_fn(ccx).ptr_to();
     let tyds = &mut ccx.tydescs;
     for tyds.each_value |&val| {
         let ti = val;
@@ -782,7 +780,3 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
         }
     };
 }
-
-pub fn type_of_glue_fn(ccx: &CrateContext) -> Type {
-    Type::glue_fn(ccx.tydesc_type)
-}
diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs
index 7b02030078c..64688ac4134 100644
--- a/src/librustc/middle/trans/type_.rs
+++ b/src/librustc/middle/trans/type_.rs
@@ -20,7 +20,6 @@ use middle::trans::base;
 
 use syntax::ast;
 use syntax::abi::{Architecture, X86, X86_64, Arm, Mips};
-use back::abi;
 
 use core::vec;
 use core::cast;
@@ -189,22 +188,20 @@ impl Type {
             None => ()
         }
 
-        let ty = Type::glue_fn(cx.tydesc_type).ptr_to();
+        let ty = Type::glue_fn();
         cx.tn.associate_type("glue_fn", &ty);
 
         return ty;
     }
 
-    pub fn glue_fn(tydesc: Type) -> Type {
-        let tydescpp = tydesc.ptr_to().ptr_to();
-        Type::func([ Type::nil().ptr_to(), tydescpp, Type::i8p() ],
+    pub fn glue_fn() -> Type {
+        Type::func([ Type::nil().ptr_to(), Type::i8p() ],
             &Type::void())
     }
 
     pub fn tydesc(arch: Architecture) -> Type {
         let mut tydesc = Type::named_struct("tydesc");
-        let pvoid = Type::i8p();
-        let glue_fn_ty = Type::glue_fn(tydesc).ptr_to();
+        let glue_fn_ty = Type::glue_fn().ptr_to();
 
         let int_ty = Type::int(arch);
 
diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs
index 557a2fbc4ae..ee9fdd3c620 100644
--- a/src/libstd/cleanup.rs
+++ b/src/libstd/cleanup.rs
@@ -11,9 +11,10 @@
 #[doc(hidden)];
 
 use libc::{c_char, intptr_t, uintptr_t};
-use ptr::{mut_null, to_unsafe_ptr};
+use ptr::{mut_null};
 use repr::BoxRepr;
 use cast::transmute;
+use unstable::intrinsics::TyDesc;
 #[cfg(not(test))] use unstable::lang::clear_task_borrow_list;
 
 /**
@@ -158,6 +159,19 @@ fn debug_mem() -> bool {
     false
 }
 
+#[inline]
+#[cfg(not(stage0))]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    // This function should be inlined when stage0 is gone
+    ((*tydesc).drop_glue)(data);
+}
+
+#[inline]
+#[cfg(stage0)]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    ((*tydesc).drop_glue)(0 as **TyDesc, data);
+}
+
 /// Destroys all managed memory (i.e. @ boxes) held by the current task.
 #[cfg(not(test))]
 #[lang="annihilate"]
@@ -201,7 +215,7 @@ pub unsafe fn annihilate() {
         if !uniq {
             let tydesc = (*box).header.type_desc;
             let data = transmute(&(*box).data);
-            ((*tydesc).drop_glue)(to_unsafe_ptr(&tydesc), data);
+            call_drop_glue(tydesc, data);
         }
     }
 
diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs
index 2a211484e73..c9e33219fa5 100644
--- a/src/libstd/gc.rs
+++ b/src/libstd/gc.rs
@@ -316,6 +316,19 @@ fn expect_sentinel() -> bool { true }
 #[cfg(nogc)]
 fn expect_sentinel() -> bool { false }
 
+#[inline]
+#[cfg(not(stage0))]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    // This function should be inlined when stage0 is gone
+    ((*tydesc).drop_glue)(data);
+}
+
+#[inline]
+#[cfg(stage0)]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    ((*tydesc).drop_glue)(0 as **TyDesc, data);
+}
+
 // Entry point for GC-based cleanup. Walks stack looking for exchange
 // heap and stack allocations requiring drop, and runs all
 // destructors.
@@ -359,7 +372,7 @@ pub fn cleanup_stack_for_failure() {
                 // FIXME #4420: Destroy this box
                 // FIXME #4330: Destroy this box
             } else {
-                ((*tydesc).drop_glue)(&tydesc as **TyDesc, *root as *i8);
+                call_drop_glue(tydesc, *root as *i8);
             }
         }
     }
diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs
index 84bb2a952f2..bd34574c3b7 100644
--- a/src/libstd/unstable/intrinsics.rs
+++ b/src/libstd/unstable/intrinsics.rs
@@ -36,6 +36,10 @@ A quick refresher on memory ordering:
 #[cfg(test)]
 pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor};
 
+#[cfg(not(stage0))]
+pub type GlueFn = extern "Rust" fn(*i8);
+
+#[cfg(stage0)]
 pub type GlueFn = extern "Rust" fn(**TyDesc, *i8);
 
 // NB: this has to be kept in sync with the Rust ABI.
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index fe1b4622137..81ae991623f 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -183,7 +183,11 @@ void task_start_wrapper(spawn_args *a)
     if(env) {
         // free the environment (which should be a unique closure).
         const type_desc *td = env->td;
-        td->drop_glue(NULL, NULL, box_body(env));
+        td->drop_glue(NULL,
+#ifdef _RUST_STAGE0
+                      NULL,
+#endif
+                      box_body(env));
         task->kernel->region()->free(env);
     }
 
diff --git a/src/rt/rust_type.h b/src/rt/rust_type.h
index 70b5c1dc6be..30ff5f1fa54 100644
--- a/src/rt/rust_type.h
+++ b/src/rt/rust_type.h
@@ -25,7 +25,11 @@ typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *);
 
 struct type_desc;
 
-typedef void CDECL (glue_fn)(void *, const type_desc **, void *);
+typedef void CDECL (glue_fn)(void *,
+#ifdef _RUST_STAGE0
+                             const type_desc **,
+#endif
+                             void *);
 
 // Corresponds to the boxed data in the @ region.  The body follows the
 // header; you can obtain a ptr via box_body() below.