Commit Graph

44 Commits

Author SHA1 Message Date
Anthony Latsis
eafc48fb1a [test] Fix REQUIRES line in test 2025-05-20 12:08:44 +01:00
Dario Rexin
b6e7f96c76 Disable layout_string_witnesses_dynamic.swift
rdar://151476435

The test is currently crashing on Amazon Linux 2, so until we have a solution, we are disabling it.
2025-05-19 18:39:34 -07:00
Dario Rexin
a904fee7fe [IRGen] Don't set HasLayoutString flag on non-copyable generic types
rdar://151176697

While generic types generally have layout strings (when enabled), non-copyable types don't, so
we have to make sure the flag does not get set.
2025-05-15 10:21:22 -07:00
Dario Rexin
c0c31c0613 [IRGen] Set minimum runtime availability version for CVW
rdar://139375022

CVW should not be generated when the deployment target does not have the necessary runtime functions.
2024-11-13 22:36:15 -08:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Dario Rexin
a5bb53aee9 [Runtime] Properly compute offset for unmanaged properties in generic CVW instantiation
rdar://137066879

An unmanaged property does not map to an operation in CVW, instead it will be copied like primitive values. When instantiating the layout string, we correctly do not emit an operation, but we compute the offset to the next field as if we did. This is causing the offset to be incorrect and subsequent operations to be executed on the wrong address, causing crashes or other misbehavior.
2024-10-01 11:25:14 -07:00
Dario Rexin
09cd036d15 [IRGen] Fix size computation for imported C types in type layouts (#73271)
rdar://126954341

C types don't have separate size and stride, but in type layouts we always computed the size as if they did. This could cause wrong offsets in compact value witnesses
2024-04-25 19:58:14 -07:00
Dario Rexin
b97fbac9a6 [Runtime] Fix CVW for genreic single payload enums with no extra inha… (#73186)
* [Runtime] Fix CVW for genreic single payload enums with no extra inhabitants

rdar://126728925

When the payload of a generic SPE did not have any extra inhabitants, we erroneously always treated it as the no payload case.
Additionally the offset and skip values were improperly computed.

* Fixed FileCheck string
2024-04-22 22:56:57 -07:00
Dario Rexin
b238c16f51 [IRGen] Disable simple single payload enum in layout strings (#70528)
rdar://119792426

There are a few issues with wrong assumptions around extra inhabitants that cause tags to not be identified properly in some cases. Until a proper fix is identified, we emit tag functions instead.
2023-12-20 14:55:52 -08:00
Dario Rexin
506fbb3c91 [Runtime] Fix alignment of tuples in runtime layout string instantiation (#69975)
rdar://118366415

If a tuple was not already aligned, this would cause a wrong offset to be used in the layout string.
2023-11-27 08:03:38 -08:00
Dario Rexin
56d0975668 [Runtime] Add layout string handling in swift_arrayAssignWithCopyFrontToBack
By using a specialize function, we only call through the witness table and fetch the layout string once for the whoe buffer, instead of once per element.
2023-09-21 09:52:46 -07:00
Dario Rexin
5ef441c4b1 [IRGen] Only use value witness getEnumTag function for "normal" enums
rdar://115013153

For special enum cases, e.g. effectively optional references, the layout string will be the same as the payload, because we don't have to check for the particular case. For those cases we have to use the regular witnesses, which should be shared among all those cases.
2023-09-05 16:34:10 -07:00
Nate Chandler
2d2e68aa18 [Test] Mark 3 tests unsupported on use_os_stdlib.
These tests require an OS with Swift 5.9, and that can't be expressed as
a REQUIRES: line.

rdar://114564735
2023-08-29 17:21:01 -07:00
Dario Rexin
904418f517 [Test] Remove accidentally commited broken test code 2023-08-21 14:32:46 -07:00
Dario Rexin
7e3f56de24 [Runtime] Fix generic existentials in layout strings 2023-08-21 10:57:33 -07:00
Dario Rexin
7c0203dd55 [Runtime] Combine copy and destroy in assignWithCopy 2023-08-21 10:56:19 -07:00
Dario Rexin
8ab845fdca [Runtime+IRGen] Fix offsets of existentials in layout strings 2023-08-21 10:55:51 -07:00
Dario Rexin
6fb232510b [Runtime] Fix SinglePayloadEnumSimple read offset in swift_resolve_resilientAccessors
The offset was off by 1, causing subsequent tags to not be resolved properly.
2023-07-24 09:47:42 -07:00
Dario Rexin
10685367ce [Runtime] Use the properly resolved tag when adding offset after resolving relative pointers in layout strings
The tag was overwritten after resolve when a prior field caused a non-zero offset. This then caused the runtime to treat is a relative instead of an absolute pointer, causing invalid pointers to be dereferenced.
2023-07-24 09:36:26 -07:00
Dario Rexin
93a70a0e38 Merge pull request #67349 from drexin/wip-resilient-metadata-inst
[IRGen] Fix enum metadata instantiation for resilient payload
2023-07-18 13:11:36 -07:00
Dario Rexin
8a260ff089 [Test] Add tests for prespecialized single payload enums with layout strings 2023-07-18 09:43:39 -07:00
Dario Rexin
649aa1ad72 [Test] Add tests for prespecialized single payload enums with layout strings 2023-07-18 09:41:22 -07:00
Dario Rexin
c8537963fa [Test] Add tests for prespecialized singleton enums with layout strings 2023-07-18 09:12:47 -07:00
Dario Rexin
937d1727a3 [IRGen] Fix enum metadata instantiation for resilient payload
The metadata can't be constant when we generate a layout string at runtime.
2023-07-17 16:00:41 -07: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
c046253039 [IRGen] Emit swift_singletonEnum_destructiveInjectEnumTag 2023-07-06 15:47:51 -07:00
Dario Rexin
2f0726a9a1 [IRGen] Emit swift_enumSimple_destructiveInjectEnumTag 2023-07-06 15:25:11 -07:00
Dario Rexin
707330c8bd [IRGen] Emit swift_multiPayloadEnumGeneric_destructiveInjectEnumTag
Assign swift_multiPayloadEnumGeneric_destructiveInjectEnumTag as witness function on generic multi payload enums when using layout strings
2023-06-29 16:34:18 -07:00
Dario Rexin
8ccaad1db5 [IRGen] Emit swift_singlePayloadEnumGeneric_destructiveInjectEnumTag
Assign swift_singlePayloadEnumGeneric_destructiveInjectEnumTag as witness function on generic single payload enums when using layout strings
2023-06-29 10:39:54 -07:00
Dario Rexin
3524945cd4 [IRGen+Runtime] Implement getEnumTag for singleton enums in layout strings (#66985) 2023-06-28 14:25:34 -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
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
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
5cbf9f9641 [IRGen] Handle complex single payload enum cases (#66289)
* [IRGen] Handle complex single payload enum cases

rdar://110138498

Handles single payload enum cases with more complex bit patterns (e.g. >64 bits or scattered) by storing a relative pointer to a function that reads the tag.

* Use proper symbol for enum tag helper
2023-06-02 11:49:57 -07:00
Dario Rexin
5db2b28420 [Runtime] Handle single payload enums in swift_resolve_resilientAccessors (#66218)
rdar://109803119

It is sufficient to skip the header, because everything after that are regular ref counts
2023-05-30 18:27:00 -07:00
Dario Rexin
022311e438 [IRGen] Fix layout string generation for pre-specialized metadata (#65162)
* [IRGen] Fix layout string generation for pre-specialized metadata

rdar://108012057

Pre-specialized metadata has to be specifically handled by using the bound generic type instead of the unbound one. All the necessary information is already being passed down as BoundGenericTypeCharacteristics, we just need to apply them when present.

* Add tests and a few fixes

* Fixes after rebase

* Attempt to fix Windows linker issue in test
2023-04-20 13:26:41 -07: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
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
Dario Rexin
38decb8ab3 [Test] Disable layout string tests on back deployment runtime (#64002)
rdar://106085766
2023-03-01 21:23:28 -08:00
Dario Rexin
a8d4d57f11 [IRGen] Generate compressed representation of value witnesses (#63813)
rdar://105837040

* WIP: Store layout string in type metadata

* WIP: More cases working

* WIP: Layout strings almost working

* Add layout string pointer to struct metadata

* Fetch bytecode layout strings from metadata in runtime

* More efficient bytecode layout

* Add support for interpreted generics in layout strings

* Layout string instantiation, take and more

* Remove duplicate information from layout strings

* Include size of previous object in next objects offset to reduce number of increments at runtime

* Add support for existentials

* Build type layout strings with StructBuilder to support target sizes and metadata pointers

* Add support for resilient types

* Properly cache layout strings in compiler

* Generic resilient types working

* Non-generic resilient types working

* Instantiate resilient type in layout when possible

* Fix a few issues around alignment and signing

* Disable generics, fix static alignment

* Fix MultiPayloadEnum size when no extra tag is necessary

* Fixes after rebase

* Cleanup

* Fix most tests

* Fix objcImplementattion and non-Darwin builds

* Fix BytecodeLayouts on non-Darwin

* Fix Linux build

* Fix sizes in linux tests

* Sign layout string pointers

* Use nullptr instead of debug value
2023-02-24 15:40:28 -08:00