Repository navigation
Conversation
rintaro
force-pushed
the
productize-raw-x-syntax
branch
5 times, most recently
from
July 18, 2026 22:05
d14adae to
f48659f
Compare
rintaro
force-pushed
the
productize-raw-x-syntax
branch
from
July 28, 2026 18:31
f48659f to
ff4b8f4
Compare
rintaro
force-pushed
the
productize-raw-x-syntax
branch
from
August 30, 2026 21:49
ff4b8f4 to
2b71b19
Compare
nkcsgexi
approved these changes
Sep 22, 2026
rintaro
marked this pull request as draft
September 23, 2026 03:11
rintaro
force-pushed
the
productize-raw-x-syntax
branch
2 times, most recently
from
October 13, 2026 07:40
f29ccf9 to
b0cbb15
Compare
rintaro
force-pushed
the
productize-raw-x-syntax
branch
2 times, most recently
from
October 20, 2026 07:32
56d0889 to
b5e198c
Compare
rintaro
marked this pull request as ready for review
October 20, 2026 20:23
The typed `RawXXXSyntax` nodes, `RawSyntaxNodeProtocol` and `RawSyntaxNodeList` are only used while parsing, so move them from SwiftSyntax into SwiftParser as internal types. Making them internal narrows SwiftSyntax's API and lets the optimizer drop the metadata and protocol witness tables that public conformances must emit. Building a node stays in SwiftSyntax. Each layout node has a `RawSyntax.make<Kind>(...)` factory, e.g. `makeFunctionDecl(...)`, that takes the children as `RawSyntax` and inlines `RawSyntax.makeLayout`, whose storage mode and child count are constants there, so identically shaped factories still merge. Collections are built through `RawSyntax.makeCollection`, whose closure writes each element into its slot. A typed raw node's initializer in SwiftParser only unwraps its children and calls the factory. `RawTokenSyntax` stays in SwiftSyntax; it conforms to `RawSyntaxNodeProtocol` in SwiftParser. `validateLayout(layout:as:)` stays in SwiftSyntax but no longer depends on the typed raw nodes. It matches each child's `RawSyntax.kind` against the kinds allowed for the expected syntax type by calling that type's `isKindOf(_ kind: SyntaxKind)`, an internal static method generated on every syntax node, base node, collection, and child-choice enum, which the validator is handed for the concrete type.
rintaro
force-pushed
the
productize-raw-x-syntax
branch
from
October 21, 2026 23:53
b5e198c to
5f7ea02
Compare
Member
Author
|
@swift-ci Please test |
Member
Author
|
@swift-ci Please test Windows |
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.
To reduce the SwifitSyntax's code size. Move
RawXXXSyntax,RawSyntaxNodeProtocol, andRawSyntaxNodeListto SwiftParser module and make them internal.Keep the node builders in SwiftSyntax: each layout node now has
RawSyntax.make<Kind>(...)factory method e.g.makeFunctionDecl(...). This is important for inliningRawSyntax.makeLayout, and the same-shape factories are merged together.Similarly, collections are built through
RawSyntax.makeCollection(...).validateLayout(layout:as:)stays in SwiftSyntax but no longer depends on the typed raw nodes: it matches each child'sRawSyntax.kindagainst the kinds allowed for the expected syntax type by calling that type's internalisKindOf(_ kind: SyntaxKind), generated on every syntax node, base node, collection and child-choice enum, so it needs neither a protocol requirement nor any public surface.Code size:
SwiftSyntax.o__text__DATASwiftParser.o__textParsing perf is neutral (−0.12% to +0.08% instructions)
For toolchain (macOS, arm64, --no-assert)
lib_CompilerSwiftSyntax.dyliblib_CompilerSwiftParser.dyliblibSwiftSyntax.dyliblibSwiftParser.dylibSwiftSyntax.swiftmodule/…private.swiftinterface