@@ -229,6 +229,24 @@ pub fn post_alloc<VM: VMBinding>(
229229/// * `src`: The modified source object.
230230/// * `slot`: The location of the field to be modified.
231231/// * `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" ]
232250pub fn object_reference_write < VM : VMBinding > (
233251 mutator : & mut Mutator < VM > ,
234252 src : ObjectReference ,
@@ -252,12 +270,14 @@ pub fn object_reference_write<VM: VMBinding>(
252270/// * `mutator`: The mutator for the current thread.
253271/// * `src`: The modified source object.
254272/// * `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.
256276pub fn object_reference_write_pre < VM : VMBinding > (
257277 mutator : & mut Mutator < VM > ,
258278 src : ObjectReference ,
259279 slot : VM :: VMEdge ,
260- target : ObjectReference ,
280+ target : Option < ObjectReference > ,
261281) {
262282 mutator
263283 . barrier ( )
@@ -278,12 +298,14 @@ pub fn object_reference_write_pre<VM: VMBinding>(
278298/// * `mutator`: The mutator for the current thread.
279299/// * `src`: The modified source object.
280300/// * `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.
282304pub fn object_reference_write_post < VM : VMBinding > (
283305 mutator : & mut Mutator < VM > ,
284306 src : ObjectReference ,
285307 slot : VM :: VMEdge ,
286- target : ObjectReference ,
308+ target : Option < ObjectReference > ,
287309) {
288310 mutator
289311 . barrier ( )
0 commit comments