3 ms·
> Putting the defers on the stack is also part of how the runtime unwinds the stack during a panic. All exception ABIs on all major platforms can do this witho
by pcwalton 8y ago
> Putting the defers on the stack is also part of how the runtime unwinds the stack during a panic.
All exception ABIs on all major platforms can do this without any overhead in the no-exception case. The compiler embeds static metadata (in a subset of DWARF, on Linux) alongside the function, and the unwinder parses that metadata in order to determine which destructors to invoke.