Commit graph

597 commits

Author SHA1 Message Date
Ayaz Hafiz
dd55be6142
Handle guards that appear multiple times in a compiled decision tree
Suppose we have a when expression

```
15 if foo -> <b1>
b  if bar -> <b2>
_         -> <b3>
```

that may have a decision tree like

```
15?
  \true => foo?
              \true  => <b1>
              \false => bar?
                           \true  => <b2>
                           \false => <b3>
  \false => bar?
               \true  => <b2>
               \false => <b3>
```

In this case, the guard "bar?" appears twice in the compiled decision
tree. We need to materialize the guard expression in both locations in
the compiled tree, which means we cannot as-is stamp a compiled `bar?`
twice in each location. The reason is that

- the compiled joinpoint for each `bar?` guard needs to have a unique ID
- the guard expression might have call which needs unique call spec IDs,
  or other joins that need unique joinpoint IDs.

So, save the expression as we build up the decision tree and materialize
the guard each time we need it. In practice the guards should be quite
small, so duplicating should be fine. We could avoid duplication, but
it's not clear to me how to do that exactly since the branches after the
guard might end up being different.
2023-03-25 16:14:21 -05:00
Ayaz Hafiz
f3ddc254c1
Update comment 2023-03-25 16:14:21 -05:00
Ayaz Hafiz
ecad660e7f
Ensure that when jumping to a branch, all pattern symbols are loaded
If we are jumping to a target branch, it is necessary that the target
branch has all required pattern symbols loaded in it. Usually this is
already the case, but there is an exception with guarded patterns.
Guarded patterns have their patterns loaded only right before the guard
is evaluated, which happens at some point further along the decision
tree. As such, when a guarded pattern jumps to its target destination,
it should append the loaded patterns as parameters on the target
joinpoint.
2023-03-25 16:14:21 -05:00
Ayaz Hafiz
393250db92
Utility to collect symbols bound by a pattern 2023-03-25 16:14:21 -05:00
Ayaz Hafiz
fe9be63787
Utility to substitute many symbols at once 2023-03-25 16:14:20 -05:00
Ayaz Hafiz
e6094df69b
Fast-path for determining ability member impls for builtin opaques 2023-03-22 17:08:41 -05:00
Anton-4
f1b1aa6a7b
Merge branch 'main' of github.com:roc-lang/roc into glue-getters-rtfeldman 2023-03-17 11:34:29 +01:00
Brendan Hansknecht
48f17a8e2c
add Str.releaseExcessCapacity 2023-03-15 15:24:59 -07:00
Brendan Hansknecht
1319ba4844
add List.releaseExcessCapacity builtin 2023-03-13 17:43:21 -07:00
Folkert
fdf1489df6
Merge remote-tracking branch 'origin/main' into glue-getters-rtfeldman 2023-03-14 01:01:26 +01:00
Brendan Hansknecht
e6964536b2
add more Num.bytesTo* functions 2023-03-12 08:41:05 -07:00
Brendan Hansknecht
785da377c8
add Num.count*Bits functions 2023-03-12 08:41:04 -07:00
Folkert
fe15a2e79c
Merge remote-tracking branch 'origin/main' into glue-getters-rtfeldman 2023-03-08 19:46:00 +01:00
Brendan Hansknecht
f42f61e271
run a toml formatter and then clean it up a bit 2023-03-06 19:47:57 -08:00
Brendan Hansknecht
4a89bee0a5
centralize package versions except for vendor and excluded 2023-03-06 19:29:09 -08:00
Brendan Hansknecht
5485c8a5b0
update to using workspace package spec 2023-03-06 16:36:18 -08:00
Ayaz Hafiz
739bdfe64e
Fix a bug in chasing assigned/hole on switch 2023-03-05 22:19:16 -06:00
Ayaz Hafiz
7914b07a2f
Eliminate unneeded joinpoints in union lambda dispatches 2023-03-05 22:10:42 -06:00
Ayaz Hafiz
a2389c7652
Eliminate joinpoints in trivial lambda set switches 2023-03-05 21:59:01 -06:00
Ayaz Hafiz
9166922e39
Remove unused is_terminal 2023-03-05 21:41:50 -06:00
Folkert
853c0387dc
cleanup 2023-03-05 17:33:48 +01:00
Folkert
d224992bc1
Merge remote-tracking branch 'origin/main' into glue-getters-rtfeldman 2023-03-05 17:24:05 +01:00
Folkert
769a4c415b
update remaining cli tests 2023-03-05 16:57:51 +01:00
Brendan Hansknecht
66a7d08363
make List.mapN properly add all decrefs 2023-03-02 07:24:49 -08:00
Folkert
180187e5af
get old examples to work 2023-03-01 21:56:14 +01:00
Folkert
1bf2cc3b8c
cleanup 2023-02-25 16:23:40 +01:00
Folkert
35980e50b8
fix function getters 2023-02-25 15:47:20 +01:00
Folkert
033618f3f4
fixes to get rocLovesRust to work 2023-02-22 21:17:50 +01:00
Folkert
0d4135c57a
Merge remote-tracking branch 'origin/main' into glue-getters-rtfeldman 2023-02-22 21:11:39 +01:00
Folkert de Vries
bd6623dab4
Merge pull request #5055 from roc-lang/abilities-bug-generic
Lambda set compaction must preserve unique specializations of concrete types
2023-02-21 15:24:23 +01:00
Folkert de Vries
088bd5211f
Merge pull request #5054 from roc-lang/glue-generate-lambda-set-callers
Glue generate lambda set callers
2023-02-21 02:19:53 +01:00
Ayaz Hafiz
f7aa7e734d
Pass interner through to debug proc layouts misisng in param map 2023-02-20 18:49:29 -06:00
Ayaz Hafiz
e5c3376e90
Debug ProcLayouts 2023-02-20 18:49:18 -06:00
Ayaz
2f251310c0
Merge pull request #5010 from roc-lang/tuple-record-unify
Unify IR generation for tuples and records
2023-02-20 18:40:52 -06:00
Folkert
958d44a21c
cleanup 2023-02-20 22:25:48 +01:00
Folkert
68524ef07e
generate callers based on layout traversal 2023-02-20 22:05:35 +01:00
Folkert
90c45a197b
use extracted functions 2023-02-18 17:57:50 +01:00
Folkert
784ebde24b
helper functions 2023-02-18 17:34:41 +01:00
Folkert
edd10a079c
create hook for future glue proc codegen 2023-02-18 17:34:23 +01:00
Folkert
b6bae82913
hello world works 2023-02-14 22:11:23 +01:00
Ayaz
b0d3d8fc7c
Merge pull request #5029 from roc-lang/lambda-set-cleanup 2023-02-14 08:51:35 -06:00
Ayaz Hafiz
b11cf19658
Remove unreachable lambda set layout branches
Lambda sets can only appear under function types, so we don't need to
handle them independently in layout gen.
2023-02-13 17:50:24 -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
2903ec4ac2
Remove obsolete comments 2023-02-13 10:54:05 -06:00
Folkert
587c5c18d7
mono refcount: use box instaed of non-nullable unwrapped 2023-02-10 20:19:49 +01:00
Folkert
6c15284a8f
more wip; now we just need to generate the exposed procs at the right time 2023-02-08 22:56:38 +01:00
Ayaz Hafiz
a22dcb5784
Unify record and tuple access 2023-02-08 11:13:36 -05:00
Ayaz Hafiz
1ee5f9d02b
Unify logic for building record and tuple IR 2023-02-08 11:03:02 -05:00
Joshua Warner
5a6be05ead
implement mono / lowering for tuples 2023-02-07 18:54:50 -08:00
Ayaz Hafiz
0af5929411
Add comments for debug reprs 2023-01-30 17:22:16 -06:00