std: Re-optimize tls access on local allocation path
I did this once but acciddentally undid it in a later patch.
This commit is contained in:
parent
59da4e0bc9
commit
95badabaaf
4 changed files with 24 additions and 16 deletions
|
|
@ -13,6 +13,7 @@
|
|||
use c_str::ToCStr;
|
||||
use cast::transmute;
|
||||
use libc::{c_char, c_void, size_t, uintptr_t};
|
||||
use option::{Some, None};
|
||||
use sys;
|
||||
use rt::task::Task;
|
||||
use rt::local::Local;
|
||||
|
|
@ -35,14 +36,13 @@ pub fn fail_bounds_check(file: *c_char, line: size_t,
|
|||
|
||||
#[lang="malloc"]
|
||||
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
|
||||
let mut alloc = ::ptr::null();
|
||||
do Local::borrow::<Task,()> |task| {
|
||||
rtdebug!("task pointer: %x, heap pointer: %x",
|
||||
::borrow::to_uint(task),
|
||||
::borrow::to_uint(&task.heap));
|
||||
alloc = task.heap.alloc(td as *c_void, size as uint) as *c_char;
|
||||
// XXX: Unsafe borrow for speed. Lame.
|
||||
match Local::try_unsafe_borrow::<Task>() {
|
||||
Some(task) => {
|
||||
(*task).heap.alloc(td as *c_void, size as uint) as *c_char
|
||||
}
|
||||
None => rtabort!("local malloc outside of task")
|
||||
}
|
||||
return alloc;
|
||||
}
|
||||
|
||||
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue