Skip to content

Commit 8fe506b

Browse files
committed
rt: Move more setup code into create_stack
1 parent ea76d3f commit 8fe506b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/rt/rust_stack.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ template <class T>
1717
stk_seg *
1818
create_stack(T allocer, size_t sz) {
1919
size_t total_sz = sizeof(stk_seg) + sz;
20-
return (stk_seg *)allocer->malloc(total_sz, "stack");
20+
stk_seg *stk = (stk_seg *)allocer->malloc(total_sz, "stack");
21+
memset(stk, 0, sizeof(stk_seg));
22+
stk->end = (uintptr_t) &stk->data[sz];
23+
return stk;
2124
}
2225

2326
template <class T>

src/rt/rust_task.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,9 @@ rust_task::new_stack(size_t requested_sz) {
584584
size_t sz = rust_stk_sz + RED_ZONE_SIZE;
585585
stk_seg *new_stk = create_stack(this, sz);
586586
LOGPTR(thread, "new stk", (uintptr_t)new_stk);
587-
memset(new_stk, 0, sizeof(stk_seg));
588587
add_stack_canary(new_stk);
589588
new_stk->prev = NULL;
590589
new_stk->next = stk;
591-
new_stk->end = (uintptr_t) &new_stk->data[rust_stk_sz + RED_ZONE_SIZE];
592590
LOGPTR(thread, "stk end", new_stk->end);
593591

594592
stk = new_stk;

0 commit comments

Comments
 (0)