cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.91k stars 982 forks source link

update docs and tests for weak `cas!` and `lock!` operations #731

Closed mflatt closed 9 months ago

mflatt commented 9 months ago

This PR is intended to close #720.

The vector-cas!, box-cas!, and ftype-lock! operations are "weak" in the sense that they may spuriously fail on an architecture (like AArch64) with a weak memory model. Also, those operation do not necessarily imply any overall memory ordering, so using memory-order-acquire and memory-order-release may be needed. The documentation did not make this clear, and some tests did not handle spurious failure.

As noted in the discussion for #720, a good case could be made that these operations should be "strong", which could mean both avoiding spurious failure and ensuring more memory ordering. The approach here is conservative: it keeps the current implementation and allows access to the underlying machine's behavior, but it's also compatible with the possibility that we decide to strengthen guarantees in the future.

burgerrg commented 9 months ago

One of the tests triggered the error near line 1176 of mats/misc.ms. The call (error 'compute-size-increments should be (errorf 'compute-size-increments

mflatt commented 9 months ago

One of the tests triggered the error near line 1176 of mats/misc.ms. The call (error 'compute-size-increments should be (errorf 'compute-size-increments

Thanks - I'll work on that in another PR in the near future, since it's unrelated to the change here.

burgerrg commented 9 months ago

Thank you for this helpful update!