Commit Graph

1552 Commits

Author SHA1 Message Date
Dario Rexin
36ddb77fcd [IRGen+Runtime] Layout string getEnumTag for generic multi payload enums (#66872)
We already store all necessary information to extract the tag in the layout string, so we should utilize it for the getEnumTag witness
2023-06-22 19:07:50 -07:00
Dario Rexin
fd369cd050 [Runtime] Refactor layout string code (#66831)
Made the code a bit more readable by adding a reader and writer type that encapsulate
the layout string and offset.
2023-06-21 19:46:22 -07:00
Dario Rexin
493a25faae [IRGen+Runtime] Add layout string support for generic single payload enums (#66791) 2023-06-20 20:46:54 -07:00
Dario Rexin
d74c085fe8 [Runtime+IRGen] Add layout string support for generic singleton enums (#66647) 2023-06-14 20:13:15 -07:00
Dario Rexin
8b48a0d3e0 [Runtime+IRGen] Instantiate layout strings for generic multi payload enum (#66621)
Instantiating layout strings for generic types reduces code size and is expected to improve performance of generic value witnesses.
2023-06-14 09:31:11 -07:00
Dario Rexin
58ff42af16 [Runtime] Properly handle tuple types in layout string instantiation (#66603)
Tuple types contain metadata entries for each element, so we can handle them individually to avoid unnecessary indirection.
2023-06-13 13:48:05 -07:00
Dario Rexin
4ec82768ce [Runtime] Extract some layout string functionality into separate functions (#66577)
We want to re-use them for enum layout string instantiation, so best to pull them into separate functions.
2023-06-12 23:40:58 -07:00
Alastair Houghton
2f0e42ba8d [Backtracing] Use stderr by default unless interactive.
This means we don't need to specify `output-to` in CI.

rdar://110371557
2023-06-07 13:54:36 +01:00
Alastair Houghton
5d03a72dcb Merge pull request #66338 from al45tair/eng/PR-101623265
[Backtracing][Linux] Enable Linux backtracing, add tests.
2023-06-07 13:49:49 +01:00
Alastair Houghton
d67354473f Merge pull request #66335 from al45tair/eng/PR-110261712
[Backtracing][Linux] Add support for Linux in the _Backtracing module.
2023-06-07 13:48:46 +01:00
Alastair Houghton
ee5596428f [Backtracing][Linux] Enable Linux backtracing, add tests.
Turn on the Linux backtracing implementation and update the tests.

rdar://101623265
2023-06-07 09:08:18 +01:00
Alastair Houghton
ae9a0c1007 Merge pull request #66334 from al45tair/eng/PR-110261430
[Backtracing][Linux] Add Linux crash handler to the runtime.
2023-06-07 08:41:28 +01:00
Alastair Houghton
582946b3ee [Backtracing][Linux] Remove status argument.
The `status` argument to the `_swift_backtrace_demangle()` function
isn't especially useful, won't match behaviour on Windows, and we
actually don't use it in the Swift code that calls this SPI.

Remove it.

rdar://110261712
2023-06-07 08:19:13 +01:00
Alastair Houghton
438ab7fa29 [Backtracing][Linux] Add Linux support to the _Backtracing module.
Use the new module structure rather the old SwiftShims header.  This
is much cleaner and lets us include operating system headers to get
the relevant definitions where possible.

Add code to support ELF and DWARF, including decompression using
zlib, zstd and liblzma if those turn out to be required and available.

rdar://110261712
2023-06-06 16:16:20 +01:00
Alastair Houghton
979b749a0d [Backtracing][Linux] Move doc comment to header.
Moved the comment for `_swift_backtrace_demangle` into the header file
instead of it being in the implementation.

rdar://110261430
2023-06-06 16:12:47 +01:00
Alastair Houghton
14fcdbd389 [Backtracing][Linux] Tidy a few things up after review.
Mike and Max made various helpful suggestions, so I've added and updated
various comments and amended the code to cope with partial reads and
writes.

rdar://110261430
2023-06-06 16:06:21 +01:00
Alastair Houghton
deb06c8348 [Backtracing][Linux] Add missing CrashInfo.h header.
This was added to a later PR, but not to this one, though we need
it here.

rdar://110261430
2023-06-05 16:59:14 +01:00
Alastair Houghton
2dcaa6f14f [Backtracing][Linux] Add Linux crash handler to the runtime.
This also adds a function to demangle a symbol, and a way for the
backtracing code to report warning messages to the same place as
the main runtime.

I'd like to rename the _swift_isThunkFunction() SPI also, but we
can't do that until we've made the changes to the _Backtracing
library, so we'll do that there instead.

rdar://110261430
2023-06-05 15:39:50 +01:00
Mike Ash
bf868b0b04 [Runtime] Add ptrauth to standard concurrency descriptors.
Put the __ptrauth_swift_type_descriptor qualifier on the fields of ConcurrencyStandardTypeDescriptors.
2023-05-30 10:29:31 -04:00
Mike Ash
dfd313cd6c [Runtime] Fast lookups of Concurrency types with standard manglings.
Have the Concurrency runtime register a struct containing pointers to all of its type descriptors with standard manglings. Then have the runtime use that struct to quickly look up those types, instead of using the standard, slower type lookup code.

rdar://109783861
2023-05-24 16:08:23 -04:00
Slava Pestov
8a6bb30c4c IRGen: Heap-allocate metadata and witness table packs captured by escaping closures 2023-03-28 21:44:53 -04:00
Konrad `ktoso` Malawski
0586c14b60 [Concurrency] SerialExecutor.isSameExclusiveExecutionContext (#64604) 2023-03-28 15:56:28 +09:00
Alastair Houghton
9209bdd8c4 [Backtracing] Add an option to output to stderr.
In CI, it would be better if the backtraces went to stderr rather than
stdout, so provide an option for that.

rdar://107192120
2023-03-24 17:13:52 +00:00
Konrad `ktoso` Malawski
e0877594da [Concurrency] Custom executors with move-only Job (#63569) 2023-03-18 14:02:43 +09:00
Dario Rexin
2f8c1a402c [IRGen] Make pointers to accessor functions in layout strings relative (#64155)
* [IRGen] Make pointers to accessor functions in layout strings relative

rdar://106319336

Pointers embedded in static layout strings should always be relative, so layout strings can reside in read-only memory.

* Properly handle reference storage ownership

* Pass layout tag and metadata / type layout ppointers separately

* Layout string instantiation fully working

* Fix cases where hasLayoutString flag was not set when it should have

* Update include/swift/ABI/Metadata.h
2023-03-17 09:02:51 -07:00
Kuba (Brecka) Mracek
78a406a75d In Metadata.h/.cpp, start building the relative wtable support even on platforms that don't use it yet (#64354) 2023-03-15 09:41:40 -07:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
Evan Wilde
2c49700ed5 Merge pull request #64054 from etcwilde/ewilde/startOnMainActor
Concurrency: swift_task_startOnMainActor
2023-03-06 18:57:51 -08:00
Evan Wilde
1bd1c468a0 Concurrency: Task.startOnMainActor
This patch adds an SPI to run the first partial function of a MainActor
asynchronous function on the MainActor synchronously. This is
effectively like the asynchronous program entrypoint behavior. The first
partial function is run synchronously. Following continuations are
enqueued for execution like any other asynchronous function.
2023-03-06 13:33:22 -08:00
Alastair Houghton
b9800fda43 Merge pull request #64102 from al45tair/backtracing/full-extra-shims
[Backtracing] Build work.
2023-03-06 20:54:27 +00:00
Dario Rexin
5fe716577b [IRGen] Add layout strings for generic and resilient types (#64023)
* [IRGen] Add layout strings for generic and resilient types

rdar://105837048

* Add some corner cases

* Add flag to enable generic instantiation and some fixes

* Fix resilient types

* Fix metadata accessor function pointers in combined layout strings
2023-03-05 15:26:45 -08:00
Alastair Houghton
1258d45152 [Backtracing] Build work.
Additional shimming required for some builds, as well as a few other build
related tweaks.

rdar://106234311
2023-03-04 15:46:30 +00:00
Alastair Houghton
43ac069ad0 [Backtracing] Add control over symbol caching.
Some symbolication frameworks have a symbol cache; we probably don't want
to use that for test cases, to avoid running into problems where the cache
holds stale information.

rdar://105409147
2023-03-04 08:00:09 +00:00
Alastair Houghton
55104aae54 [Backtracing] Fix Windows assembler related problem.
We need to enable MASM/MARMASM and we need to add a get-cpu-context.asm
file for it to build.

rdar://104336548
2023-03-04 07:56:03 +00:00
Alastair Houghton
8a29657f4c [Runtime] [Darwin] Add code to trigger the external backtracer.
When a Swift program crashes, we should catch the crash and execute the
external backtracer.

rdar://105391747
2023-03-04 07:56:02 +00:00
Slava Pestov
66ed09e72b Runtime: Variadic generic type fixes 2023-03-03 02:24:01 -05:00
Evan Wilde
877d03f4f5 Merge pull request #61692 from etcwilde/ewilde/fix-noreturn-warning
Fix asyncMainDrainQueue noreturn warning
2023-03-02 18:21:38 -08:00
Alastair Houghton
95b8a4877b Merge pull request #63964 from al45tair/backtracing/path-lookup
[Backtracing] Add support for looking up paths for auxiliary executables
2023-03-03 00:09:14 +00:00
Slava Pestov
68378b8feb Merge pull request #64031 from slavapestov/remove-obsolete-concurrent-map
Remove obsolete ConcurrentMap and friends
2023-03-02 15:07:16 -05:00
Slava Pestov
01acda7730 Runtime: Remove linear order on metadata cache keys 2023-03-02 10:22:11 -05:00
Slava Pestov
affc232b8a Runtime: Remove ConcurrentMap 2023-03-02 09:35:28 -05:00
Slava Pestov
64c796eea2 Runtime: Remove ConcurrentList 2023-03-02 09:33:31 -05:00
Evan Wilde
841fda5dbe Add asyncMainDrainQueue hook
The swift_task_asyncMainDrainQueue function acts as the entrypoint into
driving the main queues, ultimately running the whole program and acting
as the backing driver of the main actor. Making the function hookable
means that custom concurrency runtimes can implement their own async
entrypoints, allowing async top-level code and async-main to "just
work".
2023-03-01 22:16:23 -08:00
Slava Pestov
2173db0a2a Merge pull request #63961 from slavapestov/variadic-generic-types-plumbing
Start working on runtime support for variadic generic types
2023-03-01 15:48:11 -05:00
Alastair Houghton
f6bfa7ef35 [Backtracing] Change the return type of one of the paths functions.
Since it's copying, it may as well return `char *` instead of
`const char *`.

rdar://103071801
2023-03-01 19:08:08 +00:00
Alastair Houghton
69bad8cb09 [Backtracing] Rename a couple of functions, some comment changes.
Renamed a couple of functions following review feedback.  Also added some
extra words to the comments.

rdar://103071801
2023-03-01 13:43:15 +00:00
Alastair Houghton
4b066d4868 [Backtracing] Update the comment for swift_getAuxiliaryExecutablePath()
This should have said how to release the string.

rdar://103071801
2023-03-01 13:43:15 +00:00
Alastair Houghton
f02f62f1e3 [Backtracing] Add support for looking up paths for auxiliary executables.
We need to be able to locate `swift-backtrace` relative to the current
location of the runtime library.

This needs to work:

* In a Swift build directory.
* On Darwin, where we're installed in /usr/lib/swift and /usr/libexec/swift.
* On Linux, where we're in /usr/lib/swift/linux and /usr/libexec/swift/linux.
* On Windows, where we may be in a flat directory layout (because of limitations
  of Windows DLL lookups).

rdar://103071801
2023-03-01 13:43:15 +00:00
Konrad `ktoso` Malawski
a2783b2e8d [Concurrency] UnownedJob.priority and description for TaskPriority 2023-02-28 16:17:48 +09:00
Slava Pestov
d764167783 Runtime: Fix Windows build 2023-02-28 02:12:32 -05:00