What should happen here?
Steven Schveighoffer
schveiguy at gmail.com
Mon Sep 27 13:59:57 UTC 2021
On 9/27/21 5:53 AM, deadalnix wrote:
> On Sunday, 26 September 2021 at 20:39:48 UTC, Steven Schveighoffer wrote:
>> You realize what `GC.addRoot` does? It adds a pointer to a treap,
>> through a virtual function call after taking a global lock. Pushing a
>> stack item is going to be at least 10x faster, probably more compared
>> to that. In the function call alone, there are a few stack pushes.
>>
>
> Sure, but it does so exclusively for one specific address. The optimizer
> would have to do so for every single thing that might be pointing to
> something that is owned by the GC.
>
> However, one thing that could be done is to have an intrinsic to do so,
> so the optimizer knows exactly which references not to mess with. LLVM
> already has intrinsics for this at the IR level.
Yes, I'm not looking to have all dead stores kept, just ones that are
important (as designated by the developer).
What I'm saying is, *if* you need a specific address saved for later in
a function, wouldn't you prefer to store that on the stack rather than
store it in the GC's roots? This would absolutely be opt-in, not
automatic, as I don't see how we can do it automatically.
-Steve
More information about the Digitalmars-d
mailing list