Skip to content
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

Fix bug in finding arity for verify attributes #2812

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

bakaq
Copy link
Contributor

@bakaq bakaq commented Feb 4, 2025

This fixes a bug in the current attributed variables implementation that creates a lot of strange bugs that seem like miscompilations.

Closes #2706, closes #2809, closes #2632.

Copy link
Contributor

@adri326 adri326 left a comment

Choose a reason for hiding this comment

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

I don't have much experience with the logic behind verify_attributes, but I couldn't find any issue with this fix.

I wonder how hard it would be to store somewhere else the number of temporary variables, so that the WAM instructions don't need to be scanned for every attributed variable unification.


I do believe that the current method of modifying self.code to eventually call verify_attr_interrupt is iffy. It feels flimsy and it will make JIT impossible in its current form.

src/machine/dispatch.rs Outdated Show resolved Hide resolved
src/machine/dispatch.rs Outdated Show resolved Hide resolved
@bakaq
Copy link
Contributor Author

bakaq commented Feb 4, 2025

I wonder how hard it would be to store somewhere else the number of temporary variables, so that the WAM instructions don't need to be scanned for every attributed variable unification.

I do believe that the current method of modifying self.code to eventually call verify_attr_interrupt is iffy. It feels flimsy and it will make JIT impossible in its current form.

I think ideally this should all be done in the compilation step, although maybe the verify attributes interrupt really needs to be this dynamic.

@bakaq
Copy link
Contributor Author

bakaq commented Feb 5, 2025

I made the code more functional, put some asserts and comments, and now scan the entire current predicate for use of temporary registers. I'm not sure if that is needed, but I think it's better to be conservative with this, because saving more registers than necessary will never be wrong, just inefficient.

If someone who understands how this works can assure me that we only need to scan from machine_st.p to the end of the predicate this is very easy to change.

@mthom mthom merged commit e5cca9d into mthom:master Feb 13, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants