Add noalloc annotation RFC#235
Open
SeanTAllen wants to merge 1 commit into
Open
Conversation
9bbdbab to
3fe769a
Compare
Member
Author
|
we discussed. allow noalloc on trait methods. disallow on interface. like the no supertype annotation's interaction with the type system, we can require any trait method that is \noalloc\ to require its implementers to have \noalloc\ on the same methods. however it isn't required. that's an open question. at the time that we are doing our check for allocations, we can see all trait possibilities at virtual dispatch call sites and verify that none will allocate because by the time we are past heap2stack and optimizations, we have a fully closed world. for interfaces, we have to use the same closed world at any virtual dispatch site to see if any implementers would alloc and if yes, disallow. |
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 RFC proposes
noalloc, a compile-time annotation that verifies a method, and everything it transitively calls, performs no heap allocation. You mark a hot method; in release builds the compiler fails the build if anything under it allocates, including code you didn't write and didn't annotate. The check runs after optimization on the shipped binary, so whatever stays on the stack passes. It also goes on interface and trait methods, where it forces every implementer to benoalloc, which is what lets anoallocmethod dispatch through an interface.The open questions are about the compiler error: whether it can point at the specific allocation, and what it reports when more than one allocation caused the failure.