| author | |
| committer | |
| log | 018262d537959701566f2dfece66a462c3bbc976 |
| tree | a4d09b23dfd649ffa61313891560b5b33e17810b |
| parent | ceb76b2ba705f362dbd5437ec5804b670298b420 |
| signature |
Also, update `std.math.Log2Int[Ceil]` to more efficient implementations
that don't use up so much damn quota!8 files changed, 17 insertions(+), 21 deletions(-)
lib/std/crypto/aes/soft.zig+2| ... | ... | @@ -629,6 +629,8 @@ fn generateSbox(invert: bool) [256]u8 { |
| 629 | 629 | |
| 630 | 630 | // Generate lookup tables. |
| 631 | 631 | fn generateTable(invert: bool) [4][256]u32 { |
| 632 | @setEvalBranchQuota(50000); | |
| 633 | ||
| 632 | 634 | var table: [4][256]u32 = undefined; |
| 633 | 635 | |
| 634 | 636 | for (generateSbox(invert), 0..) |value, index| { |
lib/std/crypto/blake2.zig+2-2| ... | ... | @@ -786,7 +786,7 @@ test "blake2b384 streaming" { |
| 786 | 786 | |
| 787 | 787 | test "comptime blake2b384" { |
| 788 | 788 | comptime { |
| 789 | @setEvalBranchQuota(10000); | |
| 789 | @setEvalBranchQuota(20000); | |
| 790 | 790 | var block = [_]u8{0} ** Blake2b384.block_length; |
| 791 | 791 | var out: [Blake2b384.digest_length]u8 = undefined; |
| 792 | 792 | |
| ... | ... | @@ -878,7 +878,7 @@ test "blake2b512 keyed" { |
| 878 | 878 | |
| 879 | 879 | test "comptime blake2b512" { |
| 880 | 880 | comptime { |
| 881 | @setEvalBranchQuota(10000); | |
| 881 | @setEvalBranchQuota(12000); | |
| 882 | 882 | var block = [_]u8{0} ** Blake2b512.block_length; |
| 883 | 883 | var out: [Blake2b512.digest_length]u8 = undefined; |
| 884 | 884 |
lib/std/enums.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ const testing = std.testing; |
| 6 | 6 | const EnumField = std.builtin.Type.EnumField; |
| 7 | 7 | |
| 8 | 8 | /// Increment this value when adding APIs that add single backwards branches. |
| 9 | const eval_branch_quota_cushion = 5; | |
| 9 | const eval_branch_quota_cushion = 10; | |
| 10 | 10 | |
| 11 | 11 | /// Returns a struct with a field matching each unique named enum element. |
| 12 | 12 | /// If the enum is extern and has multiple names for the same value, only |
lib/std/hash/xxhash.zig+1-1| ... | ... | @@ -890,7 +890,7 @@ test "xxhash32 smhasher" { |
| 890 | 890 | } |
| 891 | 891 | }; |
| 892 | 892 | try Test.do(); |
| 893 | @setEvalBranchQuota(75000); | |
| 893 | @setEvalBranchQuota(85000); | |
| 894 | 894 | comptime try Test.do(); |
| 895 | 895 | } |
| 896 | 896 |
lib/std/math.zig+8-16| ... | ... | @@ -749,31 +749,23 @@ test rotl { |
| 749 | 749 | try testing.expect(rotl(@Vector(1, u32), @Vector(1, u32){1 << 31}, @as(isize, -1))[0] == @as(u32, 1) << 30); |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | /// Returns an unsigned int type that can hold the number of bits in T | |
| 753 | /// - 1. Suitable for 0-based bit indices of T. | |
| 752 | /// Returns an unsigned int type that can hold the number of bits in T - 1. | |
| 753 | /// Suitable for 0-based bit indices of T. | |
| 754 | 754 | pub fn Log2Int(comptime T: type) type { |
| 755 | 755 | // comptime ceil log2 |
| 756 | 756 | if (T == comptime_int) return comptime_int; |
| 757 | comptime var count = 0; | |
| 758 | comptime var s = @typeInfo(T).Int.bits - 1; | |
| 759 | inline while (s != 0) : (s >>= 1) { | |
| 760 | count += 1; | |
| 761 | } | |
| 762 | ||
| 763 | return std.meta.Int(.unsigned, count); | |
| 757 | const bits: u16 = @typeInfo(T).Int.bits; | |
| 758 | const log2_bits = 16 - @clz(bits - 1); | |
| 759 | return std.meta.Int(.unsigned, log2_bits); | |
| 764 | 760 | } |
| 765 | 761 | |
| 766 | 762 | /// Returns an unsigned int type that can hold the number of bits in T. |
| 767 | 763 | pub fn Log2IntCeil(comptime T: type) type { |
| 768 | 764 | // comptime ceil log2 |
| 769 | 765 | if (T == comptime_int) return comptime_int; |
| 770 | comptime var count = 0; | |
| 771 | comptime var s = @typeInfo(T).Int.bits; | |
| 772 | inline while (s != 0) : (s >>= 1) { | |
| 773 | count += 1; | |
| 774 | } | |
| 775 | ||
| 776 | return std.meta.Int(.unsigned, count); | |
| 766 | const bits: u16 = @typeInfo(T).Int.bits; | |
| 767 | const log2_bits = 16 - @clz(bits); | |
| 768 | return std.meta.Int(.unsigned, log2_bits); | |
| 777 | 769 | } |
| 778 | 770 | |
| 779 | 771 | /// Returns the smallest integer type that can hold both from and to. |
lib/std/math/hypot.zig+1| ... | ... | @@ -114,6 +114,7 @@ test "hypot.precise" { |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | test "hypot.special" { |
| 117 | @setEvalBranchQuota(2000); | |
| 117 | 118 | inline for (.{ f16, f32, f64, f128 }) |T| { |
| 118 | 119 | try expect(math.isNan(hypot(nan(T), 0.0))); |
| 119 | 120 | try expect(math.isNan(hypot(0.0, nan(T)))); |
lib/std/math/nextafter.zig+1-1| ... | ... | @@ -144,7 +144,7 @@ test "int" { |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | test "float" { |
| 147 | @setEvalBranchQuota(3000); | |
| 147 | @setEvalBranchQuota(4000); | |
| 148 | 148 | |
| 149 | 149 | // normal -> normal |
| 150 | 150 | try expect(nextAfter(f16, 0x1.234p0, 2.0) == 0x1.238p0); |
lib/std/unicode.zig+1| ... | ... | @@ -535,6 +535,7 @@ fn testUtf16CountCodepoints() !void { |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | test "utf16 count codepoints" { |
| 538 | @setEvalBranchQuota(2000); | |
| 538 | 539 | try testUtf16CountCodepoints(); |
| 539 | 540 | try comptime testUtf16CountCodepoints(); |
| 540 | 541 | } |