mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 22:22:44 +00:00
rustc: Implement interior string logging in DPS
This commit is contained in:
parent
f6f7f61908
commit
88574c3cea
@ -8,6 +8,7 @@ import middle::trans_common::T_bool;
|
||||
import middle::trans_common::T_i8;
|
||||
import middle::trans_common::T_i32;
|
||||
import middle::trans_common::T_int;
|
||||
import middle::trans_common::T_ivec;
|
||||
import middle::trans_common::T_nil;
|
||||
import middle::trans_common::T_opaque_chan_ptr;
|
||||
import middle::trans_common::T_opaque_ivec;
|
||||
@ -28,6 +29,7 @@ type upcalls =
|
||||
ValueRef log_float,
|
||||
ValueRef log_double,
|
||||
ValueRef log_str,
|
||||
ValueRef log_istr,
|
||||
ValueRef trace_word,
|
||||
ValueRef trace_str,
|
||||
ValueRef new_port,
|
||||
@ -82,6 +84,7 @@ fn declare_upcalls(type_names tn, TypeRef tydesc_type, TypeRef taskptr_type,
|
||||
log_float=dv("log_float", ~[T_i32(), T_f32()]),
|
||||
log_double=dv("log_double", ~[T_i32(), T_ptr(T_f64())]),
|
||||
log_str=dv("log_str", ~[T_i32(), T_ptr(T_str())]),
|
||||
log_istr=dv("log_istr", ~[T_i32(), T_ptr(T_ivec(T_i8()))]),
|
||||
trace_word=dv("trace_word", ~[T_int()]),
|
||||
trace_str=dv("trace_str", ~[T_ptr(T_i8())]),
|
||||
new_port=d("new_port", ~[T_size_t()], T_opaque_port_ptr()),
|
||||
|
@ -222,6 +222,9 @@ fn trans_log(&@block_ctxt cx, &span sp, int level, &@ast::expr expr)
|
||||
ty::ty_machine(ast::ty_u32) {
|
||||
by_val = true; llupcall = bcx_ccx(bcx).upcalls.log_int;
|
||||
}
|
||||
ty::ty_istr {
|
||||
by_val = false; llupcall = bcx_ccx(bcx).upcalls.log_istr;
|
||||
}
|
||||
_ {
|
||||
bcx_ccx(bcx).sess.span_unimpl(sp, "logging for values of type " +
|
||||
ppaux::ty_to_str(bcx_tcx(bcx), t));
|
||||
@ -322,11 +325,12 @@ fn trans_lit_str_common(&@crate_ctxt ccx, &str s)
|
||||
none);
|
||||
}
|
||||
|
||||
auto llarray = tc::C_array(tc::T_i8(), array);
|
||||
auto llheappart = tc::C_struct(~[tc::C_uint(len),
|
||||
tc::C_array(tc::T_i8(), array)]);
|
||||
ret tup(tc::C_struct(~[tc::C_uint(0u),
|
||||
tc::C_uint(abi::ivec_default_length),
|
||||
tc::C_null(tc::T_ptr(lltype_of(llarray)))]),
|
||||
some(llarray));
|
||||
tc::C_null(tc::T_ptr(lltype_of(llheappart)))]),
|
||||
some(llheappart));
|
||||
}
|
||||
|
||||
// As above, we don't use destination-passing style here.
|
||||
|
@ -75,6 +75,16 @@ upcall_log_str(rust_task *task, uint32_t level, rust_str *str) {
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
upcall_log_istr(rust_task *task, uint32_t level, rust_ivec *str) {
|
||||
LOG_UPCALL_ENTRY(task);
|
||||
if (task->sched->log_lvl < level)
|
||||
return;
|
||||
const char *buf = (const char *)
|
||||
(str->fill ? str->payload.data : str->payload.ptr->data);
|
||||
task->sched->log(task, level, "rust: %s", buf);
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
upcall_trace_word(rust_task *task, uintptr_t i) {
|
||||
LOG_UPCALL_ENTRY(task);
|
||||
|
@ -68,6 +68,7 @@ upcall_kill
|
||||
upcall_log_double
|
||||
upcall_log_float
|
||||
upcall_log_int
|
||||
upcall_log_istr
|
||||
upcall_log_str
|
||||
upcall_malloc
|
||||
upcall_mark
|
||||
|
Loading…
Reference in New Issue
Block a user