RFR (S) 8150465: Unsafe methods to produce uninitialized arrays

Aleksey Shipilev aleksey.shipilev at oracle.com
Thu Feb 25 08:10:40 UTC 2016


On 02/25/2016 03:20 AM, Vladimir Kozlov wrote:
> On 2/24/16 3:51 PM, Aleksey Shipilev wrote:
>> On 02/25/2016 02:21 AM, Vladimir Kozlov wrote:
>>> What is your story for GC? When an array become visible and GC happens,
>>> it will expect only initialized arrays.
>>
>> New method allows primitive arrays only, and its headers should be
>> intact. This is corroborated by the new jtreg test (and benchmarks!)
>> that allocate lots of uninitialized arrays, and obviously they get GCed.
> 
> Yes, primitive arrays are fine if the header is correct. In this case
> changes are fine but you may need to add a check in
> inline_unsafe_newArray() that it is only primitive types.

Alas, the class argument may not be constant, and so we would need a
runtime check there, which would duplicate the check we already have in
Unsafe.java. I'd prefer to follow the upcoming pattern in Mikael's
Unsafe cleanup with making as much checks on Java side.

> testIAE() should throw exception if IllegalArgumentException is not thrown.

D'uh, of course!

See updates:
  http://cr.openjdk.java.net/~shade/8150465/webrev.jdk.01/
  http://cr.openjdk.java.net/~shade/8150465/webrev.hs.02/

Cheers,
-Aleksey



More information about the jdk9-dev mailing list