52 KiB
Changelog
Each version's changes, newest first. Versions follow semantic versioning.
Unreleased
-
whenchooses by the version of the compiler reading the program: the keycompiler, compared with a version aswhen compiler >= 1.2.0, by==,!=,<,<=,>, or>=, the parts left out counted as 0. It works in awhenof declarations or statements and on a section's line, asmodule x when compiler >= 1.2;. A library read by an older compiler than the one it was written for chooses what that compiler understands, socoreand the libraries beside it can change without breaking the compiler of the release before, which builds the next. Onlycompileris ordered, and only by a version:os >= linuxandcompiler == linuxare each an error. -
coredeclaresversion, three numbers compared in order withtextas1.2.0, andcompiler(), which gives the version of the compiler checking the program.if const compiler() >= (version { 1, 2 })checks only the branch it takes. -
sakurac --version, and the subcommandversion, print the compiler's version, which lives inanalyzer/version.sakuraascompiler_versionand follows the blossomfile'ssemv. -
--lib core=DIR,--lib system=DIR, and--lib runtime=DIRname each of the compiler's own libraries in place of the one beside it, forcheck,run,build, andlsp, as blossom names a package's. Where none is beside the compiler or above it, the one in theshare/sakurafolder nearest above it is read. The ones found beside the compiler were read whatever--libsaid. -
coresays the release it is for, ascore::toolchain::release, and acorefor another release than the compiler's is refused, saying both. -
The runtime says the ABI it implements, as
runtime::abi, which the native back end'sruntime_abimust match: the helpers the generated code calls, the words of the runtime's state, and the records the compiler writes. A build with a runtime of another ABI is refused, saying both. -
systemis a package of its own rather than a part of this repository, which std requires, so blossom gives it as--lib system=DIRas it gives any library; without blossom it is found as before, beside the compiler or above it, or inshare/sakura.blossom installinstallscoreand the runtime alone. The tests of signals moved with it, and the corpus and the tests read it from its repository beside this one, as../system. -
A
systemfound beside the compiler or above it that's a checkout of its repository is read from itssystemfolder, where the library is, so a compiler built beside the repository finds it. -
Importing
system, or a path beginning with it, where no file of it was read says it's a package of its own, which std requires: to require it, or give it by--lib system=DIR. -
The runtime reads
corealone: the functions of kernel32 it calls on Windows are its own, inruntime::win32, rather thansystem::windows's, so a program reading nothing builds with nothing beside the compiler butcoreand the runtime. A program reading both imports each function once. -
@sealedmarks 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, ascloses::<T>::valueandstrip<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 withinif const owns::<T>::value,Tis owning, as withinif const T is owning. Within it, a constant names the others and its types by their names, andselfis the trait. A type or trait naming it, a bound,is, ormatch constnaming 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, socloses::<T>::valuewas 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
selfthat type and the trait's parameters its arguments, astrait sized { const bytes: u64 = size_of::<self>(); }. The value was left unread, and each type gave its own. -
A type parameter bounded by
referencetakes the reference an argument is, asaddress(src)ofaddress<T>(r: T): castptr<T> where T: referencegivesTthe&mut Tthatsrcis; it took what the reference reaches, which noreferencebound 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 pointeris false. Amatch constchoosing 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, socastptr<&mut T>ofmatch const T { pointer => T, reference => ..., else => ... }is a*mut T, andcastref<*mut T>a&mut T. Each was left to each instance, sothrough(address(src))was refused, andthrough(p) *= 2of a*mut Twas 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, soconv::<u32>::bytes()namesTau32;Twas left a type parameter there, sosize_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, asval x := args;, is an error; it was taken as the local's type. -
corehastuple<Ts...>, a struct holding a pack, made bytuple::of(1, true)and read or written byt.at::<0>(). -
A pack's type at an index worked out from constant parameters, as
Ts...[I]ofdef 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, sopick::<1>(5, true)gave a value of no size, printed as nothing. -
C ? A : Bis a type:Awhere the constantboolCholds andBwhere it doesn't, astype makeref<T, const MUTABLE: bool> = MUTABLE ? &mut decay<T> : &decay<T>;. Each part ofCchooses asmatch constdoes: a test of a type by what it tests, astype remref<T> = T is reference ? T::target : T;, and any other part by theboolit is, as a constant, a constant parameter,N == 4, or what a function gives, assmall(N). What follows each part is resolved with what it says, soT::targetnames whatTrefers to, and the right of&&is resolved where its left holds.Cis a name,!of one, a call, a name tested withisor compared with==or!=, or an expression in parentheses, and what&&and||join to one of those, assmall(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 whereif const C, orif 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, asconst isptr<T>::value := T is pointer;makesisptr::<*i32>::valuetrue. A constant of one is known while compiling, toif constand 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, orM ? 4 : 8, is worked out for each instance, sotype pick<const M: bool> = buffer<u8, M ? 4 : 8>;, a field ofu8[small(N) ? 1 : 2], andbuffer<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, asbuffer<u8, small(2) ? 3 : 5>, and a type argument may call a function given type arguments, assize_of::<T>(), which was read as a type. -
Within an instance, a
match consttype resolves no arm the type it chooses by doesn't fit, and none after the one it fits, which gets the bound it tests, soreference => T::targetno longer reportsu8having notargetwhereTisu8. -
Within a generic's own body, a value given where a type not chosen yet is expected, as
castref<T>beforeT::mutableis 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 withas, given to a parameter, or held, and so is one given as a type holding one, as&castref<T>orvector<castref<T>>. Soreturn p as addptr<T, M>;andreturn through(p);for acastref<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*pof anaddptr<i32, M>is ani32, andtotal += xof aword<N>works. Each was refused, as converting to, from, or using a type of its own. Where what is proved chooses one, asif const Mdoes, 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 asif constdoes: 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 constchooses by a constant where its patterns are values written in place, asmatch const N { 4 => u32, else => u64 }as a type, ormatch 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 !Mholds, andreturn 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
referenceis a&T::target, or a&mut T::targetwithinif const T::mutable, as one bounded bypointeris a pointer, sor as *T::targetworks. -
A pointer converts to a reference with
as, asp as &mut node, asthroughgives 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
pointeris the pointer it is toasand to a call inferring type arguments, sop as u64andthrough(p)work, and one bounded bypointer,reference,array,integer,real, orgeneric, or said to fit one, fits none of the others, soT: pointerdecidesT is reference. -
Notes name a type a bound asks of a type parameter as it is written, as
T::target, where they saidtarget, and a note said in one way a constantboolgoes says which, as "(WhereMisfalse.)". -
x as *T != nullandx as *T ? a : bread!=and?as the expression's, asx as T != nulldoes; within the pointer's type they began a type's condition. -
Within a generic's own body,
T: arraytakesTas aT::element[T::length], whichx[i],for, and conversions read, with a zero value whereTiszeroabletoo;T: pointeras a*T::target, which*xreads, and writes withinif const T::mutable; andT is vectoras avector<T::args...[0]>, withvector's members, a generic's pack given the types from its place on, asT::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 ofTis 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 afterif const T is not u16 { return 0; }. -
A
match constvalue none is expected of is of the type its arms share in the generic's own body, in each instance, sointeger => 1u, else => 0is au64in each, where it was the chosen arm's, anintwhereelsewas chosen. -
Within a generic's own body, what follows
if const A && B { return ...; }is checked once whereAfails and once whereBdoes, where it knew nothing; a trait ruled out rules out what implies it, asnumericdoesintegerandi32; and a branch is checked in each of the cases its condition holds in, cases that can't hold, asT 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 ofif constdoes: the first arm whose patternTfits is kept, andelsefits any. A pattern is a trait, a generic type without type arguments, or a type, fit asisfits 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, astype 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, sostrip_pointer<*i32>isi32, toisand as a type argument. Within a generic's own body, each arm is checked with its pattern fittingTand those before it not, once for each pattern it lists, and a type it chooses byTis chosen where what is proved ofTdecides it, sodef 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 withoutelseis 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 whetherTis one of its instances, looking through aliases, and gives the branch the boundgeneric. -
core's traits naming a type's parts, which the compiler decides:pointernamesT::targetandT::mutable, newreferencenames the same of a reference, newarraynamesT::elementandT::length, and newgenericnamesT::args, the pack of a generic type's type arguments. -
A pack of types is walked by
for const U in Ts, asT::argsorF::params, andTs...[i]is its type at an index known while compiling. Within a template,args[i]is of the typeTs...[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 constan instance decides gives its branch the bounds it tests, so what they ask for is named through the type parameter, asF::resultwithinif const F is signature, which each instance reported having no typeresult, and ofA || B, those of each side that holds. -
Within a generic's own body, an
if constbranch is checked with what its condition says of a type parameter, which now rules out what it doesn't fit, asT is not pointer, theelseofT is pointer, or what follows a branch that leaves does. One holding in several cases, asT 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 "(WhereTisreal.)". An undeclared name it tests by is reported once, not three times. -
A constant a trait asks for, as
T::bytesoftrait sized { const bytes: u64; }, orT::lengthof anarray, 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, asbuffer<u8, T::bytes>, which was refused. So is a localconstworked out from one, or from a constant parameter, asconst 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::makereaches the typeshapeof the moduleshape, which reported that the module declares nomake. -
F::params.length, a pack a bound asks for, is a constant asTs.lengthis, rather than overflowing the stack while it's compiled. -
buildshows 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 TEXTand--semv VERSIONare what its properties say of it, as Task Manager names it; and--windowedruns it in windows of its own, with no console. They're written as its resources, throughbinary::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.binaryis 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 issystem's, whichstd::processstarts programs through. -
A property called through its type, as
span::<T>::empty(), is reported as a property, read of a value asx.emptyis, and where the type'semptyis one and it has ablank(), 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 itsget, which takes&mut thisand reads it where the value can be written, as a method's&mut thisoverload is called there. Where the property's type is a reference, it gives one that writes, sov.first = 4andv.first += 1write through it, while a value that only reads reads by theget. A property only aget mutreads 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.iteratorgives avector<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 isiter<T>, rather thaniterator<T>, named as the types the syntax makes are, which leavesiteratorto the type a container lends. -
iterableasks for aniterator, astype list<T>::iterator = ...;, rather than acursor. Within a type that has one, as withiniterable,iteratornames that type, so the trait isiterthere.span<T>::cursorisspan<T>::iterator, and no container has acursor. -
spannable<T>, which wasviewable<T>, asks forspan_of(other: &self, start: u64 = 0, count: u64 = ~0u): span<T>rather thanview, andsliceable<T>forslice_of(other: &mut self, start: u64 = 0, count: u64 = ~0u): slice<T>rather thanslice: a view ofcountelements fromstart, where a count of~0uis every element after it. Generic code reads them through its bound, asC::span_of(c)for all of them. -
x[start:count]of what is no view calls its type'sspan_of, or itsslice_ofwherexcan be written, asx[k]callsat, so avector, astring, and whatever else implements the traits is sliced as a view is:v[1:3],s[6:], andc[:2]of ac: &CwhereC: 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, asvector'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, andfull, asv.span,v.first = 4, andv.empty, rather than the methodsview(),slice(),first(), andlast()and the propertiesis_emptyandis_full.span<T>::empty()andslice<T>::empty(), which made a view over nothing, areblank(), sinceemptyis the property, and a view'sfirstandlastare properties giving amaybe, as the methods did. An iterator'sis_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 thisof it,&mutof it, or assigning it, asv.append(x)withinfor x in v,for x in v.span,for x in v[1:], orfor x in v.iter(). Changing what it holds in place, asv[i] = xorv.first += 1, or what holds it, as a method ofthiswithinfor x in this.items, isn't warned of, nor is a fixed array, which holds its elements where it is. The errorlockedis gone. -
Contracts are checked where the program is:
runchecks them unless--fast, andbuilddoesn't unless--checks, where they were checked everywhere but where--contracts offsaid.--contracts onand--contracts offsay otherwise, whichever the program is. -
checking()is gone:core's containers check what they're asked for with contracts, asexpects(index < this._len)andexpects(!this.empty, "The vector is empty."), rather thanif const checking() { ... past_end(...) }, so a checked program stops as it did, with the contract's report.contracts()says whether they're checked, assimd'sshuffle,gather, andscatterask before the instructions trusting their lanes. -
check --checks-reportlists a container's checks among the contracts, asfault, rather than among indexes. -
coregives the iterators a container indexed by position lends, so it needn't write its own:positions_iterator<C, T>reads each element throughat, andposition_mutator<C, T>writes it, from either end, each remembering how many are left. -
assignable<K, V>is the half ofindexablethat writes,at(&mut this, key): &mut V, whichindexableno longer asks for as@optional. Through a bound of it,x[key] = vwrites.slice,vector, andstringname it, and so does the compiler'sids. -
iterable's writing iterator is itsmutator, asiteratoris its reading one, rather than itsmut_cursor.slice,vectorandstringname theirsmutator, andslice<T>::iteratorisspan<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, andfunctions. -
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
i32arithmetic 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 anf32is not rounded again. - Simplifying folds constants applied one after another into one, as
(x * 3) * 5isx * 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, soxs[i + 1]is read at an offset fromxs[i]'s address; compares what a constant was added to rather than the sum, asx + 1 == 5asks whetherxis 4; takes(x + y) - yasx; 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 anf32negated as anf32. - 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, thatxis the constant where that way goes, as LLVM's numbering does, and reads it so. - Loops regroup
(i + a) + b, whereaandbstay the same each time round, asi + (a + b), whosea + bmoves 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.
- 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
-
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
f32andf64, 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 inxmm0to the one before. f32s are compared withucomiss, and negated and chosen asf32s, rather than widened first; a choice of reals by<of reals ismaxssorminsswhere it picks the greater or lesser, asa < b ? b : adoes, and a mask ofcmpssotherwise, with no branch; andx != xandx == xare 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
f32s 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 newlanes_lane, so the cell holds one width and promotes. It runs once more after numbering, at-O2. - Rounding to an
f32and 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
simdheld in memory is copied by its function 16 bytes at a time;simd::scatterwrites its lanes out where there are at most 16, and checks its places only where the program checks indexes.
- A conversion between
-
run --checkschecks 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 arelaxedatomic orders nothing. A local a closure takes is watched in the function declaring it too. The machine'satomicinstruction carries its order. -
run --checksandbuild --checksstop 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, andcheck --checks-reportcounts the checks left asoverflows. -
run --checkschecks 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 variableundefinedstays in its memory at every level, so reading a word of one before writing it stops the program at-O2too, 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'sattachedandattributes_ofgive a parameter's. An anonymous function's parameters take none. -
@kept, ofcore, 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 andthread::spawn's andspawn_with's body are@kept. Returning what such a call gave, as afunctionof 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 ton, 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, ashold(def() => n)giving aholding<F>. Avarno assignment changes, andx else y, are followed to their values, as avalis. -
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 acompile_errorwithin std's walk names the call ofjson::to_textthat 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 runrunsfib(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 forfor const, a constant type argument a constant gives, and the text ofcompile_error. The checker's own evaluator, which ran numbers and arrays of them, is gone, with thecompile_errors held for evaluating after checking. So anif constonly 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, sosize_or_refuse::<u64, i64>()builds rather than reporting thecompile_errorafter itsif 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 --allasks 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
nopeintake::<i32>(make(nope)), which checked, then stopped lowering. The checker notes nothing of what it checks for its results alone, as a type written forthis, 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.sakuraon 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::addtakes whether the file is the program's own,truewhere it is left out, andchecker.wholechecks every declaration.- What keeps results of a file's node keys it by a
file_node, and of a table's by atable_node, inkeyedmaps that take no bare node;checker::table_node_oftakes the place ofresult_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::recordreads a slot of a node's record by the slots its kind names, asfunction_slot::body, which a checked program checks it has.resolver::read_forgives the target files are read for, andresolver::cut_ofhow much of a file is read;source::opentakes it.checker.evaluatoris what runs code while checking, whichsakura::machine::check_evaluatinggives a checker and checks with, forevaluate, which ran once checking was done;checker::run_value,ask_evaluator,evaluation_ask, andevaluation_answerare how the checker asks.to_evaluate,held_errors, andreport_heldare gone, and the server'sprogram::check_wholeisgive_whole.- A value worked out while compiling is a
knownof its own kind, number or real:checker::intern_constantisvalue_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
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. -
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/allocatorschecks 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::clockkeeps 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; 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.