about summary refs log tree commit diff
path: root/src/rt/rust_stack.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-01-13 16:53:13 -0800
committerBrian Anderson <banderson@mozilla.com>2013-02-06 14:27:36 -0800
commite43c5bdc6b47e8dd5e2ddcd6cf57fec79388523a (patch)
tree309c89fe29131346dc5e258e2dd948c381ec256d /src/rt/rust_stack.cpp
parente91040c704aa9ab46fb1c7a10e293fd5f6bfe079 (diff)
downloadrust-e43c5bdc6b47e8dd5e2ddcd6cf57fec79388523a.tar.gz
rust-e43c5bdc6b47e8dd5e2ddcd6cf57fec79388523a.zip
Rewrite the exchange allocator to work without an active scheduler. #4457
Diffstat (limited to 'src/rt/rust_stack.cpp')
-rw-r--r--src/rt/rust_stack.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rt/rust_stack.cpp b/src/rt/rust_stack.cpp
index 466399bd5b5..3bcda8adf40 100644
--- a/src/rt/rust_stack.cpp
+++ b/src/rt/rust_stack.cpp
@@ -53,6 +53,8 @@ check_stack_canary(stk_seg *stk) {
     assert(stk->canary == canary_value && "Somebody killed the canary");
 }
 
+// XXX: Duplication here between the local and exchange heap constructors
+
 stk_seg *
 create_stack(memory_region *region, size_t sz) {
     size_t total_sz = sizeof(stk_seg) + sz;
@@ -69,3 +71,20 @@ destroy_stack(memory_region *region, stk_seg *stk) {
     deregister_valgrind_stack(stk);
     region->free(stk);
 }
+
+stk_seg *
+create_exchange_stack(rust_exchange_alloc *exchange, size_t sz) {
+    size_t total_sz = sizeof(stk_seg) + sz;
+    stk_seg *stk = (stk_seg *)exchange->malloc(total_sz, false);
+    memset(stk, 0, sizeof(stk_seg));
+    stk->end = (uintptr_t) &stk->data[sz];
+    add_stack_canary(stk);
+    register_valgrind_stack(stk);
+    return stk;
+}
+
+void
+destroy_exchange_stack(rust_exchange_alloc *exchange, stk_seg *stk) {
+    deregister_valgrind_stack(stk);
+    exchange->free(stk);
+}