From ed86a56bcf606e4fc10f581d04a81fed15996425 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Wed, 21 Aug 2024 09:32:00 -0700 Subject: [PATCH 1/2] Builtins: set evalBranchQuota properly --- build/GenerateDef.zig | 6 +++++- src/aro/Parser.zig | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/GenerateDef.zig b/build/GenerateDef.zig index 508a629f..a9d70e29 100644 --- a/build/GenerateDef.zig +++ b/build/GenerateDef.zig @@ -305,6 +305,10 @@ fn generate(self: *GenerateDef, input: []const u8) ![]const u8 { \\/// If found, returns the index of the node within the `dafsa` array. \\/// Otherwise, returns `null`. \\pub fn findInList(first_child_index: u16, char: u8) ?u16 { + \\ + ); + try writer.print(" @setEvalBranchQuota({d});\n", .{values.count() * 2}); + try writer.writeAll( \\ var index = first_child_index; \\ while (true) { \\ if (dafsa[index].char == char) return index; @@ -453,7 +457,7 @@ fn generate(self: *GenerateDef, input: []const u8) ![]const u8 { fn writeData(writer: anytype, values: []const Value) !void { try writer.writeAll("pub const data = blk: {\n"); - try writer.print(" @setEvalBranchQuota({});\n", .{values.len}); + try writer.print(" @setEvalBranchQuota({d});\n", .{values.len * 7}); try writer.writeAll(" break :blk [_]@This(){\n"); for (values, 0..) |value, i| { try writer.print(" // {s}\n", .{value.name}); diff --git a/src/aro/Parser.zig b/src/aro/Parser.zig index 90cd552a..c4baeb8c 100644 --- a/src/aro/Parser.zig +++ b/src/aro/Parser.zig @@ -4986,7 +4986,6 @@ const CallExpr = union(enum) { } fn checkVarArg(self: CallExpr, p: *Parser, first_after: TokenIndex, param_tok: TokenIndex, arg: *Result, arg_idx: u32) !void { - @setEvalBranchQuota(10_000); if (self == .standard) return; const builtin_tok = p.nodes.items(.data)[@intFromEnum(self.builtin.node)].decl.name; @@ -5011,7 +5010,6 @@ const CallExpr = union(enum) { /// of arguments, `paramCountOverride` is used to tell us how many arguments we should actually expect to see for /// these custom-typechecked functions. fn paramCountOverride(self: CallExpr) ?u32 { - @setEvalBranchQuota(10_000); return switch (self) { .standard => null, .builtin => |builtin| switch (builtin.tag) { From da0b756595cbfcca48abb506f7bee13565211a25 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Wed, 21 Aug 2024 09:41:53 -0700 Subject: [PATCH 2/2] Attribute: remove unneeded setEvalBranchQuota calls --- src/aro/Attribute.zig | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/aro/Attribute.zig b/src/aro/Attribute.zig index c84d3c75..fe9770e2 100644 --- a/src/aro/Attribute.zig +++ b/src/aro/Attribute.zig @@ -132,7 +132,6 @@ pub const Formatting = struct { if (@typeInfo(Unwrapped) != .Enum) unreachable; const enum_fields = @typeInfo(Unwrapped).Enum.fields; - @setEvalBranchQuota(3000); const quote = comptime quoteChar(@enumFromInt(@intFromEnum(tag))); comptime var values: []const u8 = quote ++ enum_fields[0].name ++ quote; inline for (enum_fields[1..]) |enum_field| { @@ -265,7 +264,6 @@ fn diagnoseField( @field(@field(arguments, decl.name), field.name) = enum_val; return null; } else { - @setEvalBranchQuota(3000); return .{ .tag = .unknown_attr_enum, .extra = .{ .attr_enum = .{ .tag = std.meta.stringToEnum(Tag, decl.name).? } },