Costs: Adjust the cost of calls#8047
Merged
kripken merged 6 commits intoWebAssembly:mainfrom Nov 14, 2025
Merged
Conversation
tlively
approved these changes
Nov 13, 2025
src/ir/cost.h
Outdated
| } | ||
| CostType visitCallIndirect(CallIndirect* curr) { | ||
| CostType ret = 6 + visit(curr->target); | ||
| // Model indirect calls as more expensive than call_refs. |
Member
There was a problem hiding this comment.
I don't think this is accurate on V8, at least, because function tables are privileged in some special way that actually makes call_indirect faster than call_ref even though it does more work semantically. Let's just give them the same cost here.
tlively
approved these changes
Nov 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cost of "4" earlier was in place because call costs don't really matter
(the effects prevent removing/replacing them), but there are calls without
effects, like with the proper intrinsic. Model call costs as very expensive.
The monomorphize test change is because it has hardcoded costs, and
calls are now too "heavy" for what it wants. The calls are replaced by
other code that does a bunch of work.
Fixes #8044