tla-ts 0.0.10-dev.28c823e4b → 0.0.10-dev.b4a856304
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/dist/index.cjs +1 -1
- package/dist/index.d.cts +0 -34
- package/dist/index.d.ts +0 -34
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +43 -43
- package/dist/prove.js +47 -47
- package/dist/run.cjs +30 -30
- package/dist/run.js +33 -33
- package/dist/transfer.cjs +38 -38
- package/dist/transfer.js +39 -39
- package/package.json +1 -1
- package/src/ast.ts +5 -0
- package/src/bags.ts +5 -2
- package/src/builtins.ts +8 -1
- package/src/check.ts +193 -128
- package/src/cli/run.ts +2 -0
- package/src/cli/runtime-invariants.ts +7 -8
- package/src/cli/shared.ts +4 -0
- package/src/cli/tlc-arguments.ts +30 -24
- package/src/cli/tlc-usage.ts +3 -2
- package/src/evaluate.ts +102 -26
- package/src/java-overrides.ts +9 -4
- package/src/json-reader.ts +2 -1
- package/src/json.ts +11 -4
- package/src/levels.ts +15 -7
- package/src/lexer.ts +83 -72
- package/src/liveness-checker.ts +106 -77
- package/src/liveness.ts +34 -10
- package/src/parallel.ts +33 -26
- package/src/parser.ts +226 -163
- package/src/pcal/ast.ts +65 -53
- package/src/pcal/parse.ts +191 -144
- package/src/pcal/tokenize.ts +115 -91
- package/src/pcal/translate.ts +98 -83
- package/src/pcal/validate.ts +50 -48
- package/src/pretty-print.ts +6 -6
- package/src/randomization.ts +4 -1
- package/src/resolve.ts +70 -12
- package/src/runtime.ts +18 -11
- package/src/sany/builtins.ts +3 -1
- package/src/sany/generator.ts +127 -74
- package/src/sany/levels.ts +9 -5
- package/src/sany/lexer.ts +44 -40
- package/src/sany/linter.ts +1 -0
- package/src/search.ts +1 -1
- package/src/simulate.ts +59 -50
- package/src/spec-description.ts +34 -23
- package/src/standard-definitions.ts +3 -0
- package/src/standard-modules.ts +12 -1
- package/src/state-graph.ts +8 -1
- package/src/subexpressions.ts +47 -38
- package/src/successors.ts +35 -14
- package/src/symmetry.ts +19 -4
- package/src/tlc/fingerprint.ts +21 -15
- package/src/tlc/jar-data.ts +1 -0
- package/src/tlc/messages.ts +21 -2
- package/src/tlc/order.ts +38 -20
- package/src/tlc/random.ts +30 -18
- package/src/tlc/replay.ts +33 -13
- package/src/tlc/summary.ts +45 -36
- package/src/tlc/tlc-operators.ts +14 -4
- package/src/tlc/tlcext-operators.ts +15 -11
- package/src/tlc/trace-spec.ts +4 -0
- package/src/tlc/value-stream.ts +13 -9
- package/src/tlc/version.ts +1 -0
- package/src/values.ts +181 -74
package/dist/index.cjs
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./worker.cjs"),t=require("./transfer.cjs"),n=require("./prove.cjs");exports.TlaConfigError=e._,exports.TlaError=e.y,exports.TlaEvaluationError=e.b,exports.TlaSyntaxError=e.F,exports.TlaUnsupportedError=e.B,exports.check=n.m,exports.formatValue=t.
|
|
9
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./worker.cjs"),t=require("./transfer.cjs"),n=require("./prove.cjs");exports.TlaConfigError=e._,exports.TlaError=e.y,exports.TlaEvaluationError=e.b,exports.TlaSyntaxError=e.F,exports.TlaUnsupportedError=e.B,exports.check=n.m,exports.formatValue=t.Ot,exports.parseConfig=t.en,exports.parseModule=t.V,exports.prove=n.r;
|
package/dist/index.d.cts
CHANGED
|
@@ -735,30 +735,18 @@ interface CheckOptions {
|
|
|
735
735
|
makeDirectory?: (path: string) => void;
|
|
736
736
|
seed?: bigint;
|
|
737
737
|
workers?: number;
|
|
738
|
-
/** TLC's -lncheck: "final" checks liveness only on the complete graph, "off" never looks for a cycle. */
|
|
739
738
|
livenessCheck?: "default" | "final" | "off";
|
|
740
|
-
/** TLC's -fp: the index of the polynomial in TLC's FP64.Polys that fingerprints states. */
|
|
741
739
|
fingerprintPolynomial?: number;
|
|
742
|
-
/** False for TLC's -terse, which prints a lazy value, such as SUBSET S, without enumerating it. */
|
|
743
740
|
isLazyValueExpanded?: boolean;
|
|
744
|
-
/** TLC's -view: prints each state as the value of the configuration's VIEW. */
|
|
745
741
|
isViewPrinted?: boolean;
|
|
746
|
-
/** TLC's -maxSetSize: the most elements TLC enumerates into a set, or states into a list of them. */
|
|
747
742
|
maxSetSize?: number;
|
|
748
|
-
/** TLC's -dump: writes the reachable states, or with `dot` the state graph, through writeFile. */
|
|
749
743
|
dump?: StateDump;
|
|
750
|
-
/** TLC's -tool, which changes the messages of TLC's errors. */
|
|
751
744
|
isTool?: boolean;
|
|
752
|
-
/** TLC's -continue: reports each violation through onProgress and goes on. */
|
|
753
745
|
isContinued?: boolean;
|
|
754
746
|
moduleOperators?: ModuleOperator[];
|
|
755
|
-
/** TLC's trace exploration spec, and the binary trace TLC records for it unless -noTEBin. */
|
|
756
747
|
traceSpec?: TraceSpecOptions;
|
|
757
|
-
/** Whether the caller printed SANY's report, its warnings included, before the check. */
|
|
758
748
|
isSanyReported?: boolean;
|
|
759
|
-
/** False for TLC's -nowarning, which changes how TLC computes some successors. */
|
|
760
749
|
isWarningEnabled?: boolean;
|
|
761
|
-
/** TLC's -coverage, in minutes. */
|
|
762
750
|
coverage?: number;
|
|
763
751
|
version?: TlcVersion;
|
|
764
752
|
onProgress?: (progress: CheckProgress) => void;
|
|
@@ -810,9 +798,7 @@ type CheckProgress = {
|
|
|
810
798
|
} | {
|
|
811
799
|
kind: "liveness-started";
|
|
812
800
|
branches: number;
|
|
813
|
-
/** Whether TLC checks the complete state graph. */
|
|
814
801
|
isComplete: boolean;
|
|
815
|
-
/** How many states of the graph each branch has. */
|
|
816
802
|
states: number;
|
|
817
803
|
statistics: SearchStatistics;
|
|
818
804
|
} | {
|
|
@@ -835,29 +821,22 @@ interface SearchStatistics extends Pick<CheckResult, "generatedStates" | "distin
|
|
|
835
821
|
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
836
822
|
interface TraceStep {
|
|
837
823
|
action: string | undefined;
|
|
838
|
-
/** TLC's name, parameters and location for the action that took this step. */
|
|
839
824
|
label: string | undefined;
|
|
840
825
|
state: Record<string, Value>;
|
|
841
|
-
/** What the spec prints before this step as TLC rebuilds the trace, and before it for the first. */
|
|
842
826
|
output?: OutputLine[];
|
|
843
827
|
}
|
|
844
828
|
interface Violation {
|
|
845
829
|
name: string;
|
|
846
|
-
/** Every temporal property that a liveness counterexample violates, in the configuration's order. */
|
|
847
830
|
properties?: string[];
|
|
848
831
|
trace: TraceStep[];
|
|
849
|
-
/** What the spec prints after the trace, as TLC finds the lasso's step back or rebuilds the trace. */
|
|
850
832
|
traceOutput?: OutputLine[];
|
|
851
|
-
/** What the postconditions print, which TLC checks after the lasso's step back. */
|
|
852
833
|
postconditionOutput?: OutputLine[];
|
|
853
834
|
loopStart: number | undefined;
|
|
854
835
|
loopLabel?: string;
|
|
855
836
|
message?: string;
|
|
856
837
|
counts?: string;
|
|
857
838
|
unwitnessed?: Postcondition;
|
|
858
|
-
/** A POSTCONDITION that is false or fails, which TLC checks as it prints the counterexample. */
|
|
859
839
|
postcondition?: Postcondition;
|
|
860
|
-
/** What TLC warns about after a counterexample, with its code. */
|
|
861
840
|
warning?: {
|
|
862
841
|
code: number;
|
|
863
842
|
text: string;
|
|
@@ -869,7 +848,6 @@ interface Postcondition {
|
|
|
869
848
|
message: string;
|
|
870
849
|
counts?: string;
|
|
871
850
|
}
|
|
872
|
-
/** An evaluation that failed during the search, with the behavior up to the state TLC was working on. */
|
|
873
851
|
interface EvaluationFailure {
|
|
874
852
|
code: number;
|
|
875
853
|
message: string;
|
|
@@ -878,17 +856,11 @@ interface EvaluationFailure {
|
|
|
878
856
|
traceOutput?: OutputLine[];
|
|
879
857
|
initialState: Record<string, Value> | undefined;
|
|
880
858
|
exitCode: number;
|
|
881
|
-
/** The expressions TLC was evaluating, outermost first, when its replay finds them. */
|
|
882
859
|
callStack: Expression[] | undefined;
|
|
883
|
-
/** Whether TLC prints the call stack before the error, as it does for a failed liveness check. */
|
|
884
860
|
isCallStackFirst?: boolean;
|
|
885
|
-
/** The FingerprintException the replay raises, which TLC reports in place of the call stack. */
|
|
886
861
|
fingerprint?: FingerprintFailure;
|
|
887
|
-
/** How TLC reports failing again as it prints the trace, since it can't fingerprint the state. */
|
|
888
862
|
traceFailure?: FailureMessage;
|
|
889
|
-
/** A POSTCONDITION that is false or fails after the trace, which TLC checks as it prints one. */
|
|
890
863
|
postcondition?: Postcondition;
|
|
891
|
-
/** Whether TLC stops before it prints the statistics, as it does for an illegal initial state. */
|
|
892
864
|
isWithoutStatistics?: boolean;
|
|
893
865
|
}
|
|
894
866
|
interface InitialStates {
|
|
@@ -903,17 +875,11 @@ interface CheckResult {
|
|
|
903
875
|
distinctStates: number;
|
|
904
876
|
queuedStates: number;
|
|
905
877
|
depth: number;
|
|
906
|
-
/** Once TLC computed all the initial states without a violation or an error. */
|
|
907
878
|
initialStates: InitialStates | undefined;
|
|
908
|
-
/** How many expanded states found each number of new states, when TLC prints the outdegree. */
|
|
909
879
|
outDegrees: number[] | undefined;
|
|
910
|
-
/** The smallest distance between two fingerprints, when TLC estimates a collision from them. */
|
|
911
880
|
fingerprintDistance: bigint | undefined;
|
|
912
|
-
/** A temporal property TLC finds violated as it adds a deadlocked state, reported after. */
|
|
913
881
|
additionalViolation?: Violation;
|
|
914
|
-
/** Where TLC's worker fails to add the state to the behavior graph after it reports a violation. */
|
|
915
882
|
liveCallStack?: Expression[];
|
|
916
|
-
/** The outdegrees when TLC's workers stop on a violation that TLC 1.7.4 reports as a success. */
|
|
917
883
|
violationOutDegrees?: number[];
|
|
918
884
|
traceSpec?: string;
|
|
919
885
|
coverage?: CoverageReport;
|
package/dist/index.d.ts
CHANGED
|
@@ -735,30 +735,18 @@ interface CheckOptions {
|
|
|
735
735
|
makeDirectory?: (path: string) => void;
|
|
736
736
|
seed?: bigint;
|
|
737
737
|
workers?: number;
|
|
738
|
-
/** TLC's -lncheck: "final" checks liveness only on the complete graph, "off" never looks for a cycle. */
|
|
739
738
|
livenessCheck?: "default" | "final" | "off";
|
|
740
|
-
/** TLC's -fp: the index of the polynomial in TLC's FP64.Polys that fingerprints states. */
|
|
741
739
|
fingerprintPolynomial?: number;
|
|
742
|
-
/** False for TLC's -terse, which prints a lazy value, such as SUBSET S, without enumerating it. */
|
|
743
740
|
isLazyValueExpanded?: boolean;
|
|
744
|
-
/** TLC's -view: prints each state as the value of the configuration's VIEW. */
|
|
745
741
|
isViewPrinted?: boolean;
|
|
746
|
-
/** TLC's -maxSetSize: the most elements TLC enumerates into a set, or states into a list of them. */
|
|
747
742
|
maxSetSize?: number;
|
|
748
|
-
/** TLC's -dump: writes the reachable states, or with `dot` the state graph, through writeFile. */
|
|
749
743
|
dump?: StateDump;
|
|
750
|
-
/** TLC's -tool, which changes the messages of TLC's errors. */
|
|
751
744
|
isTool?: boolean;
|
|
752
|
-
/** TLC's -continue: reports each violation through onProgress and goes on. */
|
|
753
745
|
isContinued?: boolean;
|
|
754
746
|
moduleOperators?: ModuleOperator[];
|
|
755
|
-
/** TLC's trace exploration spec, and the binary trace TLC records for it unless -noTEBin. */
|
|
756
747
|
traceSpec?: TraceSpecOptions;
|
|
757
|
-
/** Whether the caller printed SANY's report, its warnings included, before the check. */
|
|
758
748
|
isSanyReported?: boolean;
|
|
759
|
-
/** False for TLC's -nowarning, which changes how TLC computes some successors. */
|
|
760
749
|
isWarningEnabled?: boolean;
|
|
761
|
-
/** TLC's -coverage, in minutes. */
|
|
762
750
|
coverage?: number;
|
|
763
751
|
version?: TlcVersion;
|
|
764
752
|
onProgress?: (progress: CheckProgress) => void;
|
|
@@ -810,9 +798,7 @@ type CheckProgress = {
|
|
|
810
798
|
} | {
|
|
811
799
|
kind: "liveness-started";
|
|
812
800
|
branches: number;
|
|
813
|
-
/** Whether TLC checks the complete state graph. */
|
|
814
801
|
isComplete: boolean;
|
|
815
|
-
/** How many states of the graph each branch has. */
|
|
816
802
|
states: number;
|
|
817
803
|
statistics: SearchStatistics;
|
|
818
804
|
} | {
|
|
@@ -835,29 +821,22 @@ interface SearchStatistics extends Pick<CheckResult, "generatedStates" | "distin
|
|
|
835
821
|
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
836
822
|
interface TraceStep {
|
|
837
823
|
action: string | undefined;
|
|
838
|
-
/** TLC's name, parameters and location for the action that took this step. */
|
|
839
824
|
label: string | undefined;
|
|
840
825
|
state: Record<string, Value>;
|
|
841
|
-
/** What the spec prints before this step as TLC rebuilds the trace, and before it for the first. */
|
|
842
826
|
output?: OutputLine[];
|
|
843
827
|
}
|
|
844
828
|
interface Violation {
|
|
845
829
|
name: string;
|
|
846
|
-
/** Every temporal property that a liveness counterexample violates, in the configuration's order. */
|
|
847
830
|
properties?: string[];
|
|
848
831
|
trace: TraceStep[];
|
|
849
|
-
/** What the spec prints after the trace, as TLC finds the lasso's step back or rebuilds the trace. */
|
|
850
832
|
traceOutput?: OutputLine[];
|
|
851
|
-
/** What the postconditions print, which TLC checks after the lasso's step back. */
|
|
852
833
|
postconditionOutput?: OutputLine[];
|
|
853
834
|
loopStart: number | undefined;
|
|
854
835
|
loopLabel?: string;
|
|
855
836
|
message?: string;
|
|
856
837
|
counts?: string;
|
|
857
838
|
unwitnessed?: Postcondition;
|
|
858
|
-
/** A POSTCONDITION that is false or fails, which TLC checks as it prints the counterexample. */
|
|
859
839
|
postcondition?: Postcondition;
|
|
860
|
-
/** What TLC warns about after a counterexample, with its code. */
|
|
861
840
|
warning?: {
|
|
862
841
|
code: number;
|
|
863
842
|
text: string;
|
|
@@ -869,7 +848,6 @@ interface Postcondition {
|
|
|
869
848
|
message: string;
|
|
870
849
|
counts?: string;
|
|
871
850
|
}
|
|
872
|
-
/** An evaluation that failed during the search, with the behavior up to the state TLC was working on. */
|
|
873
851
|
interface EvaluationFailure {
|
|
874
852
|
code: number;
|
|
875
853
|
message: string;
|
|
@@ -878,17 +856,11 @@ interface EvaluationFailure {
|
|
|
878
856
|
traceOutput?: OutputLine[];
|
|
879
857
|
initialState: Record<string, Value> | undefined;
|
|
880
858
|
exitCode: number;
|
|
881
|
-
/** The expressions TLC was evaluating, outermost first, when its replay finds them. */
|
|
882
859
|
callStack: Expression[] | undefined;
|
|
883
|
-
/** Whether TLC prints the call stack before the error, as it does for a failed liveness check. */
|
|
884
860
|
isCallStackFirst?: boolean;
|
|
885
|
-
/** The FingerprintException the replay raises, which TLC reports in place of the call stack. */
|
|
886
861
|
fingerprint?: FingerprintFailure;
|
|
887
|
-
/** How TLC reports failing again as it prints the trace, since it can't fingerprint the state. */
|
|
888
862
|
traceFailure?: FailureMessage;
|
|
889
|
-
/** A POSTCONDITION that is false or fails after the trace, which TLC checks as it prints one. */
|
|
890
863
|
postcondition?: Postcondition;
|
|
891
|
-
/** Whether TLC stops before it prints the statistics, as it does for an illegal initial state. */
|
|
892
864
|
isWithoutStatistics?: boolean;
|
|
893
865
|
}
|
|
894
866
|
interface InitialStates {
|
|
@@ -903,17 +875,11 @@ interface CheckResult {
|
|
|
903
875
|
distinctStates: number;
|
|
904
876
|
queuedStates: number;
|
|
905
877
|
depth: number;
|
|
906
|
-
/** Once TLC computed all the initial states without a violation or an error. */
|
|
907
878
|
initialStates: InitialStates | undefined;
|
|
908
|
-
/** How many expanded states found each number of new states, when TLC prints the outdegree. */
|
|
909
879
|
outDegrees: number[] | undefined;
|
|
910
|
-
/** The smallest distance between two fingerprints, when TLC estimates a collision from them. */
|
|
911
880
|
fingerprintDistance: bigint | undefined;
|
|
912
|
-
/** A temporal property TLC finds violated as it adds a deadlocked state, reported after. */
|
|
913
881
|
additionalViolation?: Violation;
|
|
914
|
-
/** Where TLC's worker fails to add the state to the behavior graph after it reports a violation. */
|
|
915
882
|
liveCallStack?: Expression[];
|
|
916
|
-
/** The outdegrees when TLC's workers stop on a violation that TLC 1.7.4 reports as a success. */
|
|
917
883
|
violationOutDegrees?: number[];
|
|
918
884
|
traceSpec?: string;
|
|
919
885
|
coverage?: CoverageReport;
|
package/dist/index.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
import{B as e,F as t,_ as n,b as r,y as i}from"./worker.js";import{
|
|
9
|
+
import{B as e,F as t,_ as n,b as r,y as i}from"./worker.js";import{Ot as a,V as o,en as s}from"./transfer.js";import{m as c,r as l}from"./prove.js";export{n as TlaConfigError,i as TlaError,r as TlaEvaluationError,t as TlaSyntaxError,e as TlaUnsupportedError,c as check,a as formatValue,s as parseConfig,o as parseModule,l as prove};
|
package/dist/parallel-worker.cjs
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
const e=require("./worker.cjs"),t=require("./transfer.cjs"),n=(n,r)=>{let i=new Map(n.modules),a=e=>i.get(e),o=new Map(n.classes),s=t.z(n.source,a);t.
|
|
9
|
+
const e=require("./worker.cjs"),t=require("./transfer.cjs"),n=(n,r)=>{let i=new Map(n.modules),a=e=>i.get(e),o=new Map(n.classes),s=t.z(n.source,a);t.Rt(s.getStringOrder(n.config)),t.zt(n),t.St(n.fingerprintPolynomial??0),t.kt();let c=t.R(n.config,{source:n.source,loadModule:a,order:s,loadClass:e=>o.get(e),print:()=>{},files:{readFile:void 0,writeFile:void 0,makeDirectory:void 0},isTool:n.isTool,traceFile:n.traceFile,isWarningEnabled:n.isWarningEnabled,version:n.version}),l=c.environment,u=t.h(n.config,l,c.variableLocations,()=>s.getDeclarationOrder(`variable`)),d=u?.spec.next;if(!u||d===void 0)return r.postMessage({type:`abort`});let f=n.index,p=t.wt(),m=t.t(l.variables.length),h=n.fingerprints,g=n.requests,_=n.remaining,v=u.isSymmetric?t.r():void 0,y=/* @__PURE__ */ new Int32Array(2),b=()=>{},x=e=>{};n.ports.forEach(e=>{e?.addEventListener(`message`,e=>x(e.data)),e?.start?.()});let S=m(n.seed).map(p),C=e.t(),w=(e,r)=>{let i=Atomics.load(g,f)-1,a=Math.floor((e.end-e.origin-1)/2),o=t.n(),s=e.states.slice(e.end-a,e.end),c=a>0&&s.every(o.encode);c&&(e.end-=a);let l=c?o.finish():t.n().finish();n.ports[i]?.postMessage(l,[l.words.buffer]),Atomics.store(g,f,r),Atomics.notify(g,f)},T=e=>{Atomics.store(_,f,0),Atomics.compareExchange(g,f,0,-1)!==0&&w(e,-1)},E=e=>{Atomics.store(_,f,e.end-e.origin),Atomics.store(g,f,0)},D=e=>{for(;e.origin<e.end;e.origin++){let r=e.states[e.origin];if(!e.successors){if(performance.now()>=e.breakAt)return`break`;if(Atomics.load(g,f)>0&&w(e,0),Atomics.store(_,f,e.end-e.origin-1),e.successors=t.et(d,r,l,u.spec.scope),e.generated+=e.successors.length,e.successors.length===0&&n.config.checkDeadlock)return}let i=e.successors;for(;e.index<i.length;e.index++){if(t.s(h))return`paused`;let n=i[e.index];if(u.findViolatedActionProperty(r,n.state))return;if(!u.satisfiesActionConstraints(r,n.state)){if(u.findViolatedInvariant(n.state,r))return;continue}if(v&&(t.c(n.state,y),!v.insert(y[0],y[1])))continue;p(n.state);let a=u.getFingerprintState(n.state);if(t.c(a,y),t.o(h,y[0],y[1])){if(u.findViolatedInvariant(n.state,r))return;u.satisfiesConstraints(n.state,r)&&(e.next.push(n.state),e.fingerprintStates.push(a),e.added++)}}e.outDegrees[Math.min(e.added,31)]++,e.successors=void 0,e.index=0,e.added=0}return`done`},O=async e=>{let t=/* @__PURE__ */ new Set;for(;;){let r=n.ports.reduce((e,n,r)=>!n||t.has(r)||Atomics.load(_,r)<2?e:e===void 0||Atomics.load(_,r)>Atomics.load(_,e)?r:e,void 0);if(r===void 0)return!1;let i=Atomics.compareExchange(g,r,0,f+1);if(i===-1&&t.add(r),i>0&&Atomics.wait(g,r,i),i!==0)continue;let a=await new Promise(e=>x=e);if(a.count===0)t.add(r);else return e.states=m(a).map(p),e.origin=0,e.end=e.states.length,E(e),!0}},k=e=>r.postMessage(e,e.type===`level`?[e.fingerprints.buffer]:[]),A=async()=>{let e={states:S,origin:0,end:S.length,successors:void 0,index:0,added:0,generated:0,outDegrees:Array.from({length:32},()=>0),next:[],fingerprintStates:[],breakAt:performance.now()+100};for(;;){let t=D(e);if(t===void 0)return;if(t===`break`)await C(),e.breakAt=performance.now()+100;else if(T(e),t===`paused`){let t=new Promise(e=>b=e);k({type:`paused`}),await t,E(e)}else if(!await O(e))break}let n=t.Pt();return n===void 0?(S=e.next,Atomics.store(_,f,S.length),{type:`level`,generated:e.generated,added:e.next.length,outDegrees:e.outDegrees,fingerprints:u.getStoredFingerprints(e.next,e.fingerprintStates)}):{type:`abort`,string:n}},j=()=>{A().then(e=>k(e??{type:`abort`}),()=>k({type:`abort`}))};r.addEventListener(`message`,e=>{let t=e.data;t.type===`level`&&j(),t.type===`resize`&&(h=t.fingerprints,b())}),Atomics.store(_,f,S.length),k({type:`ready`})};e.n().then(e=>{let t=r=>{let i=r.data;if(i.type===`start`){e.removeEventListener?.(`message`,t);try{n(i,e)}catch{e.postMessage({type:`abort`})}}};e.addEventListener(`message`,t),e.start?.()});
|
package/dist/parallel-worker.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
import{n as e,t}from"./worker.js";import{
|
|
9
|
+
import{n as e,t}from"./worker.js";import{Pt as n,R as r,Rt as i,St as a,c as o,et as s,h as c,kt as l,n as u,o as d,r as f,s as p,t as m,wt as h,z as g,zt as _}from"./transfer.js";const v=(e,v)=>{let y=new Map(e.modules),b=e=>y.get(e),x=new Map(e.classes),S=g(e.source,b);i(S.getStringOrder(e.config)),_(e),a(e.fingerprintPolynomial??0),l();let C=r(e.config,{source:e.source,loadModule:b,order:S,loadClass:e=>x.get(e),print:()=>{},files:{readFile:void 0,writeFile:void 0,makeDirectory:void 0},isTool:e.isTool,traceFile:e.traceFile,isWarningEnabled:e.isWarningEnabled,version:e.version}),w=C.environment,T=c(e.config,w,C.variableLocations,()=>S.getDeclarationOrder(`variable`)),E=T?.spec.next;if(!T||E===void 0)return v.postMessage({type:`abort`});let D=e.index,O=h(),k=m(w.variables.length),A=e.fingerprints,j=e.requests,M=e.remaining,N=T.isSymmetric?f():void 0,P=/* @__PURE__ */ new Int32Array(2),F=()=>{},I=e=>{};e.ports.forEach(e=>{e?.addEventListener(`message`,e=>I(e.data)),e?.start?.()});let L=k(e.seed).map(O),R=t(),z=(t,n)=>{let r=Atomics.load(j,D)-1,i=Math.floor((t.end-t.origin-1)/2),a=u(),o=t.states.slice(t.end-i,t.end),s=i>0&&o.every(a.encode);s&&(t.end-=i);let c=s?a.finish():u().finish();e.ports[r]?.postMessage(c,[c.words.buffer]),Atomics.store(j,D,n),Atomics.notify(j,D)},B=e=>{Atomics.store(M,D,0),Atomics.compareExchange(j,D,0,-1)!==0&&z(e,-1)},V=e=>{Atomics.store(M,D,e.end-e.origin),Atomics.store(j,D,0)},H=t=>{for(;t.origin<t.end;t.origin++){let n=t.states[t.origin];if(!t.successors){if(performance.now()>=t.breakAt)return`break`;if(Atomics.load(j,D)>0&&z(t,0),Atomics.store(M,D,t.end-t.origin-1),t.successors=s(E,n,w,T.spec.scope),t.generated+=t.successors.length,t.successors.length===0&&e.config.checkDeadlock)return}let r=t.successors;for(;t.index<r.length;t.index++){if(p(A))return`paused`;let e=r[t.index];if(T.findViolatedActionProperty(n,e.state))return;if(!T.satisfiesActionConstraints(n,e.state)){if(T.findViolatedInvariant(e.state,n))return;continue}if(N&&(o(e.state,P),!N.insert(P[0],P[1])))continue;O(e.state);let i=T.getFingerprintState(e.state);if(o(i,P),d(A,P[0],P[1])){if(T.findViolatedInvariant(e.state,n))return;T.satisfiesConstraints(e.state,n)&&(t.next.push(e.state),t.fingerprintStates.push(i),t.added++)}}t.outDegrees[Math.min(t.added,31)]++,t.successors=void 0,t.index=0,t.added=0}return`done`},U=async t=>{let n=/* @__PURE__ */ new Set;for(;;){let r=e.ports.reduce((e,t,r)=>!t||n.has(r)||Atomics.load(M,r)<2?e:e===void 0||Atomics.load(M,r)>Atomics.load(M,e)?r:e,void 0);if(r===void 0)return!1;let i=Atomics.compareExchange(j,r,0,D+1);if(i===-1&&n.add(r),i>0&&Atomics.wait(j,r,i),i!==0)continue;let a=await new Promise(e=>I=e);if(a.count===0)n.add(r);else return t.states=k(a).map(O),t.origin=0,t.end=t.states.length,V(t),!0}},W=e=>v.postMessage(e,e.type===`level`?[e.fingerprints.buffer]:[]),G=async()=>{let e={states:L,origin:0,end:L.length,successors:void 0,index:0,added:0,generated:0,outDegrees:Array.from({length:32},()=>0),next:[],fingerprintStates:[],breakAt:performance.now()+100};for(;;){let t=H(e);if(t===void 0)return;if(t===`break`)await R(),e.breakAt=performance.now()+100;else if(B(e),t===`paused`){let t=new Promise(e=>F=e);W({type:`paused`}),await t,V(e)}else if(!await U(e))break}let t=n();return t===void 0?(L=e.next,Atomics.store(M,D,L.length),{type:`level`,generated:e.generated,added:e.next.length,outDegrees:e.outDegrees,fingerprints:T.getStoredFingerprints(e.next,e.fingerprintStates)}):{type:`abort`,string:t}},K=()=>{G().then(e=>W(e??{type:`abort`}),()=>W({type:`abort`}))};v.addEventListener(`message`,e=>{let t=e.data;t.type===`level`&&K(),t.type===`resize`&&(A=t.fingerprints,F())}),Atomics.store(M,D,L.length),W({type:`ready`})};e().then(e=>{let t=n=>{let r=n.data;if(r.type===`start`){e.removeEventListener?.(`message`,t);try{v(r,e)}catch{e.postMessage({type:`abort`})}}};e.addEventListener(`message`,t),e.start?.()});
|