Skip to content

Commit 2ca8331

Browse files
committed
---
yaml --- r: 63586 b: refs/heads/snap-stage3 c: e2f1049 h: refs/heads/master v: v3
1 parent 887b62c commit 2ca8331

File tree

10 files changed

+67
-38
lines changed

10 files changed

+67
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1b76bac41de9f52295a99db21abdd1ad5b0fc231
4+
refs/heads/snap-stage3: e2f1049bd5f041f1f219d683e4e29e32ca30cd1c
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/arena.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ fn round_up_to(base: uint, align: uint) -> uint {
115115
(base + (align - 1)) & !(align - 1)
116116
}
117117

118+
#[inline]
119+
#[cfg(not(stage0))]
120+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
121+
// This function should be inlined when stage0 is gone
122+
((*tydesc).drop_glue)(data);
123+
}
124+
125+
#[inline]
126+
#[cfg(stage0)]
127+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
128+
((*tydesc).drop_glue)(0 as **TyDesc, data);
129+
}
130+
118131
// Walk down a chunk, running the destructors for any objects stored
119132
// in it.
120133
unsafe fn destroy_chunk(chunk: &Chunk) {
@@ -134,8 +147,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
134147
//debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
135148
// start, size, align, is_done);
136149
if is_done {
137-
((*tydesc).drop_glue)(&tydesc as **TyDesc,
138-
ptr::offset(buf, start) as *i8);
150+
call_drop_glue(tydesc, ptr::offset(buf, start) as *i8);
139151
}
140152

141153
// Find where the next tydesc lives

branches/snap-stage3/src/librustc/back/abi.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
12-
13-
1411
pub static rc_base_field_refcnt: uint = 0u;
1512

1613
pub static task_field_refcnt: uint = 0u;
@@ -69,14 +66,4 @@ pub static vec_elt_elems: uint = 2u;
6966
pub static slice_elt_base: uint = 0u;
7067
pub static slice_elt_len: uint = 1u;
7168

72-
pub static worst_case_glue_call_args: uint = 7u;
73-
7469
pub static abi_version: uint = 1u;
75-
76-
pub fn memcpy_glue_name() -> ~str { return ~"rust_memcpy_glue"; }
77-
78-
pub fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; }
79-
80-
pub fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; }
81-
82-
pub fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; }

branches/snap-stage3/src/librustc/middle/trans/glue.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
232232
field: uint,
233233
ti: @mut tydesc_info) {
234234
let _icx = push_ctxt("lazily_emit_tydesc_glue");
235-
let llfnty = type_of_glue_fn(ccx);
235+
let llfnty = Type::glue_fn();
236236

237237
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
238238
return;
@@ -338,9 +338,7 @@ pub fn call_tydesc_glue_full(bcx: block,
338338
}
339339
};
340340

341-
Call(bcx, llfn, [C_null(Type::nil().ptr_to()),
342-
C_null(bcx.ccx().tydesc_type.ptr_to().ptr_to()),
343-
llrawptr]);
341+
Call(bcx, llfn, [C_null(Type::nil().ptr_to()), llrawptr]);
344342
}
345343

346344
// See [Note-arg-mode]
@@ -680,7 +678,7 @@ pub fn make_generic_glue_inner(ccx: @mut CrateContext,
680678

681679
let bcx = top_scope_block(fcx, None);
682680
let lltop = bcx.llbb;
683-
let rawptr0_arg = fcx.arg_pos(1u);
681+
let rawptr0_arg = fcx.arg_pos(0u);
684682
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, rawptr0_arg as c_uint) };
685683
let llty = type_of(ccx, t);
686684
let llrawptr0 = PointerCast(bcx, llrawptr0, llty.ptr_to());
@@ -715,7 +713,7 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
715713
let _icx = push_ctxt("emit_tydescs");
716714
// As of this point, allow no more tydescs to be created.
717715
ccx.finished_tydescs = true;
718-
let glue_fn_ty = Type::generic_glue_fn(ccx);
716+
let glue_fn_ty = Type::generic_glue_fn(ccx).ptr_to();
719717
let tyds = &mut ccx.tydescs;
720718
for tyds.each_value |&val| {
721719
let ti = val;
@@ -782,7 +780,3 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
782780
}
783781
};
784782
}
785-
786-
pub fn type_of_glue_fn(ccx: &CrateContext) -> Type {
787-
Type::glue_fn(ccx.tydesc_type)
788-
}

branches/snap-stage3/src/librustc/middle/trans/type_.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use middle::trans::base;
2020

2121
use syntax::ast;
2222
use syntax::abi::{Architecture, X86, X86_64, Arm, Mips};
23-
use back::abi;
2423

2524
use core::vec;
2625
use core::cast;
@@ -189,22 +188,20 @@ impl Type {
189188
None => ()
190189
}
191190

192-
let ty = Type::glue_fn(cx.tydesc_type).ptr_to();
191+
let ty = Type::glue_fn();
193192
cx.tn.associate_type("glue_fn", &ty);
194193

195194
return ty;
196195
}
197196

198-
pub fn glue_fn(tydesc: Type) -> Type {
199-
let tydescpp = tydesc.ptr_to().ptr_to();
200-
Type::func([ Type::nil().ptr_to(), tydescpp, Type::i8p() ],
197+
pub fn glue_fn() -> Type {
198+
Type::func([ Type::nil().ptr_to(), Type::i8p() ],
201199
&Type::void())
202200
}
203201

204202
pub fn tydesc(arch: Architecture) -> Type {
205203
let mut tydesc = Type::named_struct("tydesc");
206-
let pvoid = Type::i8p();
207-
let glue_fn_ty = Type::glue_fn(tydesc).ptr_to();
204+
let glue_fn_ty = Type::glue_fn().ptr_to();
208205

209206
let int_ty = Type::int(arch);
210207

branches/snap-stage3/src/libstd/cleanup.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#[doc(hidden)];
1212

1313
use libc::{c_char, intptr_t, uintptr_t};
14-
use ptr::{mut_null, to_unsafe_ptr};
14+
use ptr::{mut_null};
1515
use repr::BoxRepr;
1616
use cast::transmute;
17+
use unstable::intrinsics::TyDesc;
1718
#[cfg(not(test))] use unstable::lang::clear_task_borrow_list;
1819

1920
/**
@@ -158,6 +159,19 @@ fn debug_mem() -> bool {
158159
false
159160
}
160161

162+
#[inline]
163+
#[cfg(not(stage0))]
164+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
165+
// This function should be inlined when stage0 is gone
166+
((*tydesc).drop_glue)(data);
167+
}
168+
169+
#[inline]
170+
#[cfg(stage0)]
171+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
172+
((*tydesc).drop_glue)(0 as **TyDesc, data);
173+
}
174+
161175
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
162176
#[cfg(not(test))]
163177
#[lang="annihilate"]
@@ -201,7 +215,7 @@ pub unsafe fn annihilate() {
201215
if !uniq {
202216
let tydesc = (*box).header.type_desc;
203217
let data = transmute(&(*box).data);
204-
((*tydesc).drop_glue)(to_unsafe_ptr(&tydesc), data);
218+
call_drop_glue(tydesc, data);
205219
}
206220
}
207221

branches/snap-stage3/src/libstd/gc.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,19 @@ fn expect_sentinel() -> bool { true }
316316
#[cfg(nogc)]
317317
fn expect_sentinel() -> bool { false }
318318

319+
#[inline]
320+
#[cfg(not(stage0))]
321+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
322+
// This function should be inlined when stage0 is gone
323+
((*tydesc).drop_glue)(data);
324+
}
325+
326+
#[inline]
327+
#[cfg(stage0)]
328+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
329+
((*tydesc).drop_glue)(0 as **TyDesc, data);
330+
}
331+
319332
// Entry point for GC-based cleanup. Walks stack looking for exchange
320333
// heap and stack allocations requiring drop, and runs all
321334
// destructors.
@@ -359,7 +372,7 @@ pub fn cleanup_stack_for_failure() {
359372
// FIXME #4420: Destroy this box
360373
// FIXME #4330: Destroy this box
361374
} else {
362-
((*tydesc).drop_glue)(&tydesc as **TyDesc, *root as *i8);
375+
call_drop_glue(tydesc, *root as *i8);
363376
}
364377
}
365378
}

branches/snap-stage3/src/libstd/unstable/intrinsics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ A quick refresher on memory ordering:
3636
#[cfg(test)]
3737
pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor};
3838

39+
#[cfg(not(stage0))]
40+
pub type GlueFn = extern "Rust" fn(*i8);
41+
42+
#[cfg(stage0)]
3943
pub type GlueFn = extern "Rust" fn(**TyDesc, *i8);
4044

4145
// NB: this has to be kept in sync with the Rust ABI.

branches/snap-stage3/src/rt/rust_task.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ void task_start_wrapper(spawn_args *a)
183183
if(env) {
184184
// free the environment (which should be a unique closure).
185185
const type_desc *td = env->td;
186-
td->drop_glue(NULL, NULL, box_body(env));
186+
td->drop_glue(NULL,
187+
#ifdef _RUST_STAGE0
188+
NULL,
189+
#endif
190+
box_body(env));
187191
task->kernel->region()->free(env);
188192
}
189193

branches/snap-stage3/src/rt/rust_type.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *);
2525

2626
struct type_desc;
2727

28-
typedef void CDECL (glue_fn)(void *, const type_desc **, void *);
28+
typedef void CDECL (glue_fn)(void *,
29+
#ifdef _RUST_STAGE0
30+
const type_desc **,
31+
#endif
32+
void *);
2933

3034
// Corresponds to the boxed data in the @ region. The body follows the
3135
// header; you can obtain a ptr via box_body() below.

0 commit comments

Comments
 (0)