aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-08-19 07:50:57 +0100
committermlugg <mlugg@mlugg.co.uk>2024-08-21 01:26:55 +0100
commit9cf8a7661f34e764f785583a3028429e2a700d20 (patch)
tree44d19306bf88259cdb82f7b23eee976a2a6711a0 /lib
parent16d74809d44d6bb8db1a32923ef8db43d956e24d (diff)
downloadzig-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')
-rw-r--r--lib/compiler/aro/aro/Builtins/Builtin.zig2
-rw-r--r--lib/compiler/aro/aro/Parser.zig2
-rw-r--r--lib/std/crypto/pcurves/p384.zig2
3 files changed, 4 insertions, 2 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) {
diff --git a/lib/std/crypto/pcurves/p384.zig b/lib/std/crypto/pcurves/p384.zig
index f8c5713209..3ab95da5e8 100644
--- a/lib/std/crypto/pcurves/p384.zig
+++ b/lib/std/crypto/pcurves/p384.zig
@@ -393,7 +393,7 @@ pub const P384 = struct {
}
const basePointPc = pc: {
- @setEvalBranchQuota(50000);
+ @setEvalBranchQuota(70000);
break :pc precompute(P384.basePoint, 15);
};