Commit graph

1091 commits

Author SHA1 Message Date
Cameron Zwarich
639baaaa03
refactor: adopt do notation (#9882) 2025-08-12 22:12:59 +00:00
Cameron Zwarich
6f7ca5e5d3
refactor: take more advantage of anonymous constructors (#9881) 2025-08-12 21:19:40 +00:00
Cameron Zwarich
e9df183e87
perf: avoid ref count increments for borrowed array accesses (#9866) 2025-08-12 05:27:35 +00:00
Cameron Zwarich
bf348ae60f
refactor: use more helper functions (#9862) 2025-08-11 23:56:50 +00:00
Cameron Zwarich
ca05569cd5
refactor: rename VarProjInfo to DerivedValInfo (#9859)
We want to use this for non-projections in the near future.
2025-08-11 22:02:28 +00:00
Cameron Zwarich
5b5bb5174b
fix: check for recursive decls before instance proj inlining (#9847)
This PR adds a check for reursive decls in this bespoke inlining path,
which fixes a regression from the old compiler.

Fixes #9624.
2025-08-11 13:50:26 +00:00
Cameron Zwarich
4506173a27
fix: support overapplication of Quot.lift in the compiler (#9827)
This PR changes the lowering of `Quot.lcInv` (the compiler-internal form
of `Quot.lift`) in `toMono` to support overapplication.

Fixes #9806.
2025-08-11 01:51:54 +00:00
Cameron Zwarich
544f9912b7
chore: add separate profiling entries for base, mono, and IR phases (#9817) 2025-08-10 05:00:49 +00:00
Cameron Zwarich
361ca788a7
refactor: split the LCNF pass list into separate base/mono lists (#9816)
This will make it easier to run the two phases in parallel.
2025-08-10 04:23:19 +00:00
Cameron Zwarich
756f837f82
perf: reduce redundant inc/dec using "implied borrows" from projections and liveness (#9801)
This PR changes the IR RC pass to take "implied borrows" from
projections into account. If a projected value's lifetime is contained
in that of its parent (or any projection ancestor), then it does not
need its reference count incremented (or later decremented).

I believe that this same technique should generalize to both the
reset/reuse and borrow signature inference passes.
2025-08-09 14:13:50 +00:00
Cameron Zwarich
2104fd7da9
chore: remove unused default (#9791) 2025-08-07 16:27:23 +00:00
Cameron Zwarich
a2f24fac65
chore: use unreachable! for unreachable cases, not silent fallback (#9790) 2025-08-07 15:23:01 +00:00
Cameron Zwarich
eaec888dc3
refactor: add isPossibleRef/isDefiniteRef fields to RC VarInfo (#9789)
These are the only uses of the existing `type` field, so we might as
well compute them up-front and store them.
2025-08-07 14:21:19 +00:00
Cameron Zwarich
aaf831cd93
perf: don't mark params stored in tagged pointers as borrowed (#9775) 2025-08-07 03:49:23 +00:00
Cameron Zwarich
472a0b4954
refactor: invert and rename RC VarInfo.mustBeConsumed to .inheritsBorrowFromParam (#9777) 2025-08-07 02:04:12 +00:00
Cameron Zwarich
c04323a7d5
perf: use a slightly more refined borrowed param test in RC pass (#9774) 2025-08-07 01:08:32 +00:00
Cameron Zwarich
fac4905e89
chore: fix function body indentation (#9773) 2025-08-07 00:44:43 +00:00
Cameron Zwarich
f23d24ec7c
perf: avoid computing liveness twice for cases in RC pass (#9770) 2025-08-06 18:54:58 +00:00
Cameron Zwarich
e332adf3d5
perf: avoid computing liveness twice for join point decls in RC pass (#9768)
We compute the liveness information for the join point body, so the only
thing that updateJPLiveVarMap should be adding is the binding of the
params, which we can easily do ourselves.

If we supported recursive join points, I believe this would actually be
a correctness issue, but as-is it doesn't affect the output.
2025-08-06 17:34:29 +00:00
Cameron Zwarich
f759d5dbc1
perf: erase all constructor params in the mono phase (#9764) 2025-08-06 14:23:28 +00:00
Cameron Zwarich
d8c7c9fdb5
refactor: reduce code duplication (#9753) 2025-08-06 05:38:10 +00:00
Cameron Zwarich
885b8bcc60
chore: inline a function into its only caller (#9750) 2025-08-06 03:47:38 +00:00
Cameron Zwarich
31e05cd2bd
chore: fix typos (#9747) 2025-08-06 00:49:49 +00:00
Cameron Zwarich
7fb72a0081
refactor: rename RC VarInfo.consume field to .mustBeConsumed (#9746) 2025-08-06 00:48:10 +00:00
Cameron Zwarich
51b780cd9f
chore: rewrite LiveVars in a monadic style (#9745) 2025-08-05 21:49:43 +00:00
Cameron Zwarich
25b0c5af34
chore: don't match on Context (#9744) 2025-08-05 21:32:34 +00:00
Cameron Zwarich
6846a5179b
chore: reduce code duplication (#9742) 2025-08-05 20:42:56 +00:00
Cameron Zwarich
eb5399445a
chore: clean up parens (#9740) 2025-08-05 18:21:38 +00:00
Cameron Zwarich
83c08880a6
chore: use dotted constructor names (#9738) 2025-08-05 17:17:06 +00:00
Cameron Zwarich
172a02557e
chore: clean up uses of getters (#9737) 2025-08-05 16:48:35 +00:00
Cameron Zwarich
ed860dfa23
chore: use better struct literal syntax (#9731) 2025-08-05 14:07:39 +00:00
Cameron Zwarich
12cd4ca742
fix: remove incorrect error in LCNF's check (#9720)
This PR removes an error which implicitly assumes that the sort of type
dependency between erased types present in the test being added can not
occur. It would be difficult to refine the error using only the
information present in LCNF types, and it is of very little ongoing
value (I don't recall it ever finding an actual problem), so it makes
more sense to delete it.

Fixes #9692.
2025-08-05 04:36:57 +00:00
Cameron Zwarich
713a46cd75
chore: adopt <||> to reduce code duplication (#9719) 2025-08-05 04:13:02 +00:00
Cameron Zwarich
f236328bc3
chore: don't check type of erased arguments in FixedParams analysis (#9602) 2025-08-05 02:41:36 +00:00
Cameron Zwarich
8edcfbe776
fix: correctly handle non-Nat literal types in LCNF elimDeadBranches (#9703)
This PR changes the LCNF `elimDeadBranches` pass so that it considers
all non-`Nat` literal types to be `⊤`. It turns out that fixing this to
correctly handle all of these types with the current abstract value
representation is surprisingly nontrivial, and it's better to just land
the fix first.
2025-08-05 02:14:07 +00:00
Cameron Zwarich
59579bfc3e
refactor: remove goBig case from UnreachableBranches.ofNat (#9717)
This case can't meaningfully contribute to the result, because there are
no uses of `Nat` constructors in the `mono` phase.
2025-08-04 19:47:40 +00:00
Cameron Zwarich
78b941019b
refactor: use a state monad rather than combinators for computing free indices (#9711) 2025-08-04 13:55:41 +00:00
Cameron Zwarich
c260435913
refactor: use a state monad rather than combinators for computing max indices (#9707) 2025-08-04 05:15:22 +00:00
Cameron Zwarich
1459d17bfd
chore: lift redundant markSimplified (#9691) 2025-08-02 23:21:21 +00:00
Sebastian Ullrich
1e83f62d31
perf: clarify and granularize access to async env ext state (#9587)
* Have asynchronous environment extensions specify whether they are
manipulate data for declarations from the "outside"/main branch (e.g.
attributes) or from the "inside"/async branch (e.g. data collected from
body elaboration) in order to avoid unnecessary waiting.
* Merge `findStateAsync?` into `getState` via a new, optional
`asyncDecl` parameter.
* Make `mayContainAsync` check an automatic part of `modifyState`.
2025-08-02 17:01:08 +00:00
Cameron Zwarich
b60f97cc19
chore: remove unused code in comment (#9687) 2025-08-02 15:18:41 +00:00
Cameron Zwarich
2ea6b5068c
chore: make Compiler.findJoinPoints trace messages more useful (#9668) 2025-08-01 17:42:32 +00:00
Sebastian Ullrich
0aba471758
perf: do not export LCNF/IR function summaries under the module system (#9645)
to avoid unexpected rebuilds
2025-07-31 15:23:04 +00:00
Cameron Zwarich
7931e19572
perf: use xType field rather than conservatively recomputing it (#9345) 2025-07-30 04:34:13 +00:00
Cameron Zwarich
475bd65c90
perf: during specialization, don't abstract all local fun decls under binders (#9596)
The `isUnderBinder` check is intended to avoid inlining repeated
computations into specializations, but this doesn’t apply to local
function decls whose bodies are already delayed.
2025-07-28 17:36:43 +00:00
Cameron Zwarich
0fe7cc8794
perf: increase usage of the tagged IR type for app return values (#9589) 2025-07-28 14:09:38 +00:00
Cameron Zwarich
d7e7bd16a6
chore: increase code sharing in IR LiveVars computation (#9576) 2025-07-27 13:29:58 +00:00
Cameron Zwarich
8ce0e045a8
chore: increase code sharing in IR FreeVars computation (#9569) 2025-07-26 20:37:10 +00:00
Cameron Zwarich
2be6c75c2b
chore: replace partially redundant calls to FnBody.split with .body (#9568) 2025-07-26 20:18:37 +00:00
Cameron Zwarich
dd45a21257
chore: remove unused FnBody.mdata constructor (#9564) 2025-07-26 15:20:13 +00:00