(Issue A) -- 2 byte reduction: change _refcount from 4 bytes to 2 bytes. It's extremely unlikely that the reference count would be as high as 32767.
class Symbol : public MetaspaceObj {
private:
volatile int _refcount;
int _identity_hash;
unsigned short _length; // number of UTF8 characters in the symbol
jbyte _body[1];
(Issue B) -- 1 byte reduction: size(int) function is incorrect. It assumes (pessimistically) that sizeof(Symbol) is 11, but in fact with most compilers sizeof(Symbol) is 12.
static int size(int length) {
size_t sz = heap_word_size(sizeof(Symbol) + (length > 0 ? length - 1 : 0));
return align_object_size(sz);
}
The fix for issue B is to split Symbol into two parts:
class SymbolBase {
// all fields except _body[];
};
class Symbol: private SymbolBase {
jbyte _body[1];
static int size(int length) {
size_t sz = heap_word_size(sizeof(SymbolBase) + (length > 0 ? length : 0));
return align_object_size(sz);
}
};
class Symbol : public MetaspaceObj {
private:
volatile int _refcount;
int _identity_hash;
unsigned short _length; // number of UTF8 characters in the symbol
jbyte _body[1];
(Issue B) -- 1 byte reduction: size(int) function is incorrect. It assumes (pessimistically) that sizeof(Symbol) is 11, but in fact with most compilers sizeof(Symbol) is 12.
static int size(int length) {
size_t sz = heap_word_size(sizeof(Symbol) + (length > 0 ? length - 1 : 0));
return align_object_size(sz);
}
The fix for issue B is to split Symbol into two parts:
class SymbolBase {
// all fields except _body[];
};
class Symbol: private SymbolBase {
jbyte _body[1];
static int size(int length) {
size_t sz = heap_word_size(sizeof(SymbolBase) + (length > 0 ? length : 0));
return align_object_size(sz);
}
};
- duplicates
-
JDK-8009575 Reduce Symbol::_refcount from 4 bytes to 2 bytes
-
- Closed
-