Commit Graph

3163 Commits

Author SHA1 Message Date
Dario Rexin
8733969222 [Runtime] Fix sign-compare warning in BytecodeLayouts (#67001) 2023-06-28 19:14:37 -07:00
Dario Rexin
3524945cd4 [IRGen+Runtime] Implement getEnumTag for singleton enums in layout strings (#66985) 2023-06-28 14:25:34 -07:00
Mike Ash
811950eb93 Merge pull request #66959 from mikeash/standard-protocol-manglings-go-faster
[Runtime] Fast-path lookup of protocol descriptors with standard manglings.
2023-06-28 09:48:44 -04:00
Dario Rexin
ca664141cc [IRGen+Runtime] Add support for initializeBufferWithCopyOfBuffer to layout strings (#66965) 2023-06-27 18:05:30 -07:00
Mike Ash
516c21a790 [Runtime] Fast-path lookup of protocol descriptors with standard manglings.
We weren't taking advantage of standard manglings in _findProtocolDescriptor like wo do in _findContextDescriptor. Extract out the "standard mangling" code and call it from both to speed up those searches.

rdar://111235115
2023-06-27 14:15:15 -04:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Dario Rexin
fc6834daf6 [IRGen+Runtime] Add getEnumTag for layout strings on simple single payload enums (#66941) 2023-06-26 19:32:51 -07:00
Dario Rexin
253d8fbf33 [IRGen+Runtime] Add getEnumTag for layout strings on generic single payload enum (#66911) 2023-06-23 20:43:28 -07:00
Dario Rexin
270089f297 [IRGen+Runtime] Layout string getEnumTag for fixed size enums subset (#66899)
* [IRGen+Runtime] Layout string getEnumTag for fixed size enums subset

getEnumTag impl for layout strings of fixed sized enums that use a function to fetch the enum tag

* Fix potential UB in IRGen
2023-06-23 18:10:55 -07:00
Alastair Houghton
e5ece81cc9 [Freestanding] Remove uses of stat() and dlsym().
We shouldn't be using stat() or dlsym() in the freestanding
runtime.

rdar://111214571
rdar://106555012
2023-06-23 17:05:59 +01:00
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
Alastair Houghton
4f4d0147ca Merge pull request #66721 from al45tair/eng/PR-110665213
[Threading][TSan] Fix TSan errors from lazy init on Linux.
2023-06-22 20:03:00 +01:00
Dario Rexin
37220ed37f [Runtime] Handle generic multi payload enums in resilient resolve (#66848)
* [Runtime] Handle generic multi payload enums in resilient resolve

* Update BytecodeLayouts.cpp

* Update BytecodeLayouts.cpp
2023-06-22 12:02:46 -07:00
Dario Rexin
c3ae41381d [Runtime] Use proper offset in generic multi payload enum layout strings (#66856) 2023-06-22 12:02:33 -07:00
Dario Rexin
806fd1b58b [Runtime] Handle generic single payload enums in resilient resolve (#66849) 2023-06-22 10:53:55 -07:00
David Smith
e20be0edc6 Revert [Runtime] Let CF provide us with state, avoiding runtime lookup. rdar://111104451 (#66606) 2023-06-22 10:24:51 -07:00
Yuta Saito
a613ab2521 Revert "Revert "Merge pull request #66793 from kateinoigakukun/pr-a75d757a3dcce5b990423cf1ab73ba4cd2f95b10""
This reverts commit 7aa4a8de06.
2023-06-22 08:31:32 +00:00
Yuta Saito
ad9409b517 [static-stdlib] NFC: Generalize the static-executable-args.lnk file generation
This patch makes the build system to copy the lnk files for each
stdlib targets if needed instead of only for the Linux target.

This is the take 2 of the patch. The first one was reverted in
7aa4a8de06
2023-06-22 08:30:37 +00: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
Slava Pestov
3676379302 Merge pull request #66814 from slavapestov/variadic-type-conditional-conformance
Conditional conformances for variadic generic types
2023-06-21 17:52:28 -04:00
Slava Pestov
8742b1a1e2 Runtime: Fix shape requirement handling in _checkGenericRequirements()
We would say the shape requirement was always satisfied since we
incorrectly checked the left-hand side type twice.
2023-06-21 15:03:53 -04:00
Slava Pestov
3052e36f7e Runtime: Fix dynamic casts of variadic types that conditionally conform 2023-06-21 13:42:57 -04:00
Slava Pestov
d1cb9307c9 Runtime: Support for conditional conformances with pack conformance requirements 2023-06-21 13:42:57 -04:00
Max Desiatov
bcc102d621 Revert "Merge pull request #66759 from kateinoigakukun/pr-a33fc5da8cdbc494e3935399dd7b74eba2288267"
This reverts commit 0795dede1c, reversing
changes made to 0845bc1373.
2023-06-21 17:55:05 +01:00
Max Desiatov
7aa4a8de06 Revert "Merge pull request #66793 from kateinoigakukun/pr-a75d757a3dcce5b990423cf1ab73ba4cd2f95b10"
This reverts commit c9d20c4024, reversing
changes made to ca0061dab7.
2023-06-21 17:54:43 +01:00
David Smith
7eb8283a49 [Runtime] Let CF provide us with state, avoiding runtime lookup. rdar://111104451 (#66606)
Provide a hook for CF to tell us about the state we need from it, rather than us having to look it up at runtime
2023-06-21 08:38:14 -07:00
Yuta Saito
c9d20c4024 Merge pull request #66793 from kateinoigakukun/pr-a75d757a3dcce5b990423cf1ab73ba4cd2f95b10
[static-stdlib] Add static executable support for WASI target
2023-06-21 18:19:47 +09:00
Dario Rexin
493a25faae [IRGen+Runtime] Add layout string support for generic single payload enums (#66791) 2023-06-20 20:46:54 -07:00
Yuta Saito
2555dc7e35 [static-stdlib] Add static executable support for WASI target
This patch adds static-executble-args.lnk file for WASI target
2023-06-21 03:29:20 +00:00
swift-ci
0795dede1c Merge pull request #66759 from kateinoigakukun/pr-a33fc5da8cdbc494e3935399dd7b74eba2288267
[static-stdlib] NFC: Generalize the static-executable-args.lnk file generation
2023-06-20 20:22:44 -07:00
Yuta Saito
29b27374d9 [static-stdlib] NFC: Generalize the static-executable-args.lnk file generation
This patch makes the build system to copy the lnk files for each
stdlib targets if needed instead of only for the Linux target.

Co-authored-by: Max Desiatov <m_desiatov@apple.com>
2023-06-21 01:07:32 +00:00
Yuta Saito
ae0a061663 Merge pull request #66543 from kateinoigakukun/pr-b1e7535cbac5af8c5e06068a747c1b925d571265
[wasm] Add metadata registration for WebAssembly
2023-06-20 19:52:07 +09:00
Alastair Houghton
bad716f2cd [Threading][TSan] Rearrange things again.
We need ThreadSanitizer.cpp in libswiftCore for the runtime case, but
we also need it in libswiftThreading for non-runtime cases.

rdar://1106655213
2023-06-19 17:00:39 +01:00
Alastair Houghton
8ed8a28478 [Threading][TSan] Move ThreadSanitizer.cpp into the main runtime.
On Darwin, `RTLD_NEXT` doesn't do what we need it to here, with the
result that if `libswiftCore`'s TSan initializer gets found first,
then `libswift_Concurrency` won't have its initializer called at all,
in spite of us using `RTLD_NEXT` to find the next definition.

Fix this by centralising the initializer in `libswiftCore` instead.

rdar://110665213
2023-06-19 15:33:36 +01:00
Yuta Saito
f527f72640 Merge pull request #66423 from kateinoigakukun/pr-0c7c2f57b05a694965ab652f57cbfead006a33d7
[static-stdlib] Move static-executable-args.lnk under stdlib/public/Resources/linux
2023-06-19 19:30:53 +09:00
Yuta Saito
8d84a64556 [wasm] Add metadata registration for WebAssembly
This patch adds the metadata registration for the wasm targets, and also
adds build support for it.
2023-06-19 06:13:20 +00:00
Dario Rexin
d74c085fe8 [Runtime+IRGen] Add layout string support for generic singleton enums (#66647) 2023-06-14 20:13:15 -07:00
Saleem Abdulrasool
df71ee08ba Merge pull request #66524 from hjyamauchi/dump-generic-metadata
Fix the swift-inspect dump-generic-metadata operation.
2023-06-14 14:48:07 -07:00
swift-ci
12b1843289 Merge pull request #66377 from mikeash/section-scan-signposts
[Runtime] Add tracing for section scans.
2023-06-14 13:50:28 -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
Mike Ash
110f428780 [Runtime] Add tracing for section scans.
Section scans (for metadata, protocols, etc.) can be costly. This change adds tracing calls to those scans so we can more easily see how much time is spent in these scans and where they're initiated.

This adds an os_signpost implementation controlled by SWIFT_STDLIB_TRACING, and a default empty implementation for when that's disabled.

rdar://110266743
2023-06-14 12:07:44 -04:00
Alastair Houghton
dd7acb1739 [Backtracing][Linux] Properly align the stacks.
We have two stacks that we set up during crash handling, both of
which were potentially misaligned.  This only tripped us up on
Ubuntu 20.04 on aarch64 - my guess is that maybe `clone()` aligns
the stack pointer on newer kernels which is why we didn't see it
on 22.04.

rdar://110743884
2023-06-14 13:40:51 +01: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
Alastair Houghton
7145ff019d Merge pull request #66567 from al45tair/eng/PR-110653167
[Backtracing][Linux] Fix Ubuntu 20.04-aarch64 CI failures.
2023-06-13 15:50:01 +01: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
7e632c0ee0 [Backtracing][Linux] Fix Ubuntu 20.04-aarch64 CI failures.
These seem to be related to signal handling issues in threads that
have been started presumably by the C library or some other library.

Primarily this appears to affect Ubuntu 20.04 on aarch64, though I
have seen sporadic issues on 18.04 as well.

We address the problem by making the thread suspension mechanism
more robust in the face of threads with masked signals.

rdar://110653167
2023-06-12 18:54:05 +01:00
Yuta Saito
3198412db0 [wasm][stdlib] Fix return-address strategy selection
__GNUC__ can be defined on Wasm targets as well, so we need to check
__wasm__ first.
2023-06-10 10:15:34 +00:00
Dario Rexin
91d547f982 [Runtime] Properly handle unaligned reads in readTagBytes for layout strings (#66506) 2023-06-09 23:02:34 -07:00
Hiroshi Yamauchi
50ef384f88 Fix the swift-inspect dump-generic-metadata operation.
ReflectionContext::allocationMetadataPointer() was reading the
metadata pointer from a wrong offset because of the out-of-sync struct
layouts and dump-generic-metadata was not working correctly.

This change resync's the layouts and adds a static_assert to verify
that the offsets match between GenericMetadataCacheEntry and
GenericCacheEntry.
2023-06-09 18:33:06 -07:00