@@ -66,7 +66,6 @@ I'm familiar with some JIT implementations, and I know they tend to use safepoin
66
66
to explicitly control where garbage collections can happen.
67
67
Normally this is an unsafe operation. All live references on the stack must
68
68
be given on the stack or use after.
69
- It would be unsafe to trust the user to .
70
69
Eventually I realized I could use the borrow checker to restrict
71
70
the usage of roots around safepoints. I was inspired in part by the way
72
71
[ indexing] ( https://github.com/bluss/indexing ) uses lifetimes to enforce
@@ -92,8 +91,8 @@ I was not aware of this when I started this project.
92
91
so it wouldn't be suitable .
93
92
- They implement a basic List VM as a proof of concept.
94
93
3 . [ gc-arena] ( https://github.com/kyren/gc-arena )
95
- - Ironically the original use case for this
96
- collector was a replacement for arena allocation
94
+ - Seems like a similar idea, implemented a little later.
95
+ - Works around the awkwardness of lifetimes by using a future-like API.
97
96
- Like our collector, safepoints are explicitly requested by the user
98
97
- However instead of attempting to rebind lifetimes,
99
98
they attempt to use futures to build state machines
@@ -102,9 +101,22 @@ I was not aware of this when I started this project.
102
101
1 . The garbage collector can only run in response to an explicit ` safepoint! ` , not memory pressure,
103
102
- This is a fundamental design limitation.
104
103
- One can think of this as a feature, since garbage collection can be restricted to specific times and places.
105
- - The user must be liberal about inserting safepoins
104
+ - The user must be liberal about inserting safepoints
106
105
- Generally high-level languages which use GCs automatically insert calls to safe points
107
106
- Their safepoints tend to be lower-overhead than ours, so you need to balance the cost/benefit
108
- 2 . Unfortunately, implementing ` GcSafe ` for a type prevents it from having a explicit ` Drop ` implementation.
107
+ 2 . Implementing ` GcSafe ` for a type prevents it from having a explicit ` Drop ` implementation.
109
108
- This is needed to ensure that the destructors don't do bad things, since we don't want to deal with finalizers.
110
- - Of course unsafe code isn't bound by this restriction, since it's assumed to behave properly
109
+ - Of course unsafe code isn't bound by this restriction, since it's assumed to behave properly (and there is an opt-out if you know you're safe).
110
+
111
+ ### Implementation Flaws
112
+ None of these are fundemental design flaws. They can all be fixed (and should).
113
+ 1 . Currently, unable to return a garbage collected type from a method that uses a safepoint
114
+ - This is * not* a fundamental limitation of the design. I have plans to fix the API to support this.
115
+ - Unfortunately, this is almost crippling for many use cases, but can be worked around with an 'unchecked_safepoint'
116
+ 2 . Currently, unable to use short lifetimes in garbage collected code.
117
+ - This is because ` Gc<'gc, T> ` currently requires ` T: 'gc `
118
+ - It is possible to relax this restriction, but may make things more awkward to use...
119
+ 3 . Restriction on borrowing possibly aliased vectors of GC memory
120
+ - It is difficult to enforce Rust's mutability rules with possibly shared gc memory (See issue #30 )
121
+ 4 . Implementation isn't generational (yet)
122
+ 6 . Awkward to use from a generic context, because the API hasn't yet taken full advantage of generic associated typesd.
0 commit comments