Commit Graph

2296 Commits

Author SHA1 Message Date
Andrew Kelley
c622766156 async function fulfills promise atomically 2018-02-28 21:48:20 -05:00
Andrew Kelley
807a5e94e9 add atomicrmw builtin function 2018-02-28 21:19:51 -05:00
Andrew Kelley
36eadb569a run coroutine tests only in Debug mode
LLVM 5.0.1, 6.0.0, and trunk crash when attempting to optimize coroutine code.
So, Zig does not support ReleaseFast or ReleaseSafe for coroutines yet.
Luckily, Clang users are running into the same crashes, so folks from the LLVM
community are working on fixes. If we're really lucky they'll be fixed in 6.0.1.
Otherwise we can hope for 7.0.0.
2018-02-28 18:56:26 -05:00
Andrew Kelley
58dc2b719c better coroutine codegen, now passing first coro test
we have to use the Suspend block with llvm.coro.end to
return from the coro
2018-02-28 18:22:43 -05:00
Andrew Kelley
ad2a29ccf2 break the data dependencies that llvm coro transforms cant handle
my simple coro test program builds now

see #727
2018-02-28 16:47:13 -05:00
Andrew Kelley
026aebf2ea another workaround for llvm coroutines
this one doesn't work either
2018-02-28 04:01:22 -05:00
Andrew Kelley
d243453862 Revert "llvm coroutine workaround: sret functions return sret pointer"
This reverts commit 132e604aa3.

this workaround didn't work either
2018-02-27 17:47:18 -05:00
Andrew Kelley
138d6f9093 revert workaround for alloc and free as coro params
reverts 4ac6c4d6bf

the workaround didn't work
2018-02-27 17:46:13 -05:00
Andrew Kelley
132e604aa3 llvm coroutine workaround: sret functions return sret pointer 2018-02-27 17:12:53 -05:00
Andrew Kelley
6e2a67724c Revert "another llvm workaround for getelementptr"
This reverts commit c2f5634fb3.

It doesn't work. With this, LLVM moves the allocate fn call
to after llvm.coro.begin
2018-02-27 14:58:02 -05:00
Andrew Kelley
c2f5634fb3 another llvm workaround for getelementptr 2018-02-27 14:57:49 -05:00
Andrew Kelley
4e43bde924 workaround for llvm: delete coroutine allocation elision
maybe this can be reverted, but it seems to be related
to llvm's coro transformations crashing.

See #727
2018-02-26 21:31:00 -05:00
Andrew Kelley
4ac6c4d6bf workaround llvm coro transformations
by making alloc and free functions be parameters to async
functions instead of using getelementptr in the DynAlloc block

See #727
2018-02-26 21:14:15 -05:00
Andrew Kelley
3e86fb500d implement coroutine suspend
see #727
2018-02-26 02:46:21 -05:00
Andrew Kelley
c60496a297 parse await and suspend syntax
See #727
2018-02-26 00:04:11 -05:00
Andrew Kelley
6fef7406c8 move coroutine init code to after coro.begin 2018-02-25 20:29:14 -05:00
Andrew Kelley
6b436146a8 fix invalid memory write in coroutines implementation 2018-02-25 20:28:44 -05:00
Andrew Kelley
6cbea99ed6 async functions are allowed to accept zig types 2018-02-25 20:27:53 -05:00
Andrew Kelley
b018c64ca2 add coroutine LLVM passes 2018-02-25 18:09:39 -05:00
Andrew Kelley
fe354ebb5c coroutines: fix llvm error of instruction not dominating uses
See #727
2018-02-25 17:57:05 -05:00
Andrew Kelley
704a8acb59 fix handle_is_ptr for promise type 2018-02-25 17:34:18 -05:00
Andrew Kelley
83f8906449 codegen for coro_resume instruction
See #727
2018-02-25 17:34:05 -05:00
Andrew Kelley
4eac75914b codegen for coro_free instruction
See #727
2018-02-25 16:46:01 -05:00
Andrew Kelley
d2d2ba10e9 codegen for coro_end instruction
See #727
2018-02-25 16:40:00 -05:00
Andrew Kelley
0cf327eb17 codegen for coro_suspend instruction
See #727
2018-02-25 16:29:07 -05:00
Andrew Kelley
d0f2eca106 codegen for coro_begin instruction
See #727
2018-02-25 16:22:19 -05:00
Andrew Kelley
79f1ff574b codegen for coro_alloc_fail instruction
See #727
2018-02-25 16:15:14 -05:00
Andrew Kelley
bced3fb64c codegen for get_implicit_allocator instruction
See #727
2018-02-25 16:05:10 -05:00
Andrew Kelley
93cbd4eeb9 codegen for coro_alloc and coro_size instructions
See #727
2018-02-25 15:20:31 -05:00
Andrew Kelley
9f6c5a20de codegen for coro_id instruction
See #727
2018-02-25 15:10:29 -05:00
Andrew Kelley
7567448b91 codegen for cancel
See #727
2018-02-25 14:47:58 -05:00
Andrew Kelley
05bf666eb6 codegen for calling an async function
See #727
2018-02-25 02:47:31 -05:00
Andrew Kelley
40dbcd09da fix type_is_codegen_pointer being used incorrectly
The names of these functions should probably change, but at least
the semantics are correct now:
 * type_is_codegen_pointer - the type is either a fn, ptr, or promise
 * get_codegen_ptr_type -
   - ?&T and &T returns &T
   - ?promise and promise returns promise
   - ?fn()void and fn()void returns fn()void
   - otherwise returns nullptr
2018-02-23 12:49:21 -05:00
Andrew Kelley
99985ad6fc implement Zig IR for async functions
See #727
2018-02-23 03:03:06 -05:00
Andrew Kelley
ca1b77b2d5 IR analysis for coro.begin
See #727
2018-02-22 11:54:27 -05:00
Andrew Kelley
88e7b9bf80 ir analysis for coro_id and coro_alloc
See #727
2018-02-22 09:36:58 -05:00
Andrew Kelley
37c07d4f3f coroutines: analyze get_implicit_allocator instruction
see #727
2018-02-22 09:30:55 -05:00
Andrew Kelley
b261da0672 add coroutine startup IR to async functions
See #727
2018-02-21 23:28:35 -05:00
Andrew Kelley
236bbe1183 implement IR analysis for async function calls
See #727
2018-02-21 00:52:20 -05:00
Andrew Kelley
65a51b401c add promise type
See #727
2018-02-20 16:42:14 -05:00
Andrew Kelley
a06f3c74fd parse async fn definitions
See #727
2018-02-20 00:31:52 -05:00
Andrew Kelley
3d58d7232a parse async fn calls and cancel expressions 2018-02-20 00:05:38 -05:00
Andrew Kelley
af10b0fec2 add async, await, suspend, resume, cancel keywords
See #727
2018-02-19 23:19:59 -05:00
Andrew Kelley
bde15cf080 improve std lib linux epoll API 2018-02-17 17:53:07 -05:00
Andrew Kelley
72ca2b214d ability to slice an undefined pointer at compile time if the len is 0 2018-02-16 15:22:29 -05:00
Andrew Kelley
cbbd6cfa1e add an assert to catch #777
asserting is better than segfaulting
2018-02-15 23:39:35 -05:00
Andrew Kelley
5f5880979e zig fmt supports simple line comments 2018-02-15 12:30:29 -05:00
Andrew Kelley
cc26148ba7 fix compiler crash when struct contains...
ptr to another struct which contains original struct
2018-02-15 12:14:20 -05:00
Andrew Kelley
1c1c0691cc fix crash when doing comptime float rem comptime int
closes #776
2018-02-14 23:12:51 -05:00
Andrew Kelley
ca597e2bfb std.zig.parser understands try. zig fmt respects a double line break. 2018-02-14 23:00:53 -05:00