-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[libSyntax] Inline commonly called methods in RawSyntax and AbsoluteRawSyntax #36278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…awSyntax These methods are super small and setting up the stack frame etc. takes up the majority (or at least a significant amount) of their execution time. So let's inline them.
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about the code size. Especially, RawSyntax::make()
(via makeAndCalcLength()
) are called from many places including SyntaxFactory
and SyntaxBuilder
. Do you know the actual code side change?
include/swift/Syntax/RawSyntax.h
Outdated
/// If the \p Str is not allocated in \p Arena, copy it to \p Arena and adjust | ||
/// \p Str to point to the string's copy in \p Arena. | ||
void copyToArenaIfNecessary( | ||
StringRef &Str, const swift::RC<swift::syntax::SyntaxArena> &Arena) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a SyntaxArena
method? I'm just uncomfortable with having an anonymous namespace in a header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Then we could also use this to copy the entire source code over here: https://github.com/apple/swift/blob/main/lib/SyntaxParse/SyntaxTreeCreator.cpp#L42
I just checked and defining the
AFAIU defining a function in a header (or alternatively making it From https://en.cppreference.com/w/cpp/language/inline
|
@swift-ci Please smoke test |
@swift-ci Please smoke test macOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed the binary size doesn't change much :)
These methods are small and setting up the stack frame etc. takes up the majority (or at least a significant amount) of their execution time. So let's give the compiler a chance to inline them.