[jmm-dev] bitwise RMW operators, specifically testAndSetBit/BTS

David Holmes david.holmes at oracle.com
Thu Jul 21 05:16:52 UTC 2016

On 21/07/2016 4:20 AM, Hans Boehm wrote:
> You are not alone.  I have the suspicion that "word tearing" used to mean
> 17.7 before the 2005 JLS revision.  But the JLS usage seems to have won,
> for better or worse, at least in Java circles.

No not at all. word-tearing has "always" concerned the inability to 
perform sub-word atomic accesses - ie the subword has to be torn out of 
the word.

Here's a 2001 reference which was part of the discussion that led to the 
JLS update :)



> On Wed, Jul 20, 2016 at 9:59 AM, Martin Buchholz <martinrb at google.com>
> wrote:
>> On Wed, Jul 20, 2016 at 1:25 AM, Paul Sandoz <Paul.Sandoz at oracle.com>
>> wrote:
>>>> We should probably clarify whether we really mean that even
>> word-tearing
>>> on longs/doubles is allowed.
>>> Just to be clear you are referring to atomicity rather than word tearing
>>> as specified by JLS:
>>> https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.6 <
>>> https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.6>
>>> ? (I have tended to use word tearing interchangeably in the past and it
>>> has caused confusion.)
>> YIKES!  I just re-read
>> 17.6. Word Tearing
>> and
>> 17.7. Non-atomic Treatment of double and long
>> and now realize I've been using "word tearing" to mean 17.7 instead of 17.6
>> for many years.  I don't have a good word for 17.6, but I want something
>> along the lines of "ghost writes" or "collateral damage".
>> Am I supposed to visualize "tearing" as (sad eye water) tears running out
>> of one byte across neighbor bytes?

More information about the jmm-dev mailing list