@mark1russell7/vex-compiler 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +163 -32
- package/build/index.js.map +1 -1
- package/build/{memo-08WGBHWI.js → memo-J-Km2qc0.js} +2 -2
- package/build/{memo-08WGBHWI.js.map → memo-J-Km2qc0.js.map} +1 -1
- package/build/module-entry.d.ts +5 -0
- package/build/module-entry.d.ts.map +1 -1
- package/build/module-entry.js +644 -607
- package/build/module-entry.js.map +1 -1
- package/package.json +6 -5
- package/src/lower.ts +139 -19
- package/src/module-tidy.ts +47 -36
- package/src/module.ts +697 -662
package/README.md
CHANGED
|
@@ -94,14 +94,16 @@ With `keys: true`, the last argument of the run is an array with one different t
|
|
|
94
94
|
|
|
95
95
|
## Speed
|
|
96
96
|
|
|
97
|
-
The speed gate compares tier 2 with hand-written loops,
|
|
97
|
+
The speed gate compares tier 2 with hand-written loops. Lower is better. The tier 2 values come from 53 CI jobs on Node.js 26.13.1, from 2026-11-12 to 2026-11-14. The tier 1 values come from 5 CI jobs on 2026-10-30.
|
|
98
98
|
|
|
99
99
|
| Program | Tier 2 / loops | Tier 1 / loops |
|
|
100
100
|
|---|---|---|
|
|
101
|
-
| The nearest other box, at each of 60 keys | 1.
|
|
102
|
-
| One step of the Game of Life, 16 by 16 | 1.
|
|
103
|
-
|
|
|
104
|
-
| The
|
|
101
|
+
| The nearest other box, at each of 60 keys | 1.32 to 1.63 | 16.6 to 21.2 |
|
|
102
|
+
| One step of the Game of Life, 16 by 16 | 1.08 to 1.22 | 38.0 to 40.6 |
|
|
103
|
+
| A tree module, 1000 nodes | 0.49 to 0.59 | |
|
|
104
|
+
| The shapes module of ireko, 1111 nodes | 1.39 to 1.78 | |
|
|
105
|
+
| The radial module of ireko, 12 children, linked | 1.71 to 1.85 | |
|
|
106
|
+
| The radial module of ireko, 60 children, nested | 1.67 to 1.84 | |
|
|
105
107
|
|
|
106
108
|
`bench/gate.ts` gives the limits and the runs that set them. The plan of the compiler is in [`docs/COMPILER.md`](https://github.com/mark1russell7/vex/blob/main/docs/COMPILER.md).
|
|
107
109
|
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vex compiler (docs/COMPILER.md): generated JavaScript for Vex programs, with the results of the interpreter.
|
|
3
|
+
*/
|
|
1
4
|
import { a as Schema, i as Options, r as Method } from "./facts-3ZtCfd0v.js";
|
|
2
5
|
import { Addr, AnyDomain, Axis, CompileOptions, Envelope, ErrorText, Expr, FixJoin, FreeFn, PrimitiveKind, Program, Space, VexError } from "@mark1russell7/vex";
|
|
3
6
|
/** The functions of the runtime that generated code calls. Each one gives `FALLBACK` for a value it cannot give. */
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/loop.ts","../src/tiers.ts","../src/runtime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/loop.ts","../src/tiers.ts","../src/runtime.ts"],"mappings":";;;;;;KAoBY;;KAuBA;;KA8BA;WACG;WAAqB;;WACrB;WAAqB;;WACrB;WAAmB;;WACnB;WAAoB;;WACpB;;WAEA;;WAEA;WAAoB;;WACpB;WAAqB,gBAAgB;;WACrC;WAAoB,IAAI;WAAiB,eAAe;;WACxD;WAAoB,IAAI;WAAoB,eAAe;;WAK3D;WAAkB;WAAuB,eAAe;WAAkB,iBAAiB;;WAE3F;WAAoB;;WAEpB;WAAuB;WAAuB,gBAAgB,OAAO,OAAO;;;;;;KAM/E;WAEG;;WAEA;WAAoB,MAAM;WAAoB;;WAE9C;WAAoB;WAAuB;;WAE3C;WAAuB;WAAwB;;WAE/C;WAAuB;WAAqB;WAAoB;;WAEhE;WAAqB;WAAqB;WAAuC;;WAEjF;WA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Of, i as unshared, l as isFusedOp, o as MAX_CALLS, r as placesRead, s as entryOf, t as memoNodes } from "./memo-
|
|
1
|
+
import { c as factsOf, d as primitiveOf, i as unshared, l as isFusedOp, o as MAX_CALLS, r as placesRead, s as entryOf, t as memoNodes } from "./memo-J-Km2qc0.js";
|
|
2
2
|
import { MAX_ITERATIONS, addrExprs, asList, axisExprs, axisTargets, children, compile, errorAt, errorText, fail, findMethod, fixAddr, fixRounds, fixValueError, fromDocument, isDepthError, isDocument, isFieldName, isListOp, isStackOverflow, isVexList, joinKind, liftsAt, limitAxis, listOf, listOps, matchesKind, monotoneError, nestingError, noKeyError, ok, resolveAddr, safeIs, shapeError, sizeError, stepError, vexError, vexList, worstRow } from "@mark1russell7/vex";
|
|
3
3
|
// src/loop.ts
|
|
4
4
|
const local = (n) => ({
|
|
@@ -463,11 +463,77 @@ function lower(expr, facts = factsOf({}), schema = {}) {
|
|
|
463
463
|
value
|
|
464
464
|
});
|
|
465
465
|
return {
|
|
466
|
-
body: b.stmts,
|
|
466
|
+
body: flat(b.stmts),
|
|
467
467
|
locals: l.locals,
|
|
468
468
|
constants: l.constants
|
|
469
469
|
};
|
|
470
470
|
}
|
|
471
|
+
/** This function gives the statements that a statement holds, in the order of the source. */
|
|
472
|
+
function bodiesOf(x) {
|
|
473
|
+
if (x.t === "if") return [x.yes, x.no];
|
|
474
|
+
return x.t === "loop" || x.t === "block" || x.t === "repeat" ? [x.body] : [];
|
|
475
|
+
}
|
|
476
|
+
/** This function gives the label that a failure ends or continues, or the labels of a strict failure. */
|
|
477
|
+
function failLabels(f) {
|
|
478
|
+
if (f.t === "break") return [f.label];
|
|
479
|
+
if (f.t === "continue") return f.strict === void 0 ? [f.label] : [f.label, ...failLabels(f.strict.else)];
|
|
480
|
+
return [];
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* This function moves the first statements of a block out of the block, while they do not end it (V-089). Such a
|
|
484
|
+
* statement runs first in both places, and its jumps go to the same statements. A block with no jump to it goes away.
|
|
485
|
+
* Thus a node in the first part of a node adds no level of blocks.
|
|
486
|
+
*
|
|
487
|
+
* The first walk gives each statement a number in the order of the source, and the first jump to each label. The
|
|
488
|
+
* second walk counts in the same order. A statement holds a jump to the block only if that jump has a number in the
|
|
489
|
+
* range of the statement. Thus each walk reads each statement once.
|
|
490
|
+
*/
|
|
491
|
+
function flat(body) {
|
|
492
|
+
const first = /* @__PURE__ */ new Map();
|
|
493
|
+
const ends = [0];
|
|
494
|
+
let at = 0;
|
|
495
|
+
const note = (xs) => {
|
|
496
|
+
for (const x of xs) {
|
|
497
|
+
const self = ++at;
|
|
498
|
+
const labels = x.t === "break" ? [x.label] : x.t === "check" || x.t === "fail" ? failLabels(x.fail) : [];
|
|
499
|
+
for (const label of labels) if (!first.has(label)) first.set(label, self);
|
|
500
|
+
bodiesOf(x).forEach(note);
|
|
501
|
+
ends[self] = at;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
note(body);
|
|
505
|
+
at = 0;
|
|
506
|
+
const walk = (xs, out = []) => {
|
|
507
|
+
for (const x of xs) one(x, out);
|
|
508
|
+
return out;
|
|
509
|
+
};
|
|
510
|
+
const one = (x, out) => {
|
|
511
|
+
at++;
|
|
512
|
+
if (x.t === "if") out.push({
|
|
513
|
+
...x,
|
|
514
|
+
yes: walk(x.yes),
|
|
515
|
+
no: walk(x.no)
|
|
516
|
+
});
|
|
517
|
+
else if (x.t === "loop" || x.t === "repeat") out.push({
|
|
518
|
+
...x,
|
|
519
|
+
body: walk(x.body)
|
|
520
|
+
});
|
|
521
|
+
else if (x.t !== "block") out.push(x);
|
|
522
|
+
else {
|
|
523
|
+
const jump = first.get(x.label) ?? Number.POSITIVE_INFINITY;
|
|
524
|
+
let rest;
|
|
525
|
+
for (const y of x.body) {
|
|
526
|
+
if (rest === void 0 && jump <= (ends[at + 1] ?? 0)) rest = [];
|
|
527
|
+
one(y, rest ?? out);
|
|
528
|
+
}
|
|
529
|
+
if (rest !== void 0) out.push({
|
|
530
|
+
...x,
|
|
531
|
+
body: rest
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
return walk(body);
|
|
536
|
+
}
|
|
471
537
|
var Lowerer = class {
|
|
472
538
|
locals = 4;
|
|
473
539
|
labels = 0;
|
|
@@ -483,6 +549,12 @@ var Lowerer = class {
|
|
|
483
549
|
#memo;
|
|
484
550
|
/** The keys of the nodes of the memo whose code the lowering makes, with their values. */
|
|
485
551
|
#keys = /* @__PURE__ */ new Map();
|
|
552
|
+
/** The region of the chain whose parts the lowering makes at this time (`#chain`). */
|
|
553
|
+
#region = void 0;
|
|
554
|
+
/** The depth of the loops around the lowering. */
|
|
555
|
+
#loops = 0;
|
|
556
|
+
/** The depth of the loops at the start of the code of a node of the memo with no keys, or `undefined` outside such code. */
|
|
557
|
+
#once = void 0;
|
|
486
558
|
#facts;
|
|
487
559
|
#schema;
|
|
488
560
|
/** The kind of each local whose kind the lowering knows. A local gets its kind where it gets its value. */
|
|
@@ -616,7 +688,7 @@ var Lowerer = class {
|
|
|
616
688
|
if (key.ok !== void 0) this.check(b, key.ok, "a key with a value");
|
|
617
689
|
return key.value;
|
|
618
690
|
}
|
|
619
|
-
const keys = this.#copying > 0 ? void 0 : this.#memo.get(e);
|
|
691
|
+
const keys = this.#copying > 0 || this.#once === this.#loops ? void 0 : this.#memo.get(e);
|
|
620
692
|
return keys === void 0 ? this.#node(e, s, path, b) : this.#memoized(e, keys, s, path, b);
|
|
621
693
|
}
|
|
622
694
|
/** This method lowers a copy of a part of a failure path. */
|
|
@@ -625,6 +697,13 @@ var Lowerer = class {
|
|
|
625
697
|
make();
|
|
626
698
|
this.#copying--;
|
|
627
699
|
}
|
|
700
|
+
/** This method lowers a loop of names. A node of the memo inside the loop keeps its memo. */
|
|
701
|
+
#inLoop(make) {
|
|
702
|
+
this.#loops++;
|
|
703
|
+
const value = make();
|
|
704
|
+
this.#loops--;
|
|
705
|
+
return value;
|
|
706
|
+
}
|
|
628
707
|
/** This method lowers a node itself, without the memo. */
|
|
629
708
|
#node(e, s, path, b) {
|
|
630
709
|
if (this.#copying > 0) this.#copied++;
|
|
@@ -653,9 +732,9 @@ var Lowerer = class {
|
|
|
653
732
|
return this.value(b, call("rec", this.constant(Object.keys(e.fields)), array(...values)));
|
|
654
733
|
}
|
|
655
734
|
case "app": return this.#app(e, s, path, b);
|
|
656
|
-
case "fold": return this.#fold(e, s, path, b);
|
|
657
|
-
case "iterate": return this.#iterate(e, s, path, b);
|
|
658
|
-
case "fix": return this.#fix(e, s, path, b);
|
|
735
|
+
case "fold": return this.#inLoop(() => this.#fold(e, s, path, b));
|
|
736
|
+
case "iterate": return this.#inLoop(() => this.#iterate(e, s, path, b));
|
|
737
|
+
case "fix": return this.#inLoop(() => this.#fix(e, s, path, b));
|
|
659
738
|
case "last": {
|
|
660
739
|
const column = s.columns.get(e.name);
|
|
661
740
|
return column === void 0 ? this.fail(b) : this.#rowOf(e.name, column, s, path, b);
|
|
@@ -700,6 +779,9 @@ var Lowerer = class {
|
|
|
700
779
|
* The entry has no error, because the error of a node depends on its position and on its child nodes. Where the context
|
|
701
780
|
* keeps the error, a copy of the node evaluates after a read of such an entry. The copy gives the error at this position.
|
|
702
781
|
* A node of the memo and its keys use no extension, so this second evaluation has no effect.
|
|
782
|
+
*
|
|
783
|
+
* The code of a node with no keys evaluates once for each space. Outside its loops, a node inside it thus evaluates
|
|
784
|
+
* once too, and it gets no memo of its own (`#once`). So the code of nested nodes has no nested blocks (V-089).
|
|
703
785
|
*/
|
|
704
786
|
#memoized(e, keys, s, path, b) {
|
|
705
787
|
const memo = {
|
|
@@ -712,7 +794,10 @@ var Lowerer = class {
|
|
|
712
794
|
const outer = this.#keys;
|
|
713
795
|
this.#keys = new Map([...outer, ...keys.map((k, i) => [k, values[i]])]);
|
|
714
796
|
const compute = block(b.fail);
|
|
797
|
+
const once = this.#once;
|
|
798
|
+
this.#once = keys.length === 0 ? this.#loops : void 0;
|
|
715
799
|
const node = this.#attempt(compute, (inner) => this.#node(e, s, path, inner), false);
|
|
800
|
+
this.#once = once;
|
|
716
801
|
this.#keys = outer;
|
|
717
802
|
compute.stmts.push({
|
|
718
803
|
t: "set",
|
|
@@ -775,46 +860,63 @@ var Lowerer = class {
|
|
|
775
860
|
}
|
|
776
861
|
/**
|
|
777
862
|
* This method lowers arguments on the value path, with no new check. A failure of an argument keeps its error in a
|
|
778
|
-
* local of the argument. It then
|
|
779
|
-
* give the error of the node (`args` of the runtime).
|
|
863
|
+
* local of the argument. It then ends the value block of the region, and the failure path of the chain copies the
|
|
864
|
+
* later arguments that can fail. After the last copy, the errors give the error of the node (`args` of the runtime).
|
|
865
|
+
* The failure path clears the locals, for the next turn of a loop.
|
|
780
866
|
*
|
|
781
867
|
* Each argument evaluates once: the value path gives up at the failure, and the copies start after it.
|
|
868
|
+
*
|
|
869
|
+
* The value path of a chain has no block of its own (V-089). A chain in a part of another chain is in the region of
|
|
870
|
+
* that chain. So its parts go into the value block of the region, and its failure path goes before the failure path of
|
|
871
|
+
* the outer chain. The depth of the blocks thus stays the same for each level of a shape. Before, each level added
|
|
872
|
+
* 3 blocks around argument 0, and the time of the parse of `new Function` grew with the lines times that depth.
|
|
782
873
|
*/
|
|
783
874
|
#chain(xs, s, path, first, what, b) {
|
|
784
|
-
const
|
|
875
|
+
const joined = this.#region?.fails.has(b.fail) === true ? this.#region : void 0;
|
|
876
|
+
const region = joined ?? {
|
|
877
|
+
value: this.labels++,
|
|
878
|
+
fails: /* @__PURE__ */ new Set(),
|
|
879
|
+
paths: []
|
|
880
|
+
};
|
|
881
|
+
const outer = this.#region;
|
|
882
|
+
this.#region = region;
|
|
883
|
+
const sink = joined === void 0 ? [] : b.stmts;
|
|
785
884
|
const parts = xs.map((x, i) => {
|
|
786
|
-
const label = this.labels++;
|
|
787
885
|
const error = this.locals++;
|
|
788
|
-
const
|
|
886
|
+
const fail = {
|
|
789
887
|
t: "break",
|
|
790
|
-
label,
|
|
888
|
+
label: region.value,
|
|
791
889
|
keep: error
|
|
792
|
-
}
|
|
890
|
+
};
|
|
891
|
+
region.fails.add(fail);
|
|
793
892
|
const at = [...path, first + i];
|
|
893
|
+
const start = sink.length;
|
|
794
894
|
return {
|
|
795
895
|
x,
|
|
796
896
|
at,
|
|
797
|
-
label,
|
|
798
897
|
error,
|
|
799
|
-
value: this.expr(x, s, at,
|
|
800
|
-
|
|
898
|
+
value: this.expr(x, s, at, {
|
|
899
|
+
stmts: sink,
|
|
900
|
+
fail
|
|
901
|
+
}),
|
|
902
|
+
fails: sink.length > start
|
|
801
903
|
};
|
|
802
904
|
});
|
|
905
|
+
this.#region = outer;
|
|
803
906
|
const values = parts.map((p) => p.value);
|
|
804
|
-
const failing = parts.filter((p) => p.
|
|
907
|
+
const failing = parts.filter((p) => p.fails);
|
|
805
908
|
if (failing.length === 0) return values;
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}];
|
|
909
|
+
const failed = (p) => prim("isValue", local(p.error));
|
|
910
|
+
const after = this.locals++;
|
|
911
|
+
const copies = [];
|
|
810
912
|
failing.forEach((p, i) => {
|
|
811
|
-
body = [{
|
|
812
|
-
t: "block",
|
|
813
|
-
label: p.label,
|
|
814
|
-
body
|
|
815
|
-
}];
|
|
816
913
|
const next = failing[i + 1];
|
|
817
914
|
if (next === void 0) return;
|
|
915
|
+
copies.push({
|
|
916
|
+
t: "set",
|
|
917
|
+
n: after,
|
|
918
|
+
value: i === 0 ? failed(p) : prim("||", local(after), failed(p))
|
|
919
|
+
});
|
|
818
920
|
const label = this.labels++;
|
|
819
921
|
const copy = block({
|
|
820
922
|
t: "break",
|
|
@@ -822,10 +924,15 @@ var Lowerer = class {
|
|
|
822
924
|
keep: next.error
|
|
823
925
|
});
|
|
824
926
|
this.#copy(() => this.expr(next.x, s, next.at, copy));
|
|
825
|
-
|
|
826
|
-
t: "
|
|
827
|
-
|
|
828
|
-
|
|
927
|
+
copies.push({
|
|
928
|
+
t: "if",
|
|
929
|
+
cond: local(after),
|
|
930
|
+
yes: [{
|
|
931
|
+
t: "block",
|
|
932
|
+
label,
|
|
933
|
+
body: copy.stmts
|
|
934
|
+
}],
|
|
935
|
+
no: []
|
|
829
936
|
});
|
|
830
937
|
});
|
|
831
938
|
const inner = block(b.fail);
|
|
@@ -835,11 +942,33 @@ var Lowerer = class {
|
|
|
835
942
|
n: p.error,
|
|
836
943
|
value: { t: "none" }
|
|
837
944
|
})));
|
|
838
|
-
|
|
945
|
+
if (joined !== void 0 && b.fail.t === "break" && b.fail.keep !== void 0) inner.stmts.push({
|
|
946
|
+
t: "set",
|
|
947
|
+
n: b.fail.keep,
|
|
948
|
+
value: error
|
|
949
|
+
});
|
|
950
|
+
else this.fail(inner, error);
|
|
951
|
+
const chainFailed = failing.slice(1).reduce((x, p) => prim("||", x, failed(p)), failed(failing[0]));
|
|
952
|
+
region.paths.push({
|
|
953
|
+
t: "if",
|
|
954
|
+
cond: chainFailed,
|
|
955
|
+
yes: [...copies, ...inner.stmts],
|
|
956
|
+
no: []
|
|
957
|
+
});
|
|
958
|
+
if (joined !== void 0) return values;
|
|
959
|
+
const end = this.labels++;
|
|
960
|
+
sink.push({
|
|
961
|
+
t: "break",
|
|
962
|
+
label: end
|
|
963
|
+
});
|
|
839
964
|
b.stmts.push({
|
|
840
965
|
t: "block",
|
|
841
966
|
label: end,
|
|
842
|
-
body: [
|
|
967
|
+
body: [{
|
|
968
|
+
t: "block",
|
|
969
|
+
label: region.value,
|
|
970
|
+
body: sink
|
|
971
|
+
}, ...region.paths]
|
|
843
972
|
});
|
|
844
973
|
return values;
|
|
845
974
|
}
|
|
@@ -1396,6 +1525,7 @@ var Lowerer = class {
|
|
|
1396
1525
|
*/
|
|
1397
1526
|
#targetLoop(e, s, path, firstTest, b, items, each) {
|
|
1398
1527
|
const { axis, at: addr, as } = e;
|
|
1528
|
+
this.#loops++;
|
|
1399
1529
|
const list = listOf(axis);
|
|
1400
1530
|
const tests = firstTest + axisChildren(axis) - whereTests(axis).length;
|
|
1401
1531
|
const from = addr === void 0 || addr.length === 0 ? s.focus : this.#address(addr, s, path, firstTest + axisChildren(axis), b);
|
|
@@ -1488,6 +1618,7 @@ var Lowerer = class {
|
|
|
1488
1618
|
if (name !== void 0 && item !== void 0) names.set(name, { value: this.value(body, prim("member", item.values, local(index))) });
|
|
1489
1619
|
if (position !== void 0 && item !== void 0) names.set(position, { value: this.#typed(this.value(body, prim("member", item.nth, local(index))), "number") });
|
|
1490
1620
|
each(body, key, at, names);
|
|
1621
|
+
this.#loops--;
|
|
1491
1622
|
b.stmts.push({
|
|
1492
1623
|
t: "loop",
|
|
1493
1624
|
label,
|