Skip to content

Commit dcd64a1

Browse files
committed
---
yaml --- r: 46599 b: refs/heads/auto c: 4a04a18 h: refs/heads/master i: 46597: 6477747 46595: 9e9bb14 46591: 98b4d64 v: v3
1 parent 32dff58 commit dcd64a1

File tree

16 files changed

+58
-48
lines changed

16 files changed

+58
-48
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 2f858de1c39f3fd8bdc77a6517e12a6458c54f03
17+
refs/heads/auto: 4a04a188e3cf86cdef0e499dc65810009de27808

branches/auto/src/libcore/cleanup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn debug_mem() -> bool {
154154
#[cfg(notest)]
155155
#[lang="annihilate"]
156156
pub unsafe fn annihilate() {
157-
use rt::local_free;
157+
use rt::rt_free;
158158
use io::WriterUtil;
159159
use io;
160160
use libc;
@@ -192,7 +192,7 @@ pub unsafe fn annihilate() {
192192
stats.n_bytes_freed +=
193193
(*((*box).header.type_desc)).size
194194
+ sys::size_of::<BoxRepr>();
195-
local_free(transmute(box));
195+
rt_free(transmute(box));
196196
}
197197
}
198198

branches/auto/src/libcore/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use vec;
2020

2121
use pipes::{recv, try_recv, wait_many, peek, PacketHeader};
2222

23-
// NOTE Making this public exposes some plumbing from pipes. Needs
24-
// some refactoring
23+
// FIXME #5160: Making this public exposes some plumbing from
24+
// pipes. Needs some refactoring
2525
pub use pipes::Selectable;
2626

2727
/// A trait for things that can send multiple messages.

branches/auto/src/libcore/rt.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,54 +36,60 @@ pub extern mod rustrt {
3636
unsafe fn rust_upcall_free(ptr: *c_char);
3737
}
3838

39+
#[rt(fail_)]
3940
#[lang="fail_"]
40-
pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
41+
pub fn rt_fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
4142
sys::begin_unwind_(expr, file, line);
4243
}
4344

45+
#[rt(fail_bounds_check)]
4446
#[lang="fail_bounds_check"]
45-
pub unsafe fn fail_bounds_check(file: *c_char, line: size_t,
46-
index: size_t, len: size_t) {
47+
pub unsafe fn rt_fail_bounds_check(file: *c_char, line: size_t,
48+
index: size_t, len: size_t) {
4749
let msg = fmt!("index out of bounds: the len is %d but the index is %d",
4850
len as int, index as int);
4951
do str::as_buf(msg) |p, _len| {
50-
fail_(p as *c_char, file, line);
52+
rt_fail_(p as *c_char, file, line);
5153
}
5254
}
5355

54-
pub unsafe fn fail_borrowed() {
56+
pub unsafe fn rt_fail_borrowed() {
5557
let msg = "borrowed";
5658
do str::as_buf(msg) |msg_p, _| {
5759
do str::as_buf("???") |file_p, _| {
58-
fail_(msg_p as *c_char, file_p as *c_char, 0);
60+
rt_fail_(msg_p as *c_char, file_p as *c_char, 0);
5961
}
6062
}
6163
}
6264

6365
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
66+
#[rt(exchange_malloc)]
6467
#[lang="exchange_malloc"]
65-
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
68+
pub unsafe fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
6669
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
6770
}
6871

6972
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
7073
// inside a landing pad may corrupt the state of the exception handler. If a
7174
// problem occurs, call exit instead.
75+
#[rt(exchange_free)]
7276
#[lang="exchange_free"]
73-
pub unsafe fn exchange_free(ptr: *c_char) {
77+
pub unsafe fn rt_exchange_free(ptr: *c_char) {
7478
exchange_alloc::free(transmute(ptr))
7579
}
7680

81+
#[rt(malloc)]
7782
#[lang="malloc"]
78-
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
83+
pub unsafe fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char {
7984
return rustrt::rust_upcall_malloc(td, size);
8085
}
8186

8287
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
8388
// inside a landing pad may corrupt the state of the exception handler. If a
8489
// problem occurs, call exit instead.
90+
#[rt(free)]
8591
#[lang="free"]
86-
pub unsafe fn local_free(ptr: *c_char) {
92+
pub unsafe fn rt_free(ptr: *c_char) {
8793
rustrt::rust_upcall_free(ptr);
8894
}
8995

@@ -106,7 +112,7 @@ pub unsafe fn return_to_mut(a: *u8) {
106112
pub unsafe fn check_not_borrowed(a: *u8) {
107113
let a: *mut BoxRepr = transmute(a);
108114
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
109-
fail_borrowed();
115+
rt_fail_borrowed();
110116
}
111117
}
112118

branches/auto/src/librustc/middle/trans/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ pub fn compare_values(cx: block,
10541054
let scratch_rhs = alloca(cx, val_ty(rhs));
10551055
Store(cx, rhs, scratch_rhs);
10561056
let did = cx.tcx().lang_items.uniq_str_eq_fn();
1057-
let bcx = callee::trans_lang_call(cx, did,
1057+
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
10581058
~[scratch_lhs,
10591059
scratch_rhs],
10601060
expr::SaveIn(
@@ -1069,7 +1069,7 @@ pub fn compare_values(cx: block,
10691069
let scratch_result = scratch_datum(cx, ty::mk_bool(cx.tcx()),
10701070
false);
10711071
let did = cx.tcx().lang_items.str_eq_fn();
1072-
let bcx = callee::trans_lang_call(cx, did,
1072+
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
10731073
~[lhs, rhs],
10741074
expr::SaveIn(
10751075
scratch_result.val));

branches/auto/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub fn malloc_raw_dyn(bcx: block,
304304
// Allocate space:
305305
let tydesc = PointerCast(bcx, static_ti.tydesc, T_ptr(T_i8()));
306306
let rval = alloca(bcx, T_ptr(T_i8()));
307-
let bcx = callee::trans_lang_call(
307+
let bcx = callee::trans_rtcall_or_lang_call(
308308
bcx,
309309
langcall,
310310
~[tydesc, size],

branches/auto/src/librustc/middle/trans/callee.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ pub fn trans_method_call(in_cx: block,
332332
DontAutorefArg)
333333
}
334334

335-
pub fn trans_lang_call(bcx: block,
336-
did: ast::def_id,
337-
args: &[ValueRef],
338-
dest: expr::Dest)
339-
-> block {
335+
pub fn trans_rtcall_or_lang_call(bcx: block,
336+
did: ast::def_id,
337+
args: &[ValueRef],
338+
dest: expr::Dest)
339+
-> block {
340340
let fty = if did.crate == ast::local_crate {
341341
ty::node_id_to_type(bcx.ccx().tcx, did.node)
342342
} else {
@@ -349,12 +349,12 @@ pub fn trans_lang_call(bcx: block,
349349
ArgVals(args), dest, DontAutorefArg);
350350
}
351351

352-
pub fn trans_lang_call_with_type_params(bcx: block,
353-
did: ast::def_id,
354-
args: &[ValueRef],
355-
type_params: ~[ty::t],
356-
dest: expr::Dest)
357-
-> block {
352+
pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
353+
did: ast::def_id,
354+
args: &[ValueRef],
355+
type_params: ~[ty::t],
356+
dest: expr::Dest)
357+
-> block {
358358
let fty;
359359
if did.crate == ast::local_crate {
360360
fty = ty::node_id_to_type(bcx.tcx(), did.node);

branches/auto/src/librustc/middle/trans/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ pub fn make_opaque_cbox_take_glue(
500500
// Allocate memory, update original ptr, and copy existing data
501501
let opaque_tydesc = PointerCast(bcx, tydesc, T_ptr(T_i8()));
502502
let rval = alloca(bcx, T_ptr(T_i8()));
503-
let bcx = callee::trans_lang_call(
503+
let bcx = callee::trans_rtcall_or_lang_call(
504504
bcx,
505505
bcx.tcx().lang_items.exchange_malloc_fn(),
506506
~[opaque_tydesc, sz],

branches/auto/src/librustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ pub fn add_clean_frozen_root(bcx: block, val: ValueRef, t: ty::t) {
442442
do in_scope_cx(bcx) |scope_info| {
443443
scope_info.cleanups.push(
444444
clean_temp(val, |bcx| {
445-
let bcx = callee::trans_lang_call(
445+
let bcx = callee::trans_rtcall_or_lang_call(
446446
bcx,
447447
bcx.tcx().lang_items.return_to_mut_fn(),
448448
~[

branches/auto/src/librustc/middle/trans/controlflow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub fn trans_log(log_ex: @ast::expr,
216216
// Call the polymorphic log function
217217
let val = val_datum.to_ref_llval(bcx);
218218
let did = bcx.tcx().lang_items.log_type_fn();
219-
let bcx = callee::trans_lang_call_with_type_params(
219+
let bcx = callee::trans_rtcall_or_lang_call_with_type_params(
220220
bcx, did, ~[level, val], ~[val_datum.ty], expr::Ignore);
221221
bcx
222222
}
@@ -384,7 +384,7 @@ fn trans_fail_value(bcx: block,
384384
let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8()));
385385
let V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8()));
386386
let args = ~[V_str, V_filename, C_int(ccx, V_line)];
387-
let bcx = callee::trans_lang_call(
387+
let bcx = callee::trans_rtcall_or_lang_call(
388388
bcx, bcx.tcx().lang_items.fail_fn(), args, expr::Ignore);
389389
Unreachable(bcx);
390390
return bcx;
@@ -401,7 +401,7 @@ pub fn trans_fail_bounds_check(bcx: block, sp: span,
401401
let filename = PointerCast(bcx, filename_cstr, T_ptr(T_i8()));
402402

403403
let args = ~[filename, line, index, len];
404-
let bcx = callee::trans_lang_call(
404+
let bcx = callee::trans_rtcall_or_lang_call(
405405
bcx, bcx.tcx().lang_items.fail_bounds_check_fn(), args, expr::Ignore);
406406
Unreachable(bcx);
407407
return bcx;

branches/auto/src/librustc/middle/trans/datum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ pub impl Datum {
544544

545545
// If we need to freeze the box, do that now.
546546
if root_info.freezes {
547-
callee::trans_lang_call(
547+
callee::trans_rtcall_or_lang_call(
548548
bcx,
549549
bcx.tcx().lang_items.borrow_as_imm_fn(),
550550
~[
@@ -566,7 +566,7 @@ pub impl Datum {
566566
ByRef => Load(bcx, self.val),
567567
};
568568

569-
callee::trans_lang_call(
569+
callee::trans_rtcall_or_lang_call(
570570
bcx,
571571
bcx.tcx().lang_items.check_not_borrowed_fn(),
572572
~[ PointerCast(bcx, llval, T_ptr(T_i8())) ],

branches/auto/src/librustc/middle/trans/glue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use core::str;
3030

3131
pub fn trans_free(cx: block, v: ValueRef) -> block {
3232
let _icx = cx.insn_ctxt("trans_free");
33-
callee::trans_lang_call(
33+
callee::trans_rtcall_or_lang_call(
3434
cx,
3535
cx.tcx().lang_items.free_fn(),
3636
~[PointerCast(cx, v, T_ptr(T_i8()))],
@@ -39,7 +39,7 @@ pub fn trans_free(cx: block, v: ValueRef) -> block {
3939

4040
pub fn trans_exchange_free(cx: block, v: ValueRef) -> block {
4141
let _icx = cx.insn_ctxt("trans_exchange_free");
42-
callee::trans_lang_call(
42+
callee::trans_rtcall_or_lang_call(
4343
cx,
4444
cx.tcx().lang_items.exchange_free_fn(),
4545
~[PointerCast(cx, v, T_ptr(T_i8()))],

branches/auto/src/librustc/middle/trans/tvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: block,
306306
let llsizeval = C_uint(bcx.ccx(), s.len());
307307
let typ = ty::mk_estr(bcx.tcx(), ty::vstore_uniq);
308308
let lldestval = datum::scratch_datum(bcx, typ, false);
309-
let bcx = callee::trans_lang_call(
309+
let bcx = callee::trans_rtcall_or_lang_call(
310310
bcx,
311311
bcx.tcx().lang_items.strdup_uniq_fn(),
312312
~[ llptrval, llsizeval ],

branches/auto/src/rt/rust_builtin.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ vec_reserve_shared_actual(type_desc* ty, rust_vec_box** vp,
124124
extern "C" CDECL void
125125
vec_reserve_shared(type_desc* ty, rust_vec_box** vp,
126126
size_t n_elts) {
127-
rust_task *task = rust_get_current_task();
128-
reserve_vec_exact(task, vp, n_elts * ty->size);
127+
reserve_vec_exact(vp, n_elts * ty->size);
129128
}
130129

131130
extern "C" CDECL size_t
@@ -445,9 +444,8 @@ void tm_to_rust_tm(tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
445444
out_tm->tm_nsec = nsec;
446445

447446
if (zone != NULL) {
448-
rust_task *task = rust_get_current_task();
449447
size_t size = strlen(zone);
450-
reserve_vec_exact(task, &out_tm->tm_zone, size + 1);
448+
reserve_vec_exact(&out_tm->tm_zone, size + 1);
451449
memcpy(out_tm->tm_zone->body.data, zone, size);
452450
out_tm->tm_zone->body.fill = size + 1;
453451
out_tm->tm_zone->body.data[size] = '\0';

branches/auto/src/rt/rust_upcall.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ extern "C" CDECL void
118118
upcall_fail(char const *expr,
119119
char const *file,
120120
size_t line) {
121-
rust_task *task = rust_get_current_task();
121+
rust_task *task = rust_try_get_current_task();
122+
if (task == NULL) {
123+
// FIXME #5161: Need to think about what to do here
124+
printf("failure outside of a task");
125+
abort();
126+
}
122127
s_fail_args args = {task,expr,file,line};
123128
UPCALL_SWITCH_STACK(task, &args, upcall_s_fail);
124129
}

branches/auto/src/rt/rust_util.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ inline void reserve_vec_exact_shared(rust_task* task, rust_vec_box** vpp,
6767
}
6868
}
6969

70-
inline void reserve_vec_exact(rust_task* task, rust_vec_box** vpp,
70+
inline void reserve_vec_exact(rust_vec_box** vpp,
7171
size_t size) {
7272
if (size > (*vpp)->body.alloc) {
73-
*vpp = (rust_vec_box*)task->kernel
74-
->realloc(*vpp, size + sizeof(rust_vec_box));
73+
rust_exchange_alloc exchange_alloc;
74+
*vpp = (rust_vec_box*)exchange_alloc
75+
.realloc(*vpp, size + sizeof(rust_vec_box));
7576
(*vpp)->body.alloc = size;
7677
}
7778
}

0 commit comments

Comments
 (0)