Commit Graph

252 Commits

Author SHA1 Message Date
Richard Wei
de2dbe57ed [AutoDiff] Bump-pointer allocate pullback structs in loops. (#34886)
In derivatives of loops, no longer allocate boxes for indirect case payloads. Instead, use a custom pullback context in the runtime which contains a bump-pointer allocator.

When a function contains a differentiated loop, the closure context is a `Builtin.NativeObject`, which contains a `swift::AutoDiffLinearMapContext` and a tail-allocated top-level linear map struct (which represents the linear map struct that was previously directly partial-applied into the pullback). In branching trace enums, the payloads of previously indirect cases will be allocated by `swift::AutoDiffLinearMapContext::allocate` and stored as a `Builtin.RawPointer`.
2020-11-30 15:49:38 -08:00
Alexis Laferrière
e509d6883a Revert "[Sema] Fix availability checking in inlinable code" 2020-10-14 10:52:11 -07:00
Alexis Laferrière
2f182c2b78 [Sema] Consider unavailable functions as being unreachable
This has the effect of rejecting unavailable overrides to available
methods in a similar way as overrides that are less available than the
introduction are rejected.
2020-10-09 10:40:21 -07:00
Nate Chandler
607772aaa2 [Runtime] Stubbed entry points for task de/alloc. 2020-09-30 18:57:48 -07:00
Nate Chandler
3edf8e16de [metadata prespecialization] Bump availability.
Previously, the availability was 5.3.  Since
compareProtocolConformanceDescriptors was added in 5.4 and was used by
metadata accessors with baked-in checks for arguments which matched
prespecializations, 5.3 was incorrect.  Moreover, now that the searching
for matches is done by getGenericMetadata, the metadata accessors no
longer contain the early exits, so running against a 5.3 runtime would
entail the metadata accessor failing to produce canonical prespecialized
records.

Here, the availability is bumped to 5.4 which includes the runtime
changes to support the metadata accessors not having early exits to
return prespecialized records.
2020-08-14 11:24:41 -07:00
Nate Chandler
b0fc8daa83 [Runtime] Add entry point to canonicalize metadata.
The new function swift_getCanonicalSpecializedMetadata takes a metadata
request, a prespecialized non-canonical metadata, and a cache as its
arguments.  The idea of the function is either to bless the provided
prespecialized metadata as canonical if there is not currently a
canonical metadata record for the type it describes or else to return
the actual canonical metadata.

When called, the metadata cache checks for a preexisting entry for this
metadata.  If none is found, the passed-in prespecialized metadata is
added to the cache.  Otherwise, the metadata record found in the cache
is returned.

rdar://problem/56995359
2020-07-15 15:27:36 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Mishal Shah
60d996f060 [Apple Silicon] Add support for triple and availability canonicalization 2020-07-02 19:26:25 -07:00
Mishal Shah
0c07365a08 [Apple Silicon] Fix the availability for Swift 5.3 version 2020-07-02 19:23:11 -07:00
Mishal Shah
710ba14ddc [Apple Silicon] [Platform] Baseline arm64 simulators at iOS/tvOS 14.0 and watchOS 7.0. 2020-07-02 19:18:52 -07:00
Mishal Shah
3c9e72f6e1 [Apple Silicon] [macCatalyst] Baseline arm64(e) macCatalyst at Swift 5.3/iOS 14.0. 2020-07-02 18:28:33 -07:00
Mishal Shah
134f202e01 [Apple Silicon] Baseline arm64 macOS at Swift 5.3 / macOS 10.16 2020-07-02 16:42:15 -07:00
Nate Chandler
6d0c34caf3 [Runtime] Add entry point to compare conformance descriptors.
The new function swift_compareProtocolConformanceDescriptors calls
through to the preexisting code in MetadataCacheKey which has been
extracted out from MetadataCacheKey::compareWitnessTables into a new
public static function
MetadataCacheKey::compareProtocolConformanceDescriptors.

The new function's availability is "future" for now.
2020-06-22 15:01:28 -07:00
Nate Chandler
2c6d7d78df [Runtime] Add entry point to compare type context descriptors.
The new function `swift_compareTypeContextDescriptors` is equivalent to
a call through to swift::equalContexts.  The implementation it the same
as that of swift::equalContexts with the following removals:
- Handling of context descriptors of kind other outside of
  ContextDescriptorKind::Type_First...ContextDescriptorKind::Type_Last.
  Because the arguments are both TypeContextDescriptors, the kinds are
  known to fall within that range.
- Casting to TypeContextDescriptor.  The arguments are already of that
  type.

For now, the new function has "future" availability.
2020-06-22 12:07:02 -07:00
Brent Royal-Gordon
05736d14b8 Handle multiple @available attributes correctly
The previous commit broke a promise made by the implementation it replaced: if there were two or more @available(introduced:) attributes for the same platform, the greatest version wins. This commit restores that property while still completely overriding the parent platform’s availability with a child platform’s.
2020-04-17 02:31:25 -07:00
Brent Royal-Gordon
96e6e5042b Fix @available(macCatalyst N, iOS N+M) bug
Previously, availability checking computed a declaration’s availability as the intersection of all @available attributes with active platforms. This meant that Swift would not allow you to use an API that was available earlier in a child platform than in its parent until it was also available in the parent platform. That was incorrect.

This PR corrects availability checking to find the most specific @available attribute with an introduced version and use that instead.

Fixes rdar://60892534.
2020-04-14 14:23:33 -07:00
Joe Groff
c90b8f7722 Swift 5.3 is always available for arm64e.
Nobody has shipped an ABI-stable arm64e platform yet, so anyone who does ought to deploy at least
Swift 5.3.
2020-03-18 16:49:47 -07:00
Kuba (Brecka) Mracek
c728d7a4d2 Fix failing IRGen arm64e tests (#30296) 2020-03-10 11:22:54 -07:00
Slava Pestov
3904fe83fb AST: Centralize ABI-related deployment target checks
There were a couple of methods in LangOptions and some related ones in
Availability and ASTContext that were added more recently.

Refactor the three older checks to the newer scheme.
2020-03-03 22:49:19 -05:00
Nate Chandler
4300f711b4 [metadata prespecialization] Available in 5.3. 2020-02-06 11:13:21 -08:00
Nate Chandler
23ff5f8964 [metadata prespecialization] Future availability.
Metadata prespecialization will be available after Swift 5.2.
2020-01-24 14:46:30 -08:00
Nate Chandler
c4d13e4b4b [IRGen] Directly reference prespecializations.
When possible, directly reference metadata prespecializations.  Doing so
is possible when the type is defined in the same module, because in
those cases the metadata accessor can be modified to ensure that the
prespecialized metadata is canonical.

rdar://problem/56994171
2020-01-09 17:25:33 -08:00
Nate Chandler
89278f8cbf [metadata prespecialization] Target only >=5.2.
Compatibility with earlier swift runtimes would require modifying the
runtime compatibility libraries to adjust the behavior of
checkMetadataState by way of typeForMangledNode or even
typeForMangledName.  For now, simply require that a version of swift
whose runtime knows about prespecialized metadata is being targeted.
2020-01-09 17:25:32 -08:00
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
Arnold Schwaighofer
eb32194e97 Refactor to use RuntimeAvailability 2019-06-14 13:21:35 -07:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
Joe Groff
2ade303387 IRGen: Weak-link opaque type entry points.
When backward deploying to an OS that may not have these entry points, weak-link them so that they
can be used conditionally in availability contexts that check for them.

rdar://problem/50731151
2019-05-15 20:40:54 -07:00
Slava Pestov
7ffa09557d AST: Introduce AvailabilityContext::forDeploymentTarget() 2019-02-19 18:57:30 -05:00
Ankit Aggarwal
92d09f4e19 Extend @available to support PackageDescription
<rdar://problem/46548531> Extend @available to support PackageDescription

This introduces a new private availability kind "_PackageDescription" to
allow availability testing by an arbitary version that can be passed
using a new command-line flag "-swiftpm-manifest-version". The semantics
are exactly same as Swift version specific availability. In longer term,
it maybe possible to remove this enhancement once there is
a language-level availability support for 3rd party libraries.

Motivation:

Swift packages are configured using a Package.swift manifest file. The
manifest file uses a library called PackageDescription, which contains
various settings that can be configured for a package. The new additions
in the PackageDescription APIs are gated behind a "tools version" that
every manifest must declare. This means, packages don't automatically
get access to the new APIs. They need to update their declared tools
version in order to use the new API. This is basically similar to the
minimum deployment target version we have for our OSes.

This gating is important for allowing packages to maintain backwards
compatibility. SwiftPM currently checks for API usages at runtime in
order to implement this gating. This works reasonably well but can lead
to a poor experience with features like code-completion and module
interface generation in IDEs and editors (that use sourcekit-lsp) as
SwiftPM has no control over these features.
2018-12-08 09:38:40 +05:30
Bob Wilson
c3e02955bb [master-next] Adjust for VersionTuple moving from clang to llvm.
LLVM r334399 (and related Clang changes) moved clang::VersionTuple to
llvm::VersionTuple. Update Swift to match.

Patch by Jason Molenda.
rdar://problem/41025046
2018-06-12 16:44:11 -07:00
Slava Pestov
162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07:00
Graydon Hoare
d94b76f396 Suggest narrowing an exising availability context, when feasible. 2017-01-19 16:29:16 -08:00
Slava Pestov
7731d4c6cb Sema: Remove some unnecessary calls to getCanonicalType() 2017-01-08 21:01:13 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
Slava Pestov
abf0df367e AST: Fix a nit 2016-12-14 23:02:39 -08:00
Michael Gottesman
1af1cbfb76 [gardening] Add a bunch of end namespace comments found by clang-tidy. 2016-12-06 19:22:52 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Graydon Hoare
3ca75559a4 Exclude @available(swift) from PlatformKind::none Availability inference. 2016-10-12 11:21:31 -07:00
Graydon Hoare
42c1a6ce42 Rename UnconditionalAvailabilityKind and UnavailableInCurrentSwift.
UnconditionalAvailabilityKind => PlatformAgnosticAvailabilityKind
    ::UnavailableInCurrentSwift =>   ::SwiftVersionSpecific

Plus a couple related method renamings. Prep work for SR-2709.
2016-10-12 11:20:41 -07:00
Jordan Rose
5e0f4b704d [AST] Introduce AvailabilityContext to wrap VersionRange.
This is the beginning of the extension of the availability model
introduced in Swift 2.0 to support two interesting things: inlineable
code and binary frameworks not tied to an OS. The former is critical
to having a stable standard library that isn't shipped with a client app.

(For more information on both of these, see docs/LibraryEvolution.rst.)

The existing availability model enforces that API is not used unless
the developer has already guaranteed its existence. We want to reuse
this logic for these new purposes. Additionally, certain queries about
the AST are dependent on this type of information as well, e.g. "can I
assume this enum will not grow any additional cases?" If the enum comes
from the module being compiled, the answer is usually "yes", but not if
the code asking the question may be inlined into another binary!

(This latter purpose is currently served by ResilienceExpansion down at
the SIL level; my goal is to replace ResilienceExpansion with
AvailabilityContext. It's a bit heavier but would also allow additional
optimization in the future.)

This commit does not change any logic; it only wraps existing uses of
VersionRange in AvailabilityContext if they're not strictly referring to
the OS version.
2016-02-02 17:41:29 -08:00
practicalswift
8efa5f587e [gardening] Remove "-*- C++ -*-" tag from .cpp files
Emacs assumes .h files are C files by default which is why the
tag "-*- C++ -*-" is needed.

.cpp files do not have this problem.
2016-01-23 12:09:32 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Daniel Duan
ae601d2744 replace NULL with nullptr 2015-12-20 13:28:21 -08:00
Devin Coughlin
d1e244c7e0 [Sema] Rename version range lattice operations. NFC.
Following Jordan's advice, replace "join" with "union" and "meet" with
"intersect" in VersionRange to make it clear which direction these operations
go in the lattice of ranges.

Swift SVN r31640
2015-09-02 21:52:01 +00:00
Devin Coughlin
259b54748c Importer: Synthesize inferred availability for unannotated Obj-C protocols
Based on feedback from Jordan, update r30060 to synthesize availability
attributes on unannotated Obj-C protocols in the importer. This has a
user-visible effect: calls to protocol requirements with these synthesized
attributes will now cause an availability error if the requirement is not
available in the calling type refinement context.

Swift SVN r30096
2015-07-10 22:48:22 +00:00
Ted Kremenek
62feb5c949 Change @availability to @available.
This came out of today's language review meeting.
The intent is to match #available with the attribute
that describes availability.

This is a divergence from Objective-C.

Swift SVN r28484
2015-05-12 20:06:13 +00:00
Doug Gregor
4e0e32197f Extend 'availability' attribute with an unconditional 'deprecated' option.
Allow an unversioned 'deprecated' attribute to specify unconditional
deprecation of an API, e.g.,

  @availability(*, deprecated, message="sorry")
  func foo() { }

Also support platform-specific deprecation, e.g.,

  @availability(iOS, deprecated, message="don't use this on iOS")
  func bar() { }

Addresses rdar://problem/20562871.

Swift SVN r27355
2015-04-16 06:36:45 +00:00
Doug Gregor
921855ee0d Revert "Extend 'availability' attribute with an unconditional 'deprecated' option."
This reverts r27339; it broke an iOS test.

Swift SVN r27343
2015-04-16 03:36:40 +00:00
Doug Gregor
b4b5dbb5d8 Extend 'availability' attribute with an unconditional 'deprecated' option.
Allow an unversioned 'deprecated' attribute to specify unconditional
deprecation of an API, e.g.,

  @availability(*, deprecated, message="sorry")
  func foo() { }

Also support platform-specific deprecation, e.g.,

  @availability(iOS, deprecated, message="don't use this on iOS")
  func bar() { }

Addresses rdar://problem/20562871.

Swift SVN r27339
2015-04-15 23:59:20 +00:00