about summary refs log tree commit diff
path: root/src/rt/rust_upcall.cpp
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-03-19 14:06:59 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-03-19 14:29:39 -0700
commit869b2d706493549e1fc4a621fe9a44fa58d83c5c (patch)
tree882f79b4939e5ac60fa54a95c9be70a3d10f3605 /src/rt/rust_upcall.cpp
parentbbfa08d9474bd08b03718639ad82315d66097e6e (diff)
downloadrust-869b2d706493549e1fc4a621fe9a44fa58d83c5c.tar.gz
rust-869b2d706493549e1fc4a621fe9a44fa58d83c5c.zip
Send string concatenation to specialized upcall, shave 17s off librustc compile time.
Diffstat (limited to 'src/rt/rust_upcall.cpp')
-rw-r--r--src/rt/rust_upcall.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index dfeeda34994..647e8edf3a8 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -309,6 +309,34 @@ upcall_vec_grow(rust_vec** vp, size_t new_sz) {
     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
 __gxx_personality_v0(int version,
                      _Unwind_Action actions,