Skip to content

Commit b171d0e

Browse files
committed
auto merge of #5159 : brson/rust/rtcall, r=brson
2 parents c705440 + 2f858de commit b171d0e

File tree

11 files changed

+37
-43
lines changed

11 files changed

+37
-43
lines changed

src/libcore/cleanup.rs

+2-2
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::rt_free;
157+
use rt::local_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-
rt_free(transmute(box));
195+
local_free(transmute(box));
196196
}
197197
}
198198

src/libcore/rt.rs

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

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

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

56-
pub unsafe fn rt_fail_borrowed() {
54+
pub unsafe fn fail_borrowed() {
5755
let msg = "borrowed";
5856
do str::as_buf(msg) |msg_p, _| {
5957
do str::as_buf("???") |file_p, _| {
60-
rt_fail_(msg_p as *c_char, file_p as *c_char, 0);
58+
fail_(msg_p as *c_char, file_p as *c_char, 0);
6159
}
6260
}
6361
}
6462

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

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

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

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

@@ -112,7 +106,7 @@ pub unsafe fn return_to_mut(a: *u8) {
112106
pub unsafe fn check_not_borrowed(a: *u8) {
113107
let a: *mut BoxRepr = transmute(a);
114108
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
115-
rt_fail_borrowed();
109+
fail_borrowed();
116110
}
117111
}
118112

src/librustc/middle/trans/_match.rs

+2-2
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_rtcall_or_lang_call(cx, did,
1057+
let bcx = callee::trans_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_rtcall_or_lang_call(cx, did,
1072+
let bcx = callee::trans_lang_call(cx, did,
10731073
~[lhs, rhs],
10741074
expr::SaveIn(
10751075
scratch_result.val));

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub fn malloc_raw_dyn(bcx: block,
307307
// Allocate space:
308308
let tydesc = PointerCast(bcx, static_ti.tydesc, T_ptr(T_i8()));
309309
let rval = alloca(bcx, T_ptr(T_i8()));
310-
let bcx = callee::trans_rtcall_or_lang_call(
310+
let bcx = callee::trans_lang_call(
311311
bcx,
312312
langcall,
313313
~[tydesc, size],

src/librustc/middle/trans/callee.rs

+11-11
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_rtcall_or_lang_call(bcx: block,
336-
did: ast::def_id,
337-
args: &[ValueRef],
338-
dest: expr::Dest)
339-
-> block {
335+
pub fn trans_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_rtcall_or_lang_call(bcx: block,
349349
ArgVals(args), dest, DontAutorefArg);
350350
}
351351

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 {
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 {
358358
let fty;
359359
if did.crate == ast::local_crate {
360360
fty = ty::node_id_to_type(bcx.tcx(), did.node);

src/librustc/middle/trans/closure.rs

+1-1
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_rtcall_or_lang_call(
503+
let bcx = callee::trans_lang_call(
504504
bcx,
505505
bcx.tcx().lang_items.exchange_malloc_fn(),
506506
~[opaque_tydesc, sz],

src/librustc/middle/trans/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ pub fn add_clean_frozen_root(bcx: block, val: ValueRef, t: ty::t) {
445445
do in_scope_cx(bcx) |scope_info| {
446446
scope_info.cleanups.push(
447447
clean_temp(val, |bcx| {
448-
let bcx = callee::trans_rtcall_or_lang_call(
448+
let bcx = callee::trans_lang_call(
449449
bcx,
450450
bcx.tcx().lang_items.return_to_mut_fn(),
451451
~[

src/librustc/middle/trans/controlflow.rs

+3-3
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_rtcall_or_lang_call_with_type_params(
219+
let bcx = callee::trans_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_rtcall_or_lang_call(
387+
let bcx = callee::trans_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_rtcall_or_lang_call(
404+
let bcx = callee::trans_lang_call(
405405
bcx, bcx.tcx().lang_items.fail_bounds_check_fn(), args, expr::Ignore);
406406
Unreachable(bcx);
407407
return bcx;

src/librustc/middle/trans/datum.rs

+2-2
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_rtcall_or_lang_call(
547+
callee::trans_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_rtcall_or_lang_call(
569+
callee::trans_lang_call(
570570
bcx,
571571
bcx.tcx().lang_items.check_not_borrowed_fn(),
572572
~[ PointerCast(bcx, llval, T_ptr(T_i8())) ],

src/librustc/middle/trans/glue.rs

+2-2
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_rtcall_or_lang_call(
33+
callee::trans_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_rtcall_or_lang_call(
42+
callee::trans_lang_call(
4343
cx,
4444
cx.tcx().lang_items.exchange_free_fn(),
4545
~[PointerCast(cx, v, T_ptr(T_i8()))],

src/librustc/middle/trans/tvec.rs

+1-1
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_rtcall_or_lang_call(
309+
let bcx = callee::trans_lang_call(
310310
bcx,
311311
bcx.tcx().lang_items.strdup_uniq_fn(),
312312
~[ llptrval, llsizeval ],

0 commit comments

Comments
 (0)