ASDAlexander77/TypeScriptCompiler
关于
基于 LLVM/MLIR 构建的 TypeScript 原生提前编译(AOT)和即时编译(JIT)编译器。它可将 .ts 文件直接编译为原生可执行文件或 WebAssembly,也可通过内置 JIT 即时运行,无需 Node.js 或 JavaScript 运行时。
编程语言与运行时实测星标增长
- 24小时
- 0
- 7天
- +2
- 15天
- +3
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文TypeScript Native Compiler
A native ahead-of-time (AOT) and JIT compiler for TypeScript, built on LLVM/MLIR.
It compiles .ts files directly to native executables, shared libraries and WebAssembly, or runs
them on the fly via a built-in JIT — no Node.js or JavaScript runtime required.
Targets: Windows, Linux, Android (arm64-v8a, armeabi-v7a, x86_64), WebAssembly (wasm32, wasm64).
Contents
- Quick start
- Memory models
- Documentation
- Showcase: native_ts_graphics
- Community · License · Contributing
Quick start
Download tslang from Releases,
or try it on Compiler Explorer.
File hello.ts:
function main() {
print("Hello World!");
}
Run it with the JIT:
tslang hello.ts
Or compile it to an executable (on Linux add --relocation-model=pic):
tslang --emit=exe hello.ts
hello.exe
Hello World!
Start a new project:
tslang --new Test1
creates a Visual Studio Code project, and
tslang --cmake Test1
a CMake project for mixed C++/TypeScript (see What's new for building it).
More in Running and compiling programs: a larger example, the JIT cache, debugging JIT code with GDB, and the environment variables the linker uses.
Memory models
How heap memory is managed is selected with -mm=:
| flag | ||
|---|---|---|
-mm=gc |
garbage collection (Boehm) | the default |
-mm=rc |
reference counting - freed as soon as the last reference goes, no collector, no libgc |
does not collect reference cycles |
-mm=none |
nothing is ever freed | short-lived programs |
-mm=own |
single ownership inferred at compile time, like Rust's borrow checker - no collector, no counting | in development; ownership that cannot be proven is a compile error |
See memory-models.md and the -mm=own guide.
Under -mm=own tslang runs within 1.1-1.4x of idiomatic Rust on an object-heavy ray tracer and on
par with it on array loops — see Performance.
Documentation
| Topic | Page |
|---|---|
| Running with the JIT, compiling executables, debugging JIT code | docs/running.md |
| Android: cross-compiling and building the runtime libraries | docs/android.md |
| WebAssembly | docs/wasm.md |
Memory models (gc, rc, none) |
docs/memory-models.md |
The -mm=own single-owner model |
docs/own-memory-model.md |
How ready -mm=own is |
docs/own-readiness.md |
| Benchmarks against Rust and C++ | docs/performance.md |
C and C++ bindings with tsbindgen |
docs/tsbindgen.md |
Calling C++ classes (@cpp) |
docs/cpp-classes.md |
JSX in .tsx files: elements as calls of your own factory |
docs/jsx.md |
GPU kernels (@kernel, gpuLaunch) on NVIDIA, AMD and Intel GPUs |
docs/gpu.md |
| Building the compiler from source | docs/building.md |
| What's new and roadmap | docs/whats-new.md |
| JavaScript built-in objects library | Default Library repo |
| How-to guides and more | Wiki |
Showcase: native_ts_graphics
native_ts_graphics is a set of 25
real-time 3D graphics samples — TypeScript ports of NVIDIA's Donut
samples on Direct3D 12 and Vulkan, from basic_triangle to ray tracing, meshlets and work
graphs — compiled to native code with tslang. .ts files are a first-class CMake language
(TSLANG) linked with the C++ framework through a C interop layer, and the samples run on
Windows and Android.
Community
- GitHub Discussions (preferred)
(legacy)
License
This project is licensed under the MIT License — see the LICENSE file for details.
Contributing
Issues and pull requests are welcome. See the Wiki for documentation, build notes, and how-to guides.
探索相关项目
加载中…
