Skip to content

Commit

Permalink
runtime: fix alive reference analysis of reference counting
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Dec 8, 2024
1 parent d834012 commit f8245e0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions std/runtime/rc.jule
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,16 @@ unsafe fn _RCAddAtomic(mut p: _RCPtr) {
#export "__jule_RCDrop"
unsafe fn _RCDrop(mut p: _RCPtr): bool {
// If new data equals to zero, means references zeroed.
alive := *p >= RCDelta
*p -= RCDelta
ret alive
ret *p >= RCDelta
}

// Same as _RCDrop but have thread-safe implementation.
#export "__jule_RCDropAtomic"
unsafe fn _RCDropAtomic(mut p: _RCPtr): bool {
// The atomicAdd function returns new data of pointer.
// So if new data equals to zero, means references zeroed.
ret atomicAdd[_RCType](*p, -RCDelta, _RCMo) >= RCDelta
ret atomicAdd[_RCType](*p, -RCDelta, _RCMo) > RCDelta
}

// Deallocates reference counting data allocation.
Expand Down

0 comments on commit f8245e0

Please sign in to comment.