Skip to content

Commit

Permalink
Remove the last remnants of rtcalls
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Feb 28, 2013
1 parent 6ebc761 commit 2f858de
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/libcore/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn debug_mem() -> bool {
#[cfg(notest)]
#[lang="annihilate"]
pub unsafe fn annihilate() {
use rt::rt_free;
use rt::local_free;
use io::WriterUtil;
use io;
use libc;
Expand Down Expand Up @@ -192,7 +192,7 @@ pub unsafe fn annihilate() {
stats.n_bytes_freed +=
(*((*box).header.type_desc)).size
+ sys::size_of::<BoxRepr>();
rt_free(transmute(box));
local_free(transmute(box));
}
}

Expand Down
28 changes: 11 additions & 17 deletions src/libcore/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,60 +36,54 @@ pub extern mod rustrt {
unsafe fn rust_upcall_free(ptr: *c_char);
}

#[rt(fail_)]
#[lang="fail_"]
pub fn rt_fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
sys::begin_unwind_(expr, file, line);
}

#[rt(fail_bounds_check)]
#[lang="fail_bounds_check"]
pub unsafe fn rt_fail_bounds_check(file: *c_char, line: size_t,
index: size_t, len: size_t) {
pub unsafe fn fail_bounds_check(file: *c_char, line: size_t,
index: size_t, len: size_t) {
let msg = fmt!("index out of bounds: the len is %d but the index is %d",
len as int, index as int);
do str::as_buf(msg) |p, _len| {
rt_fail_(p as *c_char, file, line);
fail_(p as *c_char, file, line);
}
}

pub unsafe fn rt_fail_borrowed() {
pub unsafe fn fail_borrowed() {
let msg = "borrowed";
do str::as_buf(msg) |msg_p, _| {
do str::as_buf("???") |file_p, _| {
rt_fail_(msg_p as *c_char, file_p as *c_char, 0);
fail_(msg_p as *c_char, file_p as *c_char, 0);
}
}
}

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

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

#[rt(malloc)]
#[lang="malloc"]
pub unsafe fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char {
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
return rustrt::rust_upcall_malloc(td, size);
}

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

Expand All @@ -112,7 +106,7 @@ pub unsafe fn return_to_mut(a: *u8) {
pub unsafe fn check_not_borrowed(a: *u8) {
let a: *mut BoxRepr = transmute(a);
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
rt_fail_borrowed();
fail_borrowed();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ pub fn compare_values(cx: block,
let scratch_rhs = alloca(cx, val_ty(rhs));
Store(cx, rhs, scratch_rhs);
let did = cx.tcx().lang_items.uniq_str_eq_fn();
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
let bcx = callee::trans_lang_call(cx, did,
~[scratch_lhs,
scratch_rhs],
expr::SaveIn(
Expand All @@ -1069,7 +1069,7 @@ pub fn compare_values(cx: block,
let scratch_result = scratch_datum(cx, ty::mk_bool(cx.tcx()),
false);
let did = cx.tcx().lang_items.str_eq_fn();
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
let bcx = callee::trans_lang_call(cx, did,
~[lhs, rhs],
expr::SaveIn(
scratch_result.val));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ pub fn malloc_raw_dyn(bcx: block,
// Allocate space:
let tydesc = PointerCast(bcx, static_ti.tydesc, T_ptr(T_i8()));
let rval = alloca(bcx, T_ptr(T_i8()));
let bcx = callee::trans_rtcall_or_lang_call(
let bcx = callee::trans_lang_call(
bcx,
langcall,
~[tydesc, size],
Expand Down
22 changes: 11 additions & 11 deletions src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ pub fn trans_method_call(in_cx: block,
DontAutorefArg)
}

pub fn trans_rtcall_or_lang_call(bcx: block,
did: ast::def_id,
args: &[ValueRef],
dest: expr::Dest)
-> block {
pub fn trans_lang_call(bcx: block,
did: ast::def_id,
args: &[ValueRef],
dest: expr::Dest)
-> block {
let fty = if did.crate == ast::local_crate {
ty::node_id_to_type(bcx.ccx().tcx, did.node)
} else {
Expand All @@ -349,12 +349,12 @@ pub fn trans_rtcall_or_lang_call(bcx: block,
ArgVals(args), dest, DontAutorefArg);
}

pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
did: ast::def_id,
args: &[ValueRef],
type_params: ~[ty::t],
dest: expr::Dest)
-> block {
pub fn trans_lang_call_with_type_params(bcx: block,
did: ast::def_id,
args: &[ValueRef],
type_params: ~[ty::t],
dest: expr::Dest)
-> block {
let fty;
if did.crate == ast::local_crate {
fty = ty::node_id_to_type(bcx.tcx(), did.node);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pub fn make_opaque_cbox_take_glue(
// Allocate memory, update original ptr, and copy existing data
let opaque_tydesc = PointerCast(bcx, tydesc, T_ptr(T_i8()));
let rval = alloca(bcx, T_ptr(T_i8()));
let bcx = callee::trans_rtcall_or_lang_call(
let bcx = callee::trans_lang_call(
bcx,
bcx.tcx().lang_items.exchange_malloc_fn(),
~[opaque_tydesc, sz],
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub fn add_clean_frozen_root(bcx: block, val: ValueRef, t: ty::t) {
do in_scope_cx(bcx) |scope_info| {
scope_info.cleanups.push(
clean_temp(val, |bcx| {
let bcx = callee::trans_rtcall_or_lang_call(
let bcx = callee::trans_lang_call(
bcx,
bcx.tcx().lang_items.return_to_mut_fn(),
~[
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/controlflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub fn trans_log(log_ex: @ast::expr,
// Call the polymorphic log function
let val = val_datum.to_ref_llval(bcx);
let did = bcx.tcx().lang_items.log_type_fn();
let bcx = callee::trans_rtcall_or_lang_call_with_type_params(
let bcx = callee::trans_lang_call_with_type_params(
bcx, did, ~[level, val], ~[val_datum.ty], expr::Ignore);
bcx
}
Expand Down Expand Up @@ -384,7 +384,7 @@ fn trans_fail_value(bcx: block,
let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8()));
let V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8()));
let args = ~[V_str, V_filename, C_int(ccx, V_line)];
let bcx = callee::trans_rtcall_or_lang_call(
let bcx = callee::trans_lang_call(
bcx, bcx.tcx().lang_items.fail_fn(), args, expr::Ignore);
Unreachable(bcx);
return bcx;
Expand All @@ -401,7 +401,7 @@ pub fn trans_fail_bounds_check(bcx: block, sp: span,
let filename = PointerCast(bcx, filename_cstr, T_ptr(T_i8()));

let args = ~[filename, line, index, len];
let bcx = callee::trans_rtcall_or_lang_call(
let bcx = callee::trans_lang_call(
bcx, bcx.tcx().lang_items.fail_bounds_check_fn(), args, expr::Ignore);
Unreachable(bcx);
return bcx;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/datum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ pub impl Datum {

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

callee::trans_rtcall_or_lang_call(
callee::trans_lang_call(
bcx,
bcx.tcx().lang_items.check_not_borrowed_fn(),
~[ PointerCast(bcx, llval, T_ptr(T_i8())) ],
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use core::str;

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

pub fn trans_exchange_free(cx: block, v: ValueRef) -> block {
let _icx = cx.insn_ctxt("trans_exchange_free");
callee::trans_rtcall_or_lang_call(
callee::trans_lang_call(
cx,
cx.tcx().lang_items.exchange_free_fn(),
~[PointerCast(cx, v, T_ptr(T_i8()))],
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/tvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: block,
let llsizeval = C_uint(bcx.ccx(), s.len());
let typ = ty::mk_estr(bcx.tcx(), ty::vstore_uniq);
let lldestval = datum::scratch_datum(bcx, typ, false);
let bcx = callee::trans_rtcall_or_lang_call(
let bcx = callee::trans_lang_call(
bcx,
bcx.tcx().lang_items.strdup_uniq_fn(),
~[ llptrval, llsizeval ],
Expand Down

5 comments on commit 2f858de

@bors
Copy link
Contributor

@bors bors commented on 2f858de Feb 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at brson@2f858de

@bors
Copy link
Contributor

@bors bors commented on 2f858de Feb 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging brson/rust/rtcall = 2f858de into auto

@bors
Copy link
Contributor

@bors bors commented on 2f858de Feb 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brson/rust/rtcall = 2f858de merged ok, testing candidate = b171d0e

@bors
Copy link
Contributor

@bors bors commented on 2f858de Feb 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 2f858de Feb 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = b171d0e

Please sign in to comment.