Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ It is a good place to see how TypeScript code drives a native C++ framework: the
- [As WebAssembly](#compiling-as-wasm)
- [C bindings with tsbindgen](#c-bindings-with-tsbindgen)
- [Memory models](#memory-models)
- [`-mm=own`](#-mmown) ([guide](docs/own-memory-model.md))
- [Building from source](#build)
- [For Android](#build-for-android)
- [Community](#chat-room)
- [License](#license)

## What's new

- New memory model **`-mm=own`**: single ownership inferred at compile time, like Rust's borrow checker. There is no collector and no reference counting, and a program whose ownership cannot be proven is a compile error. Shared ownership is opt-in with `Shared<T>`. See [Memory models](#memory-models)
- New memory model **`-mm=own`**: single ownership inferred at compile time, like Rust's borrow checker. There is no collector and no reference counting, and a program whose ownership cannot be proven is a compile error. Shared ownership is opt-in with `Shared<T>`. See [Memory models](#memory-models) and the [`-mm=own` guide](docs/own-memory-model.md)
- **Android** targets (`arm64-v8a`, `armeabi-v7a`, `x86_64`, API 29+): executables and shared libraries linked through the Android NDK. The release zip carries the collector, async runtime and default library for all three ABIs. See [Compile for Android](#compile-for-android)
- Implemented `try/catch` exception handling in the **JIT** on Windows (x64 SEH unwinding via a custom LLJIT runtime)
- Migrared to **LLVM 22.1.8**
Expand Down Expand Up @@ -754,7 +755,7 @@ against garbage collection's 5.8 - but **objects that refer to each other in a c
freed under it**, which is the same trade Swift makes with ARC.

See **[docs/memory-models.md](docs/memory-models.md)** for which shapes leak, which do not, and
what to do about it.
what to do about it, and **[docs/own-memory-model.md](docs/own-memory-model.md)** for `-mm=own`.

### Performance

Expand Down Expand Up @@ -826,8 +827,16 @@ const b = a; // both share the Node
print(a.value.value, b.value.value, Shared.count(a)); // 1 1 2
```

`-mm=own` is still in development: some valid TypeScript does not compile under it yet. The
default library has no `-mm=own` build yet, so compile with `--no-default-lib`.
Inside a module ownership is inferred. What a function another module calls does with its
parameters is said in its signature with `@keeps`, `@lends`, `@record`, `@borrows` and
`@immortalizes`; `@nodrops` marks a C function that frees nothing, and `@final` and `@value`
classes make calls direct and values copies.

`-mm=own` is still in development: some valid TypeScript does not compile under it yet (the
default library's `Map` and `Set` among it).

See **[docs/own-memory-model.md](docs/own-memory-model.md)** for the rules, the errors and how to
fix them, `Shared<T>`, every decorator, and separate compilation.

## Build

Expand Down
3 changes: 3 additions & 0 deletions docs/memory-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ The compiler can manage heap memory in three ways, selected with `-mm=`:
| `-mm=rc` | **Reference counting.** Objects are freed the moment the last reference to them goes away. No collector, no pauses, no runtime dependency on libgc. | Predictable latency, WebAssembly, or shipping without libgc — **provided you read the cycles section below.** |
| `-mm=none` | **Nothing is ever freed.** | Short-lived programs where the process exits before memory matters. |

A fourth, `-mm=own`, infers a single owner for every object at compile time, with no collector
and no counting; it has a page of its own, [own-memory-model.md](own-memory-model.md).

`-mm=gc` is the default and stays the default. Everything below is about what changes if you
choose `-mm=rc`.

Expand Down
Loading
Loading