-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect tail calls in stack size estimation (#2005)
In some cases, the deepest stack involves a tail call. For example, consider `write_fmt`, which has no stack of its own and branches directly to `core::fmt::write` (instead of using `bl`): ```asm 0804a704 <core::fmt::Write::write_fmt>: 804a704: 460a mov r2, r1 804a706: 6849 ldr r1, [r1, #4] 804a708: 2901 cmp r1, #1 804a70a: bf18 it ne 804a70c: 2900 cmpne r1, #0 804a70e: 4901 ldr r1, [pc, #4] ; (804a714 <core::fmt::Write::write_fmt+0x10>) 804a710: f7ff ba68 b.w 8049be4 <core::fmt::write> 804a714: 0804b024 .word 0x0804b024 ``` This PR adds basic tail call support to the disassembler. The main effect is adding 80 bytes to panic stack depth. Before: ``` udprpc: 2464 bytes (limit is 4096) [+8] _start [+2264] main [+16] core::array::<impl core::ops::index::IndexMut<I> for [T; N]>::index_mut [+16] <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index_mut [+56] core::slice::index::slice_end_index_len_fail [+40] core::panicking::panic_fmt [+56] rust_begin_unwind [+8] userlib::sys_panic_stub ``` After: ``` udprpc: 2544 bytes (limit is 4096) [+8] _start [+2264] main [+16] core::array::<impl core::ops::index::IndexMut<I> for [T; N]>::index_mut [+16] <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index_mut [+56] core::slice::index::slice_end_index_len_fail [+40] core::panicking::panic_fmt [+56] rust_begin_unwind [+0] core::fmt::Write::write_fmt [+88] core::fmt::write ``` Unfortunately, this _does not_ detect the stack overflow in #2004, which happens during dynamic dispatch. Still, it's a step in the right direction!
- Loading branch information
Showing
6 changed files
with
14 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters