Preliminary RFR (L): 8001107: @Stable annotation for constant folding of lazily evaluated variables

John Rose john.r.rose at
Mon Sep 2 23:40:25 PDT 2013

On Aug 29, 2013, at 4:57 PM, Vladimir Kozlov <vladimir.kozlov at> wrote:

>>> ciTypeArray.cpp: why we need these changes?
>> I consider this as a cleanup. element_value(index).as_char() performs
>> additional checks and it looks better (IMO, of course :-) ) than
>> get_typeArrayOop()->char_at(index).
> But element_value() is much more expensive! I don't like this change.

The old char_at function works fine, but I think it needs an assert that the array being referenced is truly a char[] array.  The more expensive element_value function performs this check, so it is safer.  It is also helpful to prove (at least via an assert) that element_value is a true extension of char_at.

If we don't like making char_at slightly more expensive (it doesn't make much difference!) then I suggest putting the call to element_value into the #ifdef ASSERT, as follows:

    assert(index >= 0 && index < length(), "out of range");
!   jchar c = get_typeArrayOop()->char_at(index);
! #ifdef ASSERT
!   jchar d = element_value(index).as_char();
!   assert(c == d, "");
! #endif //ASSERT
!   return c;

— John
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the hotspot-compiler-dev mailing list