Skip to content

[NFC] Refactor closedWorld to WorldMode enum#8740

Open
tlively wants to merge 2 commits into
mainfrom
world-mode-refactor
Open

[NFC] Refactor closedWorld to WorldMode enum#8740
tlively wants to merge 2 commits into
mainfrom
world-mode-refactor

Conversation

@tlively
Copy link
Copy Markdown
Member

@tlively tlively commented May 21, 2026

Replace the closedWorld boolean in PassOptions with a WorldMode enum which has Closed and Open variants. Also introduce ModuleUtils::getExposedPublicHeapTypes to collect directly exposed public types, and updates getPublicHeapTypes to take WorldMode as a parameter. These refactorings will make a subsequent commit changing how we collect public heap types in open-world mode simpler.

Replace the `closedWorld` boolean in `PassOptions` with a `WorldMode` enum which has `Closed` and `Open` variants. Also introduce `ModuleUtils::getExposedPublicHeapTypes` to collect directly exposed public types, and updates `getPublicHeapTypes` to take `WorldMode` as a parameter. These refactorings will make a subsequent commit changing how we collect public heap types in open-world mode simpler.
@tlively tlively requested a review from a team as a code owner May 21, 2026 00:51
@tlively tlively requested a review from kripken May 21, 2026 00:51
Comment thread src/tools/fuzzing/fuzzing.cpp Outdated
// handle direct calls in fixClosedWorld, but cannot handle indirect ones
// easily, so just disallow taking references of those functions.
if (!closedWorld) {
if (worldMode != WorldMode::Closed) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (worldMode != WorldMode::Closed) {
if (worldMode == WorldMode::Open) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In other places too, or was there a reason to prefer the !=?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, I can make it consistently use ==

Update all occurrences of != WorldMode::Closed introduced by the world mode refactoring commit to use == WorldMode::Open instead, in response to reviewer feedback.
Comment thread src/ir/module-utils.h
// module, i.e. the types that would appear in the type section.
std::vector<HeapType> collectHeapTypes(Module& wasm);

std::vector<HeapType> getExposedPublicHeapTypes(Module& wasm);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs a comment, I think - how does it differ from getPublicHeapTypes?

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