Skip to content

Print tables for call_indirects for nonzero table index#7843

Merged
aheejin merged 2 commits intoWebAssembly:mainfrom
aheejin:call_indirect_table2
Aug 19, 2025
Merged

Print tables for call_indirects for nonzero table index#7843
aheejin merged 2 commits intoWebAssembly:mainfrom
aheejin:call_indirect_table2

Conversation

@aheejin
Copy link
Copy Markdown
Member

@aheejin aheejin commented Aug 19, 2025

Rather than always printing the table like in #7839, this prints the table only when either reference types is enabled or the table index is not 0 (even if the features section or --enable-reference-types is not provided)

This addresses the concern in #7802, while not printing table when it is not necessary.

There is no test changes because

  • At the moment wasm-dis enables all features so wasm-dis always prints tables in call_indirects. This will change in [wasm-dis] Restore features section in output #7840.
  • wasm-opt results didn't print table so far when reference-types is not enabled, and all call_indirects in those tests have table index 0.

Rather than always printing the table like in WebAssembly#7839, this prints the
table only when either reference types is enabled or the table index is
not 0 (even if the features section or `--enable-reference-types` is not
provided)

This addresses the concern in WebAssembly#7802, while not printing table when it is
not necessary.

There is no test changes because
- At the moment wasm-dis enables all features so wasm-dis always prints
  tables in `call_indirect`s. This will change in WebAssembly#7840.
- wasm-opt results didn't print table so far when reference-types is not
  enabled, and all `call_indirect`s in those tests have table index 0.
Comment thread src/passes/Print.cpp Outdated
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
@aheejin aheejin merged commit 9438ce1 into WebAssembly:main Aug 19, 2025
16 checks passed
aheejin added a commit that referenced this pull request Aug 26, 2025
This effectively restores pre-#7802 status, except for the case the
input binary has the features section. If the binary does not have it,
we restore the default features (mutable-global + sign-ext) + whatever
is given in the command line before the printing. If the binary has the
features section, we just restore it before the printing.

This currently does not handle the case when there is the features
section and the user gives more features flags in the command line, but
in the current interface it is cumbersome to handle. And we were not
handling that anyway pre-#7802, so it is not a regression.

And we preserve the `FeaturesSet::All` setting at parsing time so
@tlively's
[concern](#7836 (comment))
will not be an issue.

Because we preserve the features section, #7836 will be addressed too.

The main motivation for #7802 was `call_indirect` could be incorrectly
printed, and that was also separately addressed by #7843.

`ModuleReader::getFeaturesSectionFeatures` was adopted from @tlively's
commit:

ed36a8c

Because we don't set the features to `Features::All` at the printing
time, `(type $..)` in `(func)` definitions and `(table ..)` in
`call_indirect`s have been removed.

Fixes #7836.
@aheejin aheejin deleted the call_indirect_table2 branch September 2, 2025 23:35
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