Initial Commit

This commit is contained in:
SoraKatadzuma committed 2026-11-19 04:54:17 -06:00
commit f086abcea6
789 files changed
+149185

No files matched your search

+702
View File
@@ -0,0 +1,702 @@
# Changelog
Each version's changes, newest first. Versions follow [semantic
versioning](https://semver.org).
## Unreleased
- `@sealed` marks a trait nothing implements, which says something of the types it is
given rather than asking anything of one, as `@sealed pub trait closes<T> { const
value := T is closeable; }`. Its constants and types are its own, each given its
value where it is declared, and read through it given its type arguments, as
`closes::<T>::value` and `strip<T>::plain`, anywhere a constant or a type may stand,
each instance of a generic reading its own. A constant whose value tests the trait's
parameters says, in a condition, what it tests of the type parameters given for them,
so within `if const owns::<T>::value`, `T` is owning, as within `if const T is
owning`. Within it, a constant names the others and its types by their names, and
`self` is the trait. A type or trait naming it, a
bound, `is`, or `match const` naming it, a reference to it, and a function,
property, composed trait, bound on a type, or constant or type without a value within
it are each an error. A trait's constants were read only through a type implementing
it, so `closes::<T>::value` was refused.
- A value a trait gives a constant it asks for is a default, which a type naming the
trait and giving none of its own takes, worked out for each type with `self` that
type and the trait's parameters its arguments, as `trait sized { const bytes: u64 =
size_of::<self>(); }`. The value was left unread, and each type gave its own.
- A type parameter bounded by `reference` takes the reference an argument is, as
`address(src)` of `address<T>(r: T): castptr<T> where T: reference` gives `T` the `&mut
T` that `src` is; it took what the reference reaches, which no `reference` bound
holds of, so the call was refused.
- Which kind of type the compiler decides a type is, pointer, reference, array,
integer, real, or generic instance, its own shape decides whatever type parameters it
holds, so within a generic's own body `&mut T is pointer` is false. A `match const`
choosing by such a type, or an alias of one given it, chooses there where each arm up
to the one it fits tests such a kind, so `castptr<&mut T>` of `match const T { pointer
=> T, reference => ..., else => ... }` is a `*mut T`, and `castref<*mut T>` a `&mut
T`. Each was left to each instance, so `through(address(src))` was refused, and
`through(p) *= 2` of a `*mut T` was not written.
- A function declared through a generic trait, outside it, as `def conv<T>::bytes():
u64`, takes the trait's type arguments in its instance, so `conv::<u32>::bytes()`
names `T` a `u32`; `T` was left a type parameter there, so `size_of::<T>()` gave 0.
- A struct's field holds a pack, written `items: Ts...` as a variadic parameter is: a
value of each of its types, laid out in order as fields are, used as a variadic
parameter's pack is (`items[i]`, `items.length`, `for const`, `...items`), given a
pack of its types whole by a literal, and closed as fields are. What closes is moved
out by `...` and by a literal, so such a pack is a place that can be written. A pack
bound to a local, as `val x := args;`, is an error; it was taken as the local's type.
- `core` has `tuple<Ts...>`, a struct holding a pack, made by `tuple::of(1, true)` and
read or written by `t.at::<0>()`.
- A pack's type at an index worked out from constant parameters, as `Ts...[I]` of `def
pick<const I: u64, Ts...>(args: Ts...): Ts...[I]`, is the type each instance has
there. In a signature it was an error type, unreported, so `pick::<1>(5, true)` gave
a value of no size, printed as nothing.
- `C ? A : B` is a type: `A` where the constant `bool` `C` holds and `B` where it
doesn't, as `type makeref<T, const MUTABLE: bool> = MUTABLE ? &mut decay<T> :
&decay<T>;`. Each part of `C` chooses as `match const` does: a test of a type by what
it tests, as `type remref<T> = T is reference ? T::target : T;`, and any other part by
the `bool` it is, as a constant, a constant parameter, `N == 4`, or what a function
gives, as `small(N)`. What follows each part is resolved with what it says, so
`T::target` names what `T` refers to, and the right of `&&` is resolved where its left
holds. `C` is a name, `!` of one, a call, a name tested with `is` or compared with
`==` or `!=`, or an expression in parentheses, and what `&&` and `||` join to one of
those, as `small(N) && M`, where only `(N > 4)` was. An alias of one
stands for what it chooses, and within a generic's own body it is chosen where what is
proved decides it, as where `if const C`, or `if const N == 4`, which now say what a
constant parameter is.
- A generic type has associated variables and constants, one of each of its instances,
read through one, as `counter::<u8>::count`, and by name alone within the type's own
functions, as `const isptr<T>::value := T is pointer;` makes `isptr::<*i32>::value`
`true`. A constant of one is known while compiling, to `if const` and as a type's
condition. They were refused.
- Within a generic, a constant only its type arguments decide, as what a function gives
of them, `size_of::<T>()`, `T is pointer`, or `M ? 4 : 8`, is worked out for each
instance, so `type pick<const M: bool> = buffer<u8, M ? 4 : 8>;`, a field of `u8[small(N)
? 1 : 2]`, and `buffer<u8, size_of::<T>()>` work; the first stopped the compiler, and
the others were refused. What a function gives is a constant type argument outside a
generic too, as `buffer<u8, small(2) ? 3 : 5>`, and a type argument may call a
function given type arguments, as `size_of::<T>()`, which was read as a type.
- Within an instance, a `match const` type resolves no arm the type it chooses by
doesn't fit, and none after the one it fits, which gets the bound it tests, so
`reference => T::target` no longer reports `u8` having no `target` where `T` is `u8`.
- Within a generic's own body, a value given where a type not chosen yet is expected,
as `castref<T>` before `T::mutable` is known, is checked once in each way the type can
be chosen, with what that way says of type parameters, as a branch is: returned,
converted with `as`, given to a parameter, or held, and so is one given as a type
holding one, as `&castref<T>` or `vector<castref<T>>`. So `return p as addptr<T,
M>;` and `return through(p);` for a `castref<T>` work, and a call within one is
chosen in each way. A value of such a type is used in each way too: an operator, `*`,
a member, an index, a method, an assignment, `++`, `is`, `match`, `for`, or a test
naming what it holds is checked in each, and gives the type it gives in each, or one
chosen as the value's is, so `*p` of an `addptr<i32, M>` is an `i32`, and `total +=
x` of a `word<N>` works. Each was refused, as converting to, from, or using a type of
its own. Where what is proved chooses one, as `if const M` does, a value of it is one
of the type chosen.
- Within a generic, a ternary whose condition is known while compiling and names a type
parameter, as `T::mutable ? &mut p[0] : &p[0]`, chooses its branch as `if const`
does: each instance checks and compiles only the branch it takes, and the generic's
own body checks each with what the condition says. Both were checked in each instance,
so one valid only where the condition holds was refused. Where nothing is expected of
it, it is of the type its branches share, or else one chosen as its condition
chooses. A ternary over a value the program gives while running, or a constant naming
no type parameter, is unchanged.
- `match const` chooses by a constant where its patterns are values written in place,
as `match const N { 4 => u32, else => u64 }` as a type, or `match const T::mutable {
true => &mut p[0], false => &p[0] }` as a value; such patterns were refused.
- What a branch within a generic's own body proves decides a condition after it, so
after `if const M { return a; }`, `if const !M` holds, and `return a if const M;
return b if const !M;` always returns, where it was said to end without returning.
- Within a generic's own body, a type parameter bounded by `reference` is a
`&T::target`, or a `&mut T::target` within `if const T::mutable`, as one bounded by
`pointer` is a pointer, so `r as *T::target` works.
- A pointer converts to a reference with `as`, as `p as &mut node`, as `through` gives
one: one that writes only from a `*mut T`, and never one to a trait. It was refused.
- Within a generic's own body, a type parameter bounded by `pointer` is the pointer it
is to `as` and to a call inferring type arguments, so `p as u64` and `through(p)`
work, and one bounded by `pointer`, `reference`, `array`, `integer`, `real`, or
`generic`, or said to fit one, fits none of the others, so `T: pointer` decides `T is
reference`.
- Notes name a type a bound asks of a type parameter as it is written, as `T::target`,
where they said `target`, and a note said in one way a constant `bool` goes says
which, as "(Where `M` is `false`.)".
- `x as *T != null` and `x as *T ? a : b` read `!=` and `?` as the expression's, as
`x as T != null` does; within the pointer's type they began a type's condition.
- Within a generic's own body, `T: array` takes `T` as a `T::element[T::length]`, which
`x[i]`, `for`, and conversions read, with a zero value where `T` is `zeroable` too;
`T: pointer` as a `*T::target`, which `*x` reads, and writes within `if const
T::mutable`; and `T is vector` as a `vector<T::args...[0]>`, with `vector`'s members,
a generic's pack given the types from its place on, as `T::args...[1:]`, and the
shape's types bounded as the generic bounds them. Each was refused.
- A branch or arm naming a type parameter as a type, as `if const T is strview`, is
checked within the generic's own body, where a value of `T` is one of that type, so
what is wrong there is reported though no instance takes it; it was checked only in
each instance taking it. What follows a branch that leaves takes the parameter so
too, as after `if const T is not u16 { return 0; }`.
- A `match const` value none is expected of is of the type its arms share in the
generic's own body, in each instance, so `integer => 1u, else => 0` is a `u64` in
each, where it was the chosen arm's, an `int` where `else` was chosen.
- Within a generic's own body, what follows `if const A && B { return ...; }` is checked
once where `A` fails and once where `B` does, where it knew nothing; a trait ruled out
rules out what implies it, as `numeric` does `integer` and `i32`; and a branch is
checked in each of the cases its condition holds in, cases that can't hold, as `T is
i32 && T is u8`, left out, where past 8 it was checked once knowing nothing. Past 1024
is an error.
- `match const T { ... }` chooses by a type while compiling, as a chain of `if const`
does: the first arm whose pattern `T` fits is kept, and `else` fits any. A pattern is
a trait, a generic type without type arguments, or a type, fit as `is` fits it. It is
a statement, a value, whose arms are separated by commas, or a type, whose arms give
types, so an alias works one out, as `type strip_pointer<T> = match const T { pointer
=> strip_pointer<T::target>, else => T };`. An alias of one stands for the type it
chooses, unlike any other alias, so `strip_pointer<*i32>` is `i32`, to `is` and as a
type argument. Within a generic's own body, each arm is checked with its pattern
fitting `T` and those before it not, once for each pattern it lists, and a type it
chooses by `T` is chosen where what is proved of `T` decides it, so `def widen<T>(x:
T): widened<T>` gives each arm's value, and is otherwise one of its own until each
instance chooses. An instance no arm fits without `else` is an error, as is a type
whose choosing doesn't end within 32 steps, which no longer stops quietly.
- `T is vector`, a generic type without type arguments, asks whether `T` is one of its
instances, looking through aliases, and gives the branch the bound `generic`.
- `core`'s traits naming a type's parts, which the compiler decides: `pointer` names
`T::target` and `T::mutable`, new `reference` names the same of a reference, new
`array` names `T::element` and `T::length`, and new `generic` names `T::args`, the
pack of a generic type's type arguments.
- A pack of types is walked by `for const U in Ts`, as `T::args` or `F::params`, and
`Ts...[i]` is its type at an index known while compiling. Within a template,
`args[i]` is of the type `Ts...[i]`, and a pack's types fit each other there, as its
values did before, while each instance checks the types it gives.
- An `if const` an instance decides gives its branch the bounds it tests, so what they
ask for is named through the type parameter, as `F::result` within `if const F is
signature`, which each instance reported having no type `result`, and of `A || B`,
those of each side that holds.
- Within a generic's own body, an `if const` branch is checked with what its condition
says of a type parameter, which now rules out what it doesn't fit, as `T is not
pointer`, the `else` of `T is pointer`, or what follows a branch that leaves does.
One holding in several cases, as `T is integer || T is real`, is checked once for
each, where it was checked proving nothing, and a note only one case finds says which,
as "(Where `T` is `real`.)". An undeclared name it tests by is reported once, not
three times.
- A constant a trait asks for, as `T::bytes` of `trait sized { const bytes: u64; }`, or
`T::length` of an `array`, is a constant wherever one may stand: a fixed array's length
in a signature or a field, which overflowed the stack or failed to evaluate, and a
constant type argument, as `buffer<u8, T::bytes>`, which was refused. So is a local
`const` worked out from one, or from a constant parameter, as `const m := N + 1;`.
- A path's first name naming both a module and a type names the type where the module
declares nothing of the next name, so a module may share a type's name: `shape::make`
reaches the type `shape` of the module `shape`, which reported that the module
declares no `make`.
- `F::params.length`, a pack a bound asks for, is a constant as `Ts.length` is, rather
than overflowing the stack while it's compiled.
- `build` shows a Windows executable as a program of its own: `--icon FILE`, a PNG or an
icon file, given again for each size, is its icon, which Explorer, its shortcuts, and
its windows show; `--title TEXT` and `--semv VERSION` are what its properties say of
it, as Task Manager names it; and `--windowed` runs it in windows of its own, with no
console. They're written as its resources, through `binary::pe`, a PNG over 256 pixels
left out, and the icon's files are listed by `--deps`. For Linux they're left out,
saying so, as its desktops read a desktop entry instead. `binary` is required by its
folder beside this one until it's released with them.
- A program with no console window of its own, as one built `--windowed`, starts a
console program, as a shell or a compiler, in a console no one sees, so Windows opens
no window for it; one with a console still shares it. This is `system`'s, which
`std::process` starts programs through.
- A property called through its type, as `span::<T>::empty()`, is reported as
a property, read of a value as `x.empty` is, and where the type's `empty` is
one and it has a `blank()`, as views and containers do, the report says that
makes an empty value, rather than that the function takes 1 argument.
- A call whose argument is already in error, as `root_of(xs.slice())`, reports
nothing more of the overloads it fits, or doesn't, since its argument fits any
or none.
- A property may have a `get mut`, beside or instead of its `get`, which takes
`&mut this` and reads it where the value can be written, as a method's
`&mut this` overload is called there. Where the property's type is a
reference, it gives one that writes, so `v.first = 4` and `v.first += 1`
write through it, while a value that only reads reads by the `get`. A
property only a `get mut` reads is read only of what can be written.
- A property may share its name with a type declared through its type, as a
field may, as `v.iterator` gives a `vector<T>::iterator`.
- An alias of a trait names the trait among a type's traits, in a bound, and in
`is`, so a trait renamed may keep its old name as an alias for a while.
- `core`'s trait of iterators is `iter<T>`, rather than `iterator<T>`, named as
the types the syntax makes are, which leaves `iterator` to the type a
container lends.
- `iterable` asks for an `iterator`, as `type list<T>::iterator = ...;`, rather
than a `cursor`. Within a type that has one, as within `iterable`, `iterator`
names that type, so the trait is `iter` there. `span<T>::cursor` is
`span<T>::iterator`, and no container has a `cursor`.
- `spannable<T>`, which was `viewable<T>`, asks for `span_of(other: &self,
start: u64 = 0, count: u64 = ~0u): span<T>` rather than `view`, and
`sliceable<T>` for `slice_of(other: &mut self, start: u64 = 0, count: u64 =
~0u): slice<T>` rather than `slice`: a view of `count` elements from `start`,
where a count of `~0u` is every element after it. Generic code reads them
through its bound, as `C::span_of(c)` for all of them.
- `x[start:count]` of what is no view calls its type's `span_of`, or its
`slice_of` where `x` can be written, as `x[k]` calls `at`, so a `vector`, a
`string`, and whatever else implements the traits is sliced as a view is:
`v[1:3]`, `s[6:]`, and `c[:2]` of a `c: &C` where `C: spannable<T>`. A bound
left out is given as the traits give it by default, the start as 0 and the
count as `~0u`, and the type's function stops a checked program where they
reach past its last element, as `vector`'s, `string`'s, and the views' do.
- A trait may give a parameter of a function it asks for a default, which is
checked where the trait declares it, and which a call through a bound
leaving it out is given. A type's function meets one a trait asks for only
where it gives a default for each parameter the trait does.
- `core`'s containers lend what they did as properties: `span`, `slice`, which
only what can be written reads, `iterator`, `mutator`, likewise, `first`,
`last`, `empty`, and `full`, as `v.span`, `v.first = 4`, and `v.empty`,
rather than the methods `view()`, `slice()`, `first()`, and `last()` and the
properties `is_empty` and `is_full`. `span<T>::empty()` and
`slice<T>::empty()`, which made a view over nothing, are `blank()`, since
`empty` is the property, and a view's `first` and `last` are properties giving
a `maybe`, as the methods did. An iterator's `is_empty()` stays, since an
iterator is no container.
- What a loop walks is no longer locked: its body may change it, and the
checker warns, as it does of a reference that outlives what it refers to,
only where the body changes it whole, which may move what the loop reads
next: a method taking `&mut this` of it, `&mut` of it, or assigning it, as
`v.append(x)` within `for x in v`, `for x in v.span`, `for x in v[1:]`, or
`for x in v.iter()`. Changing what it holds in place, as `v[i] = x` or
`v.first += 1`, or what holds it, as a method of `this` within `for x in
this.items`, isn't warned of, nor is a fixed array, which holds its elements
where it is. The error `locked` is gone.
- Contracts are checked where the program is: `run` checks them unless
`--fast`, and `build` doesn't unless `--checks`, where they were checked
everywhere but where `--contracts off` said. `--contracts on` and `--contracts
off` say otherwise, whichever the program is.
- `checking()` is gone: `core`'s containers check what they're asked for with
contracts, as `expects(index < this._len)` and `expects(!this.empty, "The
vector is empty.")`, rather than `if const checking() { ... past_end(...) }`,
so a checked program stops as it did, with the contract's report. `contracts()`
says whether they're checked, as `simd`'s `shuffle`, `gather`, and `scatter`
ask before the instructions trusting their lanes.
- `check --checks-report` lists a container's checks among the contracts, as
`fault`, rather than among indexes.
- `core` gives the iterators a container indexed by position lends, so it
needn't write its own: `positions_iterator<C, T>` reads each element through
`at`, and `position_mutator<C, T>` writes it, from either end, each
remembering how many are left.
- `assignable<K, V>` is the half of `indexable` that writes, `at(&mut this, key):
&mut V`, which `indexable` no longer asks for as `@optional`. Through a bound
of it, `x[key] = v` writes. `slice`, `vector`, and `string` name it, and so
does the compiler's `ids`.
- `iterable`'s writing iterator is its `mutator`, as `iterator` is its reading
one, rather than its `mut_cursor`. `slice`, `vector` and `string` name theirs
`mutator`, and `slice<T>::iterator` is `span<T>::iterator`, which its own was
a copy of.
- `core`'s traits are in seven files by what they're for, rather than one file
each: `arithmetic`, `kinds`, `comparison`, `ownership`, `containers`,
`iteration`, and `functions`.
- The optimizer does more of what LLVM's passes do (Jolt's pyramid 1.1 times as
fast, its convex hulls on a mesh 1.05; see `docs/performance.md`):
- Bit tracking, a new pass, as LLVM's known bits and demanded bits: a narrowing
of a word known to hold nothing past the bits it keeps goes, as a mask of 255
narrowed to 32 bits does; one whose bits past those it keeps nothing reads
goes, so `i32` arithmetic is narrowed where its result is, not after each
operator; a comparison what is known of a word decides is its constant, as a
byte compared with 300 is; and a word of 24 bits or fewer made an `f32` is not
rounded again.
- Simplifying folds constants applied one after another into one, as
`(x * 3) * 5` is `x * 15`; multiplies or shifts a sum of a constant, read once,
as the sum of the products, and adds a constant within a sum last, so
`xs[i + 1]` is read at an offset from `xs[i]`'s address; compares what a
constant was added to rather than the sum, as `x + 1 == 5` asks whether `x` is
4; takes `(x + y) - y` as `x`; and, as IEEE 754 says exactly, takes a product
with 1 as the real, with -1 as its negation, a quotient by a power of two as a
product with its reciprocal, and an `f32` negated as an `f32`.
- Code lifting, a new pass, as LLVM's SimplifyCFG and GVNHoist: what both ways
out of a branch work out alike is worked out once before it, a read of memory
or a check only from among what both ways do first, so where they join it is
numbered as what was worked out before.
- Numbering learns from a branch on `x == C`, or a switch's case, that `x` is the
constant where that way goes, as LLVM's numbering does, and reads it so.
- Loops regroup `(i + a) + b`, where `a` and `b` stay the same each time round,
as `i + (a + b)`, whose `a + b` moves out, as LLVM's loop invariant code motion
regroups arithmetic; and products and the operators of bits alike.
- A call is inlined by what its copy costs where it is, as LLVM's inliner costs
each call: what the call's constants fold away, the ways they never go, and
the reads and writes of what the function takes as memory, or as the address
of a caller's cell, which promote once copied, cost nothing; and the limit
grows by a quarter for a copy of one block, and by half again within a loop,
but for a loop already holding so many vectors that the backend's registers
would spill them.
- Faster native code, as profiling physics's benchmarks found it (Box2D's scenes
1.5 to 1.75 times as fast, Jolt's 1.3; see `docs/performance.md`):
- A conversion between `f32` and `f64`, a square root, and an integer made a real
zero their register first, so they no longer wait on what it held, which chained
each iteration of a loop computing in `xmm0` to the one before.
- `f32`s are compared with `ucomiss`, and negated and chosen as `f32`s, rather than
widened first; a choice of reals by `<` of reals is `maxss` or `minss` where it
picks the greater or lesser, as `a < b ? b : a` does, and a mask of `cmpss`
otherwise, with no branch; and `x != x` and `x == x` are tested by the parity
flag in the branch reading them.
- A function's version for x86-64-v3 is optimized from its code as lowered, kept as
optimizing begins, rather than from the code optimized for any processor, whose
32 bytes of lanes were split in halves held in memory.
- Promotion splits a cell holding values one after another, as a statement's
temporary the next statement takes again, into a cell for each, so a call given
its address keeps only that one in memory; and makes a cell's vector of four
`f32`s written by fields and read as lanes reads of its lanes, packed, and one
written as a vector and read by fields reads of the vector, a lane taken from it
by the new `lanes_lane`, so the cell holds one width and promotes. It runs once
more after numbering, at `-O2`.
- Rounding to an `f32` and a cell's address count for nothing toward the inline
limit, as an executable works the one into its arithmetic and promotes the other.
- A parameter of `simd` held in memory is copied by its function 16 bytes at a
time; `simd::scatter` writes its lanes out where there are at most 16, and checks
its places only where the program checks indexes.
- `run --checks` checks races once the program starts a thread: two threads
reaching the same memory, one writing it, with nothing ordering the two,
stop the program with "Threads raced", naming where the other access was.
Threads are ordered by starting one, and by atomics' orders, as C++ orders
them, so std's mutexes, conditions, channels, and joining a thread order
what they guard, and a `relaxed` atomic orders nothing. A local a closure
takes is watched in the function declaring it too. The machine's `atomic`
instruction carries its order.
- `run --checks` and `build --checks` stop the program's own integer
arithmetic where it overflows its type: `+`, `-`, `*`, `/`, the compound
assignments, `++`, `--`, and negating a signed number, with "Integer
arithmetic overflowed." and where. What the program's libraries work wraps,
as everything does without `--checks`, and `check --checks-report` counts
the checks left as `overflows`.
- `run --checks` checks what the machine reads for the program as it checks
the program's own reads: interpolating a reference into memory a vector
growing released, or an element of a view of memory released, stops the
program, as does formatting a struct a field of which nothing wrote, and
`==` of arrays whose bytes nothing wrote. A variable `undefined` stays in
its memory at every level, so reading a word of one before writing it stops
the program at `-O2` too, where the optimizer kept it in a register.
- Attributes may be written on a function's parameters, before each name, as
`def spawn<T>(@kept body: def(): T)`, and reflection's `attached` and
`attributes_of` give a parameter's. An anonymous function's parameters take
none.
- `@kept`, of `core`, says what a function returns keeps a parameter's
argument, so what the argument refers to, the result refers to too.
`function::new`'s callable and `thread::spawn`'s and `spawn_with`'s body are
`@kept`. Returning what such a call gave, as a `function` of a lambda naming a
local, or a thread's handle whose function names one, is warned of as
returning the lambda is: "The value returned refers to `n`, which ends as the
function returns." So is returning what a generic call gives where its result
holds the type of the parameter given the lambda, as `hold(def() => n)`
giving a `holding<F>`. A `var` no assignment changes, and `x else y`, are
followed to their values, as a `val` is.
- A note made in an instance of a generic says where the program's own code
made the instance, as "(In `encode<point>`, made at main.sakura:8:15)", and
the language server relates it to that place, so a `compile_error` within
std's walk names the call of `json::to_text` that reached it.
- The machine compiles each function to x86-64 as it is first called on Linux
too, as it does on Windows, so `sakurac run` runs `fib(32)` in 0.09 s where
it took 0.35 s interpreted. The two systems make the same code for a
function; the stub entering it and the guard around the machine's own code
take their registers, and where the thread's stack ends, from the system's
conventions, and a call of C, which the machine makes only on Windows, is
left to the machine's own code.
- What only running gives is run while checking, by the program's machine,
where checking needs it: an array's length, the condition of an `if const`,
a local constant, a range's end for `for const`, a constant type argument a
constant gives, and the text of `compile_error`. The checker's own evaluator,
which ran numbers and arrays of them, is gone, with the `compile_error`s held
for evaluating after checking. So an `if const` only running decides checks
the branch it takes, as one folding decides does, and what follows a branch
that leaves is checked only where it isn't taken, so `size_or_refuse::<u64,
i64>()` builds rather than reporting the `compile_error` after its `if
const`; and a local constant may read another, a struct's field, or a view
of one given to a function. A program with an error isn't run.
- An edit keeps what was worked out of the declarations it left where it is:
the nodes it added have a table of their own, rather than the file's table
being made anew with what was kept copied into it.
- A library's declarations are checked where the program reaches them: the
program's own files are checked whole, and of a library what they use, and
what that uses in turn, with the runtime whole for an executable. A library's
declaration nothing uses makes no notes, but where `check --all` asks for
every declaration, and its globals are no part of the program. Checking a
program of the corpus runs about half the instructions it did; checking the
compiler, which uses most of its libraries, 5% fewer.
- Arguments that may need their parameter's type are no longer checked twice,
first with their notes dropped: a call of a generic function whose arguments
don't give its type arguments waits for its parameter's, and what else is
wrong within it is reported once, where it was never reported before, as
`nope` in `take::<i32>(make(nope))`, which checked, then stopped lowering.
The checker notes nothing of what it checks for its results alone, as a
type written for `this`, under one rule, `quiet`, where three counters read
the text of the notes they dropped.
- The lifetime warnings come from what checking a body records as it goes:
where each local is declared, and each value returned, written, or bound,
rather than walking the body again. Checking the compiler runs 8% fewer
instructions.
- The resolver lists each folder of a library once and reads each file's first
lines once, where it listed and read them again for each module it looked
for, and a library's file whose one section is of another target, as
`system/on_windows.sakura` on Linux, is read only as far as its section's
line. A folder's files that aren't Sakura's are passed over by their names,
and each round of reading grows what holds the files rather than making it
for every file a library has, so a program of the corpus checks in 67
million instructions where it took 77.
- `sakura::analyzer`'s interface changed, again:
- `checker::add` takes whether the file is the program's own, `true` where
it is left out, and `checker.whole` checks every declaration.
- What keeps results of a file's node keys it by a `file_node`, and of a
table's by a `table_node`, in `keyed` maps that take no bare node;
`checker::table_node_of` takes the place of `result_key`.
- Instance 0, table 0, binding 0, and constant 0 stand for none, so nothing
is held as one more than an index: what took one more than an instance
takes the instance.
- `syntax::record` reads a slot of a node's record by the slots its kind
names, as `function_slot::body`, which a checked program checks it has.
- `resolver::read_for` gives the target files are read for, and
`resolver::cut_of` how much of a file is read; `source::open` takes it.
- `checker.evaluator` is what runs code while checking, which
`sakura::machine::check_evaluating` gives a checker and checks with, for
`evaluate`, which ran once checking was done; `checker::run_value`,
`ask_evaluator`, `evaluation_ask`, and `evaluation_answer` are how the
checker asks. `to_evaluate`, `held_errors`, and `report_held` are gone,
and the server's `program::check_whole` is `give_whole`.
- A value worked out while compiling is a `known` of its own kind, number or
real: `checker::intern_constant` is `value_known`, which finds one made
before.
- Checking holds less and does less: of the compiler's own sources, the
analyzer's tables take 28 MB where they took 49, and checking them runs
1,440 million instructions where it ran 1,900, with a fifth fewer cycles.
- A token keeps its kind, where it begins, and its name. How many bytes it
covers is its kind's, or its name's, and only a literal's is kept. A node
keeps where it ends in a byte, as how many tokens past its own.
- The token and node vectors are trimmed to fit once a file is read.
- A node's result flags take two bytes. The type it converts to and the
constant it is, which few nodes have, are kept by row in maps rather than
in columns mostly of zeros, and each constant is kept once.
- The checker's maps hold a key and a value, twelve bytes a slot, where a
`dict` took forty, and types, constants, and known values are found by
their hash in an index of IDs, eight bytes a slot.
- The resolver looks each path up by the IDs of its names, once for the
program, where it made the path's text again in each file, a tenth of
checking.
- The lifetime warnings walk each body on one stack, noting where its locals
are in a column by node, where they made a vector for each node and two
maps for each function, an eighth of checking.
- A frame zeroes a cell whose address a call is given, or an edge, only where
a word of it may not be written yet, and the copy of a function inlined
clears only the cells its own frame would zero, where it cleared every one:
the checker's `expr` cleared 1.9 KB on each call. Checking the compiler runs
5% fewer instructions.
- `values_of` in a default argument evaluates the locals of the call where it
was written, rather than a parameter of the function whose default it is
with the same node in another file, which gave a wrong value, or none, as
`std::testing`'s `expects` did of a loop's variable, stopping the virtual
machine.
- `sakura::analyzer`'s interface changed:
- `source::open` takes the path alone, and `names::new` and `syntax::new`
take no allocator.
- `parser::new`, `syntax::reparse`, `syntax::print`, and `syntax::token`
take the names the tokens were lexed with, and `syntax::token_length`
gives a token's length, for `token_lengths`.
- `syntax::node_end` and `syntax::set_node_end` read and write where a node
ends, for `node_ends`.
- A `note` holds its `detail`, `instance`, and `related` as `string`s, so it
is moved rather than copied: `note_sink::give` and what hears notes take
`&mut note`, `checker::keep` is gone, and `report_text` and `warn_text`
take `&string`.
- The kinds of type are `ty`, for `tkind`, and the words the checker knows
are `word`'s members, constants, for `checker.words`.
- `resolver::refer` is given the program's one table of names for each file.
- `id_index` takes the place of `chains`, and `core`'s `trailing_zeros` of
`lowest_bit`.
- Executables work `f32` arithmetic in single precision, `addss` and the rest,
where every reader rounds it to an `f32` anyway, which gives the same bits, and
hold `f32`s as `f32`s where every reader takes one, rather than converting
each way around every operation.
- The register allocator keeps a value a loop reads in every arm in one register
through the loop: one living across a call takes a register a call keeps from
a value read later, and none takes a register from a value read more often.
The virtual machine's loop does about half the work it did for each operation.
- A function calling one whose x86-64-v3 version is small enough to be inlined
gets a version too, so `simd`'s `fma` in a loop is one instruction there.
- `simd`'s `fma` is `vfmadd231ps` or `vfmadd231pd` alone. It also took the
product where it was NaN, five instructions more, to give the NaN std's `fma`
gave without FMA3, which gives the instruction's now.
- Splatting `f32`, `f64`, and 32-bit lanes shuffles within the register, and an
`f32` only splats read is held as an `f32` too, rather than converted to an
`f64` and back.
- A function returning memory copies it 16 bytes at a time, as callers read it
back, so the processor forwards the stores.
- Each function begins at a multiple of 16 bytes.
- The virtual machine works an `f32` arithmetic and its rounding as one
operation, and each arithmetic of reals as a case of its own.
- The virtual machine's loop keeps why it stops in a register: each check of
its steps gives the reason, rather than writing it where the loop read it
back every operation.
- A loop whose head jumps through a table, as the virtual machine's loop over
its operations does, begins that head at a multiple of 64 bytes, so it never
lies across two lines of the cache. The machine's loop ran 16% slower where
it did, as code before it grew or shrank.
- `@inline` copies a function, method, or property wherever it's called, at
every level, `-O0` too, whatever its size, and `core`'s word and byte tests
are `@inline`, so `-O0` searches of text no longer call a function for each
word.
- Debugging information keeps a variable whose value is a constant the
optimizer made where it's read, so gdb shows a parameter given a constant, as
`scale (by=2)`, at `-O2` too.
- A `compile_error` in a branch of `if const` that only running the condition
decides, as `if const size_of::<A>() != size_of::<B>()`, is reported once the
condition chooses that branch, by `check`, `run`, and `build` alike, rather
than stopping the program as it runs; one in a branch not chosen never is.
- `compile_error` says text it is given that isn't written, a constant's or text
worked out while compiling, as `$"{f.name} is not read"`, rather than "The
program reports an error here."
- The accessors of a generic type's property are checked for each instance a
value reaches, as a method called is, so a `compile_error` in one is reported
while checking, rather than stopping lowering without the note.
- `simd`'s `bits` refuses a vector of another size while compiling, rather than
stopping the program as it runs.
- `lanes_have` and `lanes_apply` take one real alone, worked with the
instruction of one number: `roundss` and `roundsd`, `sqrtss` and `sqrtsd`, and
`vfmadd231ss` and `vfmadd231sd`.
- Counting a word's ones, leading zeros, and trailing zeros is `popcnt`,
`lzcnt`, and `tzcnt` in a function's x86-64-v3 version, which asks for them.
`SAKURA_CPU` names `popcnt`, `lzcnt`, `bmi1`, `avx512`, and `x86-64-v4` too.
- `simd`'s lanes are worked with instructions where they were a lane at a time:
`*` of every width of integer, the least and greatest of 64-bit lanes, `abs`
and `>>` of `i64`, shifts of bytes, `round`, `sum`, the `product` of reals,
the `smallest` and `largest` of integers, `shuffle`, by `pshufb` and across 32
bytes `vpermd`, `convert`, and gathering. A constant vector, as a splat of a
constant, is read from constants written after the function.
- `simd` has `low` and `high`, the halves of 32 bytes, `join`, of two of 16,
`widened` and `widened_high`, each lane twice as wide, `narrowed`, half as
wide and saturated, `gather`, and `scatter`.
- Vectors of 64 bytes, of 16 bits a lane or more: `f32x16`, `f64x8`, `i16x32`,
`u16x32`, `i32x16`, `u32x16`, `i64x8`, and `u64x8`. Executables work them with
AVX-512 where the processor has it, which an x86-64-v3 version still asks,
and a half or a quarter at a time where it doesn't.
- The stores filling 16 bytes of a struct, four `f32`s or two words, are merged
into one store of a vector, so a struct returned in memory is copied out
without waiting on each field: `linear`'s `cross` takes 12 cycles where it
took 30, and `quat * quat` 18 where it took 35.
- A narrow integer held as a value is wrapped once, where it was wrapped again
as each field read and through each loop's parameter, so a loop of
`vec3<i32>` arithmetic takes 11 ms where it took 17.
- The register allocator weighs values by how often they're read only where they
live in a loop. Elsewhere it spills the value read furthest ahead, rather than
each value as it's made, which it read straight back, as `linear`'s
`mat4::inverse` did with nearly every product.
- The runtime's allocator holds its lock far less, as a game allocating on 16
threads at once found it waited on it. Blocks of up to 256 KiB, of 47 sizes,
16 bytes to 256 by sixteens, then 512, 1 KiB, and 2 KiB, and past that four
sizes to each power of two, are carved from chunks of a MiB; each thread
keeps blocks of each size given back, as many as 64 of each small size and of
each larger as many as 256 KiB holds, two at least, taking and giving back
many at once under the lock; larger blocks are mapped and unmapped outside it, the last let go of
kept for the next as large; and a block resized is made again, copied, and
let go of, the copy outside the lock, or on Linux remapped. A block of the
middle sizes is cleared only as far as it's asked to be. A thread allocating
beside 15 others allocating takes 0.36 µs a small block where it took 34, and
8.9 µs a block of 4 to 100 KiB where it took 121. `tests/core/allocators`
checks blocks of every size holding what's written and coming back zeroed,
keeping what they hold resized through every size, and of threads allocating
at once.
- On Windows, `system::clock` keeps the counter's frequency atomically, where two
threads asking for the time at once first raced on it, as the VM's checks
found.
## 1.0.0 - Unreleased
- The first version of `sakurac`, the Sakura compiler, written in Sakura and
built by itself. It holds:
- the command line: `check`; `run`, on the virtual machine; `build`, of
standalone x86-64 executables for Linux and Windows, with no assembler,
linker, or C library; and `lsp`, the language server;
- the language as the README describes it;
- `core`, `system`, and the runtime, in `runtime`, found beside the compiler, and
the standard library;
- checked programs, with `run --checks` checking memory too, and contracts,
which `--contracts off` leaves out;
- debugging information, as DWARF, and for Windows as a PDB file too;
- the tests, run with `blossom test`.
- Its parts are libraries of this repository, each in the folder of its name
with its tests in `tests/`, and exported for other projects to read:
- `sakura::analyzer`: the lexer and parser, with reparsing after an edit; the
checker, with checking again after an edit and the evaluation of constants;
the resolver finding a program's library files; and the queries the language
server answers with;
- `sakura::compiler`: lowering a checked program to intermediate code,
verifying and optimizing it, and assembling each function into the
machine's code, on threads, with the same result however many there are;
- `sakura::machine`: the virtual machine `run` runs programs on, with its
heap, its threads, and its calls to the system and to C; the memory checks
`run --checks` asks for; and the evaluation of constants while compiling;
- `sakura::native`: x86-64 executables for Linux as ELF and for Windows as PE;
the selection of instructions, with SSE and AVX for a `simd`'s lanes; the
register allocator, and the checker replaying what it chose; calls to C and
from it; and the debugging information, as DWARF and as a PDB file;
- `sakura::server`: the language server `lsp` serves, with diagnostics,
hovering, completion, signature help, colouring, going to a declaration,
finding references, and renaming, each job in a process of its own; and
`toolchain_folder`, which finds `core`, `system`, and `runtime`.
- Each was a package of its own, at version 1.0.0, from 2026-10-25 or 2026-10-26
until it came back on 2026-10-26.
- The standard library is a repository of its own, `sakura/std`, each module
a library of its own, which it requires, naming the modules each of its
libraries reads. Its tests went with it, but for those of `core` and
`system`, which ship with the compiler, as `tests/core`.
- `core` holds only what the compiler names, or what that, `system`, and the
runtime are built from:
- `dict`, `hashset`, `rc`, `arc`, and `arena` are std's, as are the streams'
traits, `readable`, `writable`, and `flushable`, with `string`'s `write`
and `strview`'s `read`, so the built-in `string` names no `writable`;
- `io_error` is `system`'s;
- `core::intrinsics` holds `square_root`, `lanes_have`, and `lanes_apply`,
which `std::math` declared, and `system` holds `start`, which
`std::thread` did, so std declares no intrinsic.
- The standard library is the folder `--lib std=DIR` names, else a `std`
folder beside the compiler or above it, else its libraries in the
`share/sakura` folder above it, where `blossom install` puts them. `--std`
and `SAKURA_STD` are gone, and `sakurac lsp` finds it the same way.
- `install` puts `system` beside `core` and `runtime`.
- It requires packages for the standard library, `std::args` and `std::json`
among it, and for the back end's libraries, in `binary`.
- Fixed, from what building `hearth` met:
- `close(x)`, which a `box` and the containers close what they hold with,
closed a value's own `close` but not its fields after, as a scope ending
does, so what the fields held leaked; and generic code closing a type of
another module whose `close` isn't `pub` was refused. It's the compiler's
own closing now, `close_where_it_is`.
- `f(...xs)` copied a pack's values that close to the function given them,
so both closed them; it moves them.
- An anonymous function whose parameters' types are written gives its type
to a type parameter where overloads are chosen between, and to the type
parameters a function type leaves unknown, as `T` of `def(&T): bool`,
where before neither was given and the call was refused.
- `? :` names what its condition's `is` tests give, as `if` does.
- `for` walks a literal of text, as the `strview` it settles as.
- A pack of types has a `length`, as `Ts.length`.
- A folder holding a module's file and the one file of a module within it,
as `nest/nest.sakura` and `nest/deeper.sakura`, was taken for the deeper
module's alone, by its first file, which hid the folder's own module.
- A file beginning with UTF-8's byte order mark is read past it.
- `decl_of` of a type no declaration makes, as a reference, is refused where
it's checked, rather than failing as it's lowered.
- The checker's columns are given back as a checker closes, which the
language server leaked a checker's worth of with each check.
- Notes: a property called, as `m.is_none()`, says it's a property; and a
copy an `is` test names, written, says `&mut` names the reference.
- `is some(_)`, `is not some(_)`, and an arm's `some(_)` took a field that
closes out of the union and closed it, through a reference too, so the
union's owner lost it; `_` names nothing, and takes nothing.
- The condition of an `if const` within a pass of `for const` over
reflection, where only evaluating decides it, as `d.name == "x"`, couldn't
read the pass's description, which evaluating's function never declared.
- `path_of::<T>()` spells a type with the module of each type it names, as
`&mut game::position`, which no two types share, as `name_of` doesn't.
- `sakura::machine` is embeddable, as `hearth::scripting` runs scripts:
- `begin` gives a program's globals their values without calling `main`, and
`call` and `call_value` call a function, or a function value, given the
words of its parameters, `result` giving the words it returned;
- `provide` gives a foreign declaration's name a function of the host's, as
a `cfn`, found before any library's, which may call back into the program,
a fault there stopping the calls under way as the host returns to them;
- `interpreting::steps` stops a call taking more steps than that, with the
new `halt::step_limit`;
- `interpreting::capture`, `stack`, and `steps` are `pub`, and `take_output`
gives what was kept; on Windows it keeps what `WriteFile` and
`WriteConsoleW` write to the output and error, as it kept Linux's `write`
alone before;
- a fault in a function C called back keeps the trace of where each function
was, which the program's call of C ending forgot.