about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-03-29 16:55:04 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-04-19 11:53:31 -0700
commitf903ae9e72ec02539373da22fd4d025422af7554 (patch)
treeccaf3a5daf113fc468c2e2a00ee10e6034a8ceb5 /src/rt
parent1a36b0f17ef0b59411981fdd25ac9ce4ba7e20e0 (diff)
downloadrust-f903ae9e72ec02539373da22fd4d025422af7554.tar.gz
rust-f903ae9e72ec02539373da22fd4d025422af7554.zip
librustc: Implement fast-ffi and use it in various places
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_task.cpp5
-rw-r--r--src/rt/rust_upcall.cpp15
-rw-r--r--src/rt/rustrt.def.in2
3 files changed, 20 insertions, 2 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 63dc1c9833e..021811ffa76 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -457,8 +457,9 @@ rust_task::get_next_stack_size(size_t min, size_t current, size_t requested) {
         "min: %" PRIdPTR " current: %" PRIdPTR " requested: %" PRIdPTR,
         min, current, requested);
 
-    // Allocate at least enough to accomodate the next frame
-    size_t sz = std::max(min, requested);
+    // Allocate at least enough to accomodate the next frame, plus a little
+    // slack to avoid thrashing
+    size_t sz = std::max(min, requested + (requested / 2));
 
     // And double the stack size each allocation
     const size_t max = 1024 * 1024;
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 9f39e1433fc..e524e6de859 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -191,6 +191,14 @@ rust_upcall_malloc(type_desc *td, uintptr_t size) {
     return upcall_malloc(td, size);
 }
 
+extern "C" CDECL uintptr_t
+rust_upcall_malloc_noswitch(type_desc *td, uintptr_t size) {
+    rust_task *task = rust_get_current_task();
+    s_malloc_args args = {task, 0, td, size};
+    upcall_s_malloc(&args);
+    return args.retval;
+}
+
 /**********************************************************************
  * Called whenever an object in the task-local heap is freed.
  */
@@ -231,6 +239,13 @@ rust_upcall_free(void* ptr) {
     upcall_free(ptr);
 }
 
+extern "C" CDECL void
+rust_upcall_free_noswitch(void* ptr) {
+    rust_task *task = rust_get_current_task();
+    s_free_args args = {task,ptr};
+    upcall_s_free(&args);
+}
+
 /**********************************************************************/
 
 extern "C" _Unwind_Reason_Code
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index f63e3f53a7c..4a79b2e4ae6 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -66,7 +66,9 @@ upcall_del_stack
 upcall_reset_stack_limit
 rust_upcall_fail
 rust_upcall_free
+rust_upcall_free_noswitch
 rust_upcall_malloc
+rust_upcall_malloc_noswitch
 rust_uv_loop_new
 rust_uv_loop_delete
 rust_uv_walk