Flat Array null check issue - Re: RFR(L) Valhalla support for AArch64 v.05

Dmitry Samersoff dms at samersoff.net
Tue Jul 9 09:33:41 UTC 2019


Roland,

> Is the sequence above the actual code generated by c2? It would then
> seem that we test for the property bit on the already masked klass
> pointer.

Yes. It's the code generated by C2 and I agree with you finding.

What is the correct way to fix it?

Is it possible to move this logic to *.ad file and re-use the code from
macroAssembler_*.cpp or it's better to replace LoadKlassNode with
LoadPNode inside GraphKit::gen_value_array_null_guard and update
dependent code?

-Dmitry


On 09.07.19 11:46, Roland Westrelin wrote:
> 
>> GetNullFreeProperty in compile.cpp
>>
>>
>> Interpreter in a similar place uses the code (below):
>>
>>   ldrw(dst, Address(src, oopDesc::klass_offset_in_bytes()));
>>   asrw(dst, dst, oopDesc::narrow_storage_props_shift);
>>
>>   andr(dst, dst, ArrayStorageProperties::null_free_value);
>>   cbnz(dst, is_null_free_array);
>>
>>
>> but C2 does:
>>
>>    # LoadNKlass node
>>    ldrw  $dst, $mem
>>    andr  $dst, $dst, oopDesc::compressed_klass_mask()
>>
>>    #AndINode
>>    andr  $dst, 1 << (oopDesc::narrow_storage_props_shift  +
>>                      ArrayStorageProperties::null_free_bit);
>>
>>    # cmpI
>>    cbz(temp_reg, is_null_free_array);
>>
>>
>> Is it correct?
>> Do you have any ideas how to go forward with it?
> 
> The klass pointer of a null free array is tagged with property bits
> (there are 2 property bits: null free and flattened). So before we use
> the klass pointer as an actual pointer we need to mask out the property
> bits. That's what:
> andr $dst, $dst, oopDesc::compressed_klass_mask()
> does.
> 
> To check for a null free array, we need to test for the null free
> property bit on the unmasked klass pointer.
> 
> Is the sequence above the actual code generated by c2? It would then
> seem that we test for the property bit on the already masked klass
> pointer.
> 
> Roland.
> 


More information about the valhalla-dev mailing list