Commit Graph

2981 Commits

Author SHA1 Message Date
Mike Ash
fe7e13bba5 [Runtime][IRGen] Sign type context descriptor pointers.
Ensure that context descriptor pointers are signed in the runtime by putting the ptrauth_struct attribute on the types.

We use the new __builtin_ptrauth_struct_key/disc to conditionally apply ptrauth_struct to TrailingObjects based on the signing of the base type, so that pointers to TrailingObjects get signed when used with a context descriptor pointer.

We add new runtime entrypoints that take signed pointers where appropriate, and have the compiler emit calls to the new entrypoints when targeting a sufficiently new OS.

rdar://111480914
2023-07-07 18:10:35 -04:00
Dario Rexin
b3cdcda6c7 Merge pull request #67173 from drexin/wip-singleton-inject
Support destructiveInjectEnumTag in singleton enums with layout strings
2023-07-06 19:33:05 -07:00
Dario Rexin
de177dc2ec [Runtime] Add destructiveEnumInject support for singleton enums with layout strings 2023-07-06 15:46:59 -07:00
Dario Rexin
81153489f6 [Runtime] Add destructiveEnumInject support for simple single payload enums in layout strings 2023-07-06 15:23:38 -07:00
Slava Pestov
b471cd308f TypeDecoder: Don't demangle freestanding PackExpansionTypes 2023-07-05 16:35:17 -04:00
Slava Pestov
da145aa43a Runtime: Relax prohibition on packs in SubstGenericParameterFn implementations 2023-07-05 16:35:16 -04:00
Slava Pestov
f40a447980 TypeDecoder: Implement lane-wise pack expansion 2023-07-05 16:35:16 -04:00
Slava Pestov
338cb7ccb9 TypeDecoder: Change createTupleType() to take labels as ArrayRef<StringRef> instead of std::string 2023-07-05 16:33:43 -04:00
Dario Rexin
fd4ef74266 Merge pull request #67067 from drexin/wip-refactor-simple-enum-tag
[Runtime] Abstract handling of simple single payload enum handling
2023-06-30 17:03:02 -07:00
Dario Rexin
13930c9347 [Runtime] Abstract handling of simple single payload enum handling
We can re-use some of this in destructiveInjectEnumTag, so adding the abstraction in preparation of that.
2023-06-30 13:51:47 -07:00
Dario Rexin
e2b8366fdb [Runtime] Remove incorrect skip in handleSinglePayloadEnumGenericTag 2023-06-30 13:05:32 -07:00
Dario Rexin
36914d9a68 Merge pull request #67039 from drexin/wip-mp-gen-destr-inject-tag
Support destructiveInjectEnumTag in generic multi payload enums with layout strings
2023-06-29 19:20:38 -07:00
Yuta Saito
af9b8293e0 Merge pull request #67014 from swiftwasm/pr-5212f18969d0b9d9853af4bc8293cb156ac57eec
[wasm][stdlib] Add wasi-libc support for Heap.cpp
2023-06-30 09:00:08 +09:00
Dario Rexin
8114ecc3e0 [Runtime] Add destructiveInjectEnumTag support for generic multi payload enums with layout strings 2023-06-29 16:34:10 -07:00
Dario Rexin
89d37da9ee [Runtime] Add destructiveInjectEnumTag support for generic single payload enums with layout strings 2023-06-29 10:37:51 -07:00
Yuta Saito
cc6f53efed [wasm][stdlib] Add wasi-libc support for Heap.cpp
Pointers returned by malloc() are 16-byte aligned on wasi-libc, even
it's 32-bit architecture. See wasi-libc's dlmalloc configuration:
aecd368c6d/dlmalloc/src/dlmalloc.c (L31)
2023-06-29 08:32:09 +00:00
Dario Rexin
964a51f4e9 [Runtime] Abstract tag handling for generic single payload enums (#67002)
* [Runtime] Abstract tag handling for generic single payload enums

This functionality will be shared across multiple functions, so adding the abstraction in preparation of that.

* Update BytecodeLayouts.cpp
2023-06-28 22:13:58 -07:00
Yuta Saito
7aa6cbbe2d Merge pull request #66851 from kateinoigakukun/katei/patch-series/driver-wasm-toolchain
Re-land `static-executable-args.lnk` changes
2023-06-29 12:38:51 +09:00
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