7123315: instanceKlass::_static_oop_field_count and instanceKlass::_java_fields_count should be u2 type
Change instanceKlass::_static_oop_field_count and instanceKlass::_java_fields_count to u2 type. Reviewed-by: never, bdelsart, dholmes
This commit is contained in:
parent
82a0e26723
commit
0671e90755
@ -1050,7 +1050,7 @@ static FieldAllocationType basic_type_to_atype(bool is_static, BasicType type) {
|
||||
|
||||
class FieldAllocationCount: public ResourceObj {
|
||||
public:
|
||||
unsigned int count[MAX_FIELD_ALLOCATION_TYPE];
|
||||
u2 count[MAX_FIELD_ALLOCATION_TYPE];
|
||||
|
||||
FieldAllocationCount() {
|
||||
for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
|
||||
@ -1060,6 +1060,8 @@ class FieldAllocationCount: public ResourceObj {
|
||||
|
||||
FieldAllocationType update(bool is_static, BasicType type) {
|
||||
FieldAllocationType atype = basic_type_to_atype(is_static, type);
|
||||
// Make sure there is no overflow with injected fields.
|
||||
assert(count[atype] < 0xFFFF, "More than 65535 fields");
|
||||
count[atype]++;
|
||||
return atype;
|
||||
}
|
||||
@ -1070,7 +1072,7 @@ typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name,
|
||||
constantPoolHandle cp, bool is_interface,
|
||||
FieldAllocationCount *fac,
|
||||
objArrayHandle* fields_annotations,
|
||||
int* java_fields_count_ptr, TRAPS) {
|
||||
u2* java_fields_count_ptr, TRAPS) {
|
||||
ClassFileStream* cfs = stream();
|
||||
typeArrayHandle nullHandle;
|
||||
cfs->guarantee_more(2, CHECK_(nullHandle)); // length
|
||||
@ -2843,7 +2845,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
|
||||
local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle));
|
||||
}
|
||||
|
||||
int java_fields_count = 0;
|
||||
u2 java_fields_count = 0;
|
||||
// Fields (offsets are filled in later)
|
||||
FieldAllocationCount fac;
|
||||
objArrayHandle fields_annotations;
|
||||
|
@ -91,7 +91,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC {
|
||||
constantPoolHandle cp, bool is_interface,
|
||||
FieldAllocationCount *fac,
|
||||
objArrayHandle* fields_annotations,
|
||||
int* java_fields_count_ptr, TRAPS);
|
||||
u2* java_fields_count_ptr, TRAPS);
|
||||
|
||||
// Method parsing
|
||||
methodHandle parse_method(constantPoolHandle cp, bool is_interface,
|
||||
|
@ -227,9 +227,9 @@ class instanceKlass: public Klass {
|
||||
// (including inherited fields but after header_size()).
|
||||
int _nonstatic_field_size;
|
||||
int _static_field_size; // number words used by static fields (oop and non-oop) in this klass
|
||||
int _static_oop_field_count;// number of static oop fields in this klass
|
||||
u2 _static_oop_field_count;// number of static oop fields in this klass
|
||||
u2 _java_fields_count; // The number of declared Java fields
|
||||
int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
|
||||
int _java_fields_count; // The number of declared Java fields
|
||||
|
||||
u2 _minor_version; // minor version number of class file
|
||||
u2 _major_version; // major version number of class file
|
||||
@ -299,8 +299,8 @@ class instanceKlass: public Klass {
|
||||
int static_field_size() const { return _static_field_size; }
|
||||
void set_static_field_size(int size) { _static_field_size = size; }
|
||||
|
||||
int static_oop_field_count() const { return _static_oop_field_count; }
|
||||
void set_static_oop_field_count(int size) { _static_oop_field_count = size; }
|
||||
int static_oop_field_count() const { return (int)_static_oop_field_count; }
|
||||
void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
|
||||
|
||||
// Java vtable
|
||||
int vtable_length() const { return _vtable_len; }
|
||||
@ -340,14 +340,14 @@ class instanceKlass: public Klass {
|
||||
Symbol* field_signature (int index) const { return field(index)->signature(constants()); }
|
||||
|
||||
// Number of Java declared fields
|
||||
int java_fields_count() const { return _java_fields_count; }
|
||||
int java_fields_count() const { return (int)_java_fields_count; }
|
||||
|
||||
// Number of fields including any injected fields
|
||||
int all_fields_count() const { return _fields->length() / sizeof(FieldInfo::field_slots); }
|
||||
|
||||
typeArrayOop fields() const { return _fields; }
|
||||
|
||||
void set_fields(typeArrayOop f, int java_fields_count) {
|
||||
void set_fields(typeArrayOop f, u2 java_fields_count) {
|
||||
oop_store_without_check((oop*) &_fields, (oop) f);
|
||||
_java_fields_count = java_fields_count;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ static inline uint64_t cast_uint64_t(size_t x)
|
||||
nonstatic_field(instanceKlass, _nof_implementors, int) \
|
||||
nonstatic_field(instanceKlass, _implementors[0], klassOop) \
|
||||
nonstatic_field(instanceKlass, _fields, typeArrayOop) \
|
||||
nonstatic_field(instanceKlass, _java_fields_count, int) \
|
||||
nonstatic_field(instanceKlass, _java_fields_count, u2) \
|
||||
nonstatic_field(instanceKlass, _constants, constantPoolOop) \
|
||||
nonstatic_field(instanceKlass, _class_loader, oop) \
|
||||
nonstatic_field(instanceKlass, _protection_domain, oop) \
|
||||
@ -305,7 +305,7 @@ static inline uint64_t cast_uint64_t(size_t x)
|
||||
nonstatic_field(instanceKlass, _inner_classes, typeArrayOop) \
|
||||
nonstatic_field(instanceKlass, _nonstatic_field_size, int) \
|
||||
nonstatic_field(instanceKlass, _static_field_size, int) \
|
||||
nonstatic_field(instanceKlass, _static_oop_field_count, int) \
|
||||
nonstatic_field(instanceKlass, _static_oop_field_count, u2) \
|
||||
nonstatic_field(instanceKlass, _nonstatic_oop_map_size, int) \
|
||||
nonstatic_field(instanceKlass, _misc_flags, u1) \
|
||||
nonstatic_field(instanceKlass, _minor_version, u2) \
|
||||
|
Loading…
Reference in New Issue
Block a user