Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 1 of bringing
scarlet/wireback: the descriptor. The compiler describes wire types again and refuses the ones it cannot. The VM does not walk bytes yet — a wire call still stops with "not built yet", and the walks are stage 2.All of this existed before the VM rewrite and was deleted in
44218b7. It is brought back rather than reinvented, retargeted at the crate layout it has to live in now.Where it lives
scarlet_ir::wireholds the descriptor the compiler and the VM share:NodeIdx,Ctor,HandleKind,Node,Desc. It used to sit in the VM crate, which the compiler cannot depend on;scarlet_iris the contract between them, which is wheredocs/vm-design.mdsaid this had to come back through.It deliberately carries less than the compiler's own descriptor: no type, constructor or field names. The walks need structure, and a decoder rebuilds a constructor through
Program::types, keyed on the identity aVariantRefalready has. A name in here would be a second identity for a constructor that has one. The fingerprint travels with it rather than being recomputed, because it folds names as text and this table holds none.HandleKindused to borrow its numbers from the VM'sSocketKind. Sockets are not built yet, so it stands alone with its bytes written down as the stable wire surface, and says that whatever re-introduces sockets must line its numbers up rather than mint a second set.How the descriptor reaches the VM
Programcarries aTiVec<WireDescIdx, Desc>, and Core IR gains its own atom:Its own atom rather than an argument smuggled through
Atom::Intrinsic, for the same reasonAtom::Ctoris one: a descriptor is not a value. Two call sites at one type share an entry — the dedup is on the descriptor itself, never on its fingerprint, which excludes a type's identity and so is shared by two different types of one shape.The builder
Back at
crates/scarlet_core/src/typed_ir/wire.rs. The two things worth knowing are in its module doc:List(Int)is unbounded; its descriptor is two nodes, andCons.tailis an index back at the node it sits in. That closure is bought by memoising a nominal node before its fields are walked. The memo is keyed on the arguments' descriptor nodes, never theirRTys — substitution mints a freshRTyforCons.tail'sList(Int)every time, so anRTy-keyed memo would never hit and the walk would not terminate.Tests un-ignored
wire_descriptor.rs(4) and the wire refusal tests intype_errors.rs(3) were parked with "waits for the wire redesign: check stopped refusing wire types in #50". They pass again.wire_handles.rs,wire_closures.rs,wire_bool.rsandwire_uninhabited.rsstay parked — they need the byte walks — and one intype_errors.rsnow says so accurately rather than "needs the VM".On version 4
docs/wire-format.md(#131) specifies version 4 for the new VM. The fingerprint constant here is still 3, deliberately: version 4 changes what a closure node contributes, so the bump belongs with the work that builds closures, not here, where nothing writes a byte and no peer holds a number. The constant says so.All seven CI gates pass locally. hawk ran for the host target, and nothing here is gated on a cfg.