Commit graph

474 commits

Author SHA1 Message Date
Ayaz
858670fac7
Merge pull request #4833 from roc-lang/intern-layouts
Intern all the layouts
2022-12-29 18:28:44 -06:00
Ayaz Hafiz
abf248372d
Fix clippy lint 2022-12-29 12:59:01 -06:00
Ayaz Hafiz
d6669aed2e
Don't assume tag id is in the tag arguments in making decision tree 2022-12-29 12:26:13 -06:00
Ayaz Hafiz
3aab378bab
Correct pattern matching of nullable wrapped tag unions
The nullable ID always has zero tags. For everything else, we should
just match with the arity of the number of arguments, which doesn't
include the tag ID.
2022-12-29 12:22:05 -06:00
Ayaz Hafiz
d59b137f45
Implement printing of nullable wrapped IR layouts 2022-12-29 12:17:46 -06:00
Ayaz Hafiz
58930cc96c
Correct ircheck of nullable-wrapped unions 2022-12-29 12:10:23 -06:00
Ayaz
d6c32ded7d
Merge pull request #4829 from roc-lang/fix-holl-reference-borrow
Collect references to functions passed to HOLLs in borrow inference
2022-12-29 09:15:26 -06:00
Ayaz Hafiz
e4b5252e51
List takes interned element 2022-12-29 08:52:37 -06:00
Ayaz Hafiz
ed9804248c
Unnecessary mut ref 2022-12-28 18:52:45 -06:00
Ayaz Hafiz
1878fc1c4f
Allow too many args 2022-12-28 18:52:26 -06:00
Ayaz Hafiz
7ab7fdfa7b
Push interned layouts as mut throughout the backend, and intern box layouts 2022-12-28 18:51:26 -06:00
Ayaz Hafiz
1aa89fc567
Remove dead code 2022-12-28 17:08:05 -06:00
Ayaz Hafiz
58a28bb7b8
Intern unwrapped capture layout 2022-12-28 17:06:44 -06:00
Ayaz Hafiz
7045001f64
Intern captures layouts 2022-12-28 17:05:04 -06:00
Ayaz Hafiz
db547a600a
Turn off false-positive producing debug assert for now
See #4831
2022-12-28 16:31:25 -06:00
Ayaz Hafiz
2f7c4b4083
Macro to recruse when resolving recursive layouts 2022-12-28 16:01:01 -06:00
Ayaz Hafiz
a31b617ac8
Collect references to functions passed to HOLLs in borrow inference
During borrow inference, SCCs of references between procs are first
constructed. Previously we didn't collect any references for HOLL calls,
but since such calls pass a Roc-function, we need to include a reference
to the Roc function.
2022-12-28 15:32:23 -06:00
Ayaz
562a2748cb
Merge branch 'main' into i4732
Signed-off-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com>
2022-12-28 11:56:08 -06:00
Ayaz
fe2bab56f9
Merge pull request #4819 from roc-lang/i4717
Compile anonymous closures with multiple specializations, and various fixes to lambda set compilation
2022-12-28 11:45:04 -06:00
Folkert de Vries
f4894183d7
Merge pull request #4823 from roc-lang/fix-check-union
Fix checking of recursive layouts in the ir-checker
2022-12-28 16:20:01 +01:00
Ayaz
b400851586
Merge branch 'main' into i4717
Signed-off-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com>
2022-12-27 18:58:16 -06:00
Ayaz Hafiz
13bb657b97
Follow recursive pointers in mono IR checker to not appear on top-level 2022-12-27 12:47:53 -06:00
Ayaz Hafiz
ce61386d0a
Expose set and representation to crate 2022-12-27 12:47:04 -06:00
Ayaz Hafiz
23fc7f1413
Appropriately substitute symbols in switch conditions
Closes #4557
2022-12-27 12:29:23 -06:00
Ayaz Hafiz
d23d0b9b88
Remove unneeded branch when extending lambda dispatch with closure args
If we pass ClosureInfo that indicates that a lambda captures, then when
we extend the lambda's argument list with the lambda set it appears it,
the extension must necessarily be material.
2022-12-27 10:56:23 -06:00
Ayaz Hafiz
25117bf50e
More do not ignore the specialized layout 2022-12-27 10:52:47 -06:00
Ayaz Hafiz
6ed1ad9fd5
Do not ignore layout, base it off specialization 2022-12-27 10:48:24 -06:00
Ayaz Hafiz
e7aaeb931a
Add a comment regarding behavior of extend_argument_list_for_named 2022-12-27 10:42:35 -06:00
Ayaz Hafiz
830843da82
Remove unused extend_argument_list 2022-12-27 10:40:09 -06:00
Ayaz Hafiz
468f76a424
Remove unused layout cache parameters 2022-12-27 10:39:44 -06:00
Ayaz Hafiz
3e906855e3
Extend called lambda argument lists only with explicit lambda names 2022-12-27 10:37:25 -06:00
Ayaz Hafiz
679557e44e
ProcLayout::new is crate-public 2022-12-27 10:33:38 -06:00
Ayaz Hafiz
8431b27282
Remove redundant parameter in from_raw_named
The captures niche is already accounted for by the lambda name, so we
don't need that as an extra param.
2022-12-27 10:30:07 -06:00
Ayaz Hafiz
e89f5ad6e5
Mark a couple functions as crate-exposed 2022-12-27 10:28:00 -06:00
Ayaz Hafiz
0b57d2f74f
Remove unneeded import 2022-12-27 10:27:19 -06:00
Ayaz Hafiz
198417c183
Remove ProcLayout::from_raw 2022-12-27 10:25:43 -06:00
Ayaz Hafiz
7a6e68861c
Account for non-capturing functions in larger lambda sets passed to HOLLs
Previously, if the lambda set passed to a HOLL contained any function
that captured, we would assume that the specialization of the HOLL we
should make for each function in the lambda set that we dispatch to
should capture.

This is not right. Instead, we should specialize for each lambda in the
set passed to the HOLL. The present patch enforces that, making sure
that for each lambda in the set, we compute the exact proc layout needed
to call the lambda, based on the captures of the specific lambda in the
set, rather than looking at the set entirely.
2022-12-27 10:22:18 -06:00
Ayaz Hafiz
bb0493918e
Update more usages of from_raw 2022-12-27 09:54:18 -06:00
Ayaz Hafiz
38920b98fa
Debug missing lambda names 2022-12-27 09:54:12 -06:00
Ayaz Hafiz
ccd68b70e1
Do not associate top-level accessor thunks as closures
Leftover follow-up to #4645
2022-12-27 09:49:51 -06:00
Ayaz Hafiz
fe58a0591b
Migrate some more uses of from_raw 2022-12-27 09:27:29 -06:00
Ayaz Hafiz
54bb258aac
Remove stale uniqueness inference comment 2022-12-27 09:26:08 -06:00
Ayaz Hafiz
1e847efbfe
Correctly choose specialized shapes for anonymous closures 2022-12-27 09:18:41 -06:00
Ayaz Hafiz
593344f5c5
Determine the proc layout based on captures of an individual lambda
Previously, we determined whether a closure argument should be added to
the proc layout of a compiled function by checking whether the lambda
set was material at all. But, the extension for a single function should
be added if and only if the function itself captures.
2022-12-27 09:15:21 -06:00
Ayaz Hafiz
877714ff91
We prefer slices 2022-12-25 16:56:00 -06:00
Ayaz Hafiz
a8693e6102
Order list-min-size tests in descending order
Some of the head-constructor tests we generate can be supersets of other tests.
Edges must be ordered so that more general tests always happen after their
specialized variants.

For example, patterns

  [1, ..] -> ...
  [2, 1, ..] -> ...

may generate the edges

  ListLen(>=1) -> <rest>
  ListLen(>=2) -> <rest>

but evaluated in exactly this order, the second edge is never reachable.
The necessary ordering is

  ListLen(>=2) -> <rest>
  ListLen(>=1) -> <rest>

Closes #4732
2022-12-25 16:55:58 -06:00
Ayaz Hafiz
a295e7ac3d
Allow any int in switch condition layout 2022-12-25 16:55:37 -06:00
Folkert de Vries
4022b44ff9
Merge pull request #4798 from JTeeuwissen/main
Replace DeclarationToIndex elements with a hash map.
2022-12-22 17:19:37 +01:00
J.Teeuwissen
1caafbc131
Feedback 2022-12-22 15:42:26 +01:00
J.Teeuwissen
5229edd742
Use hash instead of binary search 2022-12-22 14:08:41 +01:00