Integrated code formatter

H. S. Teoh hsteoh at
Wed Jan 19 19:42:23 UTC 2022

On Tuesday, 18 January 2022 at 17:12:35 UTC, H. S. Teoh wrote:
> On Tue, Jan 18, 2022 at 07:37:42AM -0800, H. S. Teoh via 
> Digitalmars-d wrote: [...]
>> Outlined a few possible approaches to fix this here:
>> I'm not sure I have the compiler chops to actually fix this 
>> myself, though.  This is a little beyond my level of 
>> familiarity with dmd code.  Would be nice if somebody picked 
>> this up.
> [...]
> OK, so to *completely* fix this may be a little beyond me, but 
> a partial fix that at least covers std.array.array was within 
> reach.

I surprise myself sometimes.  I've managed to ferret out enough 
of the -profile=gc implementation that I now have a fix that 
covers allocations via core.memory.GC.* as well:

So essentially, this fixes the entire bug.  Well, almost:

1) It still doesn't cover direct calls to the C API `gc_malloc`, 
but I'm just gonna pretend for now that that doesn't exist, 
because normal D code is supposed to call the GC via 
core.memory.GC instead of invoking the C API directly.  (I 
suppose this could be documented, though. Maybe I'll post a doc 
PR for that.)

2) GC API allocations inside Phobos will show up as some obscure 
internal private Phobos function, which is probably unhelpful in 
determining where in the user's code the allocation happened. 
This part is tricky to fix without adding runtime penalties when 
not compiling with -profile=gc, so I'm reluctant to touch this at 
the moment.  But anyway, I see that as a further enhancement 
request; the core issue in 14892 is essentially fixed by the 
above PR and my previous PRs which have already been merged.


More information about the Digitalmars-d mailing list