Skip to content
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

[SR-6243] _fastEnumerationStorageMutationsPtr isn't doing anything #3796

Closed
belkadan opened this issue Oct 28, 2017 · 4 comments
Closed

[SR-6243] _fastEnumerationStorageMutationsPtr isn't doing anything #3796

belkadan opened this issue Oct 28, 2017 · 4 comments

Comments

@belkadan
Copy link

Previous ID SR-6243
Radar None
Original Reporter @belkadan
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation, Standard Library
Labels Improvement, AffectsABI, StarterBug
Assignee @Moximillian
Priority Medium

md5: 9bb9fcf2a83ea5b9efb2c46f78f1009d

Issue Description:

In the standard library's Shims.swift, there are these declarations:

/// A dummy value to be used as the target for `mutationsPtr` in fast
/// enumeration implementations.
internal var _fastEnumerationStorageMutationsTarget: CUnsignedLong = 0

/// A dummy pointer to be used as `mutationsPtr` in fast enumeration
/// implementations.
public // SPI(Foundation)
var _fastEnumerationStorageMutationsPtr: UnsafeMutablePointer<CUnsignedLong> {
  return UnsafeMutablePointer(
      Builtin.addressof(&_fastEnumerationStorageMutationsTarget))
}

There's no reason to expose this publicly. The way NSFastEnumeration works, the mutationsPtr either points to a word-sized chunk of memory that will change if the collection is mutated (to catch mutation-while-iterating bugs), or it points to some constant memory. That means the standard library and the Foundation overlay can each use the address of their own global variable if they don't want to bother checking for mutations, and they don't need a wrapper function to do it.

@belkadan
Copy link
Author

@phausler, can you confirm that I understand NSFastEnumeration correctly?

@Moximillian
Copy link
Contributor

Trying to fix this in PR apple/swift#16018. I hope I got it right...

@Moximillian
Copy link
Contributor

Somewhat confused with the @_inlineable and friends... Should they not be used here, similar to https://github.com/apple/swift/pull/15634/files ?

@Moximillian
Copy link
Contributor

PR has been merged to master. Resolving the issue.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants