Value Semantics Optimization
9 sections
Overview
Make Ori's value semantics as fast as reference-based mutation in any language — period. Every collection operation (push, pop, insert, remove, concat, slice, sort) must achieve O(1) amortized or better when the value is uniquely owned, with zero-copy views for read-only access and compile-time elimination of runtime checks when ownership is provable. This plan covers the entire system: runtime primitives, LLVM codegen, interpreter parity, static analysis, and exhaustive verification across correctness, memory safety, and performance.
Completed
9 sections
Runtime COW Foundation
Provide the runtime primitives that all COW collection operations depend on
List COW Operations
Every list mutation is O(1) amortized when uniquely owned
String Optimization
Small strings avoid heap allocation entirely; string concat is O(1) amortized when unique
Map & Set COW Operations
Every map/set mutation is O(1) amortized when uniquely owned
Seamless Slices
Slicing a list or string produces a zero-copy view that shares the underlying buffer
Interpreter COW Parity
The interpreter achieves the same COW semantics as the LLVM backend using Arc::make_mut()
Static Uniqueness Analysis
Compile-time proof of uniqueness eliminates runtime COW checks for provably unique values
Collection Memory Recycling
Dead collection buffers are recycled for new allocations, reducing malloc/free pressure
Verification & Benchmarks
Prove the system works correctly, safely, and performantly through exhaustive testing