Skip to content

[Code Annotations] Start Branch Hinting support, in the text format, for Breaks #7567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 2, 2025

Conversation

kripken
Copy link
Member

@kripken kripken commented May 2, 2025

This adds the first minimal amount of work for Branch Hinting (and
code annotations, more generally): Just the text format, and just a
single instruction (Break).

This design follows debug info: Assuming most instructions have no
branch hints (like most do not have debug info), we do not add a field
to the Break class itself, but to metadata on the side.

@kripken kripken requested a review from tlively May 2, 2025 18:36
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

return std::nullopt;
}

return bool((*str)[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's validate that the byte is a 0 or 1 as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -2698,6 +2701,18 @@ void PrintSExpression::printDebugLocation(Expression* curr) {
doIndent(o, indent);
}
}

auto iter2 = currFunction->codeAnnotations.find(curr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename the iterators locIter and annotIter or similar? Alternatively, we could limit the scope of the iter variables by using if (auto iter = ...; iter != ...) { }.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@kripken kripken merged commit 1df8e5c into WebAssembly:main May 2, 2025
14 checks passed
@kripken kripken deleted the branch.hint branch May 2, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants