| ... | @@ -38,7 +38,7 @@ func: ?*Module.Fn, | ... | @@ -38,7 +38,7 @@ func: ?*Module.Fn, |
| 38 | /// generic function which uses a type expression for the return type. | 38 | /// generic function which uses a type expression for the return type. |
| 39 | /// The type will be `void` in the case that `func` is `null`. | 39 | /// The type will be `void` in the case that `func` is `null`. |
| 40 | fn_ret_ty: Type, | 40 | fn_ret_ty: Type, |
| 41 | branch_quota: u32 = 1000, | 41 | branch_quota: u32 = default_branch_quota, |
| 42 | branch_count: u32 = 0, | 42 | branch_count: u32 = 0, |
| 43 | /// Populated when returning `error.ComptimeBreak`. Used to communicate the | 43 | /// Populated when returning `error.ComptimeBreak`. Used to communicate the |
| 44 | /// break instruction up the stack to find the corresponding Block. | 44 | /// break instruction up the stack to find the corresponding Block. |
| ... | @@ -102,6 +102,8 @@ const Package = @import("Package.zig"); | ... | @@ -102,6 +102,8 @@ const Package = @import("Package.zig"); |
| 102 | const crash_report = @import("crash_report.zig"); | 102 | const crash_report = @import("crash_report.zig"); |
| 103 | const build_options = @import("build_options"); | 103 | const build_options = @import("build_options"); |
| 104 | | 104 | |
| | 105 | pub const default_branch_quota = 1000; |
| | 106 | |
| 105 | pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, Air.Inst.Ref); | 107 | pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, Air.Inst.Ref); |
| 106 | | 108 | |
| 107 | /// This is the context needed to semantically analyze ZIR instructions and | 109 | /// This is the context needed to semantically analyze ZIR instructions and |
| ... | @@ -3752,8 +3754,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi | ... | @@ -3752,8 +3754,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 3752 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 3754 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3753 | const src = inst_data.src(); | 3755 | const src = inst_data.src(); |
| 3754 | const quota = @intCast(u32, try sema.resolveInt(block, src, inst_data.operand, Type.u32)); | 3756 | const quota = @intCast(u32, try sema.resolveInt(block, src, inst_data.operand, Type.u32)); |
| 3755 | if (sema.branch_quota < quota) | 3757 | sema.branch_quota = @maximum(sema.branch_quota, quota); |
| 3756 | sema.branch_quota = quota; | | |
| 3757 | } | 3758 | } |
| 3758 | | 3759 | |
| 3759 | fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 3760 | fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| ... | @@ -5679,6 +5680,8 @@ fn instantiateGenericCall( | ... | @@ -5679,6 +5680,8 @@ fn instantiateGenericCall( |
| 5679 | break :callee new_func; | 5680 | break :callee new_func; |
| 5680 | } else gop.key_ptr.*; | 5681 | } else gop.key_ptr.*; |
| 5681 | | 5682 | |
| | 5683 | callee.branch_quota = @maximum(callee.branch_quota, sema.branch_quota); |
| | 5684 | |
| 5682 | const callee_inst = try sema.analyzeDeclVal(block, func_src, callee.owner_decl); | 5685 | const callee_inst = try sema.analyzeDeclVal(block, func_src, callee.owner_decl); |
| 5683 | | 5686 | |
| 5684 | // Make a runtime call to the new function, making sure to omit the comptime args. | 5687 | // Make a runtime call to the new function, making sure to omit the comptime args. |
| ... | @@ -6773,6 +6776,7 @@ fn funcCommon( | ... | @@ -6773,6 +6776,7 @@ fn funcCommon( |
| 6773 | .lbrace_column = @truncate(u16, src_locs.columns), | 6776 | .lbrace_column = @truncate(u16, src_locs.columns), |
| 6774 | .rbrace_column = @truncate(u16, src_locs.columns >> 16), | 6777 | .rbrace_column = @truncate(u16, src_locs.columns >> 16), |
| 6775 | .param_names = param_names, | 6778 | .param_names = param_names, |
| | 6779 | .branch_quota = default_branch_quota, |
| 6776 | }; | 6780 | }; |
| 6777 | if (maybe_inferred_error_set_node) |node| { | 6781 | if (maybe_inferred_error_set_node) |node| { |
| 6778 | new_func.inferred_error_sets.prepend(node); | 6782 | new_func.inferred_error_sets.prepend(node); |