Skip to content

[WIP] Dictionary/Set cumulative test PR #19586

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

Closed
wants to merge 25 commits into from

Conversation

lorentey
Copy link
Member

This is just a test, consisting of the sum of the following PRs:

They all seem to trigger a source compatibility failure within the same project, but none of these failures seem reproducible locally.

The mutation count will allow us to recognize and trap on invalid indices more reliably. (However, it won’t be foolproof — some invalid indices may pass through the checks.)

- Change _scale to Int8 to make space for an extra Int32 without enlarging the storage header.
- Add an _age field inside the new gap.
- Initialize the age to a scrambled version of the storage address.
- Generate a new counter for every newly allocated storage instance, except for identical copy-on-write copies.
- Increment the mutation counter after every removal.
(For symmetry with Dictionary, which already has this check.)
Also add static_assert for Set/Dictionary storage header size.
Set and Dictionary will start using this shortly as their native index types.
@lorentey
Copy link
Member Author

@swift-ci please test source compatibility

…-level indices

Native sets and (especially!) native dictionaries must support indexing with Cocoa indices — indices must be preserved when a Cocoa set/dictionary is converted to native.

This is especially the case for Dictionaries that were converted because of a mutation restricted to values — such as those done through the Values view.
…sages

Capital Index seems too nitpicky, somehow
This makes it a little easier to follow validation logic.
Like before, allow the use of Cocoa indices to access native sets/dictionaries, but approximate the same mutation count-based check as we do for native indices.

- Ensure that native collections that were converted from Cocoa have an age generated from the address of the original Cocoa object.
- To get the age of a Cocoa index, regenerate one from the object embedded in it.
- Compare self.age to index.age and trap if it doesn’t match.
Affected operations:

subscript(index:)
remove(at:)

Note that index(after:) is intentionally not on this list.
…tionaries

Affected operations:

subscript(index:)
keys.subscript(index:)
values.subscript(index:) (setter and _modify)
remove(at:)
swapAt(_:, _:)

Note that index(after:) is intentionally not on this list.
@lorentey
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b1a3ece

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b1a3ece

@lorentey lorentey closed this Sep 28, 2018
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