Send string concatenation to specialized upcall, shave 17s off librustc compile time.
This commit is contained in:
@@ -309,6 +309,34 @@ upcall_vec_grow(rust_vec** vp, size_t new_sz) {
|
|||||||
UPCALL_SWITCH_STACK(&args, upcall_s_vec_grow);
|
UPCALL_SWITCH_STACK(&args, upcall_s_vec_grow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct s_str_concat_args {
|
||||||
|
rust_vec* lhs;
|
||||||
|
rust_vec* rhs;
|
||||||
|
rust_vec* retval;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" CDECL void
|
||||||
|
upcall_s_str_concat(s_str_concat_args *args) {
|
||||||
|
rust_vec *lhs = args->lhs;
|
||||||
|
rust_vec *rhs = args->rhs;
|
||||||
|
rust_task *task = rust_task_thread::get_task();
|
||||||
|
size_t fill = lhs->fill + rhs->fill - 1;
|
||||||
|
rust_vec* v = (rust_vec*)task->kernel->malloc(fill + sizeof(rust_vec),
|
||||||
|
"str_concat");
|
||||||
|
v->fill = v->alloc = fill;
|
||||||
|
memmove(&v->data[0], &lhs->data[0], lhs->fill - 1);
|
||||||
|
memmove(&v->data[lhs->fill - 1], &rhs->data[0], rhs->fill);
|
||||||
|
args->retval = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" CDECL rust_vec*
|
||||||
|
upcall_str_concat(rust_vec* lhs, rust_vec* rhs) {
|
||||||
|
s_str_concat_args args = {lhs, rhs, 0};
|
||||||
|
UPCALL_SWITCH_STACK(&args, upcall_s_str_concat);
|
||||||
|
return args.retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" _Unwind_Reason_Code
|
extern "C" _Unwind_Reason_Code
|
||||||
__gxx_personality_v0(int version,
|
__gxx_personality_v0(int version,
|
||||||
_Unwind_Action actions,
|
_Unwind_Action actions,
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ upcall_shared_malloc
|
|||||||
upcall_shared_free
|
upcall_shared_free
|
||||||
upcall_shared_realloc
|
upcall_shared_realloc
|
||||||
upcall_vec_grow
|
upcall_vec_grow
|
||||||
|
upcall_str_concat
|
||||||
upcall_call_shim_on_c_stack
|
upcall_call_shim_on_c_stack
|
||||||
upcall_call_shim_on_rust_stack
|
upcall_call_shim_on_rust_stack
|
||||||
upcall_new_stack
|
upcall_new_stack
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type upcalls =
|
|||||||
mark: ValueRef,
|
mark: ValueRef,
|
||||||
vec_grow: ValueRef,
|
vec_grow: ValueRef,
|
||||||
vec_push: ValueRef,
|
vec_push: ValueRef,
|
||||||
|
str_concat: ValueRef,
|
||||||
cmp_type: ValueRef,
|
cmp_type: ValueRef,
|
||||||
log_type: ValueRef,
|
log_type: ValueRef,
|
||||||
alloc_c_stack: ValueRef,
|
alloc_c_stack: ValueRef,
|
||||||
@@ -69,6 +70,9 @@ fn declare_upcalls(targ_cfg: @session::config,
|
|||||||
dvi("vec_push",
|
dvi("vec_push",
|
||||||
[T_ptr(T_ptr(opaque_vec_t)), T_ptr(tydesc_type),
|
[T_ptr(T_ptr(opaque_vec_t)), T_ptr(tydesc_type),
|
||||||
T_ptr(T_i8())]),
|
T_ptr(T_i8())]),
|
||||||
|
str_concat:
|
||||||
|
d("str_concat", [T_ptr(opaque_vec_t), T_ptr(opaque_vec_t)],
|
||||||
|
T_ptr(opaque_vec_t)),
|
||||||
cmp_type:
|
cmp_type:
|
||||||
dv("cmp_type",
|
dv("cmp_type",
|
||||||
[T_ptr(T_i1()), T_ptr(tydesc_type),
|
[T_ptr(T_i1()), T_ptr(tydesc_type),
|
||||||
|
|||||||
@@ -194,15 +194,16 @@ fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t,
|
|||||||
fn trans_add(bcx: block, vec_ty: ty::t, lhs: ValueRef,
|
fn trans_add(bcx: block, vec_ty: ty::t, lhs: ValueRef,
|
||||||
rhs: ValueRef, dest: dest) -> block {
|
rhs: ValueRef, dest: dest) -> block {
|
||||||
let ccx = bcx.ccx();
|
let ccx = bcx.ccx();
|
||||||
let strings = alt ty::get(vec_ty).struct {
|
|
||||||
ty::ty_str { true }
|
if ty::get(vec_ty).struct == ty::ty_str {
|
||||||
_ { false }
|
let n = Call(bcx, ccx.upcalls.str_concat, [lhs, rhs]);
|
||||||
};
|
ret base::store_in_dest(bcx, n, dest);
|
||||||
|
}
|
||||||
|
|
||||||
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
|
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
|
||||||
let llunitty = type_of::type_of(ccx, unit_ty);
|
let llunitty = type_of::type_of(ccx, unit_ty);
|
||||||
|
|
||||||
let lhs_fill = get_fill(bcx, lhs);
|
let lhs_fill = get_fill(bcx, lhs);
|
||||||
if strings { lhs_fill = Sub(bcx, lhs_fill, C_int(ccx, 1)); }
|
|
||||||
let rhs_fill = get_fill(bcx, rhs);
|
let rhs_fill = get_fill(bcx, rhs);
|
||||||
let new_fill = Add(bcx, lhs_fill, rhs_fill);
|
let new_fill = Add(bcx, lhs_fill, rhs_fill);
|
||||||
let {bcx: bcx, val: new_vec_ptr} = alloc_raw(bcx, new_fill, new_fill);
|
let {bcx: bcx, val: new_vec_ptr} = alloc_raw(bcx, new_fill, new_fill);
|
||||||
|
|||||||
Reference in New Issue
Block a user