-
Notifications
You must be signed in to change notification settings - Fork 4
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
call_tags and engine implementations #7
Comments
Thanks for looking over the proposal and giving feedback, @dbezhetskov! These are great observations and questions. You might want to look at the recent PR #6, which has a bunch of updates, some of which are related to your questions.
Thanks for confirming that's how SpiderMonkey works. Call tags are meant to be a generalization of what you're already doing. Also, we did some experiments and found that, at least for our language that we used call tags for (compiling to LLVM, not WebAssembly), this implementation strategy performs just as well as typed function calls. So that suggests y'all chose a good implementation strategy 😃
That's a nice optimization you're performing! If you have some numbers on how that affects performance, I'd love to see them. I agree with your observation that the optimization of private tables and private call tags have overlapping benefits in this case. But there are other situations where the private call-tags optimization can be used where the private tables optimization cannot be. For example, one thing people are doing with C++ WebAssembly modules is splitting them into smaller modules in order to get faster load times. In order to implement C++ dispatch properly, these smaller modules need to all share the same
Thanks for confirming this! I had heard conflicting stories here, but this is what I'd inferred from discussions of engine performance. For this reason, I added
My comment was from the perspective of a generator wanting to have assurances about limiting unintended backdoors into their program. But your comment does make me realize that I hadn't thought through the JS API implications of this change. My sense is that the In #6, there are a bunch of additional applications of call tags, many of which integrate extensions like |
Hi @RossTate, recently you have asked about performance measurements of improved call_indirect, so, you can find some graphs in the end of the article https://dbezhetskov.dev/blog/opt-ind-call/. TLTR: it is about - 30% for a indirect call to a local function but the optimization has its tradeoff as well. |
Thanks for directing me to your nice write-up! I'm glad your optimization efforts paid off 😃 |
Hi, I'm working on optimization of indirect calls [https://bugzilla.mozilla.org/show_bug.cgi?id=1639153] and happy to leave some comments about call_tags:
Well, right now it works as you described, with a few low-level details. So, we don't need call_tags here.
Yes, this is useful, there is an motivational example for C++ -> wasm:
The
Bar
function will be compiled tocall_indirect
and wasm engine can't optimize it becausecall_indirect
target can be from different instance or from js [https://godbolt.org/z/41M9rc8jK]. We can optimize this case viacall-tags
or we can use private tables and do the same stuff via existing mechanism.When an engine (let it be SpiderMonkey) populates the table with pointers it can deduce what this table is.
If the table has been created in the current module and it hasn't been exported than we can fill the table with raw pointers to the specified functions.
We don't need to switch instances in that case too and so,
call_indirect
for this case can be as effective as simplecall
+ signature check.Since we can declare any number of tables we can restrict how our functions will be called via
call_indirect
.Could you clarify benefits of call-tags vs tables for this case? @RossTate
table.get $table
is really expensive one because we should create JS wrapper for that function as we don't now how we will use that reference - does it flow out to JS or stay in wasm realm?BTW,
In any case we need to track what function is referenced because we need to create some JS wrappers for that function, so this information is already available.
The text was updated successfully, but these errors were encountered: