@@ -19,12 +19,15 @@ public struct ClassMetadata {
19
19
20
20
// There is no way to express the actual calling convention on the heap desroy
21
21
// function (swiftcc with 'self') currently, so let's use UnsafeRawPointer
22
- // and a helper function in C (_swift_runtime_invoke_heap_object_destroy ).
22
+ // and a helper function in C (_swift_embedded_invoke_heap_object_destroy ).
23
23
var destroy : UnsafeRawPointer
24
24
}
25
25
26
26
public struct HeapObject {
27
- var metadata : UnsafeMutablePointer < ClassMetadata >
27
+ // There is no way to express the custom ptrauth signature on the metadata
28
+ // field, so let's use UnsafeRawPointer and a helper function in C instead
29
+ // (_swift_embedded_set_heap_object_metadata_pointer).
30
+ var metadata : UnsafeRawPointer
28
31
29
32
// TODO: This is just an initial support for strong refcounting only. We need
30
33
// to think about supporting (or banning) weak and/or unowned references.
@@ -82,7 +85,7 @@ public func swift_slowDealloc(_ ptr: UnsafeMutableRawPointer, _ size: Int, _ ali
82
85
public func swift_allocObject( metadata: UnsafeMutablePointer < ClassMetadata > , requiredSize: Int , requiredAlignmentMask: Int ) -> UnsafeMutablePointer < HeapObject > {
83
86
let p = swift_slowAlloc ( requiredSize, requiredAlignmentMask) !
84
87
let object = p. assumingMemoryBound ( to: HeapObject . self)
85
- object. pointee . metadata = metadata
88
+ _swift_embedded_set_heap_object_metadata_pointer ( object, metadata)
86
89
object. pointee. refcount = 1
87
90
return object
88
91
}
@@ -103,14 +106,14 @@ public func swift_deallocClassInstance(object: UnsafeMutablePointer<HeapObject>,
103
106
104
107
@_silgen_name ( " swift_initStaticObject " )
105
108
public func swift_initStaticObject( metadata: UnsafeMutablePointer < ClassMetadata > , object: UnsafeMutablePointer < HeapObject > ) -> UnsafeMutablePointer < HeapObject > {
106
- object. pointee . metadata = metadata
109
+ _swift_embedded_set_heap_object_metadata_pointer ( object, metadata)
107
110
object. pointee. refcount = HeapObject . immortalRefCount
108
111
return object
109
112
}
110
113
111
114
@_silgen_name ( " swift_initStackObject " )
112
115
public func swift_initStackObject( metadata: UnsafeMutablePointer < ClassMetadata > , object: UnsafeMutablePointer < HeapObject > ) -> UnsafeMutablePointer < HeapObject > {
113
- object. pointee . metadata = metadata
116
+ _swift_embedded_set_heap_object_metadata_pointer ( object, metadata)
114
117
object. pointee. refcount = 1 | HeapObject . doNotFreeBit
115
118
return object
116
119
}
0 commit comments