Skip to content

rework async function semantics #3033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 83 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
54e716a
remove coroutines implementation and promise type
andrewrk Jun 28, 2019
72e9836
simple async function call working
andrewrk Jul 21, 2019
27a5f2c
remove errors for async calling convention
andrewrk Jul 21, 2019
6053ca4
fix not jumping to entry
andrewrk Jul 21, 2019
56c08eb
returning from async fn adds bad resume safety
andrewrk Jul 21, 2019
78e03c4
simple async function passing test
andrewrk Jul 21, 2019
11bd50f
implement coroutine resume
andrewrk Jul 22, 2019
59bf9ca
implement async function parameters
andrewrk Jul 22, 2019
32d0ac1
fix wrong calling convention on async resume
andrewrk Jul 22, 2019
5b69a9c
disable segfault handler when panicking
andrewrk Jul 22, 2019
650e07e
fix suspend at end of function
andrewrk Jul 22, 2019
fcadeb5
fix multiple coroutines existing clobbering each other
andrewrk Jul 22, 2019
317d1ec
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
andrewrk Jul 22, 2019
7e9760d
inferring async from async calls
andrewrk Jul 23, 2019
19ee495
add error for function with ccc indirectly calling async function
andrewrk Jul 23, 2019
e220812
implement local variables in async functions
andrewrk Jul 24, 2019
ead2d32
calling an inferred async function
andrewrk Jul 25, 2019
70bced5
implement `@frame` and `@Frame`
andrewrk Jul 25, 2019
538c0cd
implement `@frameSize`
andrewrk Jul 25, 2019
7b36868
`@frameSize` works via PrefixData
andrewrk Jul 26, 2019
018a89c
async functions return void, no more GetSize resume block
andrewrk Jul 26, 2019
ee64a22
add the `anyframe` and `anyframe->T` types
andrewrk Jul 26, 2019
dbdc4d6
improve support for anyframe and anyframe->T
andrewrk Jul 29, 2019
e7ae4e4
reimplement async with function splitting instead of switch
andrewrk Aug 1, 2019
1dd0c3d
fix calling an inferred async function
andrewrk Aug 1, 2019
0f879d0
more passing coroutine tests
andrewrk Aug 1, 2019
056c4e2
implement async await and return
andrewrk Aug 2, 2019
f07f09a
Merge branch 'master' into rewrite-coroutines
andrewrk Aug 2, 2019
b3b6a98
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
andrewrk Aug 2, 2019
5bd330e
add heap allocated async function frame test
andrewrk Aug 2, 2019
0920bb0
implement async functions returning structs
andrewrk Aug 2, 2019
24d7817
add compile error for async call of function pointer
andrewrk Aug 3, 2019
e444e73
add runtime safety for resuming an awaiting function
andrewrk Aug 3, 2019
c879209
add compile error for calling async function pointer
andrewrk Aug 3, 2019
87710a1
implement `@asyncCall` which supports async function pointers
andrewrk Aug 3, 2019
1292447
fix regression in calling extern functions
andrewrk Aug 4, 2019
fa30ebf
suspension points inside branching control flow
andrewrk Aug 4, 2019
042914d
move state from ZigFn to CodeGen to save memory
andrewrk Aug 4, 2019
fbf21ef
simpler, less memory intensive suspend/resume implementation
andrewrk Aug 4, 2019
b7c94be
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
andrewrk Aug 4, 2019
f27e5d4
refactor logic for determining if there is a frame pointer
andrewrk Aug 5, 2019
0d8c9fc
support async functions with inferred error sets
andrewrk Aug 5, 2019
a7763c0
delete IrInstructionMarkErrRetTracePtr
andrewrk Aug 5, 2019
dfe8c5a
add a src() method to AstNode to aid debugging
andrewrk Aug 5, 2019
20f63e5
async functions have error return traces where appropriate
andrewrk Aug 5, 2019
400500a
improve async function semantics
andrewrk Aug 6, 2019
17199b0
passing the error return trace async function test
andrewrk Aug 6, 2019
966c9ea
error return trace across suspend points
andrewrk Aug 6, 2019
1afbb53
fix awaiting when result type is a struct
andrewrk Aug 6, 2019
7e1fcb5
implement cancel
andrewrk Aug 7, 2019
f587fa1
clean up the bitcasting of awaiter fn ptr
andrewrk Aug 7, 2019
e11cafb
cancel works on non-pointers
andrewrk Aug 7, 2019
34bfdf1
cancel, defer, errdefer all working as intended now
andrewrk Aug 8, 2019
d813805
more debuggable safety for awaiting twice
andrewrk Aug 8, 2019
8d4cb85
async functions in single threaded mode do not use atomic ops
andrewrk Aug 8, 2019
8be95af
add compile error for unable to determine async fn frame
andrewrk Aug 8, 2019
bfa1d12
better compile errors when frame depends on itself
andrewrk Aug 8, 2019
cfe8442
fix segfault with var args
andrewrk Aug 8, 2019
93840f8
fix var args call on non-generic function
andrewrk Aug 8, 2019
da56959
closer to std lib event stuff working
andrewrk Aug 8, 2019
614cab5
fix passing string literals to async functions
andrewrk Aug 8, 2019
2e7f53f
fix cancel inside an errdefer
andrewrk Aug 9, 2019
b9d1d45
fix combining try with errdefer cancel
andrewrk Aug 10, 2019
22428a7
fix try in an async function with error union and non-zero-bit payload
andrewrk Aug 10, 2019
77d098e
fix returning a const error from async function
andrewrk Aug 10, 2019
3f5c6d7
add test case for typical async/await usage
andrewrk Aug 10, 2019
af8c6cc
fix canceling async functions which have error return tracing
andrewrk Aug 11, 2019
4d8d513
all tests passing
andrewrk Aug 11, 2019
62c5bc6
fix cancel invoking branch on undefined memory
andrewrk Aug 12, 2019
911b1a0
fix no-longer-correct `nonnull` attribute on merge err ret traces fn
andrewrk Aug 12, 2019
24d5ec0
fix async function frames not aligned enough
andrewrk Aug 12, 2019
8a92899
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
andrewrk Aug 13, 2019
12ff91c
alignment of structs no longer depends on LLVM
andrewrk Aug 13, 2019
82d4ebe
organize TODOs
andrewrk Aug 13, 2019
5092634
avoid the word "coroutine", they're "async functions"
andrewrk Aug 13, 2019
dd8c8c0
get_struct_type accepts field alignment overrides
andrewrk Aug 13, 2019
5749dc4
respect local variable alignment in async functions
andrewrk Aug 14, 2019
7799423
rename behavior test files
andrewrk Aug 14, 2019
f3f838c
add compile error for await in exported function
andrewrk Aug 14, 2019
64c293f
codegen for async call of blocking function
andrewrk Aug 14, 2019
13b5a4b
remove `cancel`
andrewrk Aug 15, 2019
55f5cee
fix error return traces for async calls of blocking functions
andrewrk Aug 15, 2019
d367249
basic docs for new async/await semantics
andrewrk Aug 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ set(ZIG_MAIN_SRC "${CMAKE_SOURCE_DIR}/src/main.cpp")
set(ZIG0_SHIM_SRC "${CMAKE_SOURCE_DIR}/src/userland.cpp")

set(ZIG_SOURCES
"${CMAKE_SOURCE_DIR}/src/glibc.cpp"
"${CMAKE_SOURCE_DIR}/src/analyze.cpp"
"${CMAKE_SOURCE_DIR}/src/ast_render.cpp"
"${CMAKE_SOURCE_DIR}/src/bigfloat.cpp"
Expand All @@ -438,6 +437,7 @@ set(ZIG_SOURCES
"${CMAKE_SOURCE_DIR}/src/compiler.cpp"
"${CMAKE_SOURCE_DIR}/src/errmsg.cpp"
"${CMAKE_SOURCE_DIR}/src/error.cpp"
"${CMAKE_SOURCE_DIR}/src/glibc.cpp"
"${CMAKE_SOURCE_DIR}/src/ir.cpp"
"${CMAKE_SOURCE_DIR}/src/ir_print.cpp"
"${CMAKE_SOURCE_DIR}/src/libc_installation.cpp"
Expand Down
4 changes: 3 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ fn addLibUserlandStep(b: *Builder) void {
artifact.bundle_compiler_rt = true;
artifact.setTarget(builtin.arch, builtin.os, builtin.abi);
artifact.linkSystemLibrary("c");
artifact.linkSystemLibrary("ntdll");
if (builtin.os == .windows) {
artifact.linkSystemLibrary("ntdll");
}
const libuserland_step = b.step("libuserland", "Build the userland compiler library for use in stage1");
libuserland_step.dependOn(&artifact.step);

Expand Down
3 changes: 1 addition & 2 deletions doc/docgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
.Keyword_async,
.Keyword_await,
.Keyword_break,
.Keyword_cancel,
.Keyword_catch,
.Keyword_comptime,
.Keyword_const,
Expand All @@ -770,7 +769,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
.Keyword_or,
.Keyword_orelse,
.Keyword_packed,
.Keyword_promise,
.Keyword_anyframe,
.Keyword_pub,
.Keyword_resume,
.Keyword_return,
Expand Down
Loading