什么死了&在 Swift 的异常堆栈中爆炸? [英] What's Dead & Exploded in Swift's exception stack?

查看:19
本文介绍了什么死了&在 Swift 的异常堆栈中爆炸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行时崩溃的异常堆栈中,Swift 经常说参数是死的或爆炸的.它是什么意思,对于调试目的是否重要?

In the exception stack for runtime crashes, Swift often says arguments are Dead or Exploded. What does it mean, and does it matter for debugging purposes?

例如:

-> 0x100209cf0 <function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()+44>: brk    #0x1

谢谢.

推荐答案

什么意思?

Swift 编译器出于多种原因标记函数参数,主要与内部优化有关.对于您的问题,我们将重点关注 mangler,因为这有助于您的 漂亮的堆栈跟踪 和节点打印机.截至本文发布时,函数专业化管理器有 6 个标记可应用于参数:

The Swift compiler marks function arguments for a number of reasons, mostly related to internal optimizations. For your question, we'll focus on the mangler, as that's what's contributing to your pretty stack trace, and the Node Printer. As of the time of this post, the function specialization mangler has 6 marks it can apply to an argument:

  • 死了

参数在函数体中未使用,可以在死参数消除过程中删除.

The argument is unused in the function body and can be removed in a dead argument elimination pass.

关闭

该参数是一个闭包,可能需要进一步的修改/拆解.

The argument is a closure and may require further mangling/demangling.

恒定

参数是一个常量.

归保证所有

调用者拥有的参数将所有权转移给被调用者.因此,该参数有一个与之关联的强引用 [调用者],并保证在调用过程中持续存在,因此编译器允许调用者省略传输,而是聚合保留自身.

A caller-owned argument transfers ownership to the callee. The argument thus has a strong reference associated with it [the caller] and is guaranteed to live through the call, so the compiler allows the caller to elide the transfer and instead aggregate retains itself.

SROA

标量替换聚合 传递应该优化这个论点.

A Scalar Replacement of Aggregates pass should optimize this argument.

In Out to Value

参数被标记为 inout 但被调用者实际上并没有改变它.

The parameter was marked inout but the callee doesn't actually mutate it.

AST 节点打印机再添加一个标记

The AST Node Printer adds one more mark

  • 爆炸

该值带有在进行调用时已实现的爆炸模式.

The value comes with an explosion schema that has been realized when the call was made.

出于所有意图和目的,我们只关心 DeadOwned to GuaranteedExploded.

For all intents and purposes we only care about Dead, Owned to Guaranteed, and Exploded.

唯一可能看起来仍然令人困惑的是Exploded.Explosion 是 Swift 编译器的优化构造用于确定将值从小型结构和枚举解包到寄存器中的策略.因此,当节点打印机说一个值是 Exploded 时,这意味着它已经在调用之前将该值解包到寄存器中.

The only one that may still seem mystifying is Exploded. An Explosion is an optimization construct the Swift compiler uses to determine a strategy to unpack values from small structs and enums into registers. Thus, when the Node Printer says a value is Exploded, what it means it has already unpacked the value into registers before the call.

这对调试有影响吗?

没有.

这篇关于什么死了&amp;在 Swift 的异常堆栈中爆炸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆