Fix a bug that pointers to ObjCInterfaces can be invalid when std vector
expended. Now allocate all the interfaces in BumpPtrAllocator so the
pointers to APIs are always valid as long as API class is alive.
rdar://76155450
Add a new swift-frontend driver option that extract APIs in the swift
module and print in JSON format. This is to allow tooling to understand
and process swift APIs without the need to be a swift compiler or
understand swift module/AST.
This adds new kinds of link entities corresponding to the three
dispatch thunk link entity kinds:
- DispatchThunkAsyncFunctionPointer
- DispatchThunkInitializerAsyncFunctionPointer
- DispatchThunkAllocatorAsyncFunctionPointer
Previously, the name of the entry point function was always main. Here,
a new frontend flag is added to enable an arbitrary name to be
specified.
rdar://58275758
Previously, the "bare" linkage of a link entity was used to determine
whether to put an async function pointer into the tbd. That did not
match the mechanism by which the linkage was determined in IRGen.
There, the linkage is the "_effective_" linkage (i.e. the value returned
from SILFunction::getEffectiveSymbolLinkage).
Here, whether to put the async function pointer corresponding to a class
method is determined on the basis of that effective linkage.
rdar://problem/73203508
- `Mangle::ASTMangler::mangleAutoDiffDerivativeFunction()` and `Mangle::ASTMangler::mangleAutoDiffLinearMap()` accept original function declarations and return a mangled name for a derivative function or linear map. This is called during SILGen and TBDGen.
- `Mangle::DifferentiationMangler` handles differentiation function mangling in the differentiation transform. This part is necessary because we need to perform demangling on the original function and remangle it as part of a differentiation function mangling tree in order to get the correct substitutions in the mangled derivative generic signature.
A mangled differentiation function name includes:
- The original function.
- The differentiation function kind.
- The parameter indices for differentiation.
- The result indices for differentiation.
- The derivative generic signature.
Previously, an async function pointer symbol was being emitted into the
TBD for all AbstractFunctionDecls which returned true for
"hasAsynContext", i.e. both those that were async and those which were
asnycHandlers. That was not correct because the async function portion
of an asyncHandler is not ABI. Here, that mistake is fixed by only
emitting this symbol for functions which are annotated async (i.e. those
for which "hasAsync" returns true).
rdar://problem/72329062
In order to call async functions, instances of the AsyncFunctionPointer
struct must be used. If those functions are exported from a module, the
AsyncFunctionPointer by means of which the function is to be called must
be exported as well.
For now, the symbol is exported by manually appending the relevant
suffix to the mangled name of the function.
This attribute allows to define a pre-specialized entry point of a
generic function in a library.
The following definition provides a pre-specialized entry point for
`genericFunc(_:)` for the parameter type `Int` that clients of the
library can call.
```
@_specialize(exported: true, where T == Int)
public func genericFunc<T>(_ t: T) { ... }
```
Pre-specializations of internal `@inlinable` functions are allowed.
```
@usableFromInline
internal struct GenericThing<T> {
@_specialize(exported: true, where T == Int)
@inlinable
internal func genericMethod(_ t: T) {
}
}
```
There is syntax to pre-specialize a method from a different module.
```
import ModuleDefiningGenericFunc
@_specialize(exported: true, target: genericFunc(_:), where T == Double)
func prespecialize_genericFunc(_ t: T) { fatalError("dont call") }
```
Specially marked extensions allow for pre-specialization of internal
methods accross module boundries (respecting `@inlinable` and
`@usableFromInline`).
```
import ModuleDefiningGenericThing
public struct Something {}
@_specializeExtension
extension GenericThing {
@_specialize(exported: true, target: genericMethod(_:), where T == Something)
func prespecialize_genericMethod(_ t: T) { fatalError("dont call") }
}
```
rdar://64993425
In #31686 changes were introduced to ensure that capacity was stored in
the ManagedBuffer allocation, and @lorentey sugested that as a stopgap
measure for addressing the lack of platform malloc introspection on
OpenBSD, we use Swift availability attributes instead on the relevant
parts of ManagedBuffer and friends.
Since platform availability symbols must be specifically set up to be
used, this commit does so in advance of the above change.
Add a `PublicSymbolsOnly` option to TBDGenOptions
that controls whether to include public-only
symbols. This is `true` by default, but will be
disabled for symbol mapping.
Add a request that leverages the TBDGenVisitor to
produce a mapping from a mangled symbol name to
the SIL or IR entity that emits it. This will be
used to enable lazy compilation where only a
specific set of symbols need to be emitted.
Refactor `TBDGenVisitor` to accept a callback for
when it discovers a symbol, and split off public
symbol gathering into `PublicSymbolsRequest` such
that we don't need to unnecessarily also build a
TBD file which we immediately throw away.
A @_fixed_layout protocol exposes its witness table layout to
clients, which prevents re-ordering of requirements or adding
new requiremenst with a default.
When library evolution is enabled, we still emit method
descriptors even for @_fixed_layout protocols; this allows a
previously-resilient protocol to become @_fixed_layout as long
as the published layout matches the resilient layout in all
previously-shipped versions of the library.