Commit graph

43 commits

Author SHA1 Message Date
Folkert
9a6f9ad26e
functions in structs, in general 2023-04-04 15:01:17 +02:00
Ayaz Hafiz
e5c3376e90
Debug ProcLayouts 2023-02-20 18:49:18 -06:00
Ayaz Hafiz
a3de22c88a
Do not fixup recursion pointers in non-recursive lambda sets
If a lambda set is non-recursive, but contains naked recursion pointers,
we should not fill those naked pointers in with the slot of the lambda
set during interning. Such naked pointers must belong to an encompassing
lambda set that is in fact recursive, and will be filled in later.

For example, `LambdaSet([Foo, LambdaSet(Bar, [<rec>])] as <rec>)` should
not have the inner lambda set's capture be filled in with itself.

Also, during reification of recursion pointers, we do not need to
traverse re-inserted lambda sets again, since they were just fixed-up.

Closes #5026
2023-02-13 17:14:04 -06:00
Ayaz Hafiz
0af5929411
Add comments for debug reprs 2023-01-30 17:22:16 -06:00
Ayaz Hafiz
4a59e24081
Address lints 2023-01-30 16:48:46 -06:00
Ayaz Hafiz
c3064dad73
Add method to get index of interned layout 2023-01-30 15:53:37 -06:00
Ayaz Hafiz
c1a937e393
Add method to debug whole nested structure of interned layout 2023-01-30 15:53:13 -06:00
Ayaz Hafiz
a294cae9cd
Don't store recursive unions by recursive pointer head-on 2023-01-25 18:05:43 -06:00
Ayaz Hafiz
36beda63ba
Lints 2023-01-25 18:00:32 -06:00
Ayaz Hafiz
478d4a2d44
Support lambda sets with recursive pointers and their equivalence-checking 2023-01-25 17:57:49 -06:00
Ayaz Hafiz
fa47e82d72
Implement equivalence of lambda sets 2023-01-25 17:20:42 -06:00
Ayaz Hafiz
61b11c9882
Single-threaded layout interner should resolve recursive pointer 2023-01-25 17:19:39 -06:00
Ayaz Hafiz
44acb7e047
Update recursive layout tests 2023-01-25 17:19:14 -06:00
Ayaz Hafiz
c9afbce053
Add an up-to-isomorphism equivalence checker for layouts 2023-01-25 16:17:30 -06:00
Ayaz Hafiz
cb00619ce3
Return normalized representation of recursive union as the rec ptr 2023-01-25 15:16:48 -06:00
Ayaz Hafiz
741b1a1bd5
Always show one level of unions when printing layouts 2023-01-25 15:16:06 -06:00
Ayaz Hafiz
7f284a753b
Lints 2023-01-23 17:09:05 -06:00
Ayaz Hafiz
8edbd3b378
Eliminate uses of RECURSIVE_PTR directly 2023-01-23 16:04:55 -06:00
Ayaz Hafiz
37d9307fbf
Call insert_recursive for union layouts 2023-01-23 15:40:40 -06:00
Ayaz Hafiz
59144f6e29
Unused var 2023-01-23 14:37:49 -06:00
Ayaz Hafiz
695b2e6363
Fix a bug by not recording normalized layouts 2023-01-23 14:37:49 -06:00
Ayaz Hafiz
7169d0974d
Add support for interning normalized recursive layouts 2023-01-23 14:37:49 -06:00
Ayaz Hafiz
8750127111
Begin support for looping-back recursive pointers to their source layouts 2023-01-23 14:37:48 -06:00
Ayaz Hafiz
3109b2b00f
Store args/return layout in the lambda set specialization layout 2023-01-16 12:45:08 -06:00
Ayaz Hafiz
8dc2a5daa7
Store args, return type on lambda set 2023-01-16 12:45:07 -06:00
Ayaz Hafiz
68d6de79de
Don't make from_reserved_index public 2023-01-11 14:39:11 -06:00
Ayaz Hafiz
856ee91642
Add layout interner tests and fix a bug with lambda set interner 2023-01-11 14:39:11 -06:00
Ayaz Hafiz
55b8aaebda
Update roc glue 2023-01-11 14:39:11 -06:00
Ayaz Hafiz
03ece6e274
Update llvm backend 2023-01-11 14:39:10 -06:00
Ayaz Hafiz
9d70c45781
Update wasm backend 2023-01-11 14:38:43 -06:00
Ayaz Hafiz
6859c2e15c
Update dev backend 2023-01-11 14:38:42 -06:00
Ayaz Hafiz
fa8effd3e8
Make all layouts interned in mono 2023-01-11 14:38:41 -06:00
Ayaz Hafiz
dc6b7003a8
Make layout methods easier on interner 2023-01-11 14:32:16 -06:00
Ayaz Hafiz
e14a0abb99
Store target info on layout interners 2023-01-11 14:32:16 -06:00
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
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
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