Data slice mutation support (#11939) #12011
Merged
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.
Explanation:
Mutation of Data slices had issues when it comes to re-indexing to the base slice region. Previously when a slice of Data was mutated the re-calculation of the slice region was incorrectly assigned to a relative region to the previous backing. Now the slice region will copy the specific region out creating a new data upon CoW semantics and offset the index region upon access. Mutating a non CoW slice will retain the previous region backing but adjust the remaining allocation buffer accordingly. To validate this I have added tests for combinations that should approximate all possible combinations of mutations, backing storages and CoW scenarios.
Scope:
This change applies to Data in all cases for the fix. It modifies all codes paths that handle mutation and re-works the slice region calculations.
Radar (and possibly SR Issue):
rdar://problem/34206043
SR-5887
SR-5873
SR-5810
Risk:
This has medium to high risk (for Data itself) since it is a critical path for the manipulation and mutation of Data. However mitigating funnel points were used to reduce overall impact as well as a large swath of tests covering the changes.
Reviewed by:
Itai Ferber, Michael LeHew Jr, and Tony Parker
Testing:
240+ new tests were added to cover all possible permutations of mutations and backing storage of Data while sliced.