Commit Graph

13406 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
5faf82c553 Improve usability of _mangledTypeName with Any.Type arguments 2020-04-05 12:27:50 +09:00
nate-chandler
feba039217 Merge pull request #30785 from nate-chandler/rdar60790020
[Runtime] Handle incomplete class metadata in _checkGenericRequirements.
2020-04-03 15:32:53 -07:00
nate-chandler
afc963aa82 Merge pull request #30793 from nate-chandler/generic-metadata-prespecialization-components/prepare-for-classes
[prespecialized metadata] Note classes are complete.
2020-04-03 14:00:45 -07:00
Nate Chandler
2863f1964d [Runtime] Handle incomplete class metadata in _checkGenericRequirements.
When constructing the metadata for a type Gen<T : Super>
where Super is a superclass constraint, the generic argument K at which
the metadata for Gen is being instantiated is verified to be a subclass
of Super via _checkGenericRequirements.

Previously, that check was done using swift_dynamicCastMetatype.  That
worked for the most part but provided an incorrect answer if the
metadata for K was not yet complete.  These classes are incomplete more
often thanks to __swift_instantiateConcreteTypeFromMangledNameAbstract.

That issue occurred concretely in the following case:

  Framework with Library Evolution enabled:

    open class Super { ... }
    public struct Gen<T : Super> {
    }

  Target in a different resilience domain from that framework:

    class Sub : Super {
      var gen: Gen<Sub>?
    }

Here, the mechanism for checking whether the generic argument K at which
the metadata for Gen is being instantiated handles the case where K's
metadata is incomplete.  At worst, every superclass name from super(K)
up to Super are demangled to instantiate metadata.  A number of faster
paths are included as well.

rdar://problem/60790020
2020-04-03 13:28:54 -07:00
Ewa Matejska
36cf56651f fixing up some tests and turning off SIMD extension which uses @_alwaysEmitIntoClient since that's not supported yet. 2020-04-03 12:59:47 -07:00
Nate Chandler
a1e2fb019e [prespecialized metadata] Note classes are complete.
In preparation for the prespecialization of metadata for generic
classes, make checkMetadataState always return that the state of
prespecialized class metadata is complete, as is done for generic
structs and enums already.
2020-04-03 11:46:54 -07:00
Michael Ilseman
5815468ebb Merge pull request #30719 from milseman/tilde_equality
[String] Concrete String/Substring overloads for ~=
2020-04-03 11:12:32 -07:00
Ewa Matejska
b72aca9a5c Merge branch 'master' of https://github.com/apple/swift 2020-04-03 10:40:56 -07:00
3405691582
f8d0174b85 Build system recognizes OpenBSD.
Commit for CMake and build scripts to recognize OpenBSD. To keep this
commit relatively short, this just deals with the rather simple and
uncontroversial changes to the build system.

Note that OpenBSD calls "x86_64" as "amd64", Since the Swift stdlib will
be put in a subdirectory named after ARCH, to ensure the standard
library is properly found later, we use the native architecture name for
OpenBSD in the build system rather than trying to deal with the
difference the other way around.
2020-04-03 13:34:17 -04:00
Mike Ash
41cc3f3569 Merge pull request #30772 from mikeash/fix-mirror-enum-payload-extraction
[Mirror] Don't destroy and reconstitute enums when reflecting them.
2020-04-03 11:36:30 -04:00
Dan Zheng
e2014e3366 Merge pull request #30781 from dan-zheng/differentiation-transform-skeleton 2020-04-02 21:01:53 -07:00
Ewa Matejska
f07ae89636 First pass at upstreaming Differentiable conformances and derivatives 2020-04-02 19:55:26 -07:00
Dan Zheng
aa66cce808 [AutoDiff upstream] Add differentiation transform.
The differentiation transform does the following:
- Canonicalizes differentiability witnesses by filling in missing derivative
  function entries.
- Canonicalizes `differentiable_function` instructions by filling in missing
  derivative function operands.
- If necessary, performs automatic differentiation: generating derivative
  functions for original functions.
  - When encountering non-differentiability code, produces a diagnostic and
    errors out.

Partially resolves TF-1211: add the main canonicalization loop.

To incrementally stage changes, derivative functions are currently created
with empty bodies that fatal error with a nice message.

Derivative emitters will be upstreamed separately.
2020-04-02 15:43:57 -07:00
Mike Ash
f4e635320a [Mirror] Don't destroy and reconstitute enums when reflecting them.
It's possible to get multiple threads reading from the same enum at the same time, and the result can be bad data extracted or even permanent corruption of the value in memory. Instead, copy the enum value, then project the data from the copy.

rdar://problem/59493486
2020-04-02 13:44:19 -04:00
Michael Ilseman
30c92574ed [String] Concrete String/Substring overloads for ~=
Add concrete overloads for ~= for String/Substring
combinations. SR-12457 tracks making this generic after we understand
the expression type checker impact.
2020-04-02 10:37:30 -07:00
swift-ci
b1b725ac83 Merge pull request #30761 from benrimmington/de-gybbed-file-headers 2020-04-02 04:14:50 -07:00
Dan Zheng
1308fc69c5 [AutoDiff] Simplify conditions enabling differentiable programming. (#30765)
Previously, two conditions were necessary to enable differentiable programming:
- Using the `-enable-experimental-differentiable-programming` frontend flag.
- Importing the `_Differentiation` module.

Importing the `_Differentiation` module is the true condition because it
contains the required compiler-known `Differentiable` protocol. The frontend
flag is redundant and cumbersome.

Now, the frontend flag is removed.
Importing `_Differentiation` is the only condition.
2020-04-02 03:24:03 -07:00
Ben Rimmington
682c1672b6 [stdlib] Update file headers of de-gybbed files 2020-04-01 22:14:03 +01:00
marcrasi
77fd034a0b Merge pull request #30711 from rxwei/differential-operators
[AutoDiff upstream] Add differential operators and some utilities.
2020-04-01 10:11:35 -07:00
Karoy Lorentey
0344f0830e Merge branch 'master' into foundation-no-inlinable-shim-calls 2020-03-31 18:24:59 -07:00
tbkka
3c8fde7885 Implement MultiPayloadEnum support for projectEnumValue (#30635)
This code rearchitects and simplifies the projectEnumValue support by
introducing a new `TypeInfo` subclass for each kind of enum, including trivial,
no-payload, single-payload, and three different classes for multi-payload enums:

* "UnsupportedEnum" that we don't understand.  This returns "don't know" answers for all requests in cases where the runtime lacks enough information to accurately handle a particular enum.

* MP Enums that only use a separate tag value.  This includes generic enums and other dynamic layouts, as well as enums whose payloads have no spare bits.

* MP Enums that use spare bits, possibly in addition to a separate tag.  This logic can only be used, of course, if we can in fact compute a spare bit mask that agrees with the compiler.

The final challenge is to choose one of the above three handlings for every MPE.  Currently, we do not have an accurate source of information for the spare bit mask, so we never choose the third option above.  We use the second option for dynamic MPE layouts (including generics) and the first for everything else.

TODO: Once we can arrange for the compiler to expose spare bit mask data, we'll be able to use that to drive more MPE cases.
2020-03-31 15:12:44 -07:00
Joe Groff
026b8b31c9 Merge pull request #30318 from ktoso/wip-mangledTypeName
Add _mangledTypeName to allow round trips T->mangledName->T
2020-03-30 18:13:56 -07:00
Marc Rasi
64d0e76dd9 improve differential operator tests 2020-03-30 14:57:59 -07:00
Richard Wei
57d228b39e [AutoDiff upstream] Add differential operators and some utilities.
* Add all [differential operators](https://github.com/apple/swift/blob/master/docs/DifferentiableProgramming.md#list-of-differential-operators).
* Add `withoutDerivative(at:)`, used for efficiently stopping the derivative propagation at a value and causing the derivative at the value to be zero.
* Add utility `differentiableFunction(from:)`, used for creating a `@differentiable` function from an original function and a derivative function.

Mostly work done by @marcrasi and @dan-zheng.
Partially resolves TF-843.

TODO:
* Add `AnyDerivative`.
* Add `Array.differentiableMap(_:)` and `differentiableReduce(_:_:)`.
2020-03-30 14:15:35 -07:00
swift-ci
e5110d7953 Merge pull request #30146 from benrimmington/static-string-documentation 2020-03-27 16:36:13 -07:00
swift-ci
047438711f Merge pull request #30355 from mikeash/remote-mirror-type-name-api 2020-03-27 10:51:24 -07:00
Ravi Kandhadai
9b75217cc0 Merge pull request #30670 from ravikandhadai/oslog-test-simplification
[stdlib/private][os log] Simplify the OSLogPrototype private module and eliminate the dependency on os overlay.
2020-03-27 09:59:06 -07:00
Ravi Kandhadai
b7e8f76108 [stdlib/private][os log] Simplify the OSLogPrototype stdlib-private
module to contain only code necessary for testing the compiler
optimizations and diagnostics. This commit comprises the following changes:

1. Rename the OSLogPrototype module to OSLogTestHelper and rename the files.
2. Make the private module: OSLogTestHelper independent of os overlay.
3. Simplify the os log test suites and make them not perform logging.
4. Enable the os log test suites on all platforms.

<rdar://problem/60542172>
2020-03-27 01:18:04 -07:00
swift-ci
216bff5213 Merge pull request #30668 from lorentey/mark-xctest-overlay-obsolete 2020-03-26 19:10:21 -07:00
Karoy Lorentey
3e8509df08 [XCTest] Add a note explaining that this is not the real XCTest overlay 2020-03-26 16:30:45 -07:00
Joe Groff
4981da4a4d Merge pull request #30632 from Azoy/swift-5-3-hacks
Bump backward compatibility to 5.3
2020-03-26 11:16:01 -07:00
David Smith
40e67b53c9 Merge pull request #30034 from Catfish-Man/what-i-tell-you-three-times-is-true
Avoid mishandling retain_n of immortal objects where n >= 3
2020-03-26 11:00:46 -07:00
David Smith
78c693ba2d Avoid mishandling retain_n of immortal objects where n >= 3 2020-03-25 15:53:31 -07:00
Mike Ash
1c1d57574c [Reflection] Make sure DemanglingForTypeRef consistently wraps all nodes in a Type node.
rdar://problem/59909982
2020-03-25 17:23:22 -04:00
Mike Ash
3a9e7a6611 [Reflection] Implement TypeRef demangling for foreign classes.
rdar://problem/59909982
2020-03-25 17:22:45 -04:00
Azoy
d8ea42adfb Bump backward compatibility to 5.3 2020-03-25 11:41:15 -04:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
Eric Miotto
d8de5bafb0 [build] set linker parameters in a single way (for stdlib) (#30596)
Match the same fix as #30339 for `AddSwiftStdlib.cmake`.

Addresses rdar://problem/60791444
2020-03-24 06:51:44 -07:00
Mike Ash
e05720cd09 [RemoteMirror] Add a call to get the demangled name for a typeref.
rdar://problem/59909982
2020-03-23 13:53:35 -04:00
Martin Boehme
3ccecc6819 Remove [extern_c] attribute from WinSDK module.
I've verified that all of the header files in this module already
contain their own `extern "C"` blocks that are activated if compiling as
C++.

The additional [extern_c] attribute causes problems for some headers,
like PathCch.h, that define additional overloads of functions when
compiled as C++. The "global" [extern_c] essentially switches off name
mangling with these overloads, which causes them to conflict with the
functions they are overloading.

See here for more context:
https://github.com/apple/swift/pull/30233#issuecomment-601594221

See here for an example of failures caused by the [extern_c]:
https://ci-external.swift.org/job/swift-PR-windows/869/console

(Search for "PathCch.h".)
2020-03-20 10:45:38 +01:00
Konrad `ktoso` Malawski
34b6e4fe58 Add precondition that no repairs were made to _mangledTypeName string 2020-03-18 11:51:28 +09:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Xiaodi Wu
90c6c491d9 [gardening] Silence a warning about unused value 2020-03-14 10:33:45 -04:00
swift-ci
cc4bfe82da Merge pull request #30398 from milseman/palloc_size 2020-03-13 17:57:59 -07:00
Michael Ilseman
d98a022924 [stdlib] Re-enable assertions on malloc size
Round up our malloc requests and assert that breadcrumbs are aligned
and where we think they should be. This is necessary because ASAN
doesn't give us pointer-rounded sizes.
2020-03-13 15:50:40 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Luciano Almeida
d0af9eee96 [NFC] Fixing redundant discard assign void type warn on stdlib (#30397) 2020-03-13 09:51:41 +00:00
Slava Pestov
afa2440f85 Merge pull request #30370 from slavapestov/encapsulate-conformance-descriptor
Runtime: Use accessor method to get TargetWitnessTable::Description
2020-03-12 00:19:24 -04:00
Kuba (Brecka) Mracek
1a3c582490 Fix typos in declarations of swift_ptrauth_key_associated_type and swift_ptrauth_key_associated_conformance (#30363) 2020-03-11 19:24:30 -07:00
tbkka
ee36c1cc3e RemoteMirror: Project some multi-payload enums (#30357)
* First part of multi-payload enum support

This handles multi-payload enums with fixed
layouts that don't use spare payload bits.
It includes XI calculations that allow us to
handle single-payload enums where the payload
ultimately includes a multi-payload enum
(For example, on 32-bit platforms, String uses
a multi-payload enum, so this now supports single-payload
enums carrying Strings.)
2020-03-11 18:48:39 -07:00