Re: JavaMemoryModel: causal warps

From: Bill Pugh (pugh@cs.umd.edu)
Date: Fri Aug 01 2003 - 18:11:15 EDT


At 7:14 PM +0000 8/1/03, Ben Wint wrote:
>Is the following the case? Just checking my understanding.
>
>1. In the absence of barriers etc, the compiler can legally make
>any transformation that does not change intra-thread semantics.

Depends on what you mean by intra-thread semantics.

Here are some of the things the compiler generally cannot do:
* introduce additional meaningful reads of shared variables. For example,
   it cannot transform
        r1 = x; r2 = r1+r1;
   into
        r1 = x+x;
* introduce additional writes to shared variables. In particular,
   it cannot transform
        x = 1;
   into
        x = 42; x = 1;

But other than transformations that increase the number of accesses
to shared variables, the answer is yes.

We are working on updating a formal proof of this.

>2. A legal transformation in thread 1 can allow thread 2 to go down
>a path which it would never otherwise have taken, which in turn can
>allow an effect in thread 1 that would never otherwise have occurred.

Since transformations can't allow new behavior, the answer is
trivially no. I'm going to modify your example to the question I
think you were asking:

2a. A legal transformation in thread 1 can allow thread 2 to go down
a path which it would never otherwise have taken in SC execution,
which in turn can allow an effect in thread 1 that would never
otherwise have occurred in SC execution.

Yes, behaviors like this are possible. I'd have to think about it
some more to decide if one of our existing test cases falls into this
category, or if I would need to create a new test case.

        Bill
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:49 EDT