[concurrency-interest] Volatile/final and the JIT

Christian Vest Hansen karmazilla at gmail.com
Thu May 7 03:01:11 EDT 2009

Awesome. I stand corrected.

On Thu, May 7, 2009 at 4:37 AM, Brian Goetz <brian at briangoetz.com> wrote:
>> Different instances of this class may have different values assigned
>> to the statistics field, but the code itself is static and, I would
>> assume, optimized as such.
> This is not true.  There's nothing that says the JIT need only compile one
> version of a given method.  HotSpot will readily clone code where it can
> spot a slow/fast path, even based on deep inlining.  For example:
> foo(Moo x) {
>  goo(x);
> }
> goo(Moo x) {
>  if (x != null) { something expensive }
> }
> Here, calls to foo() may will be inlined (or inlined-cached), and in the
> branch where it is inlined, it can pull the null check all the way out to
> the caller, and have two completely different paths based on a condition
> that is way far down the tree.

Venlig hilsen / Kind regards,
Christian Vest Hansen.

More information about the Concurrency-interest mailing list