Commit Graph

10736 Commits

Author SHA1 Message Date
Ben Cohen
345879429b [stdlib] Take several underscored stdlib functions private (#18134)
* Make _sanityCheck internal

* Make _debugPrecondition internal

* Make Optional._unsafelyUnwrappedUnchecked internal.

* Make _precondition internal

* Switch Foundation _sanityChecks to assertions

* Update file check tests

* Remove one more _debugPrecondition

* Update Optimization-with-check tests
2018-07-24 18:26:19 -07:00
swift-ci
36ead37964 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 17:49:02 -07:00
swift-ci
4edbd83576 Merge pull request #17923 from allevato/unicode-properties-docs 2018-07-24 17:45:06 -07:00
swift-ci
9fd7492fa6 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 15:09:02 -07:00
swift-ci
cf501b4f71 Merge pull request #18163 from DougGregor/protocol-context-descriptor 2018-07-24 15:00:04 -07:00
swift-ci
8aa4388545 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 07:29:29 -07:00
Mike Ash
c2452cf2c2 Merge pull request #18150 from mikeash/typeref-robustness
[Reflection] Make getSubstMap and visitDependentMemberTypeRef more robust against unexpected data.
2018-07-24 10:19:40 -04:00
Doug Gregor
e7998f1846 [ABI] Record unmangled names in Swift protocol descriptors.
Rather than storing a mangled name in a Swift protocol descriptor,
which encodes information that is redundant with the context of the
protocol, store an unmangled name as in nominal type descriptors. Update
the various places where this name is used to extract the demangle
tree from the context descriptors.
2018-07-24 04:25:13 -07:00
swift-ci
0dd8fb0061 Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 23:09:57 -07:00
Nate Cook
3d7dfc232b [stdlib] Update complexity docs for seq/collection algorithms (#17254)
* [stdlib] Update complexity docs for seq/collection algorithms

This corrects and standardizes the complexity documentation for Sequence
and Collection methods. The use of constants is more consistent, with `n`
equal to the length of the target collection, `m` equal to the length of
a collection passed in as a parameter, and `k` equal to any other passed
or calculated constant.

* Apply notes from @brentdax about complexity nomenclature

* Change `n` to `distance` in `index(_:offsetBy:)`

* Use equivalency language more places; sync across array types

* Use k instead of n for parameter names

* Slight changes to index(_:offsetBy:) discussion.

* Update tests with new parameter names
2018-07-24 01:01:34 -05:00
Doug Gregor
a54a6d8d7f [ABI] Rework protocol descriptor metadata.
Reimplement protocol descriptors for Swift protocols as a kind of
context descriptor, dropping the Objective-C protocol compatibility
layout. The new protocol descriptors have several advantages over the
current implementation:

* They drop all of the unused fields required for layout-compatibility
  with Objective-C protocols.
* They encode the full requirement signature of the protocol. This
  maintains more information about the protocol itself, including
  (e.g.) correctly encoding superclass requirements.
* They fit within the general scheme of context descriptors, rather than
  being their own thing, which allows us to share more code with
  nominal type descriptors.
* They only use relative pointers, so they’re smaller and can be placed
  in read-only memory

 Implements rdar://problem/38815359.
2018-07-23 22:12:42 -07:00
Mike Ash
e8ccfa824f [Reflection] Make getSubstMap and visitDependentMemberTypeRef more robust against unexpected data.
Remote mirrors was hitting an assertion failure due to a generic parameter not being concrete. This check catches that case early and returns a clean failure from getSubstMap, which callers can then handle appropriately.

It also hit a casting failure in visitDependentMemberTypeRef, which assumed that SubstBase was either a NominalTypeRef or a BoundGenericTypeRef. This does a dynamic cast with a graceful failure.

In general there is a tension in this code between its use in the runtime, where we usually want to treat bad data as a horrible bug and fail loudly, and its use in remote mirrors, where we need to assume that the data we're examining might be horribly broken and we just want to do the best we can. Longer term we might want to make this code configurable so that we can have an "assert and die" mode for the runtime, and a "fail gracefully" mode for remote mirrors.

rdar://problem/40136609
2018-07-23 14:32:39 -04:00
swift-ci
9095b8762a Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 10:29:27 -07:00
Ben Cohen
f4eae3fff0 Clean up debug printing code (#18126) 2018-07-23 10:11:37 -07:00
swift-ci
fe35287c42 Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 09:29:56 -07:00
Doug Gregor
72e0ee960b Merge pull request #18129 from DougGregor/protocol-descriptor-ref
[ABI] Distinguish @objc from Swift protocol descriptor references
2018-07-23 09:25:33 -07:00
swift-ci
ad5dab2227 Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 03:49:27 -07:00
Karoy Lorentey
9ff95733f4 Merge pull request #17974 from lorentey/hide-hashed-collection-details
[stdlib] Set/Dictionary: Make some implementation details non-inlinable
2018-07-23 11:40:37 +01:00
Doug Gregor
c7a02a26a1 [ABI] Distinguish Swift/ObjC protocols in TargetGenericRequirement.
In a generic requirement, distinguish between Swift and
Objective-C protocols using a spare bit within the relative
(indirectable) reference to the protocol.
2018-07-22 22:48:57 -07:00
swift-ci
6f74f5bb5c Merge remote-tracking branch 'origin/master' into master-next 2018-07-21 17:49:44 -07:00
Ben Cohen
4694310e51 [stdlib] Some minor cleanup (#18130)
* Remove case destructuring to _

* Remove some Iterator.Element

* Which idiot wrote this? Oh.

* Switch NibbleSort to just use default impls... shouldn't change perf
2018-07-21 17:29:57 -07:00
Doug Gregor
bec722df57 [Runtime/IRGen] Switch swift_getExistentialTypeMetadata() to ProtocolDescriptorRef.
Switch one entry point in the runtime (swift_getExistentialTypeMetadata)
to use ProtocolDescriptorRef rather than a protocol descriptor. Update
IRGen to produce ProtocolDescriptorRef instances for its calls, setting
the discriminator bit appropriately.

Within the runtime, verify that all instances of ProtocolDescriptorRef have
the right layout, i.e., the discriminator bit is set for @objc protocols
but not Swift protocols.
2018-07-21 07:48:34 -07:00
Doug Gregor
3464929638 [ABI] Rework existential type metadata to use ProtocolDescriptorRef.
Use ProtocolDescriptorRefs within the runtime representation of
existential type metadata (TargetExistentialTypeMetadata) instead of
bare protocol descriptor pointers. Start rolling out the use of
ProtocolDescriptorRef in a few places in the runtime that touch this
code. Note that we’re not yet establishing any strong invariants on
the TargetProtocolDescriptorRef instances.

While here, replace TargetExistentialTypeMetadata’s hand-rolled pointer 
arithmetic with swift::ABI::TrailingObjects and centralize knowledge of
its layout better.
2018-07-20 20:54:49 -07:00
Bob Wilson
b2d8227a32 Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 18:46:05 -07:00
Jordan Rose
3ef027153b Merge pull request #18064 from jrose-apple/LLVM_DEBUG
Replace old DEBUG macro with new LLVM_DEBUG
2018-07-20 17:19:23 -07:00
swift-ci
e9e8f8baa3 Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 16:09:38 -07:00
swift-ci
8f17c0a94a Merge pull request #18113 from milseman/anullable 2018-07-20 15:51:03 -07:00
swift-ci
5a83d16acf Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 15:09:48 -07:00
swift-ci
0ee0c5602f Merge pull request #18112 from dcci/deadcodemepatatinomiobello 2018-07-20 15:01:57 -07:00
Jordan Rose
d7c503d2ce [Reflection] Rename DEBUG(...) to DEBUG_LOG(...)
This DEBUG(...) emulates LLVM's DEBUG(...), but it's controlled by a
different mechanism. LLVM's DEBUG(...) is getting renamed to
LLVM_DEBUG(...), so to keep this from looking like a use of the old
name I'm adjusting it to DEBUG_LOG.
2018-07-20 14:37:26 -07:00
swift-ci
1c77358086 Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 14:29:50 -07:00
swift-ci
48eb400a93 Merge pull request #17826 from brentdax/public-optional 2018-07-20 14:12:55 -07:00
Michael Ilseman
95cbf45957 [stubs] Add nullability annotations; NFC 2018-07-20 13:28:33 -07:00
swift-ci
cf0f869915 Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 13:09:39 -07:00
Ben Cohen
34610780fd Break out conformances into extensions (#18098)
Replace LoggingRangeReplaceableCollection variants with typealiases

Replace LoggingMutableCollection variants with typealiases.

Collapse BufferAccessLoggingMutableCollection variants into typealiases

Turn LoggingRandomAccessCollection into a typealias

Turn LoggingBidirectionalCollection into a typealias
2018-07-20 12:50:12 -07:00
Davide Italiano
0e5fa49b53 [stdlib] Remove dead code in SwiftRemoteMirror. 2018-07-20 12:49:16 -07:00
swift-ci
107dfa1aa5 Merge remote-tracking branch 'origin/master' into master-next 2018-07-19 15:09:31 -07:00
Huon Wilson
ac1738f02b Merge pull request #18066 from huonw/sr8022-workaround
[stdlib] Work-around incorrect name resolution with conditional BidirectionalCollections.
2018-07-20 07:59:25 +10:00
swift-ci
eed3176a7f Merge remote-tracking branch 'origin/master' into master-next 2018-07-19 12:09:41 -07:00
Jordan Rose
37e81db569 [runtime] Tidy up symbol table patching to satisfy with upstream Clang
'const T *' isn't compatible with a function pointer, so upstream
Clang complained about the 'patch_t' convenience constructor we were
using. It's not like we need general functionality or convenience
here, so just pass the members of the patch_t type separately and
without any templating, and drop it entirely.

No functionality change.
2018-07-19 11:22:44 -07:00
swift-ci
721f3f8873 Merge remote-tracking branch 'origin/master' into master-next 2018-07-19 08:49:42 -07:00
Jordan Rose
6f42fcc8c4 Merge pull request #18060 from jrose-apple/and-you-get-a-class_getImageName
[runtime] Backwards-deployment support for class_getImageName

https://bugs.swift.org/browse/SR-1917
rdar://problem/41535552
2018-07-19 08:36:23 -07:00
swift-ci
e2acff2bbc Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 23:08:57 -07:00
Doug Gregor
67cf94fb55 Merge pull request #17976 from DougGregor/evaluator-override-isobjc
[Type checker] Introduce requests for @objc, override, and 'dynamic' checking
2018-07-18 23:00:46 -07:00
Huon Wilson
72a87a76f8 [stdlib] Work-around incorrect name resolution with conditional BidirectionalCollections.
If a type conditionally conforms to BidirectionalCollection, suffix's (and the
others) use of `index` ends up dispatching through `Collection.index` seemingly
because it is a protocol requirement. The intended function is
BidirectionalCollection's overloaded `index` (which _isn't_ connected to a
protocol requirement), which is called for non-conditional conformances. As
such, this is a work-around to stop code crashing.

Noticed in SR-8022, rdar://problem/41216424.
2018-07-19 12:22:32 +10:00
Jordan Rose
a2c1aa3624 [runtime] Backwards-deployment support for class_getImageName
Follow-up to 3ed3774e07. On Apple OSs that don't have the new
Objective-C runtime function 'objc_setHook_getImageName', override the
system definition of 'class_getImageName' by literally rewriting
symbol tables at run time.

Yes, you read that correctly.

The low-level part of this patch was written by Greg Parker, then
simplified and tweaked by me to fit the Swift coding style. Don't try
this at home; it comes with all sorts of caveats and won't actually
work on this year's iOS. (Fortunately we don't need it there, because
that will have the new ObjC entry point.)

The rest of the patch is pretty straightforward: the replacement
implementation calls the code that supports Swift objects (the same
code we use on newer OSs), which then chains back to the original
system implementation of class_getImageName. May we never have to
touch this again.

rdar://problem/41535552
2018-07-18 18:28:12 -07:00
swift-ci
3aef406989 Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 15:49:08 -07:00
Matt Diephouse
f0cb64dec3 Conform Never to Error, Equatable, Comparable, and Hashable (#16857) 2018-07-18 15:41:14 -07:00
Doug Gregor
b70466dc63 [Type Checker] Add a request kind for computing 'ValueDecl::isObjC()'.
Still a WIP
2018-07-18 14:50:39 -07:00
swift-ci
0d5e1c68a4 Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 13:49:08 -07:00