Skip to content

Commit 3406da4

Browse files
committed
rt: Extract prepare_valgrind_stack from register_valgrind_stack
1 parent c42492e commit 3406da4

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

src/rt/rust_stack.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ register_valgrind_stack(stk_seg *stk) {
88
stk->valgrind_id =
99
VALGRIND_STACK_REGISTER(&stk->data[0],
1010
stk->end);
11+
}
12+
13+
void
14+
prepare_valgrind_stack(stk_seg *stk) {
1115
#ifndef NVALGRIND
1216
// Establish that the stack is accessible. This must be done when reusing
1317
// old stack segments, since the act of popping the stack previously

src/rt/rust_stack.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ destroy_stack(T allocer, stk_seg *stk) {
4242
void
4343
register_valgrind_stack(stk_seg *stk);
4444

45+
void
46+
prepare_valgrind_stack(stk_seg *stk);
47+
4548
void
4649
deregister_valgrind_stack(stk_seg *stk);
4750

src/rt/rust_task.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ rust_task::new_stack(size_t requested_sz) {
568568
stk = stk->prev;
569569
A(thread, stk->prev == NULL, "Bogus stack ptr");
570570
register_valgrind_stack(stk);
571+
prepare_valgrind_stack(stk);
571572
return;
572573
} else {
573574
LOG(this, mem, "existing stack is not big enough");
@@ -599,6 +600,7 @@ rust_task::new_stack(size_t requested_sz) {
599600

600601
stk = new_stk;
601602
register_valgrind_stack(stk);
603+
prepare_valgrind_stack(stk);
602604
total_stack_sz += user_stack_size(new_stk);
603605
}
604606

src/rt/rust_task_thread.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ rust_task_thread::prepare_c_stack() {
373373
if (!cached_c_stack) {
374374
cached_c_stack = create_stack(kernel, C_STACK_SIZE);
375375
register_valgrind_stack(cached_c_stack);
376+
prepare_valgrind_stack(cached_c_stack);
376377
}
377378
}
378379

0 commit comments

Comments
 (0)