Field access optimisations inside loops (question).

Dawid Weiss dawid.weiss at
Fri Jan 8 02:07:35 PST 2010

> 1. I'm wondering, why there is only moved a byte (MOV8) to the 'value'
> variable instead of a int. (what is the element size in list?)

The buffer is byte[], the variable is an int -- it's just an example,
the same thing happens regardless of
the array type/ variable combination.

> 2. I agree, if:
> - list is private member in this class,
> - list is not reachable by other methods of this class from a concurrent
> thread.

list is a private member, although not final. The list field is used
in other methods of this class, but does this
change anything from the current thread's point of view? Correct me if
I'm wrong, but if there are no monitors or special fencing, the
running thread can safely assume no side effects to object fields,
can't it? After all, it's much like the CPU cache -- if you expected
list.buffer to change concurrently, you'd declare it as volatile.

> For similar problem see: Bug Id 6914095.

Yep, this ( seems
similar. I have a suspicion that my understanding of what hotspot can
do is not entirely correct though (reachability in your remark 2


More information about the hotspot-compiler-dev mailing list