Starlight-JS / starlight

JS engine in Rust
https://teletype.in/@starlight-js
Mozilla Public License 2.0
511 stars 9 forks source link

PersistentRooted update inner workings #70

Open andrieshiemstra opened 3 years ago

andrieshiemstra commented 3 years ago

As discussed here: https://github.com/Starlight-JS/starlight/pull/65#issuecomment-872387245

for persistent roots i use a HashMap based on a generated ID, at first i thought i'd just use the inner ptr of JsObejct as ID but then it would not work when multiple jobs add a persistent root for the same object.

Your persistent root can be reference counted and stored in hash map. On GC when constraint for the Runtime instance is executed you just remove all the roots that have 1 reference count left. I think you can even just use Vec there?