type _defer struct { siz int32// includes both arguments and results started bool heap bool openDefer bool sp uintptr// sp at time of defer pc uintptr// pc at time of defer fn *funcval // can be nil for open-coded defers _panic *_panic // panic that is running defer link *_defer fd unsafe.Pointer // funcdata for the function associated with the frame varp uintptr// value of varp for the stack frame framepc uintptr }
siz 是参数和结果的内存大小;
sp 和 pc 分别代表栈指针和调用方的程序计数器;
fn 是 defer 关键字中传入的函数;
_panic 是触发延迟调用的结构体,可能为空;
openDefer 表示当前 defer 是否经过开放编码的优化;
runtime._defer结构体是延迟调用链表上的一个元素,所有的结构体都会通过 link 字段串联成链表。