Commit Graph

384 Commits

Author SHA1 Message Date
Slava Pestov
f2d1e8d2e9 AST: Invent mangling for PackType and PackExpansionType 2022-11-08 19:09:07 -05:00
Allan Shortlidge
6e07c8cfe1 Mangling: Add a mangling for #_hasSymbol query functions. 2022-10-13 21:00:24 -07:00
Dario Rexin
210c68d8aa [SILOptimizer] Add prespecialization for arbitray reference types (#58846)
* [SILOptimizer] Add prespecialization for arbitray reference types

* Fix benchmark Package.swift

* Move SimpleArray to utils

* Fix multiple indirect result case

* Remove leftover code from previous attempt

* Fix test after rebase

* Move code to compute type replacements to SpecializedFunction

* Fix ownership when OSSA is enabled

* Fixes after rebase

* Changes after rebasing

* Add feature flag for layout pre-specialization

* Fix pre_specialize-macos.swift

* Add compiler flag to benchmark build

* Fix benchmark SwiftPM flags
2022-09-22 16:29:01 -07:00
Alastair Houghton
d10bda6fed [Demangler] Fix a declaration shadowing warning.
We were using the name SymbolicReferenceResolver for both an argument and
a member variable.  Rename the argument to fix.

rdar://97560843
2022-08-01 08:55:21 +01:00
Nate Chandler
a9038057b9 [Outliner] Add consuming bridged property pattern.
Previously, for the BridgedProperty pattern, there were two flavors of
outlined function that would be formed, varying on the ownership of the
instance whose field is being access:

(1) guaranteed_in -- for use by addresses
(2) unowned -- for use by values which were not destroyed until some
              time after the pattern of interest is matched

Now that the lifetime of the instance may be shortened to just after the
call to the objc method, the latter of these is not appropriate for
values.  We would have to re-extend the lifetime until after the method
returns.

Instead, here, we add a new variant

(3) owned -- for use by values which were destroyed just after the objc
             method call

Doing so requires new mangling.
2022-07-22 08:17:14 -07:00
Erik Eckstein
30cd3869b9 Mangling: add a new mangling for generic specialization
For performance annotations we need the generic specializer to trop non-generic metatype argumentrs
(which we don't do in general). For this we need a separate mangling.
2022-07-07 08:34:53 +02:00
John McCall
175f74d38f Implement symbolic demangling for extended existential metadata
Fixes rdar://96268090.
2022-07-01 11:21:53 -04:00
Robert Widmann
dde0d8f609 Generalize the Mangling of Constrained Existential Types
Upgrade the old mangling from a list of argument types to a
list of requiremnets. For now, only same-type requirements
may actually be mangled since those are all that are available
to the surface language.

Reconstruction of existential types now consists of demangling (a list of)
base protocol(s), decoding the constraints, and converting the same-type
constraints back into a list of arguments.

rdar://96088707
2022-06-30 15:32:37 -07:00
Erik Eckstein
718de937b7 Add a mangling for constant static arrays.
The layout of constant static arrays differs from non-constant static arrays.
Therefore use a different mangling to get symbol mismatches if for some reason two modules don't agree on which version a static array is.
2022-06-17 11:21:29 +02:00
Alastair Houghton
5ffcaad1be [Demangler] Fix a NULL Node pointer assertion.
Found (using fuzzing) a couple of mangled strings that trigger assertion
failures.  Fix the problem and add test cases.

rdar://94143700
2022-05-31 12:50:59 +01:00
John McCall
bd77714537 Unique extended existential shapes using the generalized AST type.
I wrote out this whole analysis of why different existential types
might have the same logical content, and then I turned around and
immediately uniqued existential shapes purely by logical content
rather than the (generalized) formal type.  Oh well.  At least it's
not too late to make ABI changes like this.

We now store a reference to a mangling of the generalized formal
type directly in the shape.  This type alone is sufficient to unique
the shape:

- By the nature of the generalization algorithm, every type parameter
  in the generalization signature should be mentioned in the
  generalized formal type in a deterministic order.

- By the nature of the generalization algorithm, every other
  requirement in the generalization signature should be implied
  by the positions in which generalization type parameters appear
  (e.g. because the formal type is C<T> & P, where C constrains
  its type parameter for well-formedness).

- The requirement signature and type expression are extracted from
  the existential type.

As a result, we no longer rely on computing a unique hash at
compile time.

Storing this separately from the requirement signature potentially
allows runtimes with general shape support to work with future
extensions to existential types even if they cannot demangle the
generalized formal type.

Storing the generalized formal type also allows us to easily and
reliably extract the formal type of the existential.  Otherwise,
it's quite a heroic endeavor to match requirements back up with
primary associated types.  Doing so would also only allows us to
extract *some* matching formal type, not necessarily the *right*
formal type.  So there's some good synergy here.
2022-04-21 23:47:01 -04:00
John McCall
24616aed5c Mangling support for extended existential type shapes 2022-04-11 22:25:11 -04:00
Alastair Houghton
eb6f9e0bba Merge pull request #41452 from al45tair/eng/PR-89139049
[Demangler] Make Node::addChild(NULL, ...) always assert.
2022-03-25 10:03:59 +00:00
Alastair Houghton
71efd95052 [Demangler][Runtime] Give the demangler its own error handling.
The demangling library can't use the error handling from the main runtime
because it isn't always linked with it.  However, it's useful to have
some error handling, and in particular to be able to get data into the
crash logs.

This is complicated because of the way the demangling library gets used,
the upshot of which is that I've had to add a second object library just
for libswiftCore's use, so that the demangler will use the runtime's
error handling functions when present, and fall back on its own when
they aren't.

rdar://89139049
2022-03-24 13:05:13 +00:00
Alastair Houghton
edbfce2a88 Simplify the code slightly.
I was trying to use fatalError() here, but that is in libswiftRuntime,
which isn't linked into everything that has the demangler code in it.
The upshot is that we'd have to touch a lot of other projects to use
fatalError().

rdar://89139049
2022-03-14 10:08:15 +00:00
Alastair Houghton
e4855e7d35 Dump additional information on demangler assertion failure.
This should help to debug things when things go wrong.

rdar://89139049
2022-03-11 11:39:47 +00:00
Robert Widmann
3b3ff6a5db Define Mangling for ParameterizedProtocol 2022-03-08 22:01:19 -08:00
Allan Shortlidge
ed6d69fb15 Mangling: Add a mangling for back deployment fallback functions and update the back deployment thunk mangling to use the same prefix. 2022-02-18 16:30:27 -08:00
Alastair Houghton
8f74eb0bd1 Make Node::addChild(NULL, ...) always assert.
We need this in order to gather relevant information when this situation
arises; it's clearly happening (e.g. rdar://86071019), but not often
enough for it to trigger in a build with assertions enabled.

rdar://89139049
2022-02-18 12:13:56 +00:00
Allan Shortlidge
ff5abc4e2f Mangling: Use 'Tw' to mangle back deployment thunks. 2022-02-17 11:28:12 -08:00
Erik Eckstein
13d2b1fe15 mangling: add a mangling for constant propagating keypaths in capture propagation.
This is not ABI affecting.
2022-02-01 08:13:27 +01:00
Xi Ge
1667c5f643 mangling: take the constness of function parameters into mangling
Taking constness of parameters into mangling allows us to support overloads of
functions vary on the constness of specific parameters.

rdar://87954644
2022-01-24 11:51:01 -08:00
swift-ci
3fb96c900e Merge remote-tracking branch 'origin/main' into rebranch 2022-01-09 07:13:54 -08:00
Konrad `ktoso` Malawski
9438cf6b2e [Distributed] Func metadata operations and implement executeDistributedTarget entry (#40605)
* [Distributed] Implement func metadata and executeDistributedTarget

dont expose new entrypoints

able to get all the way to calling _execute

* [Distributed] reimplement distributed get type info impls

* [Distributed] comment out distributed_actor_remoteCall for now

* [Distributed] disable test on linux for now
2022-01-09 23:55:06 +09:00
swift-ci
834e655ae3 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-08 18:54:28 -08:00
Michael Gottesman
5dc8b3879b [move-function] SILCloner/mangling changes to support converting inout_aliasable defer parameters to out parameters after move analysis. 2022-01-08 13:41:05 -08:00
swift-ci
59e21f8a71 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-07 16:00:06 -08:00
Doug Gregor
61d35f07a4 Merge pull request #40766 from DougGregor/mangle-multiple-opaque-types
Introduce a mangling for multiple opaque types within the declaration.
2022-01-07 15:45:38 -08:00
Doug Gregor
f89ff0485f Introduce a mangling for multiple opaque types within the declaration.
The `Qr` mangling is used to refer to the opaque type within the
declaration that produces the opaque type. When there are multiple
opaque types, e.g., due to structural or named opaque result types, it
does not specify which of the opaque type parameters it refers to.

Introduce a new mangling `QR INDEX` for opaque type parameters after
the first, retaining the `Qr` mangling for the first opaque type
parameter. This way, existing (non-structural) uses of opaque result
types retain the same manglings, but uses of structural or named
opaque result types (new features) will have distinct manglings.

Note that this mangling within a declaration is only used for the
declaration itself, and not for references to the opaque type of the
declaration, so there is no impact on the runtime demangler.
2022-01-07 10:43:45 -08:00
swift-ci
f63372b795 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-06 01:13:44 -08:00
Pavel Yaskevich
d516281da9 [Distributed] NFC: Remove Method from accessor APIs
The API is not constrained to methods only, it should support
computed properties as well.
2021-12-23 14:10:05 -08:00
swift-ci
134e17c8ec Merge remote-tracking branch 'origin/main' into rebranch 2021-12-17 16:54:09 -08:00
Pavel Yaskevich
8e1aa19188 [Mangling] Define mangling for runtime accessible function records 2021-12-17 10:52:56 -08:00
Pavel Yaskevich
b8358b26fe [Mangling] Add mangling for distributed method accessors
`Distributed Method Accessor` is a global helper function
to get access to particular `distributed method` on an actor
from outside the process.
2021-12-17 10:52:55 -08:00
Ben Barham
25b1b2517e [rebranch] Replace LLVM_ATTRIBUTE_NORETURN with [[noreturn]]
llvm-project 09529892b518c8df8c24395e68e0a7a5e8bda5fb removed
`LLVM_ATTRIBUTE_NORETURN` in favour of the C++11 `[[noreturn]]`.
2021-11-18 16:49:28 +10:00
Robert Widmann
924d15b03f [NFC] Swap LLVM_NODISCARD for LLVM_ATTRIBUTE_NORETURN
These were originally meant to be no-return functions since they're going to abort. They were accidentally changed to no-discard functions despite not having a return value.
2021-11-17 13:17:37 -08:00
zoecarver
2546406de8 [cxx-interop][nfc] Remove internal header dependency on runtime/stdlib/shims.
The internal compiler headers should not include swift shim headers. Removing this dependency allows libSwift to import Swift compiler headers (otherwise, we get name conflics, because we import SwiftShims headers twice: from the source includes and build includes).
2021-10-25 14:56:45 -07:00
Doug Gregor
142973b653 Use a non-conflicting mangling for distributed thunks.
Distributed thunks were using the same mangling as direct method
reference thunks (i.e., for "super" calls). Although not technically
conflicting so long as actors never gain inheritance, it's confusing
and could cause problems in the future. So, introduce a distinct
mangling for distributed thunks and plumb them through the demangling
and remangler.
2021-10-15 23:15:43 -07:00
Kuba (Brecka) Mracek
557bf685be Don't include support for old mangling in runtimes without ObjC interop (#39675) 2021-10-13 19:47:05 -07:00
Alastair Houghton
5c00c7e0fa Merge pull request #39506 from al45tair/problem/82870372
[Remangler] Fix remangling in static bound generic function context
2021-10-02 09:26:24 +01:00
Kuba Mracek
d0e05003f5 For individual runtime records for types/protocols/conformances, add and use new mangling suffixes 2021-09-29 13:14:58 -07:00
Alastair Houghton
1ac9159a81 [Remangler] Fix remangling of items in static bound generic function context
If you had a type alias (for instance) with its context set to a static
bound generic function, the generic arguments were remangled in the wrong
place because Node::Kind::Static wasn't handled properly in a couple of
functions.  Fix that.

rdar://82870372
2021-09-29 14:27:31 +01:00
Alastair Houghton
8be084f30a Merge pull request #39187 from al45tair/problem/79725187
[Demangler] Improve remangler error handling
2021-09-27 17:03:49 +01:00
Doug Gregor
7f2117690c Skip standard substitutions for _Concurrency types when back-deploying.
When back-deploying concurrency support, do not use the standard
substitutions for _Concurrency-defined types (such as `Task`) in type
metadata because older Swift runtimes will not be able to demangle
them. Instead, use the full mangled names so the runtime can still
demangle them appropriately.

Addresses rdar://82931890.
2021-09-09 13:23:19 -07:00
Alastair Houghton
59cfe356d5 [Demangling] Improve DEMANGLE_ASSERT, enable some disabled tests.
Defining DEMANGLE_ASSERT as assert() is simple but messes up the file/line
information from assert().  Make a dedicated assertion failure function and use
that instead to fix.

Also enable some tests that were disabled because they triggered abort()
calls in the remanglers.

rdar://79725187
2021-09-07 14:08:29 +01:00
Alastair Houghton
c23d2f45c4 [Demangler] Fix NULL dereference on malformed mangled class name.
The (invalid) type name '__TJO' caused a NULL dereference.  Fix that
and add a test case.

rdar://80602920
2021-07-16 14:19:35 +01:00
Alastair Houghton
779b10daeb [Demangler] Fix OldRemangler's handling of Subscript nodes.
The Subscript node isn't laid-out the way the code in OldRemangler thinks,
which has the unfortunate result of causing crashes.

rdar://63410196
2021-07-02 11:40:20 +01:00
Doug Gregor
58f49692ed Add mangling, metadata, and reflection support for "isolated" parameters.
Isolated parameters are part of function types. Encode them in function
type manglings and metadata, and ensure that they round-trip through
the various mangling and metadata facilities. This nails down the ABI
for isolated parameters.
2021-06-08 00:00:11 -07:00
Doug Gregor
b814e225dd Implement (de-)mangling and type metadata for global actor function types.
Implement name mangling, type metadata, runtime demangling, etc. for
global-actor qualified function types. Ensure that the manglings
round-trip through the various subsystems.

Implements rdar://78269642.
2021-06-02 23:34:22 -07:00
Doug Gregor
b57a73ab42 [Concurrency ABI] Add standard substitutions for _Concurrency types.
Introduce a second level of standard substitutions to the mangling,
all of the form `Sc<character>`, and use it to provide standard
substitutions for most of the _Concurrency types.

This is a precursor to rdar://78269642 and a good mangling-size
optimization in its own right.
2021-06-01 17:15:02 -07:00