Merged
Conversation
Member
Author
|
Release notes: Memoized Calls Use Branch QuotaAs an optimization, the Zig compiler memoizes the results of comptime function calls. Previous releases of the Zig compiler had a bug where memoized calls would not subtract from the eval branch quota, meaning The fix is simple: introduce calls to |
4e72fb1 to
222081f
Compare
andrewrk
approved these changes
Aug 19, 2024
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.
* Indices of referenced captures * Line and column of `@src()` The second point aligns with a reversal of the "incremental compilation" section of ziglang#2029 (comment). This reversal was already done as ziglang#17688 (46a6d50), with the idea to push incremental compilation down the line. My proposal is to keep it as comptime-known, and simply re-analyze uses of `@src()` whenever their line/column change. I think this decision is reasonable for a few reasons: * The Zig compiler is quite fast. Occasionally re-analyzing a few functions containing `@src()` calls is perfectly acceptable and won't noticably impact update times. * The system described by Andrew in ziglang#2029 is currently vaporware. * The system described by Andrew in ziglang#2029 is non-trivial to implement. In particular, it requires some way to have backends update a single global in certain cases, without re-doing semantic analysis. There is no other part of incremental compilation which requires this. * Having `@src().line` be comptime-known is useful. For instance, ziglang#17688 was justified by broken Tracy integration because the source line couldn't be comptime-known.
Also, update `std.math.Log2Int[Ceil]` to more efficient implementations that don't use up so much damn quota!
And add a corresponding test case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two main things:
@src()calls. This solidifies the language change implemented by Sema: make@src().linecomptime-known #17688; see commit message for details.I added a new incremental compilation test for the
@src()stuff; it passes with the C backend.@Vexu, this PR (first commit) required correcting some eval branch quotas in Aro. One of the changes I made was to
aro/Builtins/Builtin.zig, which is a generated file, but the file used to generate it isn't included downstream. Upstream Aro should make whatever the actual required change is.