延期声明在哪里实施?

时间:2017-05-16 19:53:56

标签: go compiler-construction

我想知道defer-Statement的工作原理和实现方式(在编译器源代码中)。

我找到了关于解析defer-Statement并在语法树中构建它的包

但是我在运行时实际执行延迟是非常有意义的。 我的猜测是,它位于" src / runtime"

1 个答案:

答案 0 :(得分:5)

开始阅读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

相关问题