defer 语句在哪里实现?

Where is the defer statement implemented?

我想知道 defer-Statement 是如何工作的,为什么工作以及它是在哪里实现的(在编译器源代码中)。

我找到了关于解析延迟语句并在语法树中构建它的包

但我对 defer 在运行时的实际执行很感兴趣。 我的猜测是,它位于 "src/runtime"

中的某处

从这里开始阅读https://github.com/golang/go/blob/d089a6c7187f1ff85277515405ec6c641588a7ff/src/runtime/panic.go#L70

您还可以在存储库中搜索术语 "deferreturn" 以查找更多结果。

延迟跳转的汇编https://github.com/golang/go/blob/master/src/runtime/asm_amd64.s#L550