Skip to content

Conversation

@stevenfontanella
Copy link
Member

@stevenfontanella stevenfontanella commented Nov 18, 2025

  • Add support for (module definition ...) and (module instance ...) in WAST spec tests
    • Syntax reference
    • These statements are skipped by the WAST splitter, since wasm-opt can't understand them. In the future, we need some extra work to handle explicit module instantiations correctly here.
    • This fixes the memory.wast spec test. The remaining 3 that currently depend on this syntax still break for other reasons (mentioned in shared.py)
  • Remove extra unneeded call to run_spec_test

@stevenfontanella stevenfontanella force-pushed the module-definition-and-instance-cp branch 3 times, most recently from 2480082 to 7b98b2e Compare November 18, 2025 22: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.

A few initial comments while this is still under construction.

@stevenfontanella stevenfontanella force-pushed the module-definition-and-instance-cp branch from 7b98b2e to 616165c Compare November 19, 2025 22:21
@stevenfontanella
Copy link
Member Author

(Sorry for the force-push, I already made these changes locally before your comments)

@stevenfontanella stevenfontanella force-pushed the module-definition-and-instance-cp branch from 616165c to e5c9ab4 Compare November 20, 2025 00:24
Comment on lines +483 to +484
// This is not a module instance and probably a module instead.
return {};
Copy link
Member

Choose a reason for hiding this comment

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

Let's move the lexer reset to back before the (module from the caller to here.

// (module instance ...) | (module ...)
Result<ModuleOrInstantiation> moduleOrInstantiation(Lexer& in) {
auto reset = in;

Copy link
Member

Choose a reason for hiding this comment

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

Even though they both start with (module, modules and instantiations are parsed very differently and behave very differently, so I think it would make sense to treat them as different things rather than bundling them together like this. That will simplify command below by removing the need for the std::visit variant conversion.

Copy link
Member Author

@stevenfontanella stevenfontanella Nov 25, 2025

Choose a reason for hiding this comment

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

I mostly agree, but I chose to bundle them together since we must attempt to parse (module instance ...) before attempting (module name? ...), otherwise we'll try to parse the word instance as a name and fail rather than backtracking. Does it make sense to bundle them to make the ordering clear? I agree it's a little unfortunate that the module / module instance parsers need to be aware of each other a little bit but I don't see a way around it.

The only alternative I see is to remove the ordering dependency by letting the module (not instance) parser backtrack if it sees the word instance. That lets the ordering work either way, but that means that both parsers still need to know about each other in which case it makes sense to me to bundle them in the same function.

* Fixes for lastModule / lastInstance
* Fix for python f-string in lower python versions
* Fix for Module registration when some params aren't specified
@stevenfontanella stevenfontanella marked this pull request as ready for review November 26, 2025 20:48
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