feat(js): Variant, Switch, arrays, closures and references under Node #694
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/684-js-slice-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Slice 2 of the JavaScript back end (compiler only: no syntax change, no new native, no std name the compiler looks up).
Construct,Tag,Switchover variants: a bare variant is a number, any other variant is one class per case (L<id>_<case>,tfirst).FixedArrayas anArray(literal,ArrayNew, staticItems), with the checked element read/write and the language's own bounds-check panic text.Read/WritethroughField,TupleField,VariantandElementsteps;Contentsis reported as unsupported (the lowering never writes it).ClosurewithValueandBoxedcaptures (boxes stay shared),CallClosure, adapters for functions without an environment.varparameters andArgument.placeas reference objects (torb_ref_slot/field/element); avarparameter read as a value goes through.v.torb_process_exitand theTextCompareintrinsic;Copy/borrowed aggregates are cloned.js.allowgrows by ten existing programs (matching,match-order,records,array-index-bounds,closures,closure-counts,closure-frame,places,place-counted,rest-patterns) and one new program,js-variants-arrays.trb(payload variants, element/field places, text comparison, closure over anArray). Nothing removed. Design slice table row 2 is marked done, with what it leaves out.Evidence
Local only so far: the compiler source run under the nightly VM built each program, Node ran it, and stdout/exit/stderr matched the expectation files for all eleven programs above. CI results are added below as a comment.
Not verified
js-variants-arrays.trb:.expectedcomes from the nightly VM and I checked it by hand, but it has no.allocationsbudget yet (needs a native build; to be taken from CI).sh tools/gates.sh aand the forgeconformance-jsjob: not run locally (the compiler binary cannot be built here).Bufferas a typed array (the IR builds it asnew List, part of the slice-4ListStorage),BoxNew,LazyForce,Placecaptures andContentssteps (the C back end does not support them either; they are reported as unsupported).FixedArrayis a plainArray, not a typed array. Programs that print lists/maps or usecallWitness(counted-closures, mostarray-*) stay offjs.allow: they need slice 3/4.Part of #63
Closes torbscript/language#684
CI red on
97237e7:ci / gatesandci / tier A (linux-x64)-format --checkreports./tests/conformance/js-variants-arrays.trb(1 of 1611 files would change; runtorb formaton it).ci / the playground (torb as WebAssembly)also fails:FAIL a request Monaco cancels answers nullgot a hover result instead of null (the preceding rename took 32 s, so this may be timing; re-run to tell). No other blockers found in the diff so far; I review once CI on the next head is final.Fixed on
38b03abf:torb formatjoins the if/else insmaller(js-variants-arrays.trb) onto one line, the only layout change I could derive without a local torb (no C compiler on this host for the seed); CI on this head confirms. The playgroundMonaco cancelsfailure follows a 32 s rename and looks like timing; the new run on this head tells. Re-requesting review.38b03abf4f57d3d79bfc57d3d79bfcd515ae9de9Approved at
d515ae9(CI combined status success, incl.conformance-js, tier A/B, gates, pdisc, playground).js.allow, newjs-variants-arrays.trbwith.expected/.exit/.allocations; the earlierformat --checkand playground failures are green on this head.tfirst, field numbering viavariantFieldIndexOf), bare variants as numbers, checked element places, reference objects forvarparameters (.von read), closures{ f, e }with shared boxes; unsupported cases (Placecapture,Contents) are reported, not guessed.Closes #684; nothing removed fromjs.allow.Non-blocking:
.allocationsbudget yet, butjs-variants-arrays.allocations(14) is in the diff; the body is stale.Buffer,BoxNewandLazyin its "Touches" cell while the added note says they are left out; consider trimming the row when slice 3/4 lands.Approved at
d515ae9.js-variants-arraysprogram has.expected,.exitand.allocations; I re-derived the 16 expected lines from the source by hand and they match. Eleven programs joinjs.allow, none removed.tfirst and the layout's field numbering),Tag/Switch,FixedArrayasArraywith the bounds-check panic, places through all steps, closures withValue/Boxedcaptures,varparameters as reference objects (.von read) all read consistent with the IR. Unsupported pieces (Placecapture,Contents,lazyforce) are reported, not guessed.torb_process_exitonly mapsProcess.exitonto the existing exit path); matches #684 and its non-goals.Non-blocking: the PR body's "Not verified" still says the new program has no
.allocationsbudget, but the file is in the diff; worth updating the body.