File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,15 @@ public func swift_allocEmptyBox() -> Builtin.RawPointer {
261261 return box
262262}
263263
264+ /// The embedded swift_allocBox version is different to the standad one in that
265+ /// we want to avoid building metadata for the box type. Instead we store the
266+ /// metadata of the contained type in the heap object. To make this work when
267+ /// destroying the box the release needs to be special i.e `swift_releaseBox`.
268+ /// It does not call the the heap object metadata's destroy function. Rather, it
269+ /// knows that the allocBox's metadata is the contained objects and calls an
270+ /// appropriate implementation: `_swift_embedded_invoke_box_destroy`.
271+ /// Therefore, one cannot not use `swift_release` but rather must use
272+ /// `swift_releaseBox` to implement the "release" function of a box object.
264273
265274@_silgen_name ( " swift_allocBox " )
266275public func swift_allocBox( _ metadata: Builtin . RawPointer ) -> ( Builtin . RawPointer , Builtin . RawPointer ) {
You can’t perform that action at this time.
0 commit comments