Rewrite the exchange allocator to work without an active scheduler. #4457

This commit is contained in:
Brian Anderson
2013-01-13 16:53:13 -08:00
parent e91040c704
commit e43c5bdc6b
14 changed files with 234 additions and 101 deletions
+19
View File
@@ -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);
}