Send string concatenation to specialized upcall, shave 17s off librustc compile time.
This commit is contained in:
@@ -18,6 +18,7 @@ type upcalls =
|
||||
mark: ValueRef,
|
||||
vec_grow: ValueRef,
|
||||
vec_push: ValueRef,
|
||||
str_concat: ValueRef,
|
||||
cmp_type: ValueRef,
|
||||
log_type: ValueRef,
|
||||
alloc_c_stack: ValueRef,
|
||||
@@ -69,6 +70,9 @@ fn declare_upcalls(targ_cfg: @session::config,
|
||||
dvi("vec_push",
|
||||
[T_ptr(T_ptr(opaque_vec_t)), T_ptr(tydesc_type),
|
||||
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:
|
||||
dv("cmp_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,
|
||||
rhs: ValueRef, dest: dest) -> block {
|
||||
let ccx = bcx.ccx();
|
||||
let strings = alt ty::get(vec_ty).struct {
|
||||
ty::ty_str { true }
|
||||
_ { false }
|
||||
};
|
||||
|
||||
if ty::get(vec_ty).struct == ty::ty_str {
|
||||
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 llunitty = type_of::type_of(ccx, unit_ty);
|
||||
|
||||
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 new_fill = Add(bcx, lhs_fill, rhs_fill);
|
||||
let {bcx: bcx, val: new_vec_ptr} = alloc_raw(bcx, new_fill, new_fill);
|
||||
|
||||
Reference in New Issue
Block a user