Commit graph

1119 commits

Author SHA1 Message Date
Ayaz Hafiz
26f08c999c
Store interened wrapped layout of lambda set on LambdaSet struct
The `LambdaSet` struct is frequently used independently to examine how a
lambda set should be packed or unpacked. However, it is also often
converted into a full layout via `Layout::LambdaSet(LambdaSet)` to be a
part of function arguments, for example.

In preparing to intern all layouts, we need a way to cheaply go from a
`lambda_set` to an interned `Layout::LambdaSet(lambda_set)`, since this
is a very common operation. The proposed solution is to keep the wrapped
layout cached on `LambdaSet` itself, which this PR does.

The tricky bit of inserting a lambda set is we need to fill in the
interned `full_layout` only after the lambda set is inserted,
but we don't want to allocate a new interned slot if the same lambda set
layout has already been inserted with a different `full_layout` slot.

For example, if we insert `LambdaSet { set : [A] }` twice in two
different threads, we want the `full_layout` they map to to be the same.
So we nede to check if an interned representation with a full_layout
exists, before we allocate a new full_layout and insert a fresh lambda
set.

So,
  - check if the "normalized" lambda set (with a void full_layout slot) maps to an
    inserted lambda set in
    - in a thread-local cache, or globally
  - if so, use that one immediately
  - otherwise, allocate a new (global) slot, intern the lambda set, and then fill the slot in
    - save the interned layout and lambda set mapping thread-locally
2023-01-10 09:47:13 -06:00
Ayaz Hafiz
ce717dca8b
Do not require allocating Layouts in arena before interning
This should reduce memory spend, the interner has its own effective
arena anyway
2023-01-10 09:47:13 -06:00
Folkert de Vries
61a2091b27
Merge pull request #4851 from JTeeuwissen/main
replace borrowed boolean with ownership enum
2023-01-09 23:24:39 +01:00
J.Teeuwissen
c2e14864ab
from_layout 2023-01-09 19:19:20 +01:00
Ayaz Hafiz
b2688dd3b1
Skip nullable ID in nullable wrapped tags when iterating 2023-01-09 11:54:51 -06:00
J.Teeuwissen
b28b32cdc4
moved Ownership to borrow 2023-01-09 18:15:34 +01:00
Ayaz
7c61d0d278
Merge pull request #4843 from roc-lang/pattern-as-can
Pattern as can
2023-01-08 19:36:40 -06:00
J.Teeuwissen
a11d94aee2
Replaced equality check with enum 2023-01-06 08:55:13 +01:00
J.Teeuwissen
be73d3cfc4
Removed ! 2023-01-06 08:54:44 +01:00
J.Teeuwissen
1f10d0cb92
Added traits and updated remaining borrowed 2023-01-05 12:02:20 +01:00
Folkert
1c1112ec35
Merge remote-tracking branch 'origin/main' into glue-getters-rtfeldman 2023-01-04 20:45:01 +01:00
J.Teeuwissen
09f9df1f40
specification 2023-01-04 15:43:21 +01:00
J.Teeuwissen
6ec977bf1c
imports 2023-01-04 13:34:31 +01:00
J.Teeuwissen
6c95bc1fb9
replace borrowed boolean with ownership enum 2023-01-04 13:30:42 +01:00
Ayaz Hafiz
50826d1a83
Inline interners into the layout interner module
I realized that we'll need to make the layout interner more complicated
to support things like recursive pointers pointing to their parents and
to support lambda set layout caching. Since the layout interner is the
only user of intern crate right now anyway, just inline the whole thing.
2023-01-03 14:19:39 -06:00
Ayaz Hafiz
82e6982196
Requiring sizing layout interner for traits 2023-01-03 13:46:20 -06:00
Ayaz Hafiz
69d5320958
Fix dec reference 2023-01-03 12:22:04 -06:00
Ayaz Hafiz
df6672e460
Support f32, f64, dec, and dispatched interned const layouts 2023-01-03 12:19:42 -06:00
Ayaz Hafiz
fdbc0ebdad
Thread LayoutInterner trait through 2023-01-03 11:48:46 -06:00
Ayaz Hafiz
b1424afefd
Cache many layouts into interner by default 2023-01-03 11:45:48 -06:00
Ayaz Hafiz
b60d5c0251
Push wrapped layout interners through 2023-01-03 10:51:33 -06:00
Ayaz Hafiz
947158b17e
Stub out layout interners into own module 2023-01-03 10:07:12 -06:00
Folkert
905341d849
can for normal (no-list) as 2022-12-31 15:46:11 +01:00
Ayaz Hafiz
68a1589663
Unwrap interned layout 2022-12-29 18:48:00 -06:00
Ayaz Hafiz
1ae3c3b0f8
Fix type error in niche unpacking 2022-12-29 18:45:20 -06:00
Ayaz Hafiz
bf12e9e928
Lift docs for captures niches 2022-12-29 18:45:00 -06:00
Ayaz Hafiz
6722dc3b84
Hide away the niche representation 2022-12-29 18:44:39 -06:00
Ayaz Hafiz
321ac0b06f
s/CapturesNiche/Captures 2022-12-29 18:43:45 -06:00
Ayaz Hafiz
039bab65f5
Remove unused imports 2022-12-29 18:43:28 -06:00
Ayaz Hafiz
972046445b
Lift Niche from just captures-niche to generic niche 2022-12-29 18:43:26 -06:00
Ayaz
ea53a50447
Merge pull request #4836 from roc-lang/intern-layouts-2
Intern list element layouts and thread mut layout interner through LLVM backend
2022-12-29 18:41:35 -06:00
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