<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>SIL on Last Stand</title><link>https://amatsuzero.github.io/LastStand/tags/sil/</link><description>Recent content in SIL on Last Stand</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Tue, 16 Jun 2026 09:06:27 +0800</lastBuildDate><atom:link href="https://amatsuzero.github.io/LastStand/tags/sil/index.xml" rel="self" type="application/rss+xml"/><item><title>Swift 面试：编译流程、Runtime 与元数据源码解析</title><link>https://amatsuzero.github.io/LastStand/posts/swiftinterviewsourcecode/compiler-runtime/</link><pubDate>Tue, 16 Jun 2026 09:06:27 +0800</pubDate><guid>https://amatsuzero.github.io/LastStand/posts/swiftinterviewsourcecode/compiler-runtime/</guid><description>&lt;h1 id="swift-面试编译流程runtime-与元数据源码解析"&gt;Swift 面试：编译流程、Runtime 与元数据源码解析&lt;/h1&gt;
&lt;p&gt;Swift 面试里问编译流程和 Runtime，通常不是想听一串名词，而是想看你能不能把 &lt;strong&gt;源码 -&amp;gt; AST -&amp;gt; SIL -&amp;gt; 优化 -&amp;gt; IRGen -&amp;gt; LLVM -&amp;gt; Runtime Metadata&lt;/strong&gt; 串起来。&lt;/p&gt;
&lt;p&gt;这篇文章按面试题展开，把答案落到 Swift 编译器源码里的 SILGen、SILOptimizer、IRGen、Metadata、Value Witness Table、Protocol Witness Table 和 HeapObject。&lt;/p&gt;
&lt;h2 id="面试高频问题"&gt;面试高频问题&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Swift 源码从 &lt;code&gt;.swift&lt;/code&gt; 到机器码经历哪些阶段？&lt;/li&gt;
&lt;li&gt;AST、SIL、LLVM IR 分别负责什么？&lt;/li&gt;
&lt;li&gt;为什么 Swift 需要 SIL，而不是直接生成 LLVM IR？&lt;/li&gt;
&lt;li&gt;SILGen 做什么？SILOptimizer 做什么？&lt;/li&gt;
&lt;li&gt;IRGen 为什么要生成 Metadata 和 Witness Table？&lt;/li&gt;
&lt;li&gt;Swift Runtime Metadata 保存了哪些信息？&lt;/li&gt;
&lt;li&gt;Value Witness Table 是什么？&lt;/li&gt;
&lt;li&gt;Protocol Witness Table 和 class vtable 有什么区别？&lt;/li&gt;
&lt;li&gt;class、struct、enum 在 Runtime 表示上有什么差异？&lt;/li&gt;
&lt;li&gt;HeapObject 和 Metadata 有什么关系？&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="30-秒回答版"&gt;30 秒回答版&lt;/h2&gt;
&lt;p&gt;Swift 编译流程可以简化为：&lt;/p&gt;</description></item></channel></rss>