diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-08-19 07:50:57 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-08-21 01:26:55 +0100 |
| commit | 9cf8a7661f34e764f785583a3028429e2a700d20 (patch) | |
| tree | 44d19306bf88259cdb82f7b23eee976a2a6711a0 /lib/compiler/aro | |
| parent | 16d74809d44d6bb8db1a32923ef8db43d956e24d (diff) | |
| download | zig-9cf8a7661f34e764f785583a3028429e2a700d20.tar.gz zig-9cf8a7661f34e764f785583a3028429e2a700d20.zip | |
compiler: handle eval branch quota in memoized calls
In a `memoized_call`, store how many backwards braches the call
performs. Add this to `sema.branch_count` when using a memoized call. If
this exceeds the quota, perform a non-memoized call to get a correct
"exceeded X backwards branches" error.
Also, do not memoize calls which do `@setEvalBranchQuota` or similar, as
this affects global state which must apply to the caller.
Change some eval branch quotas so that the compiler itself still builds correctly.
This commit manually changes a file in Aro which is automatically
generated. The sources which generate the file are not in this repo.
Upstream Aro should make the suitable changes on their end before the
next sync of Aro sources into the Zig repo.
Diffstat (limited to 'lib/compiler/aro')
| -rw-r--r-- | lib/compiler/aro/aro/Builtins/Builtin.zig | 2 | ||||
| -rw-r--r-- | lib/compiler/aro/aro/Parser.zig | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/compiler/aro/aro/Builtins/Builtin.zig b/lib/compiler/aro/aro/Builtins/Builtin.zig index 9564bfecb5..c5cf98608b 100644 --- a/lib/compiler/aro/aro/Builtins/Builtin.zig +++ b/lib/compiler/aro/aro/Builtins/Builtin.zig @@ -5165,7 +5165,7 @@ const dafsa = [_]Node{ .{ .char = 'e', .end_of_word = false, .end_of_list = true, .number = 1, .child_index = 4913 }, }; pub const data = blk: { - @setEvalBranchQuota(3986); + @setEvalBranchQuota(30_000); break :blk [_]@This(){ // _Block_object_assign .{ .tag = @enumFromInt(0), .properties = .{ .param_str = "vv*vC*iC", .header = .blocks, .attributes = .{ .lib_function_without_prefix = true } } }, diff --git a/lib/compiler/aro/aro/Parser.zig b/lib/compiler/aro/aro/Parser.zig index 956dc5e114..1cb5e18934 100644 --- a/lib/compiler/aro/aro/Parser.zig +++ b/lib/compiler/aro/aro/Parser.zig @@ -4802,6 +4802,7 @@ const CallExpr = union(enum) { } fn shouldPromoteVarArg(self: CallExpr, arg_idx: u32) bool { + @setEvalBranchQuota(2000); return switch (self) { .standard => true, .builtin => |builtin| switch (builtin.tag) { @@ -4902,6 +4903,7 @@ const CallExpr = union(enum) { } fn returnType(self: CallExpr, p: *Parser, callable_ty: Type) Type { + @setEvalBranchQuota(6000); return switch (self) { .standard => callable_ty.returnType(), .builtin => |builtin| switch (builtin.tag) { |
