Skip to content

Commit 363275d

Browse files
committed
More explicitly describe current limitations
All of these can (and should) be fixed.
1 parent 67fbafc commit 363275d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ I'm familiar with some JIT implementations, and I know they tend to use safepoin
6666
to explicitly control where garbage collections can happen.
6767
Normally this is an unsafe operation. All live references on the stack must
6868
be given on the stack or use after.
69-
It would be unsafe to trust the user to .
7069
Eventually I realized I could use the borrow checker to restrict
7170
the usage of roots around safepoints. I was inspired in part by the way
7271
[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.
9291
so it wouldn't be suitable .
9392
- They implement a basic List VM as a proof of concept.
9493
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.
9796
- Like our collector, safepoints are explicitly requested by the user
9897
- However instead of attempting to rebind lifetimes,
9998
they attempt to use futures to build state machines
@@ -102,9 +101,22 @@ I was not aware of this when I started this project.
102101
1. The garbage collector can only run in response to an explicit `safepoint!`, not memory pressure,
103102
- This is a fundamental design limitation.
104103
- 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
106105
- Generally high-level languages which use GCs automatically insert calls to safe points
107106
- 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.
109108
- 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

Comments
 (0)