
KotlinNative.png
这是
Kotlin/Native is an LLVM backedn for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

LLVM-Step-2-1024x576.png
kotlin -> IR -> java 字节码
获取 kotlin 源码编译为 IR 然后再将 IR 编译为 java 字节码
所以这里有两次编译,根据先后顺序分别为前编译和后编译
kotlin 之所以能够编译为 js ,就是因为后编译是可控的,我们也可以编译为其他 js 语言当然也可以直接编译为机器码。这就是 kotlin native 基本实现原理。
LLVM 好强大有机会一定研究研究

1200px-LLVM_Logo.svg.png
我们进一步细化后编译
IR -> LLVM IR -> 机器码
基于 LLVM 设计语言
- C/C++(clang)
- Objective-C
- Rust
- Swift
- Julia
- Graal VM
为什么 kotlin 需要 kotlin native - 高性能
- C APIs
- Kotlin