| author | |
| committer | |
| log | 128034481ab6eb02da4114b4d49ec3cfd4f8451c |
| tree | 3c17b89ab0d8418f2f3005af73f838d12ac4037c |
| parent | 36849d8a7b5b0ed62d966ea9c402f192ade0cadf |
| signature |
8 files changed, 75 insertions(+), 54 deletions(-)
lib/std/event/fs.zig+14-12| ... | @@ -735,24 +735,26 @@ pub fn Watch(comptime V: type) type { | ... | @@ -735,24 +735,26 @@ pub fn Watch(comptime V: type) type { |
| 735 | allocator: *Allocator, | 735 | allocator: *Allocator, |
| 736 | 736 | ||
| 737 | const OsData = switch (builtin.os) { | 737 | const OsData = switch (builtin.os) { |
| 738 | .macosx, .freebsd, .netbsd, .dragonfly => struct { | 738 | // TODO https://github.com/ziglang/zig/issues/3778 |
| 739 | file_table: FileTable, | 739 | .macosx, .freebsd, .netbsd, .dragonfly => KqOsData, |
| 740 | table_lock: event.Lock, | ||
| 741 | |||
| 742 | const FileTable = std.StringHashMap(*Put); | ||
| 743 | const Put = struct { | ||
| 744 | putter_frame: @Frame(kqPutEvents), | ||
| 745 | cancelled: bool = false, | ||
| 746 | value: V, | ||
| 747 | }; | ||
| 748 | }, | ||
| 749 | |||
| 750 | .linux => LinuxOsData, | 740 | .linux => LinuxOsData, |
| 751 | .windows => WindowsOsData, | 741 | .windows => WindowsOsData, |
| 752 | 742 | ||
| 753 | else => @compileError("Unsupported OS"), | 743 | else => @compileError("Unsupported OS"), |
| 754 | }; | 744 | }; |
| 755 | 745 | ||
| 746 | const KqOsData = struct { | ||
| 747 | file_table: FileTable, | ||
| 748 | table_lock: event.Lock, | ||
| 749 | |||
| 750 | const FileTable = std.StringHashMap(*Put); | ||
| 751 | const Put = struct { | ||
| 752 | putter_frame: @Frame(kqPutEvents), | ||
| 753 | cancelled: bool = false, | ||
| 754 | value: V, | ||
| 755 | }; | ||
| 756 | }; | ||
| 757 | |||
| 756 | const WindowsOsData = struct { | 758 | const WindowsOsData = struct { |
| 757 | table_lock: event.Lock, | 759 | table_lock: event.Lock, |
| 758 | dir_table: DirTable, | 760 | dir_table: DirTable, |
src-self-hosted/compilation.zig+32-20| ... | @@ -133,7 +133,7 @@ pub const Compilation = struct { | ... | @@ -133,7 +133,7 @@ pub const Compilation = struct { |
| 133 | zig_std_dir: []const u8, | 133 | zig_std_dir: []const u8, |
| 134 | 134 | ||
| 135 | /// lazily created when we need it | 135 | /// lazily created when we need it |
| 136 | tmp_dir: event.Future(BuildError![]u8), | 136 | tmp_dir: event.Future(BuildError![]u8) = event.Future(BuildError![]u8).init(), |
| 137 | 137 | ||
| 138 | version_major: u32 = 0, | 138 | version_major: u32 = 0, |
| 139 | version_minor: u32 = 0, | 139 | version_minor: u32 = 0, |
| ... | @@ -158,7 +158,7 @@ pub const Compilation = struct { | ... | @@ -158,7 +158,7 @@ pub const Compilation = struct { |
| 158 | 158 | ||
| 159 | /// functions that have their own objects that we need to link | 159 | /// functions that have their own objects that we need to link |
| 160 | /// it uses an optional pointer so that tombstone removals are possible | 160 | /// it uses an optional pointer so that tombstone removals are possible |
| 161 | fn_link_set: event.Locked(FnLinkSet), | 161 | fn_link_set: event.Locked(FnLinkSet) = event.Locked(FnLinkSet).init(FnLinkSet.init()), |
| 162 | 162 | ||
| 163 | pub const FnLinkSet = std.TailQueue(?*Value.Fn); | 163 | pub const FnLinkSet = std.TailQueue(?*Value.Fn); |
| 164 | 164 | ||
| ... | @@ -227,9 +227,9 @@ pub const Compilation = struct { | ... | @@ -227,9 +227,9 @@ pub const Compilation = struct { |
| 227 | /// need to wait on this group before deinitializing | 227 | /// need to wait on this group before deinitializing |
| 228 | deinit_group: event.Group(void), | 228 | deinit_group: event.Group(void), |
| 229 | 229 | ||
| 230 | // destroy_frame: @Frame(createAsync), | 230 | destroy_frame: *@Frame(createAsync), |
| 231 | // main_loop_frame: @Frame(Compilation.mainLoop), | 231 | main_loop_frame: *@Frame(Compilation.mainLoop), |
| 232 | main_loop_future: event.Future(void), | 232 | main_loop_future: event.Future(void) = event.Future(void).init(), |
| 233 | 233 | ||
| 234 | have_err_ret_tracing: bool = false, | 234 | have_err_ret_tracing: bool = false, |
| 235 | 235 | ||
| ... | @@ -245,6 +245,8 @@ pub const Compilation = struct { | ... | @@ -245,6 +245,8 @@ pub const Compilation = struct { |
| 245 | 245 | ||
| 246 | fs_watch: *fs.Watch(*Scope.Root), | 246 | fs_watch: *fs.Watch(*Scope.Root), |
| 247 | 247 | ||
| 248 | cancelled: bool = false, | ||
| 249 | |||
| 248 | const IntTypeTable = std.HashMap(*const Type.Int.Key, *Type.Int, Type.Int.Key.hash, Type.Int.Key.eql); | 250 | const IntTypeTable = std.HashMap(*const Type.Int.Key, *Type.Int, Type.Int.Key.hash, Type.Int.Key.eql); |
| 249 | const ArrayTypeTable = std.HashMap(*const Type.Array.Key, *Type.Array, Type.Array.Key.hash, Type.Array.Key.eql); | 251 | const ArrayTypeTable = std.HashMap(*const Type.Array.Key, *Type.Array, Type.Array.Key.hash, Type.Array.Key.eql); |
| 250 | const PtrTypeTable = std.HashMap(*const Type.Pointer.Key, *Type.Pointer, Type.Pointer.Key.hash, Type.Pointer.Key.eql); | 252 | const PtrTypeTable = std.HashMap(*const Type.Pointer.Key, *Type.Pointer, Type.Pointer.Key.hash, Type.Pointer.Key.eql); |
| ... | @@ -348,7 +350,9 @@ pub const Compilation = struct { | ... | @@ -348,7 +350,9 @@ pub const Compilation = struct { |
| 348 | zig_lib_dir: []const u8, | 350 | zig_lib_dir: []const u8, |
| 349 | ) !*Compilation { | 351 | ) !*Compilation { |
| 350 | var optional_comp: ?*Compilation = null; | 352 | var optional_comp: ?*Compilation = null; |
| 351 | var frame = async createAsync( | 353 | var frame = try zig_compiler.allocator.create(@Frame(createAsync)); |
| 354 | errdefer zig_compiler.allocator.destroy(frame); | ||
| 355 | frame.* = async createAsync( | ||
| 352 | &optional_comp, | 356 | &optional_comp, |
| 353 | zig_compiler, | 357 | zig_compiler, |
| 354 | name, | 358 | name, |
| ... | @@ -385,15 +389,12 @@ pub const Compilation = struct { | ... | @@ -385,15 +389,12 @@ pub const Compilation = struct { |
| 385 | .build_mode = build_mode, | 389 | .build_mode = build_mode, |
| 386 | .zig_lib_dir = zig_lib_dir, | 390 | .zig_lib_dir = zig_lib_dir, |
| 387 | .zig_std_dir = undefined, | 391 | .zig_std_dir = undefined, |
| 388 | .tmp_dir = event.Future(BuildError![]u8).init(), | 392 | .destroy_frame = @frame(), |
| 389 | // .destroy_frame = @frame(), | 393 | .main_loop_frame = undefined, |
| 390 | // .main_loop_frame = undefined, | ||
| 391 | .main_loop_future = event.Future(void).init(), | ||
| 392 | 394 | ||
| 393 | .name = undefined, | 395 | .name = undefined, |
| 394 | .llvm_triple = undefined, | 396 | .llvm_triple = undefined, |
| 395 | .is_static = is_static, | 397 | .is_static = is_static, |
| 396 | .fn_link_set = event.Locked(FnLinkSet).init(FnLinkSet.init()), | ||
| 397 | .link_libs_list = undefined, | 398 | .link_libs_list = undefined, |
| 398 | 399 | ||
| 399 | .exported_symbol_names = event.Locked(Decl.Table).init(Decl.Table.init(allocator)), | 400 | .exported_symbol_names = event.Locked(Decl.Table).init(Decl.Table.init(allocator)), |
| ... | @@ -505,7 +506,10 @@ pub const Compilation = struct { | ... | @@ -505,7 +506,10 @@ pub const Compilation = struct { |
| 505 | try comp.initTypes(); | 506 | try comp.initTypes(); |
| 506 | defer comp.primitive_type_table.deinit(); | 507 | defer comp.primitive_type_table.deinit(); |
| 507 | 508 | ||
| 508 | // comp.main_loop_frame = async comp.mainLoop(); | 509 | comp.main_loop_frame = try allocator.create(@Frame(mainLoop)); |
| 510 | defer allocator.destroy(comp.main_loop_frame); | ||
| 511 | |||
| 512 | comp.main_loop_frame.* = async comp.mainLoop(); | ||
| 509 | // Set this to indicate that initialization completed successfully. | 513 | // Set this to indicate that initialization completed successfully. |
| 510 | // from here on out we must not return an error. | 514 | // from here on out we must not return an error. |
| 511 | // This must occur before the first suspend/await. | 515 | // This must occur before the first suspend/await. |
| ... | @@ -718,8 +722,11 @@ pub const Compilation = struct { | ... | @@ -718,8 +722,11 @@ pub const Compilation = struct { |
| 718 | } | 722 | } |
| 719 | 723 | ||
| 720 | pub fn destroy(self: *Compilation) void { | 724 | pub fn destroy(self: *Compilation) void { |
| 721 | // await self.main_loop_frame; | 725 | const allocator = self.gpa(); |
| 722 | // resume self.destroy_frame; | 726 | self.cancelled = true; |
| 727 | await self.main_loop_frame; | ||
| 728 | resume self.destroy_frame; | ||
| 729 | allocator.destroy(self.destroy_frame); | ||
| 723 | } | 730 | } |
| 724 | 731 | ||
| 725 | fn start(self: *Compilation) void { | 732 | fn start(self: *Compilation) void { |
| ... | @@ -732,7 +739,7 @@ pub const Compilation = struct { | ... | @@ -732,7 +739,7 @@ pub const Compilation = struct { |
| 732 | 739 | ||
| 733 | var build_result = self.initialCompile(); | 740 | var build_result = self.initialCompile(); |
| 734 | 741 | ||
| 735 | while (true) { | 742 | while (!self.cancelled) { |
| 736 | const link_result = if (build_result) blk: { | 743 | const link_result = if (build_result) blk: { |
| 737 | break :blk self.maybeLink(); | 744 | break :blk self.maybeLink(); |
| 738 | } else |err| err; | 745 | } else |err| err; |
| ... | @@ -1130,11 +1137,10 @@ pub const Compilation = struct { | ... | @@ -1130,11 +1137,10 @@ pub const Compilation = struct { |
| 1130 | return link_lib; | 1137 | return link_lib; |
| 1131 | } | 1138 | } |
| 1132 | 1139 | ||
| 1133 | /// cancels itself so no need to await or cancel the promise. | ||
| 1134 | async fn startFindingNativeLibC(self: *Compilation) void { | 1140 | async fn startFindingNativeLibC(self: *Compilation) void { |
| 1135 | std.event.Loop.instance.?.yield(); | 1141 | event.Loop.startCpuBoundOperation(); |
| 1136 | // we don't care if it fails, we're just trying to kick off the future resolution | 1142 | // we don't care if it fails, we're just trying to kick off the future resolution |
| 1137 | _ = (self.zig_compiler.getNativeLibC()) catch return; | 1143 | _ = self.zig_compiler.getNativeLibC() catch return; |
| 1138 | } | 1144 | } |
| 1139 | 1145 | ||
| 1140 | /// General Purpose Allocator. Must free when done. | 1146 | /// General Purpose Allocator. Must free when done. |
| ... | @@ -1215,7 +1221,10 @@ pub const Compilation = struct { | ... | @@ -1215,7 +1221,10 @@ pub const Compilation = struct { |
| 1215 | node: *ast.Node, | 1221 | node: *ast.Node, |
| 1216 | expected_type: *Type, | 1222 | expected_type: *Type, |
| 1217 | ) !*Value { | 1223 | ) !*Value { |
| 1218 | const analyzed_code = try comp.genAndAnalyzeCode(tree_scope, scope, node, expected_type); | 1224 | var frame = try comp.gpa().create(@Frame(genAndAnalyzeCode)); |
| 1225 | defer comp.gpa().destroy(frame); | ||
| 1226 | frame.* = async comp.genAndAnalyzeCode(tree_scope, scope, node, expected_type); | ||
| 1227 | const analyzed_code = try await frame; | ||
| 1219 | defer analyzed_code.destroy(comp.gpa()); | 1228 | defer analyzed_code.destroy(comp.gpa()); |
| 1220 | 1229 | ||
| 1221 | return analyzed_code.getCompTimeResult(comp); | 1230 | return analyzed_code.getCompTimeResult(comp); |
| ... | @@ -1315,12 +1324,15 @@ fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void { | ... | @@ -1315,12 +1324,15 @@ fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void { |
| 1315 | try fn_type.non_key.Normal.variable_list.append(var_scope); | 1324 | try fn_type.non_key.Normal.variable_list.append(var_scope); |
| 1316 | } | 1325 | } |
| 1317 | 1326 | ||
| 1318 | const analyzed_code = try comp.genAndAnalyzeCode( | 1327 | var frame = try comp.gpa().create(@Frame(Compilation.genAndAnalyzeCode)); |
| 1328 | defer comp.gpa().destroy(frame); | ||
| 1329 | frame.* = async comp.genAndAnalyzeCode( | ||
| 1319 | tree_scope, | 1330 | tree_scope, |
| 1320 | fn_val.child_scope, | 1331 | fn_val.child_scope, |
| 1321 | body_node, | 1332 | body_node, |
| 1322 | fn_type.key.data.Normal.return_type, | 1333 | fn_type.key.data.Normal.return_type, |
| 1323 | ); | 1334 | ); |
| 1335 | const analyzed_code = try await frame; | ||
| 1324 | errdefer analyzed_code.destroy(comp.gpa()); | 1336 | errdefer analyzed_code.destroy(comp.gpa()); |
| 1325 | 1337 | ||
| 1326 | assert(fn_val.block_scope != null); | 1338 | assert(fn_val.block_scope != null); |
src-self-hosted/ir.zig+16-9| ... | @@ -658,7 +658,7 @@ pub const Inst = struct { | ... | @@ -658,7 +658,7 @@ pub const Inst = struct { |
| 658 | const amt = try align_inst.getAsConstAlign(ira); | 658 | const amt = try align_inst.getAsConstAlign(ira); |
| 659 | break :blk Type.Pointer.Align{ .Override = amt }; | 659 | break :blk Type.Pointer.Align{ .Override = amt }; |
| 660 | } else blk: { | 660 | } else blk: { |
| 661 | break :blk Type.Pointer.Align{ .Abi = {} }; | 661 | break :blk .Abi; |
| 662 | }; | 662 | }; |
| 663 | const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ | 663 | const ptr_type = try Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{ |
| 664 | .child_type = child_type, | 664 | .child_type = child_type, |
| ... | @@ -1078,6 +1078,14 @@ pub const Builder = struct { | ... | @@ -1078,6 +1078,14 @@ pub const Builder = struct { |
| 1078 | self.current_basic_block = basic_block; | 1078 | self.current_basic_block = basic_block; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | pub fn genNodeRecursive(irb: *Builder, node: *ast.Node, scope: *Scope, lval: LVal) Error!*Inst { | ||
| 1082 | const alloc = irb.comp.gpa(); | ||
| 1083 | var frame = try alloc.create(@Frame(genNode)); | ||
| 1084 | defer alloc.destroy(frame); | ||
| 1085 | frame.* = async irb.genNode(node, scope, lval); | ||
| 1086 | return await frame; | ||
| 1087 | } | ||
| 1088 | |||
| 1081 | pub async fn genNode(irb: *Builder, node: *ast.Node, scope: *Scope, lval: LVal) Error!*Inst { | 1089 | pub async fn genNode(irb: *Builder, node: *ast.Node, scope: *Scope, lval: LVal) Error!*Inst { |
| 1082 | switch (node.id) { | 1090 | switch (node.id) { |
| 1083 | .Root => unreachable, | 1091 | .Root => unreachable, |
| ... | @@ -1157,7 +1165,7 @@ pub const Builder = struct { | ... | @@ -1157,7 +1165,7 @@ pub const Builder = struct { |
| 1157 | }, | 1165 | }, |
| 1158 | .GroupedExpression => { | 1166 | .GroupedExpression => { |
| 1159 | const grouped_expr = @fieldParentPtr(ast.Node.GroupedExpression, "base", node); | 1167 | const grouped_expr = @fieldParentPtr(ast.Node.GroupedExpression, "base", node); |
| 1160 | return irb.genNode(grouped_expr.expr, scope, lval); | 1168 | return irb.genNodeRecursive(grouped_expr.expr, scope, lval); |
| 1161 | }, | 1169 | }, |
| 1162 | .BuiltinCall => return error.Unimplemented, | 1170 | .BuiltinCall => return error.Unimplemented, |
| 1163 | .ErrorSetDecl => return error.Unimplemented, | 1171 | .ErrorSetDecl => return error.Unimplemented, |
| ... | @@ -1187,14 +1195,13 @@ pub const Builder = struct { | ... | @@ -1187,14 +1195,13 @@ pub const Builder = struct { |
| 1187 | } | 1195 | } |
| 1188 | 1196 | ||
| 1189 | fn genCall(irb: *Builder, suffix_op: *ast.Node.SuffixOp, call: *ast.Node.SuffixOp.Op.Call, scope: *Scope) !*Inst { | 1197 | fn genCall(irb: *Builder, suffix_op: *ast.Node.SuffixOp, call: *ast.Node.SuffixOp.Op.Call, scope: *Scope) !*Inst { |
| 1190 | async fn genCall(irb: *Builder, suffix_op: *ast.Node.SuffixOp, call: *ast.Node.SuffixOp.Op.Call, scope: *Scope) !*Inst { | 1198 | const fn_ref = try irb.genNodeRecursive(suffix_op.lhs.node, scope, .None); |
| 1191 | const fn_ref = try irb.genNode(suffix_op.lhs, scope, .None); | ||
| 1192 | 1199 | ||
| 1193 | const args = try irb.arena().alloc(*Inst, call.params.len); | 1200 | const args = try irb.arena().alloc(*Inst, call.params.len); |
| 1194 | var it = call.params.iterator(0); | 1201 | var it = call.params.iterator(0); |
| 1195 | var i: usize = 0; | 1202 | var i: usize = 0; |
| 1196 | while (it.next()) |arg_node_ptr| : (i += 1) { | 1203 | while (it.next()) |arg_node_ptr| : (i += 1) { |
| 1197 | args[i] = try irb.genNode(arg_node_ptr.*, scope, .None); | 1204 | args[i] = try irb.genNodeRecursive(arg_node_ptr.*, scope, .None); |
| 1198 | } | 1205 | } |
| 1199 | 1206 | ||
| 1200 | //bool is_async = node->data.fn_call_expr.is_async; | 1207 | //bool is_async = node->data.fn_call_expr.is_async; |
| ... | @@ -1239,7 +1246,7 @@ pub const Builder = struct { | ... | @@ -1239,7 +1246,7 @@ pub const Builder = struct { |
| 1239 | //} else { | 1246 | //} else { |
| 1240 | // align_value = nullptr; | 1247 | // align_value = nullptr; |
| 1241 | //} | 1248 | //} |
| 1242 | const child_type = try irb.genNode(prefix_op.rhs, scope, .None); | 1249 | const child_type = try irb.genNodeRecursive(prefix_op.rhs, scope, .None); |
| 1243 | 1250 | ||
| 1244 | //uint32_t bit_offset_start = 0; | 1251 | //uint32_t bit_offset_start = 0; |
| 1245 | //if (node->data.pointer_type.bit_offset_start != nullptr) { | 1252 | //if (node->data.pointer_type.bit_offset_start != nullptr) { |
| ... | @@ -1438,7 +1445,7 @@ pub const Builder = struct { | ... | @@ -1438,7 +1445,7 @@ pub const Builder = struct { |
| 1438 | child_scope = &defer_child_scope.base; | 1445 | child_scope = &defer_child_scope.base; |
| 1439 | continue; | 1446 | continue; |
| 1440 | } | 1447 | } |
| 1441 | const statement_value = try irb.genNode(statement_node, child_scope, .None); | 1448 | const statement_value = try irb.genNodeRecursive(statement_node, child_scope, .None); |
| 1442 | 1449 | ||
| 1443 | is_continuation_unreachable = statement_value.isNoReturn(); | 1450 | is_continuation_unreachable = statement_value.isNoReturn(); |
| 1444 | if (is_continuation_unreachable) { | 1451 | if (is_continuation_unreachable) { |
| ... | @@ -1534,7 +1541,7 @@ pub const Builder = struct { | ... | @@ -1534,7 +1541,7 @@ pub const Builder = struct { |
| 1534 | 1541 | ||
| 1535 | const outer_scope = irb.begin_scope.?; | 1542 | const outer_scope = irb.begin_scope.?; |
| 1536 | const return_value = if (control_flow_expr.rhs) |rhs| blk: { | 1543 | const return_value = if (control_flow_expr.rhs) |rhs| blk: { |
| 1537 | break :blk try irb.genNode(rhs, scope, .None); | 1544 | break :blk try irb.genNodeRecursive(rhs, scope, .None); |
| 1538 | } else blk: { | 1545 | } else blk: { |
| 1539 | break :blk try irb.buildConstVoid(scope, src_span, true); | 1546 | break :blk try irb.buildConstVoid(scope, src_span, true); |
| 1540 | }; | 1547 | }; |
| ... | @@ -1713,7 +1720,7 @@ pub const Builder = struct { | ... | @@ -1713,7 +1720,7 @@ pub const Builder = struct { |
| 1713 | }; | 1720 | }; |
| 1714 | if (generate) { | 1721 | if (generate) { |
| 1715 | const defer_expr_scope = defer_scope.defer_expr_scope; | 1722 | const defer_expr_scope = defer_scope.defer_expr_scope; |
| 1716 | const instruction = try irb.genNode( | 1723 | const instruction = try irb.genNodeRecursive( |
| 1717 | defer_expr_scope.expr_node, | 1724 | defer_expr_scope.expr_node, |
| 1718 | &defer_expr_scope.base, | 1725 | &defer_expr_scope.base, |
| 1719 | .None, | 1726 | .None, |
src-self-hosted/libc_installation.zig+1-1| ... | @@ -400,7 +400,7 @@ fn ccPrintFileName(allocator: *Allocator, o_file: []const u8, want_dirname: bool | ... | @@ -400,7 +400,7 @@ fn ccPrintFileName(allocator: *Allocator, o_file: []const u8, want_dirname: bool |
| 400 | const argv = [_][]const u8{ cc_exe, arg1 }; | 400 | const argv = [_][]const u8{ cc_exe, arg1 }; |
| 401 | 401 | ||
| 402 | // TODO This simulates evented I/O for the child process exec | 402 | // TODO This simulates evented I/O for the child process exec |
| 403 | std.event.Loop.instance.?.yield(); | 403 | event.Loop.startCpuBoundOperation(); |
| 404 | const errorable_result = std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024); | 404 | const errorable_result = std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024); |
| 405 | const exec_result = if (std.debug.runtime_safety) blk: { | 405 | const exec_result = if (std.debug.runtime_safety) blk: { |
| 406 | break :blk errorable_result catch unreachable; | 406 | break :blk errorable_result catch unreachable; |
src-self-hosted/link.zig+4-5| ... | @@ -623,16 +623,15 @@ fn constructLinkerArgsWasm(ctx: *Context) void { | ... | @@ -623,16 +623,15 @@ fn constructLinkerArgsWasm(ctx: *Context) void { |
| 623 | } | 623 | } |
| 624 | 624 | ||
| 625 | fn addFnObjects(ctx: *Context) !void { | 625 | fn addFnObjects(ctx: *Context) !void { |
| 626 | // at this point it's guaranteed nobody else has this lock, so we circumvent it | 626 | const held = ctx.comp.fn_link_set.acquire(); |
| 627 | // and avoid having to be an async function | 627 | defer held.release(); |
| 628 | const fn_link_set = &ctx.comp.fn_link_set.private_data; | ||
| 629 | 628 | ||
| 630 | var it = fn_link_set.first; | 629 | var it = held.value.first; |
| 631 | while (it) |node| { | 630 | while (it) |node| { |
| 632 | const fn_val = node.data orelse { | 631 | const fn_val = node.data orelse { |
| 633 | // handle the tombstone. See Value.Fn.destroy. | 632 | // handle the tombstone. See Value.Fn.destroy. |
| 634 | it = node.next; | 633 | it = node.next; |
| 635 | fn_link_set.remove(node); | 634 | held.value.remove(node); |
| 636 | ctx.comp.gpa().destroy(node); | 635 | ctx.comp.gpa().destroy(node); |
| 637 | continue; | 636 | continue; |
| 638 | }; | 637 | }; |
src-self-hosted/main.zig+6-5| ... | @@ -127,7 +127,7 @@ pub fn main() !void { | ... | @@ -127,7 +127,7 @@ pub fn main() !void { |
| 127 | try stderr.print("unknown command: {}\n\n", args[1]); | 127 | try stderr.print("unknown command: {}\n\n", args[1]); |
| 128 | try stderr.write(usage); | 128 | try stderr.write(usage); |
| 129 | process.argsFree(allocator, args); | 129 | process.argsFree(allocator, args); |
| 130 | defer process.exit(1); | 130 | process.exit(1); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | const usage_build_generic = | 133 | const usage_build_generic = |
| ... | @@ -467,7 +467,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co | ... | @@ -467,7 +467,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co |
| 467 | 467 | ||
| 468 | fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { | 468 | fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { |
| 469 | var count: usize = 0; | 469 | var count: usize = 0; |
| 470 | while (true) { // TODO(Vexu) | 470 | while (!comp.cancelled) { |
| 471 | const build_event = comp.events.get(); | 471 | const build_event = comp.events.get(); |
| 472 | count += 1; | 472 | count += 1; |
| 473 | 473 | ||
| ... | @@ -545,7 +545,7 @@ fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_fil | ... | @@ -545,7 +545,7 @@ fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_fil |
| 545 | "Try running `zig libc` to see an example for the native target.\n", | 545 | "Try running `zig libc` to see an example for the native target.\n", |
| 546 | libc_paths_file, | 546 | libc_paths_file, |
| 547 | @errorName(err), | 547 | @errorName(err), |
| 548 | ) catch process.exit(1); | 548 | ) catch {}; |
| 549 | process.exit(1); | 549 | process.exit(1); |
| 550 | }; | 550 | }; |
| 551 | } | 551 | } |
| ... | @@ -568,7 +568,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { | ... | @@ -568,7 +568,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { |
| 568 | defer zig_compiler.deinit(); | 568 | defer zig_compiler.deinit(); |
| 569 | 569 | ||
| 570 | const libc = zig_compiler.getNativeLibC() catch |err| { | 570 | const libc = zig_compiler.getNativeLibC() catch |err| { |
| 571 | stderr.print("unable to find libc: {}\n", @errorName(err)) catch process.exit(1); | 571 | stderr.print("unable to find libc: {}\n", @errorName(err)) catch {}; |
| 572 | process.exit(1); | 572 | process.exit(1); |
| 573 | }; | 573 | }; |
| 574 | libc.render(stdout) catch process.exit(1); | 574 | libc.render(stdout) catch process.exit(1); |
| ... | @@ -706,7 +706,8 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro | ... | @@ -706,7 +706,8 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 706 | while (try it.next()) |entry| { | 706 | while (try it.next()) |entry| { |
| 707 | if (entry.kind == .Directory or mem.endsWith(u8, entry.name, ".zig")) { | 707 | if (entry.kind == .Directory or mem.endsWith(u8, entry.name, ".zig")) { |
| 708 | const full_path = try fs.path.join(fmt.allocator, [_][]const u8{ file_path, entry.name }); | 708 | const full_path = try fs.path.join(fmt.allocator, [_][]const u8{ file_path, entry.name }); |
| 709 | try group.call(fmtPath, fmt, full_path, check_mode); | 709 | @panic("TODO https://github.com/ziglang/zig/issues/3777"); |
| 710 | // try group.call(fmtPath, fmt, full_path, check_mode); | ||
| 710 | } | 711 | } |
| 711 | } | 712 | } |
| 712 | return group.wait(); | 713 | return group.wait(); |
src-self-hosted/util.zig+1-1| ... | @@ -167,7 +167,7 @@ pub fn getDarwinArchString(self: Target) [:0]const u8 { | ... | @@ -167,7 +167,7 @@ pub fn getDarwinArchString(self: Target) [:0]const u8 { |
| 167 | .powerpc64 => return "ppc64", | 167 | .powerpc64 => return "ppc64", |
| 168 | .powerpc64le => return "ppc64le", | 168 | .powerpc64le => return "ppc64le", |
| 169 | // @tagName should be able to return sentinel terminated slice | 169 | // @tagName should be able to return sentinel terminated slice |
| 170 | else => @panic("TODO"), //return @tagName(arch), | 170 | else => @panic("TODO https://github.com/ziglang/zig/issues/3779"), //return @tagName(arch), |
| 171 | } | 171 | } |
| 172 | } | 172 | } |
| 173 | 173 |
src-self-hosted/value.zig+1-1| ... | @@ -350,7 +350,7 @@ pub const Value = struct { | ... | @@ -350,7 +350,7 @@ pub const Value = struct { |
| 350 | .mut = mut, | 350 | .mut = mut, |
| 351 | .vol = Type.Pointer.Vol.Non, | 351 | .vol = Type.Pointer.Vol.Non, |
| 352 | .size = size, | 352 | .size = size, |
| 353 | .alignment = Type.Pointer.Align.Abi, | 353 | .alignment = .Abi, |
| 354 | }); | 354 | }); |
| 355 | var ptr_type_consumed = false; | 355 | var ptr_type_consumed = false; |
| 356 | errdefer if (!ptr_type_consumed) ptr_type.base.base.deref(comp); | 356 | errdefer if (!ptr_type_consumed) ptr_type.base.base.deref(comp); |