From 7d0958f70ff16ee40649a943306c9b104a5fc829 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 28 Feb 2012 11:58:50 -0800 Subject: [PATCH] add the ability to snag the frame so we can verify that we are inlining --- src/comp/middle/trans/base.rs | 7 +++++++ src/libcore/sys.rs | 5 +++++ src/rt/rust_builtin.cpp | 6 ++++++ src/rt/rust_util.h | 17 +++++++++++++++++ src/rt/rustrt.def.in | 3 ++- 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/comp/middle/trans/base.rs b/src/comp/middle/trans/base.rs index 9d05ec5e10b..04b51b85bcf 100644 --- a/src/comp/middle/trans/base.rs +++ b/src/comp/middle/trans/base.rs @@ -4583,6 +4583,13 @@ fn collect_inlined_items(ccx: crate_ctxt, inline_map: inline::inline_map) { let abi = @mutable none::; inline_map.values {|item| collect_item(ccx, abi, item); + + alt item.node { + ast::item_fn(_, _, _) { + set_always_inline(ccx.item_ids.get(item.id)); + } + _ { /* fallthrough */ } + } } } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 9d9bdb58078..9cdbfaa61af 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -20,6 +20,7 @@ native mod rustrt { fn unsupervise(); fn shape_log_str(t: *sys::type_desc, data: T) -> str; fn rust_set_exit_status(code: ctypes::intptr_t); + fn rust_frame_address() -> ctypes::uintptr_t; } #[abi = "rust-intrinsic"] @@ -77,6 +78,10 @@ fn log_str(t: T) -> str { rustrt::shape_log_str(get_type_desc::(), t) } +fn frame_address() -> uint { + rustrt::rust_frame_address() +} + #[doc( brief = "Sets the process exit code", desc = "Sets the exit code returned by the process if all supervised \ diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 29940492f79..a1b2d9eb45a 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -6,6 +6,7 @@ #include "rust_util.h" #include "rust_scheduler.h" #include "sync/timer.h" +#include "rust_abi.h" #ifdef __APPLE__ #include @@ -681,6 +682,11 @@ rust_dbg_call(dbg_callback cb, void *data) { return cb(data); } +extern "C" CDECL void * +rust_frame_address() { + return __builtin_frame_address(1); +} + // // Local Variables: // mode: C++ diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h index e1efbdf315e..211ad71b545 100644 --- a/src/rt/rust_util.h +++ b/src/rt/rust_util.h @@ -87,6 +87,23 @@ inline size_t vec_size(size_t elems) { return sizeof(rust_vec) + sizeof(T) * elems; } +template +inline rust_vec * +vec_alloc(size_t alloc_elts, size_t fill_elts, const char *name) { + rust_task *task = rust_task_thread::get_task(); + size_t size = vec_size(alloc_elts); + rust_vec *vec = (rust_vec *) task->kernel->malloc(size, name); + vec->fill = fill_elts * sizeof(T); + vec->alloc = alloc_elts * sizeof(T); + return vec; +} + +template +inline T * +vec_data(rust_vec *v) { + return reinterpret_cast(v->data); +} + inline void reserve_vec_exact(rust_task* task, rust_vec** vpp, size_t size) { if (size > (*vpp)->alloc) { *vpp = (rust_vec*)task->kernel->realloc(*vpp, size + sizeof(rust_vec)); diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 2b5929600b0..3ccee2ea508 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -100,4 +100,5 @@ rust_dbg_lock_lock rust_dbg_lock_unlock rust_dbg_lock_wait rust_dbg_lock_signal -rust_dbg_call \ No newline at end of file +rust_dbg_call +rust_frame_address