snazzy-d / sdc

The Snazzy D Compiler
MIT License
246 stars 55 forks source link

Fill out roots API #371

Closed schveiguy closed 1 month ago

schveiguy commented 1 month ago

Druntime needs the ability to add and remove roots/ranges. This covers those use cases.

  1. If you want to add a root (which is essentially just pinning a GC block), then allow adding a root "range" that is of 0 length. This will be scanned when the roots array is scanned.
  2. We need to support adding roots via pointer/length instead of array, since the DMD ABI does not match SDC.
  3. We need the ability to remove roots (this should probably be some tree structure, but for now it's a linear search for the existing root).
  4. Fix the scanning of global roots from druntime, which was previously not done.
  5. Remove calling of SDRT's thread scan, which is not how druntime scans thread stacks.

Not sure if there needs to be a test for this, as it's mostly focused on druntime integration.

schveiguy commented 1 month ago

Test added