[SR-6503] Support realloc() for tail allocated objects #49053
Labels
compiler
The Swift compiler in itself
duplicate
Resolution: Duplicates another issue
feature
A feature request or implementation
SIL
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: 5af6a0c6445f2e995b4d38fd667e94d6
is duplicated by:
Issue Description:
We should support using realloc() for increasing the size of tail allocated objects, like an array buffer.
This could be done by introducing a new built-in: Builtin.reallocWithTailElems_n (n == 1, 2, 3)
It’s similar to Builtin.allocWithTailElems_n, but receives the original object reference as an additional (first) parameter.
On the implementation side we could introduce a new instruction realloc_ref, again with an additional operand, which is the reference to the original object.
Obviously there are some restrictions: The original object must be uniquely reference, i.e. must have a reference count of 1 (and no weak/unowned references). All stored properties, including the tail allocated elements, must be bit-wise movable.
The work to do here is:
add the new builtins
add the new SIL instruction
implement the IRGen part of it
add a new runtime function swift_reallocObject (similar to swift_allocObject)
The text was updated successfully, but these errors were encountered: