Files
sakurac/CHANGELOG.md
T

236 lines
15 KiB
Markdown
Raw Normal View History

2026-10-26 10:14:11 -05:00
# Changelog
Each version's changes, newest first. Versions follow [semantic
versioning](https://semver.org).
## Unreleased
- 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.
## 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.