Value array element size represented as log2
Ioi Lam
ioi.lam at oracle.com
Tue Oct 2 06:01:41 UTC 2018
(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