Commit Graph

8 Commits

Author SHA1 Message Date
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