8170812: Metaspace corruption caused by incorrect memory size for MethodCounters

Reviewed-by: kbarrett, coleenp
This commit is contained in:
Andrew Haley 2017-04-07 13:42:00 +01:00
parent 442c887522
commit 7b865d0e66
5 changed files with 15 additions and 5 deletions

View File

@ -359,7 +359,9 @@ public:
}
// Sizing
static int header_size() { return sizeof(ConstMethod)/wordSize; }
static int header_size() {
return align_size_up(sizeof(ConstMethod), wordSize) / wordSize;
}
// Size needed
static int size(int code_size, InlineTableSizes* sizes);

View File

@ -705,7 +705,9 @@ class ConstantPool : public Metadata {
}
// Sizing (in words)
static int header_size() { return sizeof(ConstantPool)/wordSize; }
static int header_size() {
return align_size_up(sizeof(ConstantPool), wordSize) / wordSize;
}
static int size(int length) { return align_metadata_size(header_size() + length); }
int size() const { return size(length()); }
#if INCLUDE_SERVICES

View File

@ -359,7 +359,9 @@ class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC {
return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
// Code generation support
static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / wordSize); }
static WordSize size() {
return in_WordSize(align_size_up(sizeof(ConstantPoolCacheEntry), wordSize) / wordSize);
}
static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); }

View File

@ -671,7 +671,9 @@ class Method : public Metadata {
#endif
// sizing
static int header_size() { return sizeof(Method)/wordSize; }
static int header_size() {
return align_size_up(sizeof(Method), wordSize) / wordSize;
}
static int size(bool is_native);
int size() const { return method_size(); }
#if INCLUDE_SERVICES

View File

@ -116,7 +116,9 @@ class MethodCounters: public MetaspaceObj {
AOT_ONLY(Method* method() const { return _method; })
static int size() { return sizeof(MethodCounters) / wordSize; }
static int size() {
return align_size_up(sizeof(MethodCounters), wordSize) / wordSize;
}
bool is_klass() const { return false; }