On 8/2/2017 6:37 AM, Enrico Weigelt, metux IT consult wrote:
On 31.07.2017 13:53, smaug wrote:
<snip>
Reference counting is needed always if both JS and C++ can have a
pointer to the object.
By the way - just curious:
Anybody already thought about garbage collection ?
Yes. About a decade ago, Mozilla invested some resources in being able
to automatically rewrite the codebase to use GC instead of reference
counting: <https://wiki.mozilla.org/XPCOMGC>.
Some conclusions:
1. Automated rewriting of C++ code is possible (this is when the only
significant open-source C++ compiler relied on horribly inaccurate
position tracking, so it actually was a big deal).
2. Converting from reference-counting to conservative GC is barely
possible. (I recall bsmedberg saying that the resulting build could go
for a few minutes before crashing)
3. It's not the performance win you think it is. The main performance
wins are a compacting GC, which minimizes memory use over time and makes
heap allocation basically a pointer bump. On the other hand, now you
have to have threadsafe reference counting on every object.
That wouldn't have the problem w/ circular graphs, and should make the
whole code smaller and faster.
See the results on the linked page. It was neither smaller, nor faster.
We already have a cycle-collector, which is basically an opt-in garbage
collector (it only looks at a subset of the total ownership graph). The
main difficulty in using it is having to annotate classes in cycles, but
this is exactly the sort of thing that's easy to write in a #[derive()]
attr in Rust.
--
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform