Skip to content

Commit ce9e5ec

Browse files
committed
core: Inline mallocing wrapper functions
As far as I can tell, this doesn't make rust compile any faster, but it does at least remove one level of indirection on malloc, which might help speed up some operations.
1 parent bb14ea9 commit ce9e5ec

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: src/libcore/unstable/lang.rs

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub unsafe fn fail_borrowed() {
6464

6565
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
6666
#[lang="exchange_malloc"]
67+
#[inline(always)]
6768
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
6869
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
6970
}
@@ -72,11 +73,13 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
7273
// inside a landing pad may corrupt the state of the exception handler. If a
7374
// problem occurs, call exit instead.
7475
#[lang="exchange_free"]
76+
#[inline(always)]
7577
pub unsafe fn exchange_free(ptr: *c_char) {
7678
exchange_alloc::free(transmute(ptr))
7779
}
7880

7981
#[lang="malloc"]
82+
#[inline(always)]
8083
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8184
return rustrt::rust_upcall_malloc(td, size);
8285
}
@@ -85,6 +88,7 @@ pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8588
// inside a landing pad may corrupt the state of the exception handler. If a
8689
// problem occurs, call exit instead.
8790
#[lang="free"]
91+
#[inline(always)]
8892
pub unsafe fn local_free(ptr: *c_char) {
8993
rustrt::rust_upcall_free(ptr);
9094
}
@@ -117,6 +121,7 @@ pub unsafe fn check_not_borrowed(a: *u8) {
117121
}
118122

119123
#[lang="strdup_uniq"]
124+
#[inline(always)]
120125
pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
121126
str::raw::from_buf_len(ptr, len)
122127
}

0 commit comments

Comments
 (0)