Skip to content

Commit 56f9da9

Browse files
committed
---
yaml --- r: 30731 b: refs/heads/incoming c: ac822a5 h: refs/heads/master i: 30729: 21b5d56 30727: dc03639 v: v3
1 parent bbd2c3d commit 56f9da9

File tree

7 files changed

+49
-16
lines changed

7 files changed

+49
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: dbc00ced3a09a7a8c32d69a89b9e073252cca39d
9+
refs/heads/incoming: ac822a52be47579ffa59d5ca3e125680a79545d0
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/logging.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
#[forbid(deprecated_mode)];
55
#[forbid(deprecated_pattern)];
66

7-
export console_on, console_off;
7+
use cast::transmute;
8+
9+
export console_on, console_off, log_type;
810

911
#[nolink]
1012
extern mod rustrt {
1113
#[legacy_exports];
1214
fn rust_log_console_on();
1315
fn rust_log_console_off();
16+
fn rust_log_str(level: u32, string: *libc::c_char, size: libc::size_t);
1417
}
1518

1619
/// Turns on logging to stdout globally
@@ -27,4 +30,17 @@ fn console_on() {
2730
*/
2831
fn console_off() {
2932
rustrt::rust_log_console_off();
30-
}
33+
}
34+
35+
#[cfg(notest)]
36+
#[lang="log_type"]
37+
pub fn log_type<T>(level: u32, object: &T) {
38+
let bytes = do io::with_bytes_writer() |writer| {
39+
repr::write_repr(writer, object);
40+
};
41+
unsafe {
42+
let len = bytes.len() as libc::size_t;
43+
rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len);
44+
}
45+
}
46+

branches/incoming/src/rt/rust_builtin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,9 @@ rust_call_tydesc_glue(void *root, size_t *tydesc, size_t glue_index) {
952952

953953
// Don't run on the Rust stack!
954954
extern "C" void
955-
rust_log_str(uint32_t level, const char *str) {
955+
rust_log_str(uint32_t level, const char *str, size_t size) {
956956
rust_task *task = rust_get_current_task();
957-
task->sched_loop->get_log().log(task, level, "%s", str);
957+
task->sched_loop->get_log().log(task, level, "%.*s", (int)size, str);
958958
}
959959

960960
//

branches/incoming/src/rustc/middle/lang_items.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ struct LanguageItems {
4646

4747
mut str_eq_fn: Option<def_id>,
4848
mut uniq_str_eq_fn: Option<def_id>,
49-
mut annihilate_fn: Option<def_id>
49+
mut annihilate_fn: Option<def_id>,
50+
mut log_type_fn: Option<def_id>
5051
}
5152

5253
mod LanguageItems {
@@ -76,7 +77,8 @@ mod LanguageItems {
7677

7778
str_eq_fn: None,
7879
uniq_str_eq_fn: None,
79-
annihilate_fn: None
80+
annihilate_fn: None,
81+
log_type_fn: None
8082
}
8183
}
8284
}
@@ -111,6 +113,7 @@ fn LanguageItemCollector(crate: @crate, session: session,
111113
item_refs.insert(~"str_eq", &mut items.str_eq_fn);
112114
item_refs.insert(~"uniq_str_eq", &mut items.uniq_str_eq_fn);
113115
item_refs.insert(~"annihilate", &mut items.annihilate_fn);
116+
item_refs.insert(~"log_type", &mut items.log_type_fn);
114117

115118
LanguageItemCollector {
116119
crate: crate,

branches/incoming/src/rustc/middle/trans/base.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,12 +2005,6 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
20052005
}
20062006
Call(bcx, main_llfn, args);
20072007

2008-
// Call the box annihilator.
2009-
// XXX: Crashes.
2010-
//let did = bcx.tcx().lang_items.annihilate_fn.get();
2011-
//let bcx = callee::trans_rtcall_or_lang_call(bcx, did, ~[],
2012-
// expr::Ignore);
2013-
20142008
build_return(bcx);
20152009
finish_fn(fcx, lltop);
20162010
return llfdecl;

branches/incoming/src/rustc/middle/trans/callee.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,26 @@ fn trans_rtcall_or_lang_call(bcx: block, did: ast::def_id, args: ~[ValueRef],
290290
ArgVals(args), dest, DontAutorefArg);
291291
}
292292

293+
fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
294+
did: ast::def_id,
295+
args: ~[ValueRef],
296+
type_params: ~[ty::t],
297+
dest: expr::Dest) -> block {
298+
let fty;
299+
if did.crate == ast::local_crate {
300+
fty = ty::node_id_to_type(bcx.tcx(), did.node);
301+
} else {
302+
fty = csearch::get_type(bcx.tcx(), did).ty;
303+
}
304+
305+
let rty = ty::ty_fn_ret(fty);
306+
return callee::trans_call_inner(
307+
bcx, None, fty, rty,
308+
|bcx| trans_fn_ref_with_vtables_to_callee(bcx, did, 0, type_params,
309+
None),
310+
ArgVals(args), dest, DontAutorefArg);
311+
}
312+
293313
fn body_contains_ret(body: ast::blk) -> bool {
294314
let cx = {mut found: false};
295315
visit::visit_block(body, cx, visit::mk_vt(@{

branches/incoming/src/rustc/middle/trans/controlflow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ fn trans_log(log_ex: @ast::expr,
190190
191191
// Translate the value to be logged
192192
let val_datum = unpack_datum!(bcx, expr::trans_to_datum(bcx, e));
193-
let tydesc = get_tydesc_simple(ccx, val_datum.ty);
194193
195194
// Call the polymorphic log function
196195
let val = val_datum.to_ref_llval(bcx);
197-
let val = PointerCast(bcx, val, T_ptr(T_i8()));
198-
Call(bcx, ccx.upcalls.log_type, [tydesc, val, level]);
196+
let did = bcx.tcx().lang_items.log_type_fn.get();
197+
let bcx = callee::trans_rtcall_or_lang_call_with_type_params(
198+
bcx, did, ~[level, val], ~[val_datum.ty], expr::Ignore);
199199
bcx
200200
}
201201
}

0 commit comments

Comments
 (0)