@@ -1352,105 +1352,16 @@ void ClassFileParser::parse_field_attributes(const ClassFileStream* const cfs,
1352
1352
}
1353
1353
1354
1354
1355
- // Field allocation types. Used for computing field offsets.
1356
-
1357
- enum FieldAllocationType {
1358
- STATIC_OOP, // Oops
1359
- STATIC_BYTE, // Boolean, Byte, char
1360
- STATIC_SHORT, // shorts
1361
- STATIC_WORD, // ints
1362
- STATIC_DOUBLE, // aligned long or double
1363
- NONSTATIC_OOP,
1364
- NONSTATIC_BYTE,
1365
- NONSTATIC_SHORT,
1366
- NONSTATIC_WORD,
1367
- NONSTATIC_DOUBLE,
1368
- MAX_FIELD_ALLOCATION_TYPE,
1369
- BAD_ALLOCATION_TYPE = -1
1370
- };
1371
-
1372
- static FieldAllocationType _basic_type_to_atype[2 * (T_CONFLICT + 1 )] = {
1373
- BAD_ALLOCATION_TYPE, // 0
1374
- BAD_ALLOCATION_TYPE, // 1
1375
- BAD_ALLOCATION_TYPE, // 2
1376
- BAD_ALLOCATION_TYPE, // 3
1377
- NONSTATIC_BYTE , // T_BOOLEAN = 4,
1378
- NONSTATIC_SHORT, // T_CHAR = 5,
1379
- NONSTATIC_WORD, // T_FLOAT = 6,
1380
- NONSTATIC_DOUBLE, // T_DOUBLE = 7,
1381
- NONSTATIC_BYTE, // T_BYTE = 8,
1382
- NONSTATIC_SHORT, // T_SHORT = 9,
1383
- NONSTATIC_WORD, // T_INT = 10,
1384
- NONSTATIC_DOUBLE, // T_LONG = 11,
1385
- NONSTATIC_OOP, // T_OBJECT = 12,
1386
- NONSTATIC_OOP, // T_ARRAY = 13,
1387
- BAD_ALLOCATION_TYPE, // T_VOID = 14,
1388
- BAD_ALLOCATION_TYPE, // T_ADDRESS = 15,
1389
- BAD_ALLOCATION_TYPE, // T_NARROWOOP = 16,
1390
- BAD_ALLOCATION_TYPE, // T_METADATA = 17,
1391
- BAD_ALLOCATION_TYPE, // T_NARROWKLASS = 18,
1392
- BAD_ALLOCATION_TYPE, // T_CONFLICT = 19,
1393
- BAD_ALLOCATION_TYPE, // 0
1394
- BAD_ALLOCATION_TYPE, // 1
1395
- BAD_ALLOCATION_TYPE, // 2
1396
- BAD_ALLOCATION_TYPE, // 3
1397
- STATIC_BYTE , // T_BOOLEAN = 4,
1398
- STATIC_SHORT, // T_CHAR = 5,
1399
- STATIC_WORD, // T_FLOAT = 6,
1400
- STATIC_DOUBLE, // T_DOUBLE = 7,
1401
- STATIC_BYTE, // T_BYTE = 8,
1402
- STATIC_SHORT, // T_SHORT = 9,
1403
- STATIC_WORD, // T_INT = 10,
1404
- STATIC_DOUBLE, // T_LONG = 11,
1405
- STATIC_OOP, // T_OBJECT = 12,
1406
- STATIC_OOP, // T_ARRAY = 13,
1407
- BAD_ALLOCATION_TYPE, // T_VOID = 14,
1408
- BAD_ALLOCATION_TYPE, // T_ADDRESS = 15,
1409
- BAD_ALLOCATION_TYPE, // T_NARROWOOP = 16,
1410
- BAD_ALLOCATION_TYPE, // T_METADATA = 17,
1411
- BAD_ALLOCATION_TYPE, // T_NARROWKLASS = 18,
1412
- BAD_ALLOCATION_TYPE, // T_CONFLICT = 19,
1413
- };
1414
-
1415
- static FieldAllocationType basic_type_to_atype (bool is_static, BasicType type) {
1416
- assert (type >= T_BOOLEAN && type < T_VOID, " only allowable values" );
1417
- FieldAllocationType result = _basic_type_to_atype[type + (is_static ? (T_CONFLICT + 1 ) : 0 )];
1418
- assert (result != BAD_ALLOCATION_TYPE, " bad type" );
1419
- return result;
1420
- }
1421
-
1422
- class ClassFileParser ::FieldAllocationCount : public ResourceObj {
1423
- public:
1424
- u2 count[MAX_FIELD_ALLOCATION_TYPE];
1425
-
1426
- FieldAllocationCount () {
1427
- for (int i = 0 ; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
1428
- count[i] = 0 ;
1429
- }
1430
- }
1431
-
1432
- void update (bool is_static, BasicType type) {
1433
- FieldAllocationType atype = basic_type_to_atype (is_static, type);
1434
- if (atype != BAD_ALLOCATION_TYPE) {
1435
- // Make sure there is no overflow with injected fields.
1436
- assert (count[atype] < 0xFFFF , " More than 65535 fields" );
1437
- count[atype]++;
1438
- }
1439
- }
1440
- };
1441
-
1442
1355
// Side-effects: populates the _fields, _fields_annotations,
1443
1356
// _fields_type_annotations fields
1444
1357
void ClassFileParser::parse_fields (const ClassFileStream* const cfs,
1445
1358
bool is_interface,
1446
- FieldAllocationCount* const fac,
1447
1359
ConstantPool* cp,
1448
1360
const int cp_size,
1449
1361
u2* const java_fields_count_ptr,
1450
1362
TRAPS) {
1451
1363
1452
1364
assert (cfs != nullptr , " invariant" );
1453
- assert (fac != nullptr , " invariant" );
1454
1365
assert (cp != nullptr , " invariant" );
1455
1366
assert (java_fields_count_ptr != nullptr , " invariant" );
1456
1367
@@ -1544,8 +1455,10 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs,
1544
1455
1545
1456
const BasicType type = cp->basic_type_for_signature_at (signature_index);
1546
1457
1547
- // Update FieldAllocationCount for this kind of field
1548
- fac->update (is_static, type);
1458
+ // Update number of static oop fields.
1459
+ if (is_static && is_reference_type (type)) {
1460
+ _static_oop_count++;
1461
+ }
1549
1462
1550
1463
FieldInfo fi (access_flags, name_index, signature_index, constantvalue_index, fieldFlags);
1551
1464
fi.set_index (n);
@@ -1590,10 +1503,6 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs,
1590
1503
FieldInfo fi (aflags, (u2)(injected[n].name_index ), (u2)(injected[n].signature_index ), 0 , fflags);
1591
1504
fi.set_index (index );
1592
1505
_temp_field_info->append (fi);
1593
-
1594
- // Update FieldAllocationCount for this kind of field
1595
- const BasicType type = Signature::basic_type (injected[n].signature ());
1596
- fac->update (false , type);
1597
1506
index ++;
1598
1507
}
1599
1508
}
@@ -5117,8 +5026,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik,
5117
5026
// Not yet: supers are done below to support the new subtype-checking fields
5118
5027
ik->set_nonstatic_field_size (_field_info->_nonstatic_field_size );
5119
5028
ik->set_has_nonstatic_fields (_field_info->_has_nonstatic_fields );
5120
- assert (_fac != nullptr , " invariant" );
5121
- ik->set_static_oop_field_count (_fac->count [STATIC_OOP]);
5029
+ ik->set_static_oop_field_count (_static_oop_count);
5122
5030
5123
5031
// this transfers ownership of a lot of arrays from
5124
5032
// the parser onto the InstanceKlass*
@@ -5360,6 +5268,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream,
5360
5268
_is_hidden(cl_info->is_hidden ()),
5361
5269
_can_access_vm_annotations(cl_info->can_access_vm_annotations ()),
5362
5270
_orig_cp_size(0 ),
5271
+ _static_oop_count(0 ),
5363
5272
_super_klass(),
5364
5273
_cp(nullptr ),
5365
5274
_fieldinfo_stream(nullptr ),
@@ -5380,7 +5289,6 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream,
5380
5289
_klass(nullptr ),
5381
5290
_klass_to_deallocate(nullptr ),
5382
5291
_parsed_annotations(nullptr ),
5383
- _fac(nullptr ),
5384
5292
_field_info(nullptr ),
5385
5293
_temp_field_info(nullptr ),
5386
5294
_method_ordering(nullptr ),
@@ -5706,10 +5614,8 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream,
5706
5614
assert (_local_interfaces != nullptr , " invariant" );
5707
5615
5708
5616
// Fields (offsets are filled in later)
5709
- _fac = new FieldAllocationCount ();
5710
5617
parse_fields (stream,
5711
5618
_access_flags.is_interface (),
5712
- _fac,
5713
5619
cp,
5714
5620
cp_size,
5715
5621
&_java_fields_count,
@@ -5867,7 +5773,6 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
5867
5773
_itable_size = _access_flags.is_interface () ? 0 :
5868
5774
klassItable::compute_itable_size (_transitive_interfaces);
5869
5775
5870
- assert (_fac != nullptr , " invariant" );
5871
5776
assert (_parsed_annotations != nullptr , " invariant" );
5872
5777
5873
5778
_field_info = new FieldLayoutInfo ();
0 commit comments