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

Heap2Local: Track interactions in detail #6834

Merged
merged 13 commits into from
Aug 13, 2024

Conversation

kripken
Copy link
Member

@kripken kripken commented Aug 13, 2024

Previously we tracked only whether an expression was relevant to analysis, that is,
whether it interacted with the allocation we were tracing the behavior of. That is
not enough for all cases, though, so also track the form of the interaction, namely
whether the allocation flows through or is fully consumed. An example where that
matters:

(ref.eq
  (struct.get $A 0
    (local.tee $x
      (struct.new_default $A)
    )
  )
  (local.get $x)
)

Here the local.get flows out the allocation, but the struct.get only fully consumes
it. Before this PR we thought the struct.get flowed the allocation, and we misoptimized
this to 1.

To make this possible, do a bunch of minor refactoring:

  • Move ParentChildInteraction out of the class.
  • Add a "None" interaction there.
  • Replace the set of reached expressions with a map of them to their interactions.
  • Add helper functions to get an expression's interaction or to update it when replacing.

The new testcase here shows the main fix. The new assertions are covered by existing
testcases.

@kripken kripken requested a review from tlively August 13, 2024 18:57
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.

Was this found by the fuzzer?

@kripken
Copy link
Member Author

kripken commented Aug 13, 2024

Yes, fuzzer.

@kripken kripken merged commit 0c84afe into WebAssembly:main Aug 13, 2024
13 checks passed
@kripken kripken deleted the heap2local.interact branch August 13, 2024 23:04
@gkdn gkdn mentioned this pull request Aug 31, 2024
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