Re: Class instance alignment

2021-02-22 Thread tsbockman via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 03:53:00 UTC, tsbockman wrote: size_t alignedSize(size_t typeSize, size_t typeAlignment) pure @safe nothrow @nogc { version(assert) { import core.bitop : bsr; assert(typeAlignment == (size_t(1) << bsr(typeAlignment))); } size_t ret =

Re: Class instance alignment

2021-02-22 Thread tsbockman via Digitalmars-d-learn
On Monday, 22 February 2021 at 02:23:27 UTC, Steven Schveighoffer wrote: Hm... but does TypeInfo detail alignment? If so, we can make this work anyway, just bump up the size needed to a power-of-2 pool. It doesn't even need to be a power-of-2, assuming the pools themselves are properly

Re: Class instance alignment

2021-02-22 Thread kinke via Digitalmars-d-learn
On Monday, 22 February 2021 at 02:23:27 UTC, Steven Schveighoffer wrote: Hm... but does TypeInfo detail alignment? Apparently not for TypeInfo_Class; .talign() returns the alignment of a class *ref*, i.e., pointer size. TypeInfo_Struct.talign() does return the struct alignment though and

Re: Class instance alignment

2021-02-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/21 6:39 PM, kinke wrote: On Saturday, 20 February 2021 at 18:43:53 UTC, Steven Schveighoffer wrote: Last I checked*, the GC uses pools of 16-byte, 32-byte, 64-byte, etc blocks. That has changed [to reduce wastage]; the new bin sizes are here and include sizes like 176 (11*16):

Re: Class instance alignment

2021-02-20 Thread kinke via Digitalmars-d-learn
On Saturday, 20 February 2021 at 18:43:53 UTC, Steven Schveighoffer wrote: Last I checked*, the GC uses pools of 16-byte, 32-byte, 64-byte, etc blocks. That has changed [to reduce wastage]; the new bin sizes are here and include sizes like 176 (11*16):

Re: Class instance alignment

2021-02-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/21 2:13 AM, tsbockman wrote: On Saturday, 20 February 2021 at 05:44:33 UTC, kinke wrote: There's https://github.com/dlang/druntime/blob/728f1d9c3b7a37eba4d59ee2637fb924053cba6d/src/core/internal/traits.d#L261. Thanks! That's helpful. But AFAIK, the GC only guarantees an alignment

Re: Class instance alignment

2021-02-20 Thread rikki cattermole via Digitalmars-d-learn
On 20/02/2021 8:13 PM, tsbockman wrote: Well, that's just another reason not to use the GC for my current project, then: I'm using 256-bit AVX vectors extensively. You can still use the GC. You just can't use it to allocate the classes you care about.

Re: Class instance alignment

2021-02-19 Thread tsbockman via Digitalmars-d-learn
On Saturday, 20 February 2021 at 05:44:33 UTC, kinke wrote: There's https://github.com/dlang/druntime/blob/728f1d9c3b7a37eba4d59ee2637fb924053cba6d/src/core/internal/traits.d#L261. Thanks! That's helpful. But AFAIK, the GC only guarantees an alignment of 16 and doesn't respect any

Re: Class instance alignment

2021-02-19 Thread kinke via Digitalmars-d-learn
On Friday, 19 February 2021 at 23:53:55 UTC, tsbockman wrote: How can I get the alignment of a class instance? I know how to get the size: __traits(classInstanceSize, T) But, there doesn't appear to be any equivalent trait for the alignment. There's