Skip to content

Commit efc6b99

Browse files
authored
Fixes some issues with the tutorial (#540)
1 parent 29afb0c commit efc6b99

File tree

3 files changed

+5
-25
lines changed

3 files changed

+5
-25
lines changed

docs/tutorial/code/mygc_semispace/global.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ impl<VM: VMBinding> MyGC<VM> {
170170
vm_map: &'static VMMap,
171171
mmapper: &'static Mmapper,
172172
options: Arc<UnsafeOptionsWrapper>,
173-
_scheduler: &'static GCWorkScheduler<VM>,
174173
) -> Self {
175174
// Modify
176175
let mut heap = HeapMeta::new(HEAP_START, HEAP_END);

docs/tutorial/src/mygc/create.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ files.
6969
vm_map: &'static VMMap,
7070
mmapper: &'static Mmapper,
7171
options: Arc<UnsafeOptionsWrapper>,
72-
scheduler: Arc<GCWorkScheduler<VM>>,
7372
) -> Box<dyn Plan<VM = VM>> {
7473
match plan {
7574
PlanSelector::NoGC => Box::new(crate::plan::nogc::NoGC::new(vm_map, mmapper, options)),
@@ -81,7 +80,7 @@ files.
8180

8281
// Create MyGC plan based on selector
8382
PlanSelector::MyGC => Box::new(crate::plan::mygc::MyGC::new(
84-
vm_map, mmapper, options, scheduler,
83+
vm_map, mmapper, options,
8584
))
8685
}
8786
}

docs/tutorial/src/mygc/ss/collection.md

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ in the preparation step of a GC (which will be discussed later when we talk abou
2020

2121
We use `CopySemantics::DefaultCopy` for our copy
2222
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
2424
binding for `CopySpaceCopyContext`. However, we will flip tospace in every GC, and rebind the
2525
copy context to the new tospace in each GC, so it does not matter which space we use as the initial
2626
space here.
@@ -77,6 +77,7 @@ and implement the trait `GCWorkContext` for it. We create this type in `gc_work.
7777

7878
```rust
7979
{{#include ../../../code/mygc_semispace/gc_work.rs:workcontext}}
80+
```
8081

8182
Then we implement `schedule_collection()` using `MyGCWorkContext` and `schedule_common_work()`.
8283

@@ -108,7 +109,7 @@ and which is 'from', then prepares the copyspaces with the new definition.
108109

109110
### Prepare worker
110111

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
112113
to the new tospace. We will override `prepare_worker()` in our `Plan` implementation.
113114
`Plan.prepare_worker()` is executed by each GC worker in the preparation phase of a GC. The code
114115
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
140141
inline attribute.
141142
Check if the object passed into the function is null
142143
(`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
144145
policy-specific object tracing code. If it is in neither space, forward the
145146
call to the common space and let the common space to handle object tracing in
146147
its spaces (e.g. immortal or large object space):
@@ -157,25 +158,6 @@ Add two new implementation blocks, `Deref` and `DerefMut` for
157158
{{#include ../../../code/mygc_semispace/gc_work.rs:deref}}
158159
```
159160

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-
179161
## Release
180162

181163
Finally, we need to fill out the functions that are, roughly speaking,

0 commit comments

Comments
 (0)