Skip to content

Direct calls 2#2935

Open
sydow wants to merge 5 commits into
mainfrom
direct-calls-2
Open

Direct calls 2#2935
sydow wants to merge 5 commits into
mainfrom
direct-calls-2

Conversation

@sydow

@sydow sydow commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

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, to Call ProtD_typD_n (PosArg w_s p) where w_s is an existing builtin static witness, the name of which is known by convention, and ProtD_typD_n is 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.

@sydow sydow mentioned this pull request Jun 16, 2026
@sydow sydow requested a review from nordlander June 16, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant