Commit graph

6348 commits

Author SHA1 Message Date
Brian Carroll
d66d432716 Wasm tests: speed up 3x by only exporting refcount symbols when used
49s vs 2m10s
2021-12-31 21:23:15 +00:00
Brian Carroll
f767014f30
Merge pull request #2301 from rtfeldman/wasm-refcount-list
Wasm refcounting for lists
2021-12-31 13:25:38 +00:00
Richard Feldman
4c62e335e5
Merge pull request #2305 from rtfeldman/soundness-assignment-tag-destructure
Parse tag destructures in defs, and make sure they are type-checked as closed unions
2021-12-31 07:13:03 -05:00
ayazhafiz
f56754a539 Remove bad test
We shouldn't expect to generate code for tag destructures that are type
errors
2021-12-30 20:59:59 -06:00
ayazhafiz
983a9f7e17 Position correct basic block before calling error catcher
While building the main function for tests, we may need to generate
additional blocks while marshalling arugments to the error catcher into
the expected calling convention. This pushes the last block in the main
function down, so that the "entry" block may not be last BB in the
function. Instead, look up the last insertion block before generating
the catcher, and then add a call to the catcher at the end of this last
block.

Closes #2300
2021-12-30 20:55:43 -06:00
ayazhafiz
8e7ca57458 Close tag unions that are in the left hand side of an assignment 2021-12-30 19:51:14 -06:00
ayazhafiz
0c81302d29 Admit tag destructuring in definitions 2021-12-30 19:50:50 -06:00
ayazhafiz
fda6c70835 Mark patterns in lambda argument position as having a presence constraint
Closes #2299
2021-12-30 18:21:28 -06:00
Brian Carroll
101ac69de2 Disable refcounting test code when not in use 2021-12-30 20:00:25 +00:00
Folkert de Vries
aaa041cee5
Merge pull request #2295 from rtfeldman/wasm-refcount-tests
Create code gen tests for refcounting
2021-12-30 19:31:41 +01:00
Brian Carroll
c5663e3538 Generate IR helper proc for list refcounting 2021-12-30 17:15:31 +00:00
Brian Carroll
e612f51905 Tweak wasm test platform 2021-12-30 15:45:20 +00:00
Brian Carroll
83d6c82e0b Wasm: avoid two memory loads for ListLen, at the cost of +1 instruction byte 2021-12-30 15:40:55 +00:00
Brian Carroll
0912f8fd45 Wasm: replace a local.set/get pair with a local.tee 2021-12-30 15:40:00 +00:00
Brian Carroll
acade33497 Wasm bugfix: allocate using the heap alignment, not the stack alignment 2021-12-30 15:37:09 +00:00
Brian Carroll
eeb4b20390 Improve string refcounting tests 2021-12-30 09:09:07 +00:00
Brian Carroll
59472d3310 Slightly improve pretty printing of inc statement 2021-12-30 09:01:22 +00:00
ayazhafiz
d966d8921f Support nullable wrapped tag union layouts in REPL 2021-12-29 17:55:21 -06:00
ayazhafiz
f52cca40b5 Dereference small (non recursive) tag unions before storing them elsewhere
Closes #2290
2021-12-29 17:55:21 -06:00
ayazhafiz
71bd77e3b2 Handle flat variants of recursive tag unions in repl 2021-12-29 17:55:21 -06:00
ayazhafiz
6da9a58b22 Remove some dead code 2021-12-29 17:55:21 -06:00
Brian Carroll
6b932f9743 Clarify some lowlevel code to make it clearer what to do when adding new ones 2021-12-29 22:11:33 +00:00
Brian Carroll
7aa3f77b3c Handle freed values in refcount tests 2021-12-29 17:31:05 +00:00
Brian Carroll
4d2e4d454b Create code gen tests for refcounting 2021-12-29 16:48:43 +00:00
Brian Carroll
37de499248 Reorganise code gen helper in roc_mono 2021-12-28 11:03:33 +00:00
Folkert
d1bf07fdcd be a bit less string in debug assert 2021-12-28 00:10:26 +01:00
Folkert
b924f7e329 use new header type in a spot we missed 2021-12-27 23:58:56 +01:00
Richard Feldman
554570a232
Merge pull request #2284 from rtfeldman/roc-std-result
add RocResult to roc_std rust crate
2021-12-27 17:43:22 -05:00
Folkert de Vries
249878cbd9
Merge pull request #2281 from rtfeldman/i/2149
(llvm) Generate code for tag unions less than 64 bits in size correctly
2021-12-27 22:38:08 +01:00
Folkert de Vries
bb935948aa
Merge pull request #2276 from rtfeldman/i/2265
Parse "as" aliases into tag/args rather than arbitrary annotations
2021-12-27 20:56:48 +01:00
Folkert de Vries
565809063b
Merge pull request #2283 from rtfeldman/eq-linked-list-tce
Tail-call elimination for equality on linked lists
2021-12-27 20:40:03 +01:00
Folkert
007d777865 flesh out api for RocResult 2021-12-27 20:01:19 +01:00
Brian Carroll
c67b9e7a6f clippy 2021-12-27 18:11:48 +00:00
Brian Carroll
0285cd88c5 Don't emit tail recursion loop for non-recursive unions 2021-12-27 18:08:43 +00:00
Brian Carroll
409a32b192 Test for equality on very long linked lists 2021-12-27 18:08:43 +00:00
Brian Carroll
0d8a2c8a49 Use tail call elimination where possible in == for tag unions 2021-12-27 18:08:43 +00:00
Brian Carroll
65a9464d98 Replace RecursivePointer todo with unreachable 2021-12-27 18:08:43 +00:00
ayazhafiz
4631ff96f5 Initialize stack pointer when it doesn't exist
I'm not sure this is right, but we have to do it somewhere.. and here
seems reasonable?
2021-12-26 17:46:06 -06:00
ayazhafiz
326bfe9aa3 Ensure WASM code gen uses proper tag ID alignment
We should use the alignment of the tag ID layout, not the alignment of
the rest of the data in the tag union. The reason is that the tag ID may
be smaller than the data.
2021-12-26 17:45:05 -06:00
ayazhafiz
b3ddfa7515 Parse destructured tag annotations as annotations rather than aliases
Closes #178
2021-12-26 16:11:29 -06:00
ayazhafiz
235d6a9e88 Fix gen_tags tests 2021-12-26 15:49:54 -06:00
ayazhafiz
a03f7fa46c Update layout tests 2021-12-26 14:44:43 -06:00
Lucas
fe62e59e31
Merge pull request #2278 from rtfeldman/configure-zig-executable
use ROC_ZIG environment variable to configure which zig is used
2021-12-26 14:40:48 -05:00
ayazhafiz
c8ba554d8c Clippy warning 2021-12-26 11:58:50 -06:00
ayazhafiz
5e5eb6dca8 (llvm) Generate code for tag unions less than 64 bits in size correctly
Previously, we assumed that a union layout always lived on >= 1 64-bit
boundary when generating an LLVM type for it. For small tags unions,
like `[ Ok i8, Err ]` this need not be the case; indeed, a tag union
like that is actually only 2 bits - 1 bit for the "i8" data, and one bit
of the tag kind.

This led to a discrepancy between what the layout IR and generated LLVM
code would assume about the size of tag unions. In the case above, the
layout IR would assume the tag data is 2 bits wide, and the tag id is 1
bit into the data. But the LLVM code would generate a type that was 65
bits wide, the first 64 bits being for the "i8" data and the last 1 bit
being for the tag kind.

Usually, just running the LLVM-emitted code would not present a problem.
But it does present a problem when we use the layout IR to inspect the
result of LLVM-run code, in particular when we try to look up the tag
ID, as the repl does. This patch fixes that issue.

Note that this bug did not present itself in `test_gen` previously
because the data that most tests check against is stored in the front of
the representation.

Closes #2149
2021-12-26 11:45:02 -06:00
ayazhafiz
0b6d3d2c55 Promote parse tests 2021-12-26 11:35:10 -06:00
ayazhafiz
b66543dd95 into_iter -> iter 2021-12-26 09:55:27 -06:00
ayazhafiz
966198a6e7 Coalesce inline and normal alias headers
Unifies `As` annotations and `Alias` defs to use a common struct for
defining alias header information, i.e. the name and type variables of
the alias.
2021-12-26 09:37:56 -06:00
ayazhafiz
597a1cef3b Attach location to alias header name 2021-12-26 09:17:27 -06:00
ayazhafiz
11da888c07 Pull out alias header as its own struct 2021-12-26 09:07:12 -06:00