Value array element size represented as log2

David Simms david.simms at oracle.com
Tue Oct 2 08:31:33 UTC 2018


> What is it you are asking here ? That you want to 20 bytes rather than 
> pow 2 aligned ?
>
> A long time ago we discussed that mul was too expensive compared to 
> shift, so that encoding is intentional (addressing uses shift)


On 2/10/2018 8:47 a.m., John Rose wrote:
> I support this; I would even support burning a couple more bits to put in a
> multiplier of 1/3/5/7.  This would reduce the fragmentation from 0-50-100%
> to 0-13-25%.

The current layout helper format for arrays has 8 bits. Bits 24-28 are 
also vacant, we have used 29 for Valhalla, and might need another one 
(maybe 28), so there may be 4 more bits.

If using a limited multiplier (going against earlier conclusions), what 
should that be ? Number of heap-words (8 bytes on x86_64) ? So max 
element 8 * 256 = 2048 bytes ?

This may be a reasonable limit to refuse flattening past this size, thus 
avoiding multiple addressing schemes (i.e. using the other bits to 
indicate shift).

Looking at the instruction latency, imul 3-4c vs shl 1c, might be worth 
benchmarking...

/D


> On Oct 1, 2018, at 11:01 PM, Ioi Lam <ioi.lam at oracle.com> wrote:
>> (Not sure if this has been discussed before. I did a quick JBS search of "valueArrayKlass" but couldn't find anything).
>>
>> For example, if my VT has 5 integers (20 bytes) it will take up 32 bytes inside the array. This seems kind of wasteful, especially when you have larger VT types.
>>
>> See:
>>
>> http://hg.openjdk.java.net/valhalla/valhalla/file/e0c13ab0b852/src/hotspot/share/oops/valueArrayKlass.cpp#l182
>>
>> jint ValueArrayKlass::array_layout_helper(ValueKlass* vk) {
>>    BasicType etype = T_VALUETYPE;
>>    int atag  = _lh_array_tag_vt_value;
>>    int esize = upper_log2(vk->raw_value_byte_size());
>>
>> klass.hpp:
>>
>>    // For arrays, layout helper is a negative number, containing four
>>    // distinct bytes, as follows:
>>    //    MSB:[tag, hsz, ebt, log2(esz)]:LSB
>>    // where:
>>    //    tag is 0x80 if the elements are oops, 0xC0 if non-oops
>>    //    hsz is array header size in bytes (i.e., offset of first element)
>>    //    ebt is the BasicType of the elements
>>    //    esz is the element size in bytes
>>
>>




More information about the valhalla-dev mailing list