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