Skip to content

Add isActive/isPassive methods to segments (NFC)#8782

Open
aheejin wants to merge 4 commits into
WebAssembly:mainfrom
aheejin:is_passive
Open

Add isActive/isPassive methods to segments (NFC)#8782
aheejin wants to merge 4 commits into
WebAssembly:mainfrom
aheejin:is_passive

Conversation

@aheejin
Copy link
Copy Markdown
Member

@aheejin aheejin commented May 27, 2026

Currently DataSegment class has isPassive member variable but ElementSegment doesn't. DataSegment's isPassive variable is redundant anyway because we can test whether its memory is set, as we do for ElementSegment's table.

This removes DataSegment::isPassive variable, and instead adds isPassive() and isActive() methods to both classes and use them instead of things like if (segment->table).

This also removes isPassive parameter from makeDataSegment in Builder.

Currently `DataSegment` class has `isPassive` member variable but
`ElementSegment` doesn't. `DataSegment`'s `isPassive` variable is
redundant anyway because we can test whether its `memory` is set, as we
do for `ElementSegment`'s `table`.

This removes `DataSegment::isPassive` variable, and instead adds
`isPassive()` and `isActive()` methods to both classes and use them
instead of things like `if (segment->table)`.
@aheejin aheejin requested review from kripken and tlively May 27, 2026 22:53
@aheejin aheejin requested a review from a team as a code owner May 27, 2026 22:53
@aheejin aheejin marked this pull request as draft May 27, 2026 22:54
@aheejin aheejin marked this pull request as ready for review May 27, 2026 22:57
Comment thread src/wasm-builder.h Outdated
seg->name = name;
seg->memory = memory;
seg->isPassive = isPassive;
if (!isPassive) {
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.

Can we remove the isPassive parameter and just unconditionally set seg->memory = memory?

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.

Done: aa605a5

@aheejin
Copy link
Copy Markdown
Member Author

aheejin commented May 28, 2026

Hmm, I'm not sure why Windows CI is failing... https://github.com/WebAssembly/binaryen/actions/runs/26546169554/job/78198387601?pr=8782

#8783 seems to have the same problem now

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.

3 participants