Commit Graph

22 Commits

Author SHA1 Message Date
Dario Rexin
ca664141cc [IRGen+Runtime] Add support for initializeBufferWithCopyOfBuffer to layout strings (#66965) 2023-06-27 18:05:30 -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
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
806fd1b58b [Runtime] Handle generic single payload enums in resilient resolve (#66849) 2023-06-22 10:53:55 -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
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
91d547f982 [Runtime] Properly handle unaligned reads in readTagBytes for layout strings (#66506) 2023-06-09 23:02:34 -07:00
Dario Rexin
fe6f8f5404 [IRGen] Implement support for multi payload enums in layout strings (#66354)
* [IRGen] Implement support for multi payload enums in layout strings

rdar://105837114

* Implement multi payload enum cases in swift_resolve_resilientAccessors

* Add missing const
2023-06-06 23:51:57 -07:00
Dario Rexin
1425e32c86 [Runtime] Refactor swift_generic_initWithTake to use shared abstraction (#66379)
We introduced shared abstractions for handling the different tags for the other runtime functions, so we should use them here as well.
2023-06-06 14:27:56 -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
658f0ea3c8 [Runtime] Refactor layout string runtime functions to simplify future specialization work (#66105)
rdar://109787818

Templatized and abstracted handling of layout strings to simplify future specializations. E.g. specilizing for a particular number of reference count operations can be done by passing the expected size as a template param:

```
extern "C" void
swift_generic_destroy_2(swift::OpaqueValue *address, const Metadata *metadata) {
  handleRefCounts<2, DestroyHandler>(metadata, (uint8_t *)address);
}
```
2023-05-26 08:30:50 -07:00
Dario Rexin
ca004c2316 [Runtime] Fix UB in layout string runtime functions (#66112)
rdar://109790722

Layout strings are not guaranteed to be properly aligned, so we can't directly read from and write to it, but have to use memcpy instead.
2023-05-25 08:33:53 -07:00
Dario Rexin
97381e6411 [IRGen] Support additional single payload enum cases in layout strings (#66042)
* [IRGen] Support additional single payload enum cases in layout strings

rdar://105837101

Adds layout string support for single payload enums with simple (non-scattered) extra inhabitant patterns

* Add more test cases
2023-05-23 13:17:51 -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
96d988a431 [Runtime] Move bytecode layout handling into runtime (#63901)
rdar://105904548
2023-02-25 10:18:45 -08:00