Skip to content
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

[NFC] Rename 'SyntaxArena' to 'RawSyntaxArena' #2926

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Dec 21, 2024

The current SyntaxArena only manages RawSyntax green tree things. In swift-syntax, "Syntax" refers to Syntax the red tree. So the naming was a bit confusing.

As for arena: argument labels, rename it to rawAllocationArena: expect in the RawSyntax world (i.e. SwiftSyntax/raw/* and SwiftParser/*).

Also rename SyntaxArenaAllocated(Buffer)Pointer to ArenaAllocated* in preparation for future introduction of other "arenas". (i.e. #2925)

@rintaro
Copy link
Member Author

rintaro commented Dec 21, 2024

@swift-ci Please test

1 similar comment
@rintaro
Copy link
Member Author

rintaro commented Dec 22, 2024

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Dec 22, 2024

@swift-ci Please test Windows

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments regarding naming / comments, otherwise LGTM.

///
/// Because the syntax arena will always outlive any syntax nodes that
/// reference its contents, we know that the pointer's contents won't get
/// deallocated while being accessed and thus we can add an unchecked `Sendable`
/// conformance.
@_spi(RawSyntax)
public struct SyntaxArenaAllocatedPointer<Element: Sendable>: @unchecked Sendable {
public struct ArenaAllocatedPointer<Element: Sendable>: @unchecked Sendable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the comment also be updated so it doesn’t mention RawSyntaxArena if this type is supposed to hold pointers allocated in arbitrary arenas?

Same for comments below.

private var arena: RetainedSyntaxArena
private var rawNodeArena: RetainedRawSyntaxArena
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn’t change all parameters / members from arena to rawNodeArena (eg. RawSyntaxTokenView still has arena: RawSyntaxArena). I think it would be good to have a consistent naming and I don’t see a problem with continuing to call it arena.

Same in some more places.

Copy link
Member Author

@rintaro rintaro Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed some places, but my intention was to leave arena: for RawSyntax operations. But for Syntax related operations, I thought it'd be clearer to use rawAllocationArena or rawNodeArena. Especially if we'd merge #2925 (let's discuss about it next year), Syntax has different "arena".

/// be reference-counted, further improving the performance of ``SwiftSyntax``
/// when worked with at that level.
public class SyntaxArena {
public class RawSyntaxArena {
Copy link
Member Author

@rintaro rintaro Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that SyntaxArena was non-SPI public. I'm going to add deprecated typealias SyntaxArena = RawSyntaxArena. Same for ParsingSyntaxArena

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alex and I discussed about this and we think they shouldn't be public. Making them SPI in #2930 before this PR.

@rintaro rintaro mentioned this pull request Jan 2, 2025
@rintaro rintaro force-pushed the raw-syntax-arena branch 2 times, most recently from 38c9f80 to 39ec125 Compare January 8, 2025 18:06
@rintaro
Copy link
Member Author

rintaro commented Jan 8, 2025

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Jan 8, 2025

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Jan 8, 2025

@swift-ci Please test Windows

The current `SyntaxArena` only manages `RawSyntax` green tree things. In
swift-syntax, "Syntax" refers to `Syntax` the red tree. So the naming was
a bit confusing.

Also rename `SyntaxArenaAllocated(Buffer)Pointer` to 'ArenaAllocated*'
in preparation for future introduction of other "arenas".
@rintaro
Copy link
Member Author

rintaro commented Jan 10, 2025

@swift-ci Please test

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.

2 participants