Repository navigation
Commit dc4ef43
Build each class's state machine once per checker (#414)
Stacked on #413.
## Description
Building a state machine takes about 25 SMT checks for a small class,
and each check creates its own Z3 context. The machine only depends on
specifications, which are all registered in the first pass, so
`TypeChecker` now builds it on the first state error and reuses it for
every later error in the same checker. Finding the receiver's current
states still runs at each error.
Other options considered:
- **Eagerly, after the first pass, for every class with `@StateSet`:**
correct programs would pay the SMT cost too. Only worth it once
something needs machines without an error, e.g. the fsm diagram.
- **Once per run, cached in `Context`:** `Context` would depend on
`state_machine`, which depends on `context` (a package cycle). The other
way is a static cache that tracks when specifications change. Neither
seemed worth it for the extra hits across classes.
## Cost
Extra time of `TestExamples` on the 269 cases that exist on `main`
(summed per case, one run each; `main` takes 80.3 s):
- #413, without the cache: +29.5 s
- with this PR: +10.6 s, spread over the 54 files with state errors
## Type of change
- [x] Code refactoring
## Checklist
- [x] `mvn test` passes locally
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent c1f53c5 commit dc4ef43
2 files changed
Lines changed: 20 additions & 4 deletions
File tree
- liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker
- object_checkers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| 56 | + | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
67 | 84 | | |
68 | 85 | | |
69 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
662 | | - | |
663 | | - | |
664 | | - | |
| 662 | + | |
665 | 663 | | |
666 | 664 | | |
667 | | - | |
| 665 | + | |
| 666 | + | |
668 | 667 | | |
669 | 668 | | |
670 | 669 | | |
| |||
0 commit comments