@@ -20,7 +20,7 @@ in the preparation step of a GC (which will be discussed later when we talk abou
20
20
21
21
We use ` CopySemantics::DefaultCopy ` for our copy
22
22
operation, and bind it with the first ` CopySpaceCopyContext ` (` CopySemantics::DefaultCopy => CopySelector::CopySpace(0) ` ).
23
- And for the rest copy semantics, they are unused for this plan. We also provide an initial space
23
+ Other copy semantics are unused in this plan. We also provide an initial space
24
24
binding for ` CopySpaceCopyContext ` . However, we will flip tospace in every GC, and rebind the
25
25
copy context to the new tospace in each GC, so it does not matter which space we use as the initial
26
26
space here.
@@ -77,6 +77,7 @@ and implement the trait `GCWorkContext` for it. We create this type in `gc_work.
77
77
78
78
``` rust
79
79
{{#include .. / .. / .. / code / mygc_semispace / gc_work . rs: workcontext }}
80
+ ```
80
81
81
82
Then we implement ` schedule_collection() ` using ` MyGCWorkContext ` and ` schedule_common_work() ` .
82
83
@@ -108,7 +109,7 @@ and which is 'from', then prepares the copyspaces with the new definition.
108
109
109
110
### Prepare worker
110
111
111
- As we flip tospac for the plan, we also need to rebind the copy context
112
+ As we flip tospace for the plan, we also need to rebind the copy context
112
113
to the new tospace. We will override ` prepare_worker() ` in our ` Plan ` implementation.
113
114
` Plan.prepare_worker() ` is executed by each GC worker in the preparation phase of a GC. The code
114
115
is straightforward -- we get the first ` CopySpaceCopyContext ` , and call ` rebind() ` on it with
@@ -140,7 +141,7 @@ This method should return an ObjectReference, and use the
140
141
inline attribute.
141
142
Check if the object passed into the function is null
142
143
(` object.is_null() ` ). If it is, return the object.
143
- Check if which space the object is in, and forward the call to the
144
+ Otherwise, check which space the object is in, and forward the call to the
144
145
policy-specific object tracing code. If it is in neither space, forward the
145
146
call to the common space and let the common space to handle object tracing in
146
147
its spaces (e.g. immortal or large object space):
@@ -157,25 +158,6 @@ Add two new implementation blocks, `Deref` and `DerefMut` for
157
158
{{#include .. / .. / .. / code / mygc_semispace / gc_work . rs: deref }}
158
159
```
159
160
160
- ## Copying objects
161
-
162
- Go back to the ` MyGCopyContext ` in ` gc_work.rs ` .
163
- In ` alloc_copy() ` , call the allocator's ` alloc ` function. Above the function,
164
- use an inline attribute (` #[inline(always)] ` ) to tell the Rust compiler
165
- to always inline the function.
166
-
167
- ``` rust
168
- {{#include .. / .. / .. / code / mygc_semispace / gc_work . rs: copycontext_alloc_copy }}
169
- ```
170
-
171
- To ` post_copy() ` , in the ` CopyContext ` implementations block, add
172
- ` forwarding_word::clear_forwarding_bits::<VM>(obj); ` . Also, add an
173
- inline attribute.
174
-
175
- ``` rust
176
- {{#include .. / .. / .. / code / mygc_semispace / gc_work . rs: copycontext_post_copy }}
177
- ```
178
-
179
161
## Release
180
162
181
163
Finally, we need to fill out the functions that are, roughly speaking,
0 commit comments