TypeInfo in struct ABI

max haughton maxhaton at gmail.com
Mon Jan 17 15:36:28 UTC 2022


On Monday, 17 January 2022 at 15:26:46 UTC, Teodor Dutu wrote:
> Hi,
>
> In order to allocate a `struct` type, two DRuntime hooks are 
> used: `_d_newitemT` for uninitialised structs and 
> `_d_newitemiT` for initialised ones. Both hooks call 
> `_d_newitemU`, which allocates memory for the struct and 
> [writes the struct’s 
> `TypeInfo`](https://github.com/dlang/druntime/blob/9d99b1ccd90d1e66c31e27cc71b8a266612aa14a/src/rt/lifetime.d#L1122) at the end of the allocated chunk.
>
> We now attempt to convert these hooks to templates, with the 
> goal of not using `TypeInfo` at all. However, the fact that the 
> ABI of a struct contains its `TypeInfo` prevents us from 
> achieving this goal. Is this `TypeInfo` object still necessary 
> for anything, or are we free to remove it from the ABI 
> altogether so that we have cleaner implementations for 
> `_d_newitem{U,iT,T}`?
>
> Thanks,
> Teodor

What do you mean by ABI here? This sounds like a detail of how 
the GC allocates memory rather than the ABI strictly - it's 
certainly not specified under "struct" in the ABI document.


More information about the Digitalmars-d mailing list