@@ -273,11 +273,58 @@ only need to run `process_weak_refs` twice:
273
273
objects.
274
274
2 . Handle ` PhandomReference ` .
275
275
276
+ To implement this, the VM binding may need to implement some kind of * state machine* so that the
277
+ ` Scanning::process_weak_refs ` function behaves differently each time it is called. For example,
278
+
279
+ ``` rust
280
+ fn process_weak_ref (... ) -> bool {
281
+ let mut state = /* Get VM-specific states here. */ ;
282
+
283
+ match * state {
284
+ State :: ProcessSoftReference => {
285
+ process_soft_references (... );
286
+ * state = State :: ProcessWeakReference ;
287
+ return true ; // Run this function again.
288
+ }
289
+ State :: ProcessWeakReference => {
290
+ process_weak_references (... );
291
+ * state = State :: ProcessFinalizableObjects ;
292
+ return true ; // Run this function again.
293
+ }
294
+ State :: ProcessFinalizableObjects => {
295
+ process_finalizable_objects (... );
296
+ * state = State :: ProcessPhantomReferences ;
297
+ return true ; // Run this function again.
298
+ }
299
+ State :: ProcessPhantomReferences => {
300
+ process_phantom_references (... );
301
+ * state = State :: ProcessSoftReference
302
+ return false ; // Proceed to the Release stage.
303
+ }
304
+ }
305
+
306
+ }
307
+ ```
308
+
276
309
### Ephemerons
277
310
278
311
TODO
279
312
280
313
314
+ ## Deprecated reference and finalizable processors
315
+
316
+ When porting MMTk from JikesRVM to a dedicated Rust library, we also ported the ` ReferenceProcessor `
317
+ and the ` FinalizableProcessor ` from JikesRVM. They are implemented in mmtk-core, and provide the
318
+ mechanisms for handling Java-style soft/weak/phantom references and finalizable objects. The VM
319
+ binding can use those utilities by implementing the ` mmtk::vm::ReferenceGlue ` and the
320
+ ` mmtk::vm::Finalizable ` traits, and calling the
321
+ ` mmtk::memory_manager::add_{soft,weak,phantom}_candidate ` and the
322
+ ` mmtk::memory_manager::add_finalizer ` functions.
323
+
324
+ However, those mechanisms are too specific to Java, and are not applicable to most other VMs. ** New
325
+ VM bindings should use the ` Scanning::process_weak_refs ` API** , and we are porting existing VM
326
+ bindings away from the built-in reference/finalizable processors.
327
+
281
328
<!--
282
329
vim: tw=100 ts=4 sw=4 sts=4 et
283
330
-->
0 commit comments