-
Notifications
You must be signed in to change notification settings - Fork 835
Use ImportResolver for table imports #8194
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
Conversation
ebcd539 to
5c7736a
Compare
34ac47d to
d465928
Compare
d465928 to
f30f8c6
Compare
| virtual const Table* tableMeta() const = 0; | ||
| }; | ||
|
|
||
| class RealRuntimeTable : public RuntimeTable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer renaming RuntimeTable to RuntimeTableBase so we can name this one RuntimeTable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to give the interface the more canonical name since code should usually use the interface rather than the concrete implementation. I feel that giving the interface the name RuntimeTableBase is misleading because it implies that it isn't actually a RuntimeTable, and Base sounds like a base class instead of an interface.
I don't mind much either way. Another option is to hide RealRuntimeTable entirely by putting it in a source file and only exposing a factory function that returns unique_ptr<RuntimeTable>. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to give the interface the more canonical name since code should usually use the interface rather than the concrete implementation.
Ok, that makes sense 👍
Another option is to hide RealRuntimeTable entirely by putting it in a source file and only exposing a factory function that returns unique_ptr. WDYT?
That sounds fine, too. I don't have a strong preference here.
|
|
||
| private: | ||
| Table table; | ||
| const bool& instanceInitialized; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why take a reference to a bool rather than just copying it in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [this, &instanceInitialized](Literal initial, Table table) { | ||
| return std::make_unique<EvallingRuntimeTable>( | ||
| table, | ||
| instanceInitialized, | ||
| this->wasm, | ||
| [this](Name name, Type type) { return makeFuncData(name, type); }); | ||
| }) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱
Is there a plan for avoiding callback hell here? It seems like pairing subclasses of ModuleRunnerBase with subclasses of RuntimeTable et. al. so that they all know about each other would let us avoid this indirection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two ideas but they would increase the footprint of this PR so I was planning to leave them for the next PR. For the outer callback, we don't need this as a param to ModuleRunnerBase, instead ctor-eval only needs to use EvallingRuntimeTable for imported tables, and we can return EvallingRuntimeTable from the ImportResolver. For non-imported tables we can use the real implementation that's already there in ModuleRunner.
For the inner callback of makeFuncData, I'm hoping this will go away once I do the refactorings for functions / function imports, but I'm not sure yet how it will turn out. Another option is to take the EvallingModuleRunner as an input instead of just the function but we'd need to move EvallingModuleRunner into its own header for that (because then EvallingRuntimeTable references EvallingModuleRunner and EvallingModuleRunner references EvallingRuntimeTable), and another downside is that it makes it harder to decouple from EvallingModuleRunner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sgtm as long as we can simplify this eventually.
Part of #8180. We currently replicate the existing behavior. In the future, we can also change ctor-eval to really simulate tables, and only use the EvallingRuntimeTable in the case of table imports. Removes existing pointer chasing logic that we repeat for each table operation (e.g. tableLoad, tableStore).
Allows us to fix spec tests where a table import becomes valid by resizing it in #8222.