15 KiB
Changelog
Each version's changes, newest first. Versions follow semantic versioning.
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
dicttook 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
exprcleared 1.9 KB on each call. Checking the compiler runs 5% fewer instructions. -
values_ofin 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, asstd::testing'sexpectsdid of a loop's variable, stopping the virtual machine. -
sakura::analyzer's interface changed:source::opentakes the path alone, andnames::newandsyntax::newtake no allocator.parser::new,syntax::reparse,syntax::print, andsyntax::tokentake the names the tokens were lexed with, andsyntax::token_lengthgives a token's length, fortoken_lengths.syntax::node_endandsyntax::set_node_endread and write where a node ends, fornode_ends.- A
noteholds itsdetail,instance, andrelatedasstrings, so it is moved rather than copied:note_sink::giveand what hears notes take&mut note,checker::keepis gone, andreport_textandwarn_texttake&string. - The kinds of type are
ty, fortkind, and the words the checker knows areword's members, constants, forchecker.words. resolver::referis given the program's one table of names for each file.id_indextakes the place ofchains, andcore'strailing_zerosoflowest_bit.
-
Executables work
f32arithmetic in single precision,addssand the rest, where every reader rounds it to anf32anyway, which gives the same bits, and holdf32s asf32s 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'sfmain a loop is one instruction there. -
simd'sfmaisvfmadd231psorvfmadd231pdalone. It also took the product where it was NaN, five instructions more, to give the NaN std'sfmagave without FMA3, which gives the instruction's now. -
Splatting
f32,f64, and 32-bit lanes shuffles within the register, and anf32only splats read is held as anf32too, rather than converted to anf64and 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
f32arithmetic 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.
-
@inlinecopies a function, method, or property wherever it's called, at every level,-O0too, whatever its size, andcore's word and byte tests are@inline, so-O0searches 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-O2too. -
A
compile_errorin a branch ofif constthat only running the condition decides, asif const size_of::<A>() != size_of::<B>(), is reported once the condition chooses that branch, bycheck,run, andbuildalike, rather than stopping the program as it runs; one in a branch not chosen never is. -
compile_errorsays 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_errorin one is reported while checking, rather than stopping lowering without the note. -
simd'sbitsrefuses a vector of another size while compiling, rather than stopping the program as it runs. -
lanes_haveandlanes_applytake one real alone, worked with the instruction of one number:roundssandroundsd,sqrtssandsqrtsd, andvfmadd231ssandvfmadd231sd. -
Counting a word's ones, leading zeros, and trailing zeros is
popcnt,lzcnt, andtzcntin a function's x86-64-v3 version, which asks for them.SAKURA_CPUnamespopcnt,lzcnt,bmi1,avx512, andx86-64-v4too. -
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,absand>>ofi64, shifts of bytes,round,sum, theproductof reals, thesmallestandlargestof integers,shuffle, bypshufband across 32 bytesvpermd,convert, and gathering. A constant vector, as a splat of a constant, is read from constants written after the function. -
simdhaslowandhigh, the halves of 32 bytes,join, of two of 16,widenedandwidened_high, each lane twice as wide,narrowed, half as wide and saturated,gather, andscatter. -
Vectors of 64 bytes, of 16 bits a lane or more:
f32x16,f64x8,i16x32,u16x32,i32x16,u32x16,i64x8, andu64x8. 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
f32s 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'scrosstakes 12 cycles where it took 30, andquat * quat18 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'smat4::inversedid 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; andlsp, the language server; - the language as the README describes it;
core,system, and the runtime, inruntime, found beside the compiler, and the standard library;- checked programs, with
run --checkschecking memory too, and contracts, which--contracts offleaves out; - debugging information, as DWARF, and for Windows as a PDB file too;
- the tests, run with
blossom test.
- the command line:
- 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 machinerunruns programs on, with its heap, its threads, and its calls to the system and to C; the memory checksrun --checksasks 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 asimd'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 serverlspserves, with diagnostics, hovering, completion, signature help, colouring, going to a declaration, finding references, and renaming, each job in a process of its own; andtoolchain_folder, which findscore,system, andruntime.
- 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 ofcoreandsystem, which ship with the compiler, astests/core. coreholds only what the compiler names, or what that,system, and the runtime are built from:dict,hashset,rc,arc, andarenaare std's, as are the streams' traits,readable,writable, andflushable, withstring'swriteandstrview'sread, so the built-instringnames nowritable;io_errorissystem's;core::intrinsicsholdssquare_root,lanes_have, andlanes_apply, whichstd::mathdeclared, andsystemholdsstart, whichstd::threaddid, so std declares no intrinsic.
- The standard library is the folder
--lib std=DIRnames, else astdfolder beside the compiler or above it, else its libraries in theshare/sakurafolder above it, whereblossom installputs them.--stdandSAKURA_STDare gone, andsakurac lspfinds it the same way. installputssystembesidecoreandruntime.- It requires packages for the standard library,
std::argsandstd::jsonamong it, and for the back end's libraries, inbinary. - Fixed, from what building
hearthmet:close(x), which aboxand the containers close what they hold with, closed a value's ownclosebut not its fields after, as a scope ending does, so what the fields held leaked; and generic code closing a type of another module whosecloseisn'tpubwas 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
Tofdef(&T): bool, where before neither was given and the call was refused. ? :names what its condition'sistests give, asifdoes.forwalks a literal of text, as thestrviewit settles as.- A pack of types has a
length, asTs.length. - A folder holding a module's file and the one file of a module within it,
as
nest/nest.sakuraandnest/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_ofof 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 anistest names, written, says&mutnames the reference. is some(_),is not some(_), and an arm'ssome(_)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 constwithin a pass offor constover reflection, where only evaluating decides it, asd.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, asname_ofdoesn't.sakura::machineis embeddable, ashearth::scriptingruns scripts:begingives a program's globals their values without callingmain, andcallandcall_valuecall a function, or a function value, given the words of its parameters,resultgiving the words it returned;providegives a foreign declaration's name a function of the host's, as acfn, 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::stepsstops a call taking more steps than that, with the newhalt::step_limit;interpreting::capture,stack, andstepsarepub, andtake_outputgives what was kept; on Windows it keeps whatWriteFileandWriteConsoleWwrite to the output and error, as it kept Linux'swritealone 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.