Skip to content

[Serialization] Store offset of decls in .swiftsourceinfo #37105

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

Merged
merged 1 commit into from
Apr 29, 2021

Conversation

bnbarham
Copy link
Contributor

The locations stored in .swiftsourceinfo included the presumed file,
line, and column. When a location is requested it would read these, open
the external file, create a line map, and find the offset corresponding
to that line/column.

The offset is known during serialization though, so output it as well to
avoid having to read the file and generate the line map.

Since the serialized location is returned from Decl::getLoc(), it
should not be the presumed location. Instead, also output the line
directives so that the presumed location can be built as per normal
locations.

Finally, move the cache out of Decl and into ASTContext, since very
few declarations will actually have their locations deserialized. Make
sure to actually write to that cache so it's used - the old cache was
never written to.

@bnbarham
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

Are the line/columm in the serialized locations still being used for anything?

@bnbarham bnbarham force-pushed the serialize-offsets branch from 3e69121 to 67f9578 Compare April 28, 2021 22:56
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham force-pushed the serialize-offsets branch from 67f9578 to ff28009 Compare April 29, 2021 00:26
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ff28009d00a6e76d6c7069c7e2a732a3d434599d

The locations stored in .swiftsourceinfo included the presumed file,
line, and column. When a location is requested it would read these, open
the external file, create a line map, and find the offset corresponding
to that line/column.

The offset is known during serialization though, so output it as well to
avoid having to read the file and generate the line map.

Since the serialized location is returned from `Decl::getLoc()`, it
should not be the presumed location. Instead, also output the line
directives so that the presumed location can be built as per normal
locations.

Finally, move the cache out of `Decl` and into `ASTContext`, since very
few declarations will actually have their locations deserialized. Make
sure to actually write to that cache so it's used - the old cache was
never written to.
@bnbarham bnbarham force-pushed the serialize-offsets branch from ff28009 to c763ab5 Compare April 29, 2021 02:33
@bnbarham
Copy link
Contributor Author

bnbarham commented Apr 29, 2021

Forgot to up the .swiftsourceinfo version, have done so now. The .swiftsourceinfo will currently be ignored if the version doesn't match. (This wasn't the failure, which looks to be unrelated and will likely fail again...)

@swift-ci please test

@bnbarham bnbarham merged commit 0fc005d into swiftlang:main Apr 29, 2021
@bnbarham bnbarham deleted the serialize-offsets branch April 29, 2021 06:37
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.

3 participants