Compile and run both files with (on Linux x86):
rustc --crate-type=staticlib gc_experiment4.rs && \
gcc -O0 -g -o gc_experiment4 gc_experiment4.c -lgc_experiment4 -L. && \
./gc_experiment4
This will output the following:
&local_a_1: 0x7ffc6c344440 (11)
&local_a_2: 0x7ffc6c344448 (22)
&local_a_3: 0x7ffc6c344450 (33)
&local_c_1: 0x7ffc6c344400 (77)
&local_c_2: 0x7ffc6c344408 (88)
&local_c_3: 0x7ffc6c344410 (99)
call gc through trampoline
start mark phase. stack_top: 0x7ffc6c3443f0, stack_bottom: 0x7ffc6c344480, slots=18
stack_slot=0x7ffc6c3443f0 content=0x7ffc6c344420
stack_slot=0x7ffc6c3443f8 content=0x56075106c807
stack_slot=0x7ffc6c344400 content=0x4d
stack_slot=0x7ffc6c344408 content=0x58
stack_slot=0x7ffc6c344410 content=0x63
stack_slot=0x7ffc6c344418 content=0x2a1880e880ec4500
stack_slot=0x7ffc6c344420 content=0x7ffc6c344430
stack_slot=0x7ffc6c344428 content=0x56075106c849
stack_slot=0x7ffc6c344430 content=0x7ffc6c344460
stack_slot=0x7ffc6c344438 content=0x56075106c8e6
stack_slot=0x7ffc6c344440 content=0xb
stack_slot=0x7ffc6c344448 content=0x16
stack_slot=0x7ffc6c344450 content=0x21
stack_slot=0x7ffc6c344458 content=0x2a1880e880ec4500
stack_slot=0x7ffc6c344460 content=0x7ffc6c344480
stack_slot=0x7ffc6c344468 content=0x56075106c924
stack_slot=0x7ffc6c344470 content=0x7ffc6c344598
stack_slot=0x7ffc6c344478 content=0x15106c660
call gc WITHOUT trampoline
start mark phase. stack_top: 0x7ffc6c344420, stack_bottom: 0x7ffc6c344480, slots=12
stack_slot=0x7ffc6c344420 content=0x7ffc6c344430
stack_slot=0x7ffc6c344428 content=0x56075106c849
stack_slot=0x7ffc6c344430 content=0x7ffc6c344460
stack_slot=0x7ffc6c344438 content=0x56075106c8e6
stack_slot=0x7ffc6c344440 content=0xb
stack_slot=0x7ffc6c344448 content=0x16
stack_slot=0x7ffc6c344450 content=0x21
stack_slot=0x7ffc6c344458 content=0x2a1880e880ec4500
stack_slot=0x7ffc6c344460 content=0x7ffc6c344480
stack_slot=0x7ffc6c344468 content=0x56075106c924
stack_slot=0x7ffc6c344470 content=0x7ffc6c344598
stack_slot=0x7ffc6c344478 content=0x15106c660
Question: Where are the missing 4 stack slots when calling gc
(Rust) directly from C without going through gc_trampoline
(C)?