[un-revert] Replace per-save-point array snapshots with an undo trail - #881
Merged
Merged
Conversation
Creating a save point previously copied the four mutable register arrays (ints, positions, values, and storedCaptures) to enable restoration during backtracking. This led to a large amount of reference counting traffic and copy-on-write of the original register arrays whenever they were updated. This change moves the restoration data from using full copies of each array in every save point, to tracking a log of the changes to each array in the processor itself and only storing the current state of the logs in each save point. This allows `SavePoint` to be a trivial type (almost) and removes all the copy-on-write traffic. Backtracking now uses the tracking logs to unwind the registers to the specific previous state. This change also includes a minor refactor, moving the `storedCaptures` array to the `Registers` struct, alongside the other mutable registers.
signalFailure only calls `undo(to:)`, which rewinds a register's log, but doesn't touch its values or add to the log.
Member
Author
|
@swift-ci Please test Linux platform |
Member
Author
|
Checked that the macOS build worked with the |
AnthonyLatsis
added a commit
that referenced
this pull request
Sep 30, 2026
Revert "[un-revert] Replace per-save-point array snapshots with an undo trail (#881)"
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.
Second attempt at landing #870, which simplifies the
SavePointtype and logs register mutations in anUndoableArray, rather than relying on copy-on-write for the registers during backtracking. Updated from the original to include a proper import that was missed without theMemberImportVisibilityflag, and some additional performance tuning.