fix(runtime/io): bug at IO.Ref primitives in multi-threaded mode
This commit is contained in:
parent
df9ce10623
commit
d110a607fe
1 changed files with 6 additions and 10 deletions
|
|
@ -195,12 +195,10 @@ obj_res io_ref_reset(b_obj_arg ref, obj_arg r) {
|
|||
|
||||
obj_res io_ref_set(b_obj_arg ref, obj_arg a, obj_arg r) {
|
||||
if (ref_maybe_mt(ref)) {
|
||||
if (is_st_heap_obj(a)) {
|
||||
/* We must mark `a` as multi-threaded if `ref` is marked as multi-threaded.
|
||||
Reason: our runtime relies on the fact that a single-threaded object
|
||||
cannot be reached from a multi-thread object. */
|
||||
mark_mt(a);
|
||||
}
|
||||
/* We must mark `a` as multi-threaded if `ref` is marked as multi-threaded.
|
||||
Reason: our runtime relies on the fact that a single-threaded object
|
||||
cannot be reached from a multi-thread object. */
|
||||
mark_mt(a);
|
||||
atomic<object *> * val_addr = mt_ref_val_addr(ref);
|
||||
object * old_a = val_addr->exchange(a);
|
||||
if (old_a != nullptr)
|
||||
|
|
@ -216,10 +214,8 @@ obj_res io_ref_set(b_obj_arg ref, obj_arg a, obj_arg r) {
|
|||
|
||||
obj_res io_ref_swap(b_obj_arg ref, obj_arg a, obj_arg r) {
|
||||
if (ref_maybe_mt(ref)) {
|
||||
if (is_st_heap_obj(a)) {
|
||||
/* See io_ref_write */
|
||||
mark_mt(a);
|
||||
}
|
||||
/* See io_ref_write */
|
||||
mark_mt(a);
|
||||
atomic<object *> * val_addr = mt_ref_val_addr(ref);
|
||||
object * old_a = val_addr->exchange(a);
|
||||
if (old_a == nullptr)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue