Skip to content

Remove closed world validation checks #7019

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 6 commits into from
Oct 18, 2024
Merged

Conversation

kripken
Copy link
Member

@kripken kripken commented Oct 17, 2024

These were added to avoid common problems with closed world mode, but
in practice they are causing more harm than good, forcing users to work
around them. In the meantime (until #6965 ), remove this validation to unblock
current toolchain makers.

There is a risk of getting more user reports here, but I don't see any other
risk. @tlively you were worried about fuzz bugs, but I don't think we depend
on validation for deciding what to optimize, so that should be ok? (I've fuzzed
a few thousand iterations so far without issue, too.)

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.

🎉 I'm pleasantly surprised that this doesn't cause issues 👍

@kripken
Copy link
Member Author

kripken commented Oct 18, 2024

This isn't quite as simple as I'd hoped, after 100K iterations the fuzzer found an issue. While we don't use validation to decide what to optimize, we do use it to decide what to fuzz: we don't apply --closed-world when it makes a module not validate. The bug is that GTO was using visibility for one part (removals) but not another (immutability).

I added the fix here because it can't land before this PR (it won't validate) and it shouldn't land after (that would break bisection).

I'll fuzz a lot more before landing, as there might be more such issues.

@kripken
Copy link
Member Author

kripken commented Oct 18, 2024

Added a similar fix for abstract type refining (found not by fuzzing but analytically).

@kripken
Copy link
Member Author

kripken commented Oct 18, 2024

Removed a comment about validating closed world which is now obsolete.

Comment on lines 109 to 113
// Assume all public types are created, which makes them non-abstract and
// hence ignored below.
for (auto type : ModuleUtils::getPublicHeapTypes(*module)) {
createdTypes.insert(type);
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make this assumption? If we assumed the public types are not allocated outside the module due to closed-world, we could still optimize the casts in the test case without changing the public types. It is probably safer to never make assumptions about public types, though 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we could do that, if we checked and found we'd need no changes to public types. I'll add a TODO, but it seems nontrivial.

@kripken
Copy link
Member Author

kripken commented Oct 18, 2024

No new fuzzer issues, landing.

@kripken kripken merged commit bc36c02 into WebAssembly:main Oct 18, 2024
13 checks passed
@kripken kripken deleted the closed.noval branch October 18, 2024 23:14
kripken added a commit that referenced this pull request Nov 4, 2024
This fixes a regression from #7019. That PR fixed an error on situations with
mixed public and private types, but it made us stop optimizing in valid cases,
including cases with entirely private types.

The specific regression was that we checked if we had an entry in the
map of "can become immutable", and we thought that was enough. But
we may have a private child type with a public parent, and still be able to
optimize in the child if the field is not present in the parent. We also did
not have exhaustive checking of all the states canBecomeImmutable can be,
so add those + testing.
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