Commit Graph

10155 Commits

Author SHA1 Message Date
Arnold Schwaighofer
0d324d223f Add swift_getTypeByMangledNameInContextInMetadataState such that we can
use getTypeByMangledName when abstract metadata state is requested

This can significantly reduce the code size of apps constructing deeply
nested types with conditional conformances.

Requires a new runtime.

rdar://57157619
2019-11-18 14:41:35 -08:00
swift-ci
9905c44509 Merge pull request #28327 from CodaFi/do-it-for-the-datagrams 2019-11-18 13:38:21 -08:00
Philippe Hausler
498a240a98 [Foundation] Reorder _DataStorage to save 14 bytes of overhead 2019-11-18 10:52:35 -08:00
Robert Pieta
cda5676525 IndexSet.union performance improvement 2019-11-18 09:50:05 -08:00
Sergo Beruashvili
62a75d762d Use precondition instead of fatalError in DateInterval initializer 2019-11-17 15:15:55 -08:00
Slava Pestov
50872964dd Merge pull request #28289 from slavapestov/generic-parameters-are-unreliable-witnesses
Revert "Sema: Look for generic parameters first when inferring an associated type"
2019-11-16 01:56:16 -05:00
Nate Cook
8bfe519413 [stdlib] Use RRC.filter in removeAll(where: _) (#18825) 2019-11-15 16:24:27 -06:00
Mike Ash
8499a7f4fb Merge pull request #28183 from mikeash/zero-size-builtin-type-descriptors-remote-mirror
[Reflection] Ignore BuiltinTypeDescriptors with zero size, alignment, or stride.
2019-11-15 13:15:38 -08:00
Slava Pestov
55e3797471 Revert "Sema: Look for generic parameters first when inferring an associated type"
This breaks source compatibility a little bit more than we'd like, so
reverting it for now.

Fixes <rdar://problem/57213598>.

This reverts commit 04fbcc0149.
2019-11-15 14:32:13 -05:00
Nate Cook
7c0ed24867 [stdlib] Document Windows implementation of SystemRandomNumberGenerator (#28268) 2019-11-15 10:38:44 -06:00
Mike Ash
ee8447e7ab [Reflection] Reject BuiltinTypeDescriptors with non-power-of-two alignments.
rdar://problem/56784375
2019-11-15 10:50:51 -05:00
Mike Ash
e7163006ee [Reflection] Accept BuiltinTypeDescriptors with zero size.
rdar://problem/56784375
2019-11-14 16:43:51 -05:00
Mike Ash
1b8a723038 [Reflection] Ignore BuiltinTypeDescriptors with zero size, alignment, or stride.
rdar://problem/56784375
2019-11-14 16:14:48 -05:00
Luca Torella
e6992d35cd Fix reference to range(of:) in the contains doc
Signed-off-by: Luca Torella <luca@scandit.com>
2019-11-14 10:44:05 -08:00
Slava Pestov
04fbcc0149 Sema: Look for generic parameters first when inferring an associated type
Previously we did this as a last resort if inference fails. The new
behavior is technically source-breaking, but I suspect nobody
relied on the old behavior.

This can help avoid cycles by eliminating some unnecessary validation work.

Fixes <https://bugs.swift.org/browse/SR-11407>, <rdar://problem/54979757>.
2019-11-13 23:42:08 -05:00
Michael Ilseman
1d63710a06 Merge pull request #28016 from milseman/swept_under_the_bridge
[stdlib] [gardening] Refactor bridging from StringStorage.swift
2019-11-06 13:43:32 -08:00
Dan Zheng
53e61a9587 [AutoDiff upstream] Add the _Differentiation module. (#27511)
The `_Differentiation` module is the experimental support library for
differentiable programming. It is built when the build-script flag
`--enable-experimental-differentiable-programming` is enabled.

The `Differentiable` protocol generalizes all types that work with
differentiation. It is a core piece of the differentiable programming
project. Other parts depending on the `Differentiable` protocol will
be upstreamed piece by piece.

The `Differentiable` protocol is compiler-known and will be used during
type-checking, SILGen, and the SIL differentiation transform.
2019-11-06 11:31:12 -08:00
Karoy Lorentey
4008261ab8 Merge pull request #27939 from compnerd/gnu-no-more
stdlib: remove usage of GNU extensions in the Darwin os module
2019-11-05 12:01:41 -08:00
Hamish Knight
1bc56dcc11 [stdlib] Mark some parameters @_nonEphemeral
These include the pointer-to-pointer and pointer-to-buffer-pointer
initialiser parameters amongst a couple of others, such as
`Unmanaged.fromOpaque`, and the source for the `move[...]` family of
methods.
2019-11-03 08:42:26 -08:00
Michael Ilseman
8463e53df3 [stdlib] [gardening] Refactor bridging from StringStorage.swift
Add StringStorageBridge.swift to separate out ObjC interop
functionality.

NFC
2019-11-01 17:25:08 -07:00
Mike Ash
da71f6bedc [Reflection] Fix length calculation in readTypeRef.
The code was skipping 4/8 bytes to jump overn embedded reference, but it actually needs to skip 5/9 bytes in order to skip over the leading control character as well.

Also change the abort() calls to return nullptr so that we can fail more gracefully if this code is ever presented with bad data, since we want inspection tools to be robust in the face of garbage.

rdar://problem/56460096
2019-10-31 14:12:41 -04:00
David Smith
406d03bdef Merge pull request #27974 from Catfish-Man/erroneous-errors
Don't try to speculatively bridge tagged pointers to Errors
2019-10-30 18:31:16 -07:00
David Smith
acb5b570f5 Don't try to speculatively bridge tagged pointers to Errors 2019-10-30 15:16:10 -07:00
swift-ci
2d73686903 Merge pull request #27962 from mikeash/isbackdeploying-fix 2019-10-30 12:36:12 -07:00
Mike Ash
ce1112126c [Runtime] Fix guards around _swift_isBackDeploying call in SwiftObject.mm.
This could fail to build due to BackDeployment.h not always being included in Config.h. Check an additional condition to ensure that this code is only active when BackDeployment.h is included.

rdar://problem/56735154
2019-10-30 13:48:30 -04:00
Saleem Abdulrasool
7e050d14e6 stdlib: remove usage of GNU extensions in the Darwin os module
Remove the gratuitous use of the GNU extensions to implement the OS logging
module.  This allows us to enable `-Werror=gnu` globally, even on macOS builds.
2019-10-30 08:38:46 -07:00
Mike Ash
7b650c5da5 [Runtime] Extend Metadata::dump for existential type metadata.
Dump whether it's class bounded, the protocols it contains, and the superclass constraint if there is one.
2019-10-30 09:36:14 -04:00
Mike Ash
55f9d2afca Merge pull request #27863 from mikeash/will-throw-callback
[Runtime] Add a function pointer for intercepting swift_willThrow calls.
2019-10-29 16:50:36 -04:00
David Smith
ed1f9b30ef Implement both -isEqual: and -isEqualToString: to directly call the internal _isEqual, to avoid a redundant ObjC message send + type check 2019-10-28 16:36:13 -07:00
Mike Ash
b8f5e841e2 [Runtime] Add a function pointer for intercepting swift_willThrow calls.
rdar://problem/53400364
2019-10-24 14:06:14 -04:00
David Smith
637af2f9fe Merge pull request #27709 from Catfish-Man/bridge-to-the-future
Optimize accessing Swift arrays via ObjC
2019-10-23 00:19:06 -07:00
David Smith
d9cef0afef Optimize accessing Swift Arrays from ObjC 2019-10-22 20:57:36 -07:00
Julian Lettner
e819acdc29 Merge pull request #27808 from apple/tsan-empty-array-storage
[TSan] Do not report benign race on `_swiftEmptyArrayStorage`
2019-10-21 18:39:36 -07:00
David Smith
282e0c858b Merge pull request #27826 from Catfish-Man/last-object-standing
Bridging fidelity: allow removeLastObject() on empty NSMutableArrays
2019-10-21 18:32:24 -07:00
David Smith
da6adc8ba2 Bridging fidelity: allow removeLastObject() on empty NSMutableArrays 2019-10-21 17:20:32 -07:00
Julian Lettner
381dcc24fc [TSan] Do not report benign race on _swiftEmptyArrayStorage
A previous commit [1] identified and fixed a benign race on
`_swiftEmptyArrayStorage`.  Unfortunately, we have some code duplication
and the fix was not applied to all the necessary places.  Essentially,
we need to ensure that the "empty array storage" object that backs many
"array like types" is never written to.

I tried to improve the test to capture this, however, it is very
finicky.  Currently, it does not go red on my system even when I remove
the check to avoid the benign race in Release mode.

Relevant classes: Array, ArraySlice, ContiguousArray, ArrayBuffer,
ContiguousArrayBuffer, SliceBuffer.

[1] b9b4c789f3

rdar://55161564
2019-10-21 11:22:25 -07:00
David Smith
948f548247 Merge pull request #27779 from Catfish-Man/the-stars-are-aligned
Guard against passing endIndex to foreignScalarAlign when back-deploying to 5.0 stdlibs
2019-10-18 16:48:10 -07:00
David Smith
a1c1779c9f Guard against passing endIndex to foreignScalarAlign when back-deploying to 5.0 stdlibs 2019-10-18 14:24:23 -07:00
Jordan Rose
ac21ee486f [reflection] Go back to 0/1 for bitwise_takable instead of false/true
I wanted to make the output nicer, but it makes it harder to write
tests that work across OS versions, so never mind.

rdar://problem/56350587
2019-10-16 16:17:39 -07:00
Jordan Rose
52035c1cb9 Merge pull request #27081 from ismetanin/SR-7165
SR-7165. Excise <iostream> from reflection
2019-10-16 13:34:02 -07:00
Mike Ash
8dc43e6cea Merge pull request #27572 from mikeash/protocol-existential-crisis
[Runtime] Handle existential target types in swift_dynamicCastMetatypeImpl
2019-10-16 09:14:41 -04:00
swift-ci
a91d4aaa52 Merge pull request #27670 from Catfish-Man/fastscii-2 2019-10-15 18:39:45 -07:00
David Smith
007ff00617 Add fast paths for String(decoding:…, as: Unicode.ASCII.self) 2019-10-15 17:26:23 -07:00
Ivan Smetanin
8036eddc42 [stdlib] [reflection] Fix print in dumpFieldSection 2019-10-15 08:45:09 +03:00
Dan Zheng
2bd55f6755 [Autodiff upstream] Add build-script flag for differentiable programming. (#27595)
Add `--enable-experimental-differentiable-programming` build-script flag.

The build-script flag enables/disables standard library additions
related to differentiable programming. This will allow official Swift
releases to disable these additions.

The build-script flag is on by default to ensure testing of
differentiable programming standard library additions. An additional
driver flag must be enabled to use differentiable programming features:
https://github.com/apple/swift/pull/27446
2019-10-14 14:34:48 -07:00
Ivan Smetanin
0d27475be4 [stdlib] [reflection] Fix printing, remove & from 2019-10-14 22:17:48 +03:00
Ivan Smetanin
dd7d173c97 [stdlib] [reflection] Excise iostream from reflection 2019-10-14 20:28:20 +03:00
Jordan Rose
171ff440fc Remove swift::reversed in favor of llvm::reverse (#27610)
The former predates the latter, but we don't need it anymore! The
latter has more features anyway.

No functionality change.
2019-10-10 17:16:09 -07:00
Mike Ash
3ff277d31d [Runtime] Use _conformsToProtocols instead of manually checking protocol conformance.
This is cleaner and it fixes a bunch of cases the old code didn't handle: @objc protocols, class bounds, and superclass constraints.

rdar://problem/56044443
2019-10-10 14:14:41 -04:00
Mike Ash
d56173eb14 [Runtime] Handle existential target types in swift_dynamicCastMetatypeImpl.
This fixes cases like `type is T.Type` when T is generic specialized to a protocol type.

Note: the compiler can still optimize these checks away and will optimize this check down to `false` in some cases. We'll want to fix that as well.

rdar://problem/56044443
2019-10-08 11:37:39 -04:00