@@ -229,6 +229,24 @@ pub fn post_alloc<VM: VMBinding>(
229
229
/// * `src`: The modified source object.
230
230
/// * `slot`: The location of the field to be modified.
231
231
/// * `target`: The target for the write operation.
232
+ ///
233
+ /// # Deprecated
234
+ ///
235
+ /// This function needs to be redesigned. Its current form has multiple issues.
236
+ ///
237
+ /// - It is only able to write non-null object references into the slot. But dynamic language
238
+ /// VMs may write non-reference values, such as tagged small integers, special values such as
239
+ /// `null`, `undefined`, `true`, `false`, etc. into a field that previous contains an object
240
+ /// reference.
241
+ /// - It relies on `slot.store` to write `target` into the slot, but `slot.store` is designed for
242
+ /// forwarding references when an object is moved by GC, and is supposed to preserve tagged
243
+ /// type information, the offset (if it is an interior pointer), etc. A write barrier is
244
+ /// associated to an assignment operation, which usually updates such information instead.
245
+ ///
246
+ /// We will redesign a more general subsuming write barrier to address those problems and replace
247
+ /// the current `object_reference_write`. Before that happens, VM bindings should use
248
+ /// `object_reference_write_pre` and `object_reference_write_post` instead.
249
+ #[ deprecated = "Use `object_reference_write_pre` and `object_reference_write_post` instead, until this function is redesigned" ]
232
250
pub fn object_reference_write < VM : VMBinding > (
233
251
mutator : & mut Mutator < VM > ,
234
252
src : ObjectReference ,
@@ -252,12 +270,14 @@ pub fn object_reference_write<VM: VMBinding>(
252
270
/// * `mutator`: The mutator for the current thread.
253
271
/// * `src`: The modified source object.
254
272
/// * `slot`: The location of the field to be modified.
255
- /// * `target`: The target for the write operation.
273
+ /// * `target`: The target for the write operation. `None` if the slot did not hold an object
274
+ /// reference before the write operation. For example, the slot may be holding a `null`
275
+ /// reference, a small integer, or special values such as `true`, `false`, `undefined`, etc.
256
276
pub fn object_reference_write_pre < VM : VMBinding > (
257
277
mutator : & mut Mutator < VM > ,
258
278
src : ObjectReference ,
259
279
slot : VM :: VMEdge ,
260
- target : ObjectReference ,
280
+ target : Option < ObjectReference > ,
261
281
) {
262
282
mutator
263
283
. barrier ( )
@@ -278,12 +298,14 @@ pub fn object_reference_write_pre<VM: VMBinding>(
278
298
/// * `mutator`: The mutator for the current thread.
279
299
/// * `src`: The modified source object.
280
300
/// * `slot`: The location of the field to be modified.
281
- /// * `target`: The target for the write operation.
301
+ /// * `target`: The target for the write operation. `None` if the slot no longer hold an object
302
+ /// reference after the write operation. This may happen when writing a `null` reference, a small
303
+ /// integers, or a special value such as`true`, `false`, `undefined`, etc., into the slot.
282
304
pub fn object_reference_write_post < VM : VMBinding > (
283
305
mutator : & mut Mutator < VM > ,
284
306
src : ObjectReference ,
285
307
slot : VM :: VMEdge ,
286
- target : ObjectReference ,
308
+ target : Option < ObjectReference > ,
287
309
) {
288
310
mutator
289
311
. barrier ( )
0 commit comments