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