-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate unused virtual methods we detect after optimizations (#100286)
Before this PR, it was not possible to get rid of unused virtual method slots once whole program analysis determined they are needed. This PR makes it (sort of) possible. Codegen needs to know what numerical slots get assigned to virtual methods because we use the slots to index into vtable to do virtual calls/generic lookup. We also want to be able to skip generating unused virtual methods. Before we do actual codegen optimizations, we don't know what virtual method uses can actually be optimized away. ### Before this PR Without optimizations: don’t do codegen that needs slots inlined into code generated by RyuJIT. Instead instruct RyuJIT to call a helper. The helper is emitted as assembly by the compiler driver itself at the time all used virtual methods are known and we can stabilize slot numbers. When assigning slots, we skip the virtual methods that are unused. With optimizations: assign slots after whole program analysis is done and we know what slots can be skipped. Codegen might still do optimizations that avoids actually needing a slot. We still generate the slot and fill it out and it’s a bit of a waste. ### After this PR Without optimizations: assign slots based on what we see in metadata. Do codegen based on this information and allow inlining slot indices into codegen. Still try to find unused slots. Generate unused slots as null slots (place a literal null pointer in the vtable). This is a both an improvement and a regression. It’s debug so it doesn’t matter much. We can delete the handwritten assembly, so it’s an improvement there. With optimizations: assign slots after whole program analysis. Still try to find unused slots. If an unused slot is found, generate it as null. We can’t eliminate it anymore for regular vtable slots (because we did codegen that assumes indices into vtable), but at least we don’t have to generate a standalone method body and a reloc to it. For sealed vtable slots, we can actually eliminate the slot (the slot is not inlined in code) and this PR does that.
- Loading branch information
1 parent
d7c4f02
commit 91ee24a
Showing
23 changed files
with
161 additions
and
335 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.