[embedded] Fix arm64e pointer signing in embedded heap object destruction

This commit is contained in:
Kuba Mracek
2023-09-26 12:30:21 -07:00
parent e4dc6271f1
commit b718c506da
2 changed files with 9 additions and 4 deletions

View File

@@ -33,9 +33,14 @@ extern "C" {
typedef void SWIFT_CC (*HeapObjectDestroyer)(SWIFT_CONTEXT void *object); typedef void SWIFT_CC (*HeapObjectDestroyer)(SWIFT_CONTEXT void *object);
static inline void _swift_runtime_invoke_heap_object_destroy( static inline void _swift_embedded_invoke_heap_object_destroy(void *object) {
const void *destroy, void *self) { void *metadata = *(void **)object;
((HeapObjectDestroyer)destroy)(self); void **destroy_location = &((void **)metadata)[1];
#if __has_feature(ptrauth_calls)
(*(__ptrauth(0,1,0xbbbf) HeapObjectDestroyer *)destroy_location)(object);
#else
(*(HeapObjectDestroyer *)destroy_location)(object);
#endif
} }
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -117,7 +117,7 @@ public func swift_release(object: Builtin.RawPointer) {
if o.pointee.refcount == HeapObject.immortalRefCount { return } if o.pointee.refcount == HeapObject.immortalRefCount { return }
o.pointee.refcount -= 1 o.pointee.refcount -= 1
if (o.pointee.refcount & HeapObject.refcountMask) == 0 { if (o.pointee.refcount & HeapObject.refcountMask) == 0 {
_swift_runtime_invoke_heap_object_destroy(o.pointee.metadata.pointee.destroy, o) _swift_embedded_invoke_heap_object_destroy(o)
} }
} }