Direct calls#2903
Closed
sydow wants to merge 8 commits into
Closed
Conversation
…*.h for direct calls
…hrough witness and method table)
…dict[u64] and dict[bytes]
Contributor
|
@sydow at this point, wouldn't it be a good idea to look at the generated machine instructions for functions like this so we can see what is actually doing? All the C-compiler optimizations are otherwise opaque to us, right? |
Collaborator
Author
|
@plajjan, of course it would be absolutely wonderful if someone could look at this, and more generally, at what optimizations the C compilers do to our code (and how we could influence that). For the present PR, I think that the simplification of the code and the removal of some witnesses is in itself worthwhile, even if it should not give much speedup. |
Open
Collaborator
Author
|
This is replaced by PR #2935. |
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 PR implements an optimization to certain calls of methods in protocol instances, as illustrated by the following trivial example: The Acton function definition
has upto now been compiled to the C code
where we, for readability, omitted some type casts. After this PR the result is instead
There are two changes:
In this PR, the simplification/optimization applies only to instances of builtin protocols (here Sequence) to builtin types (here lists). These all have static witnesses defined and the name convention for naming the specific method to be called directly is known. (Note: For protocols with restrictions on a type parameter, such as Mapping and Set, which require the type of keys/elements to be Hashable, not all combinations of protocol and type have presently static witnesses implemented.)