authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-06 19:38:59+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-07 10:30:11+02:00
logcb20093614efecb341f8b3260bf9f91bb10556e6
treeacbc8f6fae9e00bf79223162d5c5ca747540456c
parentb06e5b8c6862ce77dab314c7817709f0832799df
signaturelock-open Commit is signed but in an unrecognized format.

self hosted compiler: remove await async pattern


9 files changed, 151 insertions(+), 192 deletions(-)

src-self-hosted/codegen.zig+1-1
......@@ -17,7 +17,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
1717 defer fn_val.base.deref(comp);
1818 defer code.destroy(comp.gpa());
1919
20 var output_path = try await (async comp.createRandomOutputPath(comp.target.objFileExt()) catch unreachable);
20 var output_path = try comp.createRandomOutputPath(comp.target.objFileExt());
2121 errdefer output_path.deinit();
2222
2323 const llvm_handle = try comp.zig_compiler.getAnyLlvmContext();
src-self-hosted/compilation.zig+63-81
......@@ -93,8 +93,8 @@ pub const ZigCompiler = struct {
9393 }
9494
9595 pub async fn getNativeLibC(self: *ZigCompiler) !*LibCInstallation {
96 if (await (async self.native_libc.start() catch unreachable)) |ptr| return ptr;
97 try await (async self.native_libc.data.findNative(self.loop) catch unreachable);
96 if (self.native_libc.start()) |ptr| return ptr;
97 try self.native_libc.data.findNative(self.loop);
9898 self.native_libc.resolve();
9999 return &self.native_libc.data;
100100 }
......@@ -227,8 +227,8 @@ pub const Compilation = struct {
227227 /// need to wait on this group before deinitializing
228228 deinit_group: event.Group(void),
229229
230 destroy_handle: promise,
231 main_loop_handle: promise,
230 // destroy_frame: @Frame(createAsync),
231 main_loop_frame: @Frame(Compilation.mainLoop),
232232 main_loop_future: event.Future(void),
233233
234234 have_err_ret_tracing: bool,
......@@ -348,7 +348,7 @@ pub const Compilation = struct {
348348 zig_lib_dir: []const u8,
349349 ) !*Compilation {
350350 var optional_comp: ?*Compilation = null;
351 const handle = try async<zig_compiler.loop.allocator> createAsync(
351 const frame = async createAsync(
352352 &optional_comp,
353353 zig_compiler,
354354 name,
......@@ -359,10 +359,7 @@ pub const Compilation = struct {
359359 is_static,
360360 zig_lib_dir,
361361 );
362 return optional_comp orelse if (getAwaitResult(
363 zig_compiler.loop.allocator,
364 handle,
365 )) |_| unreachable else |err| err;
362 return optional_comp orelse await frame;
366363 }
367364
368365 async fn createAsync(
......@@ -376,10 +373,6 @@ pub const Compilation = struct {
376373 is_static: bool,
377374 zig_lib_dir: []const u8,
378375 ) !void {
379 // workaround for https://github.com/ziglang/zig/issues/1194
380 suspend {
381 resume @handle();
382 }
383376
384377 const loop = zig_compiler.loop;
385378 var comp = Compilation{
......@@ -395,8 +388,8 @@ pub const Compilation = struct {
395388 .zig_lib_dir = zig_lib_dir,
396389 .zig_std_dir = undefined,
397390 .tmp_dir = event.Future(BuildError![]u8).init(loop),
398 .destroy_handle = @handle(),
399 .main_loop_handle = undefined,
391 .destroy_frame = @frame(),
392 .main_loop_frame = undefined,
400393 .main_loop_future = event.Future(void).init(loop),
401394
402395 .name = undefined,
......@@ -546,7 +539,7 @@ pub const Compilation = struct {
546539 try comp.initTypes();
547540 defer comp.primitive_type_table.deinit();
548541
549 comp.main_loop_handle = async comp.mainLoop() catch unreachable;
542 comp.main_loop_frame = async comp.mainLoop() catch unreachable;
550543 // Set this to indicate that initialization completed successfully.
551544 // from here on out we must not return an error.
552545 // This must occur before the first suspend/await.
......@@ -555,7 +548,7 @@ pub const Compilation = struct {
555548 suspend;
556549 // From here on is cleanup.
557550
558 await (async comp.deinit_group.wait() catch unreachable);
551 comp.deinit_group.wait();
559552
560553 if (comp.tmp_dir.getOrNull()) |tmp_dir_result| if (tmp_dir_result.*) |tmp_dir| {
561554 // TODO evented I/O?
......@@ -578,10 +571,10 @@ pub const Compilation = struct {
578571 error.Overflow => return error.Overflow,
579572 error.InvalidCharacter => unreachable, // we just checked the characters above
580573 };
581 const int_type = try await (async Type.Int.get(comp, Type.Int.Key{
574 const int_type = try Type.Int.get(comp, Type.Int.Key{
582575 .bit_count = bit_count,
583576 .is_signed = is_signed,
584 }) catch unreachable);
577 });
585578 errdefer int_type.base.base.deref();
586579 return &int_type.base;
587580 },
......@@ -758,8 +751,8 @@ pub const Compilation = struct {
758751 }
759752
760753 pub fn destroy(self: *Compilation) void {
761 cancel self.main_loop_handle;
762 resume self.destroy_handle;
754 await self.main_loop_frame;
755 resume self.destroy_frame;
763756 }
764757
765758 fn start(self: *Compilation) void {
......@@ -768,13 +761,13 @@ pub const Compilation = struct {
768761
769762 async fn mainLoop(self: *Compilation) void {
770763 // wait until start() is called
771 _ = await (async self.main_loop_future.get() catch unreachable);
764 _ = self.main_loop_future.get();
772765
773 var build_result = await (async self.initialCompile() catch unreachable);
766 var build_result = self.initialCompile();
774767
775768 while (true) {
776769 const link_result = if (build_result) blk: {
777 break :blk await (async self.maybeLink() catch unreachable);
770 break :blk self.maybeLink();
778771 } else |err| err;
779772 // this makes a handy error return trace and stack trace in debug mode
780773 if (std.debug.runtime_safety) {
......@@ -782,28 +775,28 @@ pub const Compilation = struct {
782775 }
783776
784777 const compile_errors = blk: {
785 const held = await (async self.compile_errors.acquire() catch unreachable);
778 const held = self.compile_errors.acquire();
786779 defer held.release();
787780 break :blk held.value.toOwnedSlice();
788781 };
789782
790783 if (link_result) |_| {
791784 if (compile_errors.len == 0) {
792 await (async self.events.put(Event.Ok) catch unreachable);
785 self.events.put(Event.Ok);
793786 } else {
794 await (async self.events.put(Event{ .Fail = compile_errors }) catch unreachable);
787 self.events.put(Event{ .Fail = compile_errors });
795788 }
796789 } else |err| {
797790 // if there's an error then the compile errors have dangling references
798791 self.gpa().free(compile_errors);
799792
800 await (async self.events.put(Event{ .Error = err }) catch unreachable);
793 self.events.put(Event{ .Error = err });
801794 }
802795
803796 // First, get an item from the watch channel, waiting on the channel.
804797 var group = event.Group(BuildError!void).init(self.loop);
805798 {
806 const ev = (await (async self.fs_watch.channel.get() catch unreachable)) catch |err| {
799 const ev = (self.fs_watch.channel.get()) catch |err| {
807800 build_result = err;
808801 continue;
809802 };
......@@ -814,7 +807,7 @@ pub const Compilation = struct {
814807 };
815808 }
816809 // Next, get all the items from the channel that are buffered up.
817 while (await (async self.fs_watch.channel.getOrNull() catch unreachable)) |ev_or_err| {
810 while (self.fs_watch.channel.getOrNull()) |ev_or_err| {
818811 if (ev_or_err) |ev| {
819812 const root_scope = ev.data;
820813 group.call(rebuildFile, self, root_scope) catch |err| {
......@@ -826,17 +819,17 @@ pub const Compilation = struct {
826819 continue;
827820 }
828821 }
829 build_result = await (async group.wait() catch unreachable);
822 build_result = group.wait();
830823 }
831824 }
832825
833826 async fn rebuildFile(self: *Compilation, root_scope: *Scope.Root) !void {
834827 const tree_scope = blk: {
835 const source_code = (await (async fs.readFile(
828 const source_code = fs.readFile(
836829 self.loop,
837830 root_scope.realpath,
838831 max_src_size,
839 ) catch unreachable)) catch |err| {
832 ) catch |err| {
840833 try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err));
841834 return;
842835 };
......@@ -856,13 +849,13 @@ pub const Compilation = struct {
856849 const msg = try Msg.createFromParseErrorAndScope(self, tree_scope, parse_error);
857850 errdefer msg.destroy();
858851
859 try await (async self.addCompileErrorAsync(msg) catch unreachable);
852 try self.addCompileErrorAsync(msg);
860853 }
861854 if (tree_scope.tree.errors.len != 0) {
862855 return;
863856 }
864857
865 const locked_table = await (async root_scope.decls.table.acquireWrite() catch unreachable);
858 const locked_table = root_scope.decls.table.acquireWrite();
866859 defer locked_table.release();
867860
868861 var decl_group = event.Group(BuildError!void).init(self.loop);
......@@ -876,7 +869,7 @@ pub const Compilation = struct {
876869 tree_scope,
877870 );
878871
879 try await (async decl_group.wait() catch unreachable);
872 try decl_group.wait();
880873 }
881874
882875 async fn rebuildChangedDecls(
......@@ -988,20 +981,20 @@ pub const Compilation = struct {
988981 }
989982
990983 async fn maybeLink(self: *Compilation) !void {
991 (await (async self.prelink_group.wait() catch unreachable)) catch |err| switch (err) {
984 (self.prelink_group.wait()) catch |err| switch (err) {
992985 error.SemanticAnalysisFailed => {},
993986 else => return err,
994987 };
995988
996989 const any_prelink_errors = blk: {
997 const compile_errors = await (async self.compile_errors.acquire() catch unreachable);
990 const compile_errors = self.compile_errors.acquire();
998991 defer compile_errors.release();
999992
1000993 break :blk compile_errors.value.len != 0;
1001994 };
1002995
1003996 if (!any_prelink_errors) {
1004 try await (async link(self) catch unreachable);
997 try link(self);
1005998 }
1006999 }
10071000
......@@ -1013,12 +1006,12 @@ pub const Compilation = struct {
10131006 node: *ast.Node,
10141007 expected_type: ?*Type,
10151008 ) !*ir.Code {
1016 const unanalyzed_code = try await (async ir.gen(
1009 const unanalyzed_code = try ir.gen(
10171010 comp,
10181011 node,
10191012 tree_scope,
10201013 scope,
1021 ) catch unreachable);
1014 );
10221015 defer unanalyzed_code.destroy(comp.gpa());
10231016
10241017 if (comp.verbose_ir) {
......@@ -1026,11 +1019,11 @@ pub const Compilation = struct {
10261019 unanalyzed_code.dump();
10271020 }
10281021
1029 const analyzed_code = try await (async ir.analyze(
1022 const analyzed_code = try ir.analyze(
10301023 comp,
10311024 unanalyzed_code,
10321025 expected_type,
1033 ) catch unreachable);
1026 );
10341027 errdefer analyzed_code.destroy(comp.gpa());
10351028
10361029 if (comp.verbose_ir) {
......@@ -1050,13 +1043,13 @@ pub const Compilation = struct {
10501043 const void_type = Type.Void.get(comp);
10511044 defer void_type.base.base.deref(comp);
10521045
1053 const analyzed_code = (await (async genAndAnalyzeCode(
1046 const analyzed_code = genAndAnalyzeCode(
10541047 comp,
10551048 tree_scope,
10561049 scope,
10571050 comptime_node.expr,
10581051 &void_type.base,
1059 ) catch unreachable)) catch |err| switch (err) {
1052 ) catch |err| switch (err) {
10601053 // This poison value should not cause the errdefers to run. It simply means
10611054 // that comp.compile_errors is populated.
10621055 error.SemanticAnalysisFailed => return {},
......@@ -1112,14 +1105,14 @@ pub const Compilation = struct {
11121105 ) !void {
11131106 errdefer msg.destroy();
11141107
1115 const compile_errors = await (async self.compile_errors.acquire() catch unreachable);
1108 const compile_errors = self.compile_errors.acquire();
11161109 defer compile_errors.release();
11171110
11181111 try compile_errors.value.append(msg);
11191112 }
11201113
11211114 async fn verifyUniqueSymbol(self: *Compilation, decl: *Decl) !void {
1122 const exported_symbol_names = await (async self.exported_symbol_names.acquire() catch unreachable);
1115 const exported_symbol_names = self.exported_symbol_names.acquire();
11231116 defer exported_symbol_names.release();
11241117
11251118 if (try exported_symbol_names.value.put(decl.name, decl)) |other_decl| {
......@@ -1173,9 +1166,9 @@ pub const Compilation = struct {
11731166
11741167 /// cancels itself so no need to await or cancel the promise.
11751168 async fn startFindingNativeLibC(self: *Compilation) void {
1176 await (async self.loop.yield() catch unreachable);
1169 self.loop.yield();
11771170 // we don't care if it fails, we're just trying to kick off the future resolution
1178 _ = (await (async self.zig_compiler.getNativeLibC() catch unreachable)) catch return;
1171 _ = (self.zig_compiler.getNativeLibC()) catch return;
11791172 }
11801173
11811174 /// General Purpose Allocator. Must free when done.
......@@ -1191,8 +1184,8 @@ pub const Compilation = struct {
11911184 /// If the temporary directory for this compilation has not been created, it creates it.
11921185 /// Then it creates a random file name in that dir and returns it.
11931186 pub async fn createRandomOutputPath(self: *Compilation, suffix: []const u8) !Buffer {
1194 const tmp_dir = try await (async self.getTmpDir() catch unreachable);
1195 const file_prefix = await (async self.getRandomFileName() catch unreachable);
1187 const tmp_dir = try self.getTmpDir();
1188 const file_prefix = self.getRandomFileName();
11961189
11971190 const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", file_prefix[0..], suffix);
11981191 defer self.gpa().free(file_name);
......@@ -1207,14 +1200,14 @@ pub const Compilation = struct {
12071200 /// Then returns it. The directory is unique to this Compilation and cleaned up when
12081201 /// the Compilation deinitializes.
12091202 async fn getTmpDir(self: *Compilation) ![]const u8 {
1210 if (await (async self.tmp_dir.start() catch unreachable)) |ptr| return ptr.*;
1211 self.tmp_dir.data = await (async self.getTmpDirImpl() catch unreachable);
1203 if (self.tmp_dir.start()) |ptr| return ptr.*;
1204 self.tmp_dir.data = self.getTmpDirImpl();
12121205 self.tmp_dir.resolve();
12131206 return self.tmp_dir.data;
12141207 }
12151208
12161209 async fn getTmpDirImpl(self: *Compilation) ![]u8 {
1217 const comp_dir_name = await (async self.getRandomFileName() catch unreachable);
1210 const comp_dir_name = self.getRandomFileName();
12181211 const zig_dir_path = try getZigDir(self.gpa());
12191212 defer self.gpa().free(zig_dir_path);
12201213
......@@ -1233,7 +1226,7 @@ pub const Compilation = struct {
12331226 var rand_bytes: [9]u8 = undefined;
12341227
12351228 {
1236 const held = await (async self.zig_compiler.prng.acquire() catch unreachable);
1229 const held = self.zig_compiler.prng.acquire();
12371230 defer held.release();
12381231
12391232 held.value.random.bytes(rand_bytes[0..]);
......@@ -1256,7 +1249,7 @@ pub const Compilation = struct {
12561249 node: *ast.Node,
12571250 expected_type: *Type,
12581251 ) !*Value {
1259 const analyzed_code = try await (async comp.genAndAnalyzeCode(tree_scope, scope, node, expected_type) catch unreachable);
1252 const analyzed_code = try comp.genAndAnalyzeCode(tree_scope, scope, node, expected_type);
12601253 defer analyzed_code.destroy(comp.gpa());
12611254
12621255 return analyzed_code.getCompTimeResult(comp);
......@@ -1266,7 +1259,7 @@ pub const Compilation = struct {
12661259 const meta_type = &Type.MetaType.get(comp).base;
12671260 defer meta_type.base.deref(comp);
12681261
1269 const result_val = try await (async comp.analyzeConstValue(tree_scope, scope, node, meta_type) catch unreachable);
1262 const result_val = try comp.analyzeConstValue(tree_scope, scope, node, meta_type);
12701263 errdefer result_val.base.deref(comp);
12711264
12721265 return result_val.cast(Type).?;
......@@ -1274,9 +1267,9 @@ pub const Compilation = struct {
12741267
12751268 /// This declaration has been blessed as going into the final code generation.
12761269 pub async fn resolveDecl(comp: *Compilation, decl: *Decl) !void {
1277 if (await (async decl.resolution.start() catch unreachable)) |ptr| return ptr.*;
1270 if (decl.resolution.start()) |ptr| return ptr.*;
12781271
1279 decl.resolution.data = try await (async generateDecl(comp, decl) catch unreachable);
1272 decl.resolution.data = try generateDecl(comp, decl);
12801273 decl.resolution.resolve();
12811274 return decl.resolution.data;
12821275 }
......@@ -1298,7 +1291,7 @@ async fn generateDecl(comp: *Compilation, decl: *Decl) !void {
12981291 Decl.Id.Var => @panic("TODO"),
12991292 Decl.Id.Fn => {
13001293 const fn_decl = @fieldParentPtr(Decl.Fn, "base", decl);
1301 return await (async generateDeclFn(comp, fn_decl) catch unreachable);
1294 return generateDeclFn(comp, fn_decl);
13021295 },
13031296 Decl.Id.CompTime => @panic("TODO"),
13041297 }
......@@ -1307,12 +1300,12 @@ async fn generateDecl(comp: *Compilation, decl: *Decl) !void {
13071300async fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void {
13081301 const tree_scope = fn_decl.base.tree_scope;
13091302
1310 const body_node = fn_decl.fn_proto.body_node orelse return await (async generateDeclFnProto(comp, fn_decl) catch unreachable);
1303 const body_node = fn_decl.fn_proto.body_node orelse return generateDeclFnProto(comp, fn_decl);
13111304
13121305 const fndef_scope = try Scope.FnDef.create(comp, fn_decl.base.parent_scope);
13131306 defer fndef_scope.base.deref(comp);
13141307
1315 const fn_type = try await (async analyzeFnType(comp, tree_scope, fn_decl.base.parent_scope, fn_decl.fn_proto) catch unreachable);
1308 const fn_type = try analyzeFnType(comp, tree_scope, fn_decl.base.parent_scope, fn_decl.fn_proto);
13161309 defer fn_type.base.base.deref(comp);
13171310
13181311 var symbol_name = try std.Buffer.init(comp.gpa(), fn_decl.base.name);
......@@ -1356,12 +1349,12 @@ async fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void {
13561349 try fn_type.non_key.Normal.variable_list.append(var_scope);
13571350 }
13581351
1359 const analyzed_code = try await (async comp.genAndAnalyzeCode(
1352 const analyzed_code = try comp.genAndAnalyzeCode(
13601353 tree_scope,
13611354 fn_val.child_scope,
13621355 body_node,
13631356 fn_type.key.data.Normal.return_type,
1364 ) catch unreachable);
1357 );
13651358 errdefer analyzed_code.destroy(comp.gpa());
13661359
13671360 assert(fn_val.block_scope != null);
......@@ -1378,7 +1371,7 @@ async fn addFnToLinkSet(comp: *Compilation, fn_val: *Value.Fn) void {
13781371
13791372 fn_val.link_set_node.data = fn_val;
13801373
1381 const held = await (async comp.fn_link_set.acquire() catch unreachable);
1374 const held = comp.fn_link_set.acquire();
13821375 defer held.release();
13831376
13841377 held.value.append(fn_val.link_set_node);
......@@ -1398,7 +1391,7 @@ async fn analyzeFnType(
13981391 ast.Node.FnProto.ReturnType.Explicit => |n| n,
13991392 ast.Node.FnProto.ReturnType.InferErrorSet => |n| n,
14001393 };
1401 const return_type = try await (async comp.analyzeTypeExpr(tree_scope, scope, return_type_node) catch unreachable);
1394 const return_type = try comp.analyzeTypeExpr(tree_scope, scope, return_type_node);
14021395 return_type.base.deref(comp);
14031396
14041397 var params = ArrayList(Type.Fn.Param).init(comp.gpa());
......@@ -1414,7 +1407,7 @@ async fn analyzeFnType(
14141407 var it = fn_proto.params.iterator(0);
14151408 while (it.next()) |param_node_ptr| {
14161409 const param_node = param_node_ptr.*.cast(ast.Node.ParamDecl).?;
1417 const param_type = try await (async comp.analyzeTypeExpr(tree_scope, scope, param_node.type_node) catch unreachable);
1410 const param_type = try comp.analyzeTypeExpr(tree_scope, scope, param_node.type_node);
14181411 errdefer param_type.base.deref(comp);
14191412 try params.append(Type.Fn.Param{
14201413 .typ = param_type,
......@@ -1443,7 +1436,7 @@ async fn analyzeFnType(
14431436 comp.gpa().free(key.data.Normal.params);
14441437 };
14451438
1446 const fn_type = try await (async Type.Fn.get(comp, key) catch unreachable);
1439 const fn_type = try Type.Fn.get(comp, key);
14471440 key_consumed = true;
14481441 errdefer fn_type.base.base.deref(comp);
14491442
......@@ -1451,12 +1444,12 @@ async fn analyzeFnType(
14511444}
14521445
14531446async fn generateDeclFnProto(comp: *Compilation, fn_decl: *Decl.Fn) !void {
1454 const fn_type = try await (async analyzeFnType(
1447 const fn_type = try analyzeFnType(
14551448 comp,
14561449 fn_decl.base.tree_scope,
14571450 fn_decl.base.parent_scope,
14581451 fn_decl.fn_proto,
1459 ) catch unreachable);
1452 );
14601453 defer fn_type.base.base.deref(comp);
14611454
14621455 var symbol_name = try std.Buffer.init(comp.gpa(), fn_decl.base.name);
......@@ -1468,14 +1461,3 @@ async fn generateDeclFnProto(comp: *Compilation, fn_decl: *Decl.Fn) !void {
14681461 fn_decl.value = Decl.Fn.Val{ .FnProto = fn_proto_val };
14691462 symbol_name_consumed = true;
14701463}
1471
1472// TODO these are hacks which should probably be solved by the language
1473fn getAwaitResult(allocator: *Allocator, handle: var) @typeInfo(@typeOf(handle)).Promise.child.? {
1474 var result: ?@typeInfo(@typeOf(handle)).Promise.child.? = null;
1475 cancel (async<allocator> getAwaitResultAsync(handle, &result) catch unreachable);
1476 return result.?;
1477}
1478
1479async fn getAwaitResultAsync(handle: var, out: *?@typeInfo(@typeOf(handle)).Promise.child.?) void {
1480 out.* = await handle;
1481}
src-self-hosted/ir.zig+41-41
......@@ -116,16 +116,16 @@ pub const Inst = struct {
116116 Id.Return => return @fieldParentPtr(Return, "base", base).analyze(ira),
117117 Id.Const => return @fieldParentPtr(Const, "base", base).analyze(ira),
118118 Id.Call => return @fieldParentPtr(Call, "base", base).analyze(ira),
119 Id.DeclRef => return await (async @fieldParentPtr(DeclRef, "base", base).analyze(ira) catch unreachable),
120 Id.Ref => return await (async @fieldParentPtr(Ref, "base", base).analyze(ira) catch unreachable),
119 Id.DeclRef => return @fieldParentPtr(DeclRef, "base", base).analyze(ira),
120 Id.Ref => return @fieldParentPtr(Ref, "base", base).analyze(ira),
121121 Id.DeclVar => return @fieldParentPtr(DeclVar, "base", base).analyze(ira),
122122 Id.CheckVoidStmt => return @fieldParentPtr(CheckVoidStmt, "base", base).analyze(ira),
123123 Id.Phi => return @fieldParentPtr(Phi, "base", base).analyze(ira),
124124 Id.Br => return @fieldParentPtr(Br, "base", base).analyze(ira),
125125 Id.AddImplicitReturnType => return @fieldParentPtr(AddImplicitReturnType, "base", base).analyze(ira),
126 Id.PtrType => return await (async @fieldParentPtr(PtrType, "base", base).analyze(ira) catch unreachable),
127 Id.VarPtr => return await (async @fieldParentPtr(VarPtr, "base", base).analyze(ira) catch unreachable),
128 Id.LoadPtr => return await (async @fieldParentPtr(LoadPtr, "base", base).analyze(ira) catch unreachable),
126 Id.PtrType => return @fieldParentPtr(PtrType, "base", base).analyze(ira),
127 Id.VarPtr => return @fieldParentPtr(VarPtr, "base", base).analyze(ira),
128 Id.LoadPtr => return @fieldParentPtr(LoadPtr, "base", base).analyze(ira),
129129 }
130130 }
131131
......@@ -441,13 +441,13 @@ pub const Inst = struct {
441441 .volatility = self.params.volatility,
442442 });
443443 const elem_type = target.getKnownType();
444 const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
444 const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
445445 .child_type = elem_type,
446446 .mut = self.params.mut,
447447 .vol = self.params.volatility,
448448 .size = Type.Pointer.Size.One,
449449 .alignment = Type.Pointer.Align.Abi,
450 }) catch unreachable);
450 });
451451 // TODO: potentially set the hint that this is a stack pointer. But it might not be - this
452452 // could be a ref of a global, for example
453453 new_inst.val = IrVal{ .KnownType = &ptr_type.base };
......@@ -474,7 +474,7 @@ pub const Inst = struct {
474474 }
475475
476476 pub async fn analyze(self: *const DeclRef, ira: *Analyze) !*Inst {
477 (await (async ira.irb.comp.resolveDecl(self.params.decl) catch unreachable)) catch |err| switch (err) {
477 (ira.irb.comp.resolveDecl(self.params.decl)) catch |err| switch (err) {
478478 error.OutOfMemory => return error.OutOfMemory,
479479 else => return error.SemanticAnalysisFailed,
480480 };
......@@ -527,13 +527,13 @@ pub const Inst = struct {
527527 self.base.span,
528528 Inst.VarPtr.Params{ .var_scope = self.params.var_scope },
529529 );
530 const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
530 const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
531531 .child_type = param.typ,
532532 .mut = Type.Pointer.Mut.Const,
533533 .vol = Type.Pointer.Vol.Non,
534534 .size = Type.Pointer.Size.One,
535535 .alignment = Type.Pointer.Align.Abi,
536 }) catch unreachable);
536 });
537537 new_inst.val = IrVal{ .KnownType = &ptr_type.base };
538538 return new_inst;
539539 },
......@@ -661,13 +661,13 @@ pub const Inst = struct {
661661 } else blk: {
662662 break :blk Type.Pointer.Align{ .Abi = {} };
663663 };
664 const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
664 const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
665665 .child_type = child_type,
666666 .mut = self.params.mut,
667667 .vol = self.params.vol,
668668 .size = self.params.size,
669669 .alignment = alignment,
670 }) catch unreachable);
670 });
671671 ptr_type.base.base.deref(ira.irb.comp);
672672
673673 return ira.irb.buildConstValue(self.base.scope, self.base.span, &ptr_type.base.base);
......@@ -1101,7 +1101,7 @@ pub const Builder = struct {
11011101 ast.Node.PrefixOp.Op.NegationWrap => return error.Unimplemented,
11021102 ast.Node.PrefixOp.Op.Resume => return error.Unimplemented,
11031103 ast.Node.PrefixOp.Op.PtrType => |ptr_info| {
1104 const inst = try await (async irb.genPtrType(prefix_op, ptr_info, scope) catch unreachable);
1104 const inst = try irb.genPtrType(prefix_op, ptr_info, scope);
11051105 return irb.lvalWrap(scope, inst, lval);
11061106 },
11071107 ast.Node.PrefixOp.Op.SliceType => |ptr_info| return error.Unimplemented,
......@@ -1112,7 +1112,7 @@ pub const Builder = struct {
11121112 const suffix_op = @fieldParentPtr(ast.Node.SuffixOp, "base", node);
11131113 switch (suffix_op.op) {
11141114 @TagType(ast.Node.SuffixOp.Op).Call => |*call| {
1115 const inst = try await (async irb.genCall(suffix_op, call, scope) catch unreachable);
1115 const inst = try irb.genCall(suffix_op, call, scope);
11161116 return irb.lvalWrap(scope, inst, lval);
11171117 },
11181118 @TagType(ast.Node.SuffixOp.Op).ArrayAccess => |n| return error.Unimplemented,
......@@ -1129,7 +1129,7 @@ pub const Builder = struct {
11291129 ast.Node.Id.If => return error.Unimplemented,
11301130 ast.Node.Id.ControlFlowExpression => {
11311131 const control_flow_expr = @fieldParentPtr(ast.Node.ControlFlowExpression, "base", node);
1132 return await (async irb.genControlFlowExpr(control_flow_expr, scope, lval) catch unreachable);
1132 return irb.genControlFlowExpr(control_flow_expr, scope, lval);
11331133 },
11341134 ast.Node.Id.Suspend => return error.Unimplemented,
11351135 ast.Node.Id.VarType => return error.Unimplemented,
......@@ -1143,7 +1143,7 @@ pub const Builder = struct {
11431143 ast.Node.Id.FloatLiteral => return error.Unimplemented,
11441144 ast.Node.Id.StringLiteral => {
11451145 const str_lit = @fieldParentPtr(ast.Node.StringLiteral, "base", node);
1146 const inst = try await (async irb.genStrLit(str_lit, scope) catch unreachable);
1146 const inst = try irb.genStrLit(str_lit, scope);
11471147 return irb.lvalWrap(scope, inst, lval);
11481148 },
11491149 ast.Node.Id.MultilineStringLiteral => return error.Unimplemented,
......@@ -1154,11 +1154,11 @@ pub const Builder = struct {
11541154 ast.Node.Id.Unreachable => return error.Unimplemented,
11551155 ast.Node.Id.Identifier => {
11561156 const identifier = @fieldParentPtr(ast.Node.Identifier, "base", node);
1157 return await (async irb.genIdentifier(identifier, scope, lval) catch unreachable);
1157 return irb.genIdentifier(identifier, scope, lval);
11581158 },
11591159 ast.Node.Id.GroupedExpression => {
11601160 const grouped_expr = @fieldParentPtr(ast.Node.GroupedExpression, "base", node);
1161 return await (async irb.genNode(grouped_expr.expr, scope, lval) catch unreachable);
1161 return irb.genNode(grouped_expr.expr, scope, lval);
11621162 },
11631163 ast.Node.Id.BuiltinCall => return error.Unimplemented,
11641164 ast.Node.Id.ErrorSetDecl => return error.Unimplemented,
......@@ -1167,7 +1167,7 @@ pub const Builder = struct {
11671167 ast.Node.Id.Comptime => return error.Unimplemented,
11681168 ast.Node.Id.Block => {
11691169 const block = @fieldParentPtr(ast.Node.Block, "base", node);
1170 const inst = try await (async irb.genBlock(block, scope) catch unreachable);
1170 const inst = try irb.genBlock(block, scope);
11711171 return irb.lvalWrap(scope, inst, lval);
11721172 },
11731173 ast.Node.Id.DocComment => return error.Unimplemented,
......@@ -1188,13 +1188,13 @@ pub const Builder = struct {
11881188 }
11891189
11901190 async fn genCall(irb: *Builder, suffix_op: *ast.Node.SuffixOp, call: *ast.Node.SuffixOp.Op.Call, scope: *Scope) !*Inst {
1191 const fn_ref = try await (async irb.genNode(suffix_op.lhs, scope, LVal.None) catch unreachable);
1191 const fn_ref = try irb.genNode(suffix_op.lhs, scope, LVal.None);
11921192
11931193 const args = try irb.arena().alloc(*Inst, call.params.len);
11941194 var it = call.params.iterator(0);
11951195 var i: usize = 0;
11961196 while (it.next()) |arg_node_ptr| : (i += 1) {
1197 args[i] = try await (async irb.genNode(arg_node_ptr.*, scope, LVal.None) catch unreachable);
1197 args[i] = try irb.genNode(arg_node_ptr.*, scope, LVal.None);
11981198 }
11991199
12001200 //bool is_async = node->data.fn_call_expr.is_async;
......@@ -1239,7 +1239,7 @@ pub const Builder = struct {
12391239 //} else {
12401240 // align_value = nullptr;
12411241 //}
1242 const child_type = try await (async irb.genNode(prefix_op.rhs, scope, LVal.None) catch unreachable);
1242 const child_type = try irb.genNode(prefix_op.rhs, scope, LVal.None);
12431243
12441244 //uint32_t bit_offset_start = 0;
12451245 //if (node->data.pointer_type.bit_offset_start != nullptr) {
......@@ -1366,23 +1366,23 @@ pub const Builder = struct {
13661366 buf[buf.len - 1] = 0;
13671367
13681368 // next make an array value
1369 const array_val = try await (async Value.Array.createOwnedBuffer(irb.comp, buf) catch unreachable);
1369 const array_val = try Value.Array.createOwnedBuffer(irb.comp, buf);
13701370 buf_cleaned = true;
13711371 defer array_val.base.deref(irb.comp);
13721372
13731373 // then make a pointer value pointing at the first element
1374 const ptr_val = try await (async Value.Ptr.createArrayElemPtr(
1374 const ptr_val = try Value.Ptr.createArrayElemPtr(
13751375 irb.comp,
13761376 array_val,
13771377 Type.Pointer.Mut.Const,
13781378 Type.Pointer.Size.Many,
13791379 0,
1380 ) catch unreachable);
1380 );
13811381 defer ptr_val.base.deref(irb.comp);
13821382
13831383 return irb.buildConstValue(scope, src_span, &ptr_val.base);
13841384 } else {
1385 const array_val = try await (async Value.Array.createOwnedBuffer(irb.comp, buf) catch unreachable);
1385 const array_val = try Value.Array.createOwnedBuffer(irb.comp, buf);
13861386 buf_cleaned = true;
13871387 defer array_val.base.deref(irb.comp);
13881388
......@@ -1438,7 +1438,7 @@ pub const Builder = struct {
14381438 child_scope = &defer_child_scope.base;
14391439 continue;
14401440 }
1441 const statement_value = try await (async irb.genNode(statement_node, child_scope, LVal.None) catch unreachable);
1441 const statement_value = try irb.genNode(statement_node, child_scope, LVal.None);
14421442
14431443 is_continuation_unreachable = statement_value.isNoReturn();
14441444 if (is_continuation_unreachable) {
......@@ -1481,7 +1481,7 @@ pub const Builder = struct {
14811481 try block_scope.incoming_values.append(
14821482 try irb.buildConstVoid(parent_scope, Span.token(block.rbrace), true),
14831483 );
1484 _ = try await (async irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
1484 _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit);
14851485
14861486 _ = try irb.buildGen(Inst.Br, parent_scope, Span.token(block.rbrace), Inst.Br.Params{
14871487 .dest_block = block_scope.end_block,
......@@ -1496,7 +1496,7 @@ pub const Builder = struct {
14961496 });
14971497 }
14981498
1499 _ = try await (async irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
1499 _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit);
15001500 return irb.buildConstVoid(child_scope, Span.token(block.rbrace), true);
15011501 }
15021502
......@@ -1534,7 +1534,7 @@ pub const Builder = struct {
15341534
15351535 const outer_scope = irb.begin_scope.?;
15361536 const return_value = if (control_flow_expr.rhs) |rhs| blk: {
1537 break :blk try await (async irb.genNode(rhs, scope, LVal.None) catch unreachable);
1537 break :blk try irb.genNode(rhs, scope, LVal.None);
15381538 } else blk: {
15391539 break :blk try irb.buildConstVoid(scope, src_span, true);
15401540 };
......@@ -1545,7 +1545,7 @@ pub const Builder = struct {
15451545 const err_block = try irb.createBasicBlock(scope, c"ErrRetErr");
15461546 const ok_block = try irb.createBasicBlock(scope, c"ErrRetOk");
15471547 if (!have_err_defers) {
1548 _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
1548 _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit);
15491549 }
15501550
15511551 const is_err = try irb.build(
......@@ -1568,7 +1568,7 @@ pub const Builder = struct {
15681568
15691569 try irb.setCursorAtEndAndAppendBlock(err_block);
15701570 if (have_err_defers) {
1571 _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ErrorExit) catch unreachable);
1571 _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ErrorExit);
15721572 }
15731573 if (irb.comp.have_err_ret_tracing and !irb.isCompTime(scope)) {
15741574 _ = try irb.build(Inst.SaveErrRetAddr, scope, src_span, Inst.SaveErrRetAddr.Params{});
......@@ -1580,7 +1580,7 @@ pub const Builder = struct {
15801580
15811581 try irb.setCursorAtEndAndAppendBlock(ok_block);
15821582 if (have_err_defers) {
1583 _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
1583 _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit);
15841584 }
15851585 _ = try irb.build(Inst.Br, scope, src_span, Inst.Br.Params{
15861586 .dest_block = ret_stmt_block,
......@@ -1590,7 +1590,7 @@ pub const Builder = struct {
15901590 try irb.setCursorAtEndAndAppendBlock(ret_stmt_block);
15911591 return irb.genAsyncReturn(scope, src_span, return_value, false);
15921592 } else {
1593 _ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
1593 _ = try irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit);
15941594 return irb.genAsyncReturn(scope, src_span, return_value, false);
15951595 }
15961596 },
......@@ -1610,7 +1610,7 @@ pub const Builder = struct {
16101610 // return &const_instruction->base;
16111611 //}
16121612
1613 if (await (async irb.comp.getPrimitiveType(name) catch unreachable)) |result| {
1613 if (irb.comp.getPrimitiveType(name)) |result| {
16141614 if (result) |primitive_type| {
16151615 defer primitive_type.base.deref(irb.comp);
16161616 switch (lval) {
......@@ -1628,7 +1628,7 @@ pub const Builder = struct {
16281628 error.OutOfMemory => return error.OutOfMemory,
16291629 }
16301630
1631 switch (await (async irb.findIdent(scope, name) catch unreachable)) {
1631 switch (irb.findIdent(scope, name)) {
16321632 Ident.Decl => |decl| {
16331633 return irb.build(Inst.DeclRef, scope, src_span, Inst.DeclRef.Params{
16341634 .decl = decl,
......@@ -1713,11 +1713,11 @@ pub const Builder = struct {
17131713 };
17141714 if (generate) {
17151715 const defer_expr_scope = defer_scope.defer_expr_scope;
1716 const instruction = try await (async irb.genNode(
1716 const instruction = try irb.genNode(
17171717 defer_expr_scope.expr_node,
17181718 &defer_expr_scope.base,
17191719 LVal.None,
1720 ) catch unreachable);
1720 );
17211721 if (instruction.isNoReturn()) {
17221722 is_noreturn = true;
17231723 } else {
......@@ -1918,7 +1918,7 @@ pub const Builder = struct {
19181918 Scope.Id.Root => return Ident.NotFound,
19191919 Scope.Id.Decls => {
19201920 const decls = @fieldParentPtr(Scope.Decls, "base", s);
1921 const locked_table = await (async decls.table.acquireRead() catch unreachable);
1921 const locked_table = decls.table.acquireRead();
19221922 defer locked_table.release();
19231923 if (locked_table.value.get(name)) |entry| {
19241924 return Ident{ .Decl = entry.value };
......@@ -2534,7 +2534,7 @@ pub async fn gen(
25342534 entry_block.ref(&irb); // Entry block gets a reference because we enter it to begin.
25352535 try irb.setCursorAtEndAndAppendBlock(entry_block);
25362536
2537 const result = try await (async irb.genNode(body_node, scope, LVal.None) catch unreachable);
2537 const result = try irb.genNode(body_node, scope, LVal.None);
25382538 if (!result.isNoReturn()) {
25392539 // no need for save_err_ret_addr because this cannot return error
25402540 _ = try irb.genAsyncReturn(scope, Span.token(body_node.lastToken()), result, true);
......@@ -2564,7 +2564,7 @@ pub async fn analyze(comp: *Compilation, old_code: *Code, expected_type: ?*Type)
25642564 continue;
25652565 }
25662566
2567 const return_inst = try await (async old_instruction.analyze(&ira) catch unreachable);
2567 const return_inst = try old_instruction.analyze(&ira);
25682568 assert(return_inst.val != IrVal.Unknown); // at least the type should be known at this point
25692569 return_inst.linkToParent(old_instruction);
25702570 // Note: if we ever modify the above to handle error.CompileError by continuing analysis,
src-self-hosted/libc_installation.zig+6-6
......@@ -178,7 +178,7 @@ pub const LibCInstallation = struct {
178178 },
179179 else => @compileError("unimplemented: find libc for this OS"),
180180 }
181 return await (async group.wait() catch unreachable);
181 return group.wait();
182182 }
183183
184184 async fn findNativeIncludeDirLinux(self: *LibCInstallation, loop: *event.Loop) !void {
......@@ -301,11 +301,11 @@ pub const LibCInstallation = struct {
301301 }
302302
303303 async fn findNativeLibDirLinux(self: *LibCInstallation, loop: *event.Loop) FindError!void {
304 self.lib_dir = try await (async ccPrintFileName(loop, "crt1.o", true) catch unreachable);
304 self.lib_dir = try ccPrintFileName(loop, "crt1.o", true);
305305 }
306306
307307 async fn findNativeStaticLibDir(self: *LibCInstallation, loop: *event.Loop) FindError!void {
308 self.static_lib_dir = try await (async ccPrintFileName(loop, "crtbegin.o", true) catch unreachable);
308 self.static_lib_dir = try ccPrintFileName(loop, "crtbegin.o", true);
309309 }
310310
311311 async fn findNativeDynamicLinker(self: *LibCInstallation, loop: *event.Loop) FindError!void {
......@@ -324,7 +324,7 @@ pub const LibCInstallation = struct {
324324 for (dyn_tests) |*dyn_test| {
325325 try group.call(testNativeDynamicLinker, self, loop, dyn_test);
326326 }
327 try await (async group.wait() catch unreachable);
327 try group.wait();
328328 for (dyn_tests) |*dyn_test| {
329329 if (dyn_test.result) |result| {
330330 self.dynamic_linker_path = result;
......@@ -339,7 +339,7 @@ pub const LibCInstallation = struct {
339339 };
340340
341341 async fn testNativeDynamicLinker(self: *LibCInstallation, loop: *event.Loop, dyn_test: *DynTest) FindError!void {
342 if (await (async ccPrintFileName(loop, dyn_test.name, false) catch unreachable)) |result| {
342 if (ccPrintFileName(loop, dyn_test.name, false)) |result| {
343343 dyn_test.result = result;
344344 return;
345345 } else |err| switch (err) {
......@@ -398,7 +398,7 @@ async fn ccPrintFileName(loop: *event.Loop, o_file: []const u8, want_dirname: bo
398398 const argv = [_][]const u8{ cc_exe, arg1 };
399399
400400 // TODO This simulates evented I/O for the child process exec
401 await (async loop.yield() catch unreachable);
401 loop.yield();
402402 const errorable_result = std.ChildProcess.exec(loop.allocator, argv, null, null, 1024 * 1024);
403403 const exec_result = if (std.debug.runtime_safety) blk: {
404404 break :blk errorable_result catch unreachable;
src-self-hosted/link.zig+2-2
......@@ -61,7 +61,7 @@ pub async fn link(comp: *Compilation) !void {
6161 ctx.libc = ctx.comp.override_libc orelse blk: {
6262 switch (comp.target) {
6363 Target.Native => {
64 break :blk (await (async comp.zig_compiler.getNativeLibC() catch unreachable)) catch return error.LibCRequiredButNotProvidedOrFound;
64 break :blk comp.zig_compiler.getNativeLibC() catch return error.LibCRequiredButNotProvidedOrFound;
6565 },
6666 else => return error.LibCRequiredButNotProvidedOrFound,
6767 }
......@@ -83,7 +83,7 @@ pub async fn link(comp: *Compilation) !void {
8383
8484 {
8585 // LLD is not thread-safe, so we grab a global lock.
86 const held = await (async comp.zig_compiler.lld_lock.acquire() catch unreachable);
86 const held = comp.zig_compiler.lld_lock.acquire();
8787 defer held.release();
8888
8989 // Not evented I/O. LLD does its own multithreading internally.
src-self-hosted/main.zig+12-28
......@@ -466,7 +466,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
466466 comp.link_objects = link_objects;
467467
468468 comp.start();
469 // TODO const process_build_events_handle = try async<loop.allocator> processBuildEvents(comp, color);
469 const frame = try async processBuildEvents(comp, color);
470470 loop.run();
471471}
472472
......@@ -474,7 +474,7 @@ async fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void {
474474 var count: usize = 0;
475475 while (true) {
476476 // TODO directly awaiting async should guarantee memory allocation elision
477 const build_event = await (async comp.events.get() catch unreachable);
477 const build_event = comp.events.get();
478478 count += 1;
479479
480480 switch (build_event) {
......@@ -577,13 +577,13 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void {
577577 var zig_compiler = try ZigCompiler.init(&loop);
578578 defer zig_compiler.deinit();
579579
580 // TODO const handle = try async<loop.allocator> findLibCAsync(&zig_compiler);
580 const frame = async findLibCAsync(&zig_compiler);
581581
582582 loop.run();
583583}
584584
585585async fn findLibCAsync(zig_compiler: *ZigCompiler) void {
586 const libc = (await (async zig_compiler.getNativeLibC() catch unreachable)) catch |err| {
586 const libc = zig_compiler.getNativeLibC() catch |err| {
587587 stderr.print("unable to find libc: {}\n", @errorName(err)) catch process.exit(1);
588588 process.exit(1);
589589 };
......@@ -660,24 +660,11 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void {
660660 try loop.initMultiThreaded(allocator);
661661 defer loop.deinit();
662662
663 var result: FmtError!void = undefined;
664 // TODO const main_handle = try async<allocator> asyncFmtMainChecked(
665 // TODO &result,
666 // TODO &loop,
667 // TODO &flags,
668 // TODO color,
669 // TODO );
670 loop.run();
671 return result;
672}
673
674async fn asyncFmtMainChecked(
675 result: *(FmtError!void),
676 loop: *event.Loop,
677 flags: *const Args,
678 color: errmsg.Color,
679) void {
680 result.* = await (async asyncFmtMain(loop, flags, color) catch unreachable);
663 return asyncFmtMain(
664 &flags,
665 color,
666 );
667 // loop.run();
681668}
682669
683670const FmtError = error{
......@@ -707,9 +694,6 @@ async fn asyncFmtMain(
707694 flags: *const Args,
708695 color: errmsg.Color,
709696) FmtError!void {
710 suspend {
711 resume @handle();
712 }
713697 var fmt = Fmt{
714698 .seen = event.Locked(Fmt.SeenMap).init(loop, Fmt.SeenMap.init(loop.allocator)),
715699 .any_error = false,
......@@ -723,7 +707,7 @@ async fn asyncFmtMain(
723707 for (flags.positionals.toSliceConst()) |file_path| {
724708 try group.call(fmtPath, &fmt, file_path, check_mode);
725709 }
726 try await (async group.wait() catch unreachable);
710 try group.wait();
727711 if (fmt.any_error) {
728712 process.exit(1);
729713 }
......@@ -734,7 +718,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
734718 defer fmt.loop.allocator.free(file_path);
735719
736720 {
737 const held = await (async fmt.seen.acquire() catch unreachable);
721 const held = fmt.seen.acquire();
738722 defer held.release();
739723
740724 if (try held.value.put(file_path, {})) |_| return;
......@@ -757,7 +741,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
757741 try group.call(fmtPath, fmt, full_path, check_mode);
758742 }
759743 }
760 return await (async group.wait() catch unreachable);
744 return group.wait();
761745 },
762746 else => {
763747 // TODO lock stderr printing
src-self-hosted/test.zig+4-4
......@@ -68,13 +68,13 @@ pub const TestContext = struct {
6868
6969 fn run(self: *TestContext) !void {
7070 const handle = try self.loop.call(waitForGroup, self);
71 defer cancel handle;
71 defer await handle;
7272 self.loop.run();
7373 return self.any_err;
7474 }
7575
7676 async fn waitForGroup(self: *TestContext) void {
77 self.any_err = await (async self.group.wait() catch unreachable);
77 self.any_err = self.group.wait();
7878 }
7979
8080 fn testCompileError(
......@@ -158,7 +158,7 @@ pub const TestContext = struct {
158158 const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file);
159159
160160 defer comp.destroy();
161 const build_event = await (async comp.events.get() catch unreachable);
161 const build_event = comp.events.get();
162162
163163 switch (build_event) {
164164 Compilation.Event.Ok => {
......@@ -200,7 +200,7 @@ pub const TestContext = struct {
200200 text: []const u8,
201201 ) !void {
202202 defer comp.destroy();
203 const build_event = await (async comp.events.get() catch unreachable);
203 const build_event = comp.events.get();
204204
205205 switch (build_event) {
206206 Compilation.Event.Ok => {
src-self-hosted/type.zig+18-25
......@@ -181,7 +181,7 @@ pub const Type = struct {
181181 /// If you happen to have an llvm context handy, use getAbiAlignmentInContext instead.
182182 /// Otherwise, this one will grab one from the pool and then release it.
183183 pub async fn getAbiAlignment(base: *Type, comp: *Compilation) !u32 {
184 if (await (async base.abi_alignment.start() catch unreachable)) |ptr| return ptr.*;
184 if (base.abi_alignment.start()) |ptr| return ptr.*;
185185
186186 {
187187 const held = try comp.zig_compiler.getAnyLlvmContext();
......@@ -189,7 +189,7 @@ pub const Type = struct {
189189
190190 const llvm_context = held.node.data;
191191
192 base.abi_alignment.data = await (async base.resolveAbiAlignment(comp, llvm_context) catch unreachable);
192 base.abi_alignment.data = base.resolveAbiAlignment(comp, llvm_context);
193193 }
194194 base.abi_alignment.resolve();
195195 return base.abi_alignment.data;
......@@ -197,9 +197,9 @@ pub const Type = struct {
197197
198198 /// If you have an llvm conext handy, you can use it here.
199199 pub async fn getAbiAlignmentInContext(base: *Type, comp: *Compilation, llvm_context: *llvm.Context) !u32 {
200 if (await (async base.abi_alignment.start() catch unreachable)) |ptr| return ptr.*;
200 if (base.abi_alignment.start()) |ptr| return ptr.*;
201201
202 base.abi_alignment.data = await (async base.resolveAbiAlignment(comp, llvm_context) catch unreachable);
202 base.abi_alignment.data = base.resolveAbiAlignment(comp, llvm_context);
203203 base.abi_alignment.resolve();
204204 return base.abi_alignment.data;
205205 }
......@@ -401,7 +401,7 @@ pub const Type = struct {
401401 /// takes ownership of key.Normal.params on success
402402 pub async fn get(comp: *Compilation, key: Key) !*Fn {
403403 {
404 const held = await (async comp.fn_type_table.acquire() catch unreachable);
404 const held = comp.fn_type_table.acquire();
405405 defer held.release();
406406
407407 if (held.value.get(&key)) |entry| {
......@@ -430,15 +430,8 @@ pub const Type = struct {
430430 switch (key.data) {
431431 Kind.Generic => |generic| {
432432 self.non_key = NonKey{ .Generic = {} };
433 switch (generic.cc) {
434 CallingConvention.Async => |async_allocator_type| {
435 try name_stream.print("async<{}> ", async_allocator_type.name);
436 },
437 else => {
438 const cc_str = ccFnTypeStr(generic.cc);
439 try name_stream.write(cc_str);
440 },
441 }
433 const cc_str = ccFnTypeStr(generic.cc);
434 try name_stream.write(cc_str);
442435 try name_stream.write("fn(");
443436 var param_i: usize = 0;
444437 while (param_i < generic.param_count) : (param_i += 1) {
......@@ -477,7 +470,7 @@ pub const Type = struct {
477470 self.base.init(comp, Id.Fn, name_buf.toOwnedSlice());
478471
479472 {
480 const held = await (async comp.fn_type_table.acquire() catch unreachable);
473 const held = comp.fn_type_table.acquire();
481474 defer held.release();
482475
483476 _ = try held.value.put(&self.key, self);
......@@ -606,7 +599,7 @@ pub const Type = struct {
606599
607600 pub async fn get(comp: *Compilation, key: Key) !*Int {
608601 {
609 const held = await (async comp.int_type_table.acquire() catch unreachable);
602 const held = comp.int_type_table.acquire();
610603 defer held.release();
611604
612605 if (held.value.get(&key)) |entry| {
......@@ -630,7 +623,7 @@ pub const Type = struct {
630623 self.base.init(comp, Id.Int, name);
631624
632625 {
633 const held = await (async comp.int_type_table.acquire() catch unreachable);
626 const held = comp.int_type_table.acquire();
634627 defer held.release();
635628
636629 _ = try held.value.put(&self.key, self);
......@@ -648,7 +641,7 @@ pub const Type = struct {
648641
649642 pub async fn gcDestroy(self: *Int, comp: *Compilation) void {
650643 {
651 const held = await (async comp.int_type_table.acquire() catch unreachable);
644 const held = comp.int_type_table.acquire();
652645 defer held.release();
653646
654647 _ = held.value.remove(&self.key).?;
......@@ -742,7 +735,7 @@ pub const Type = struct {
742735
743736 pub async fn gcDestroy(self: *Pointer, comp: *Compilation) void {
744737 {
745 const held = await (async comp.ptr_type_table.acquire() catch unreachable);
738 const held = comp.ptr_type_table.acquire();
746739 defer held.release();
747740
748741 _ = held.value.remove(&self.key).?;
......@@ -753,7 +746,7 @@ pub const Type = struct {
753746
754747 pub async fn getAlignAsInt(self: *Pointer, comp: *Compilation) u32 {
755748 switch (self.key.alignment) {
756 Align.Abi => return await (async self.key.child_type.getAbiAlignment(comp) catch unreachable),
749 Align.Abi => return self.key.child_type.getAbiAlignment(comp),
757750 Align.Override => |alignment| return alignment,
758751 }
759752 }
......@@ -766,14 +759,14 @@ pub const Type = struct {
766759 switch (key.alignment) {
767760 Align.Abi => {},
768761 Align.Override => |alignment| {
769 const abi_align = try await (async key.child_type.getAbiAlignment(comp) catch unreachable);
762 const abi_align = try key.child_type.getAbiAlignment(comp);
770763 if (abi_align == alignment) {
771764 normal_key.alignment = Align.Abi;
772765 }
773766 },
774767 }
775768 {
776 const held = await (async comp.ptr_type_table.acquire() catch unreachable);
769 const held = comp.ptr_type_table.acquire();
777770 defer held.release();
778771
779772 if (held.value.get(&normal_key)) |entry| {
......@@ -828,7 +821,7 @@ pub const Type = struct {
828821 self.base.init(comp, Id.Pointer, name);
829822
830823 {
831 const held = await (async comp.ptr_type_table.acquire() catch unreachable);
824 const held = comp.ptr_type_table.acquire();
832825 defer held.release();
833826
834827 _ = try held.value.put(&self.key, self);
......@@ -873,7 +866,7 @@ pub const Type = struct {
873866 errdefer key.elem_type.base.deref(comp);
874867
875868 {
876 const held = await (async comp.array_type_table.acquire() catch unreachable);
869 const held = comp.array_type_table.acquire();
877870 defer held.release();
878871
879872 if (held.value.get(&key)) |entry| {
......@@ -896,7 +889,7 @@ pub const Type = struct {
896889 self.base.init(comp, Id.Array, name);
897890
898891 {
899 const held = await (async comp.array_type_table.acquire() catch unreachable);
892 const held = comp.array_type_table.acquire();
900893 defer held.release();
901894
902895 _ = try held.value.put(&self.key, self);
src-self-hosted/value.zig+4-4
......@@ -346,13 +346,13 @@ pub const Value = struct {
346346 errdefer array_val.base.deref(comp);
347347
348348 const elem_type = array_val.base.typ.cast(Type.Array).?.key.elem_type;
349 const ptr_type = try await (async Type.Pointer.get(comp, Type.Pointer.Key{
349 const ptr_type = try Type.Pointer.get(comp, Type.Pointer.Key{
350350 .child_type = elem_type,
351351 .mut = mut,
352352 .vol = Type.Pointer.Vol.Non,
353353 .size = size,
354354 .alignment = Type.Pointer.Align.Abi,
355 }) catch unreachable);
355 });
356356 var ptr_type_consumed = false;
357357 errdefer if (!ptr_type_consumed) ptr_type.base.base.deref(comp);
358358
......@@ -428,10 +428,10 @@ pub const Value = struct {
428428 const u8_type = Type.Int.get_u8(comp);
429429 defer u8_type.base.base.deref(comp);
430430
431 const array_type = try await (async Type.Array.get(comp, Type.Array.Key{
431 const array_type = try Type.Array.get(comp, Type.Array.Key{
432432 .elem_type = &u8_type.base,
433433 .len = buffer.len,
434 }) catch unreachable);
434 });
435435 errdefer array_type.base.base.deref(comp);
436436
437437 const self = try comp.gpa().create(Value.Array);