alexcrichton opened PR #6243 from alexcrichton:more-readonly
to bytecodealliance:main
:
This commit marks the loads of
*mut VMContext
and the callee function pointer asreadonly
in the context of indirect function calls and additionally calls to imported functions (which are indirect). Once aVMCallerCheckedAnyfunc
is initialized it's never modified so it should be valid to mark these as readonly and if called in a loop should be hoistable outside of the loop.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested wasmtime-core-reviewers for a review on PR #6243.
alexcrichton requested jameysharp for a review on PR #6243.
jameysharp submitted PR review:
Yeah, this makes sense. Nice!
It'd be neat if there were some filetests demonstrating that this actually enables optimizations in some case.
I suspect there is no way to hoist the loads for indirect calls out of loops even with this change.
funcref_ptr
is the result of a load from a table, which is not read-only (right?), and it's followed by a function call, which we can't prove didn't change the table entry. But it shouldn't hurt to mark these loads as read-only anyway. If nothing else, it should leave more room for scheduling the loads against other work.I think this should help with direct calls to imported functions, anyway.
alexcrichton merged PR #6243.
Last updated: Dec 23 2024 at 12:05 UTC