Direct calls 2#2935
Open
sydow wants to merge 5 commits into
Open
Conversation
Closed
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.
This is a new version of a compiler improvement that replaces calls to protocol instance methods via a witness variable and the instance's method table with a direct call to the method, when this is statically known. This version only does this rewrite for builtin protocols and instances of these for builtin types.
The previous version (PR #2903) introduced a new constructor in the abstract syntax for expressions. Such a side channel for transferring info between passes should be avoided and this version does not change abstract syntax. Instead, in the boxing pass we rewrite the indirect call
Call (Dot w n) p(with some SrcLoc info omitted), where n is a method of some protocol Prot and w a witness that some builtin type typ implements Prot, toCall ProtD_typD_n (PosArg w_s p)wherew_sis an existing builtin static witness, the name of which is known by convention, andProtD_typD_nis the conventional name for the direct method. A problem is that this method only exists at the C level and is not accessible to QuickType. CodeGen recognizes such conventional names and is prepared to bypass qType and compute relevant types.