Skip to content

Commit bd3e65b

Browse files
committed
8256052: Remove unused allocation type from fieldInfo
Reviewed-by: redestad, lfoltan, hseigel
1 parent 6d8acd2 commit bd3e65b

File tree

5 files changed

+27
-121
lines changed

5 files changed

+27
-121
lines changed

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,14 +1557,13 @@ class ClassFileParser::FieldAllocationCount : public ResourceObj {
15571557
}
15581558
}
15591559

1560-
FieldAllocationType update(bool is_static, BasicType type) {
1560+
void update(bool is_static, BasicType type) {
15611561
FieldAllocationType atype = basic_type_to_atype(is_static, type);
15621562
if (atype != BAD_ALLOCATION_TYPE) {
15631563
// Make sure there is no overflow with injected fields.
15641564
assert(count[atype] < 0xFFFF, "More than 65535 fields");
15651565
count[atype]++;
15661566
}
1567-
return atype;
15681567
}
15691568
};
15701569

@@ -1704,9 +1703,8 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs,
17041703
constantvalue_index);
17051704
const BasicType type = cp->basic_type_for_signature_at(signature_index);
17061705

1707-
// Remember how many oops we encountered and compute allocation type
1708-
const FieldAllocationType atype = fac->update(is_static, type);
1709-
field->set_allocation_type(atype);
1706+
// Update FieldAllocationCount for this kind of field
1707+
fac->update(is_static, type);
17101708

17111709
// After field is initialized with type, we can augment it with aux info
17121710
if (parsed_annotations.has_any_annotations()) {
@@ -1749,9 +1747,8 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs,
17491747

17501748
const BasicType type = Signature::basic_type(injected[n].signature());
17511749

1752-
// Remember how many oops we encountered and compute allocation type
1753-
const FieldAllocationType atype = fac->update(false, type);
1754-
field->set_allocation_type(atype);
1750+
// Update FieldAllocationCount for this kind of field
1751+
fac->update(false, type);
17551752
index++;
17561753
}
17571754
}

src/hotspot/share/oops/fieldInfo.hpp

Lines changed: 21 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,21 @@ class FieldInfo {
4747
// as an array of 6 shorts.
4848

4949
#define FIELDINFO_TAG_SIZE 2
50-
#define FIELDINFO_TAG_BLANK 0
51-
#define FIELDINFO_TAG_OFFSET 1
52-
#define FIELDINFO_TAG_TYPE_PLAIN 2
53-
#define FIELDINFO_TAG_TYPE_CONTENDED 3
54-
#define FIELDINFO_TAG_MASK 3
50+
#define FIELDINFO_TAG_OFFSET 1 << 0
51+
#define FIELDINFO_TAG_CONTENDED 1 << 1
5552

5653
// Packed field has the tag, and can be either of:
5754
// hi bits <--------------------------- lo bits
5855
// |---------high---------|---------low---------|
59-
// ..........................................00 - blank
56+
// ..........................................CO
57+
// ..........................................00 - non-contended field
58+
// [--contention_group--]....................10 - contended field with contention group
6059
// [------------------offset----------------]01 - real field offset
61-
// ......................[-------type-------]10 - plain field with type
62-
// [--contention_group--][-------type-------]11 - contended field with type and contention group
60+
61+
// Bit O indicates if the packed field contains an offset (O=1) or not (O=0)
62+
// Bit C indicates if the field is contended (C=1) or not (C=0)
63+
// (if it is contended, the high packed field contains the contention group)
64+
6365
enum FieldOffset {
6466
access_flags_offset = 0,
6567
name_index_offset = 1,
@@ -103,78 +105,22 @@ class FieldInfo {
103105

104106
u2 access_flags() const { return _shorts[access_flags_offset]; }
105107
u4 offset() const {
106-
u2 lo = _shorts[low_packed_offset];
107-
switch(lo & FIELDINFO_TAG_MASK) {
108-
case FIELDINFO_TAG_OFFSET:
109-
return build_int_from_shorts(_shorts[low_packed_offset], _shorts[high_packed_offset]) >> FIELDINFO_TAG_SIZE;
110-
#ifndef PRODUCT
111-
case FIELDINFO_TAG_TYPE_PLAIN:
112-
fatal("Asking offset for the plain type field");
113-
case FIELDINFO_TAG_TYPE_CONTENDED:
114-
fatal("Asking offset for the contended type field");
115-
case FIELDINFO_TAG_BLANK:
116-
fatal("Asking offset for the blank field");
117-
#endif
118-
}
119-
ShouldNotReachHere();
120-
return 0;
108+
assert((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) != 0, "Offset must have been set");
109+
return build_int_from_shorts(_shorts[low_packed_offset], _shorts[high_packed_offset]) >> FIELDINFO_TAG_SIZE;
121110
}
122111

123112
bool is_contended() const {
124-
u2 lo = _shorts[low_packed_offset];
125-
switch(lo & FIELDINFO_TAG_MASK) {
126-
case FIELDINFO_TAG_TYPE_PLAIN:
127-
return false;
128-
case FIELDINFO_TAG_TYPE_CONTENDED:
129-
return true;
130-
#ifndef PRODUCT
131-
case FIELDINFO_TAG_OFFSET:
132-
fatal("Asking contended flag for the field with offset");
133-
case FIELDINFO_TAG_BLANK:
134-
fatal("Asking contended flag for the blank field");
135-
#endif
136-
}
137-
ShouldNotReachHere();
138-
return false;
113+
return (_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) != 0;
139114
}
140115

141116
u2 contended_group() const {
142-
u2 lo = _shorts[low_packed_offset];
143-
switch(lo & FIELDINFO_TAG_MASK) {
144-
case FIELDINFO_TAG_TYPE_PLAIN:
145-
return 0;
146-
case FIELDINFO_TAG_TYPE_CONTENDED:
147-
return _shorts[high_packed_offset];
148-
#ifndef PRODUCT
149-
case FIELDINFO_TAG_OFFSET:
150-
fatal("Asking the contended group for the field with offset");
151-
case FIELDINFO_TAG_BLANK:
152-
fatal("Asking the contended group for the blank field");
153-
#endif
154-
}
155-
ShouldNotReachHere();
156-
return 0;
117+
assert((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) == 0, "Offset must not have been set");
118+
assert((_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) != 0, "Field must be contended");
119+
return _shorts[high_packed_offset];
157120
}
158121

159-
u2 allocation_type() const {
160-
u2 lo = _shorts[low_packed_offset];
161-
switch(lo & FIELDINFO_TAG_MASK) {
162-
case FIELDINFO_TAG_TYPE_PLAIN:
163-
case FIELDINFO_TAG_TYPE_CONTENDED:
164-
return (lo >> FIELDINFO_TAG_SIZE);
165-
#ifndef PRODUCT
166-
case FIELDINFO_TAG_OFFSET:
167-
fatal("Asking the field type for field with offset");
168-
case FIELDINFO_TAG_BLANK:
169-
fatal("Asking the field type for the blank field");
170-
#endif
171-
}
172-
ShouldNotReachHere();
173-
return 0;
174-
}
175-
176122
bool is_offset_set() const {
177-
return (_shorts[low_packed_offset] & FIELDINFO_TAG_MASK) == FIELDINFO_TAG_OFFSET;
123+
return (_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET)!= 0;
178124
}
179125

180126
Symbol* name(ConstantPool* cp) const {
@@ -200,41 +146,11 @@ class FieldInfo {
200146
_shorts[high_packed_offset] = extract_high_short_from_int(val);
201147
}
202148

203-
void set_allocation_type(int type) {
204-
u2 lo = _shorts[low_packed_offset];
205-
switch(lo & FIELDINFO_TAG_MASK) {
206-
case FIELDINFO_TAG_BLANK:
207-
_shorts[low_packed_offset] = ((type << FIELDINFO_TAG_SIZE)) & 0xFFFF;
208-
_shorts[low_packed_offset] &= ~FIELDINFO_TAG_MASK;
209-
_shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_PLAIN;
210-
return;
211-
#ifndef PRODUCT
212-
case FIELDINFO_TAG_TYPE_PLAIN:
213-
case FIELDINFO_TAG_TYPE_CONTENDED:
214-
case FIELDINFO_TAG_OFFSET:
215-
fatal("Setting the field type with overwriting");
216-
#endif
217-
}
218-
ShouldNotReachHere();
219-
}
220-
221149
void set_contended_group(u2 val) {
222-
u2 lo = _shorts[low_packed_offset];
223-
switch(lo & FIELDINFO_TAG_MASK) {
224-
case FIELDINFO_TAG_TYPE_PLAIN:
225-
_shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_CONTENDED;
226-
_shorts[high_packed_offset] = val;
227-
return;
228-
#ifndef PRODUCT
229-
case FIELDINFO_TAG_TYPE_CONTENDED:
230-
fatal("Overwriting contended group");
231-
case FIELDINFO_TAG_BLANK:
232-
fatal("Setting contended group for the blank field");
233-
case FIELDINFO_TAG_OFFSET:
234-
fatal("Setting contended group for field with offset");
235-
#endif
236-
}
237-
ShouldNotReachHere();
150+
assert((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) == 0, "Offset must not have been set");
151+
assert((_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) == 0, "Overwritting contended group");
152+
_shorts[low_packed_offset] |= FIELDINFO_TAG_CONTENDED;
153+
_shorts[high_packed_offset] = val;
238154
}
239155

240156
bool is_internal() const {

src/hotspot/share/oops/fieldStreams.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ class FieldStreamBase : public StackObj {
134134
return field()->offset();
135135
}
136136

137-
int allocation_type() const {
138-
return field()->allocation_type();
139-
}
140-
141137
void set_offset(int offset) {
142138
field()->set_offset(offset);
143139
}

src/hotspot/share/runtime/vmStructs.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,6 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
22572257
/*************************************/ \
22582258
\
22592259
declare_preprocessor_constant("FIELDINFO_TAG_SIZE", FIELDINFO_TAG_SIZE) \
2260-
declare_preprocessor_constant("FIELDINFO_TAG_MASK", FIELDINFO_TAG_MASK) \
22612260
declare_preprocessor_constant("FIELDINFO_TAG_OFFSET", FIELDINFO_TAG_OFFSET) \
22622261
\
22632262
/************************************************/ \

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public void update(Observable o, Object data) {
5656
private static int HIGH_OFFSET;
5757
private static int FIELD_SLOTS;
5858
private static short FIELDINFO_TAG_SIZE;
59-
private static short FIELDINFO_TAG_MASK;
6059
private static short FIELDINFO_TAG_OFFSET;
6160

6261
// ClassState constants
@@ -117,7 +116,6 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
117116
HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_packed_offset").intValue();
118117
FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue();
119118
FIELDINFO_TAG_SIZE = db.lookupIntConstant("FIELDINFO_TAG_SIZE").shortValue();
120-
FIELDINFO_TAG_MASK = db.lookupIntConstant("FIELDINFO_TAG_MASK").shortValue();
121119
FIELDINFO_TAG_OFFSET = db.lookupIntConstant("FIELDINFO_TAG_OFFSET").shortValue();
122120

123121
// read ClassState constants
@@ -397,7 +395,7 @@ public int getFieldOffset(int index) {
397395
U2Array fields = getFields();
398396
short lo = fields.at(index * FIELD_SLOTS + LOW_OFFSET);
399397
short hi = fields.at(index * FIELD_SLOTS + HIGH_OFFSET);
400-
if ((lo & FIELDINFO_TAG_MASK) == FIELDINFO_TAG_OFFSET) {
398+
if ((lo & FIELDINFO_TAG_OFFSET) == FIELDINFO_TAG_OFFSET) {
401399
return VM.getVM().buildIntFromShorts(lo, hi) >> FIELDINFO_TAG_SIZE;
402400
}
403401
throw new RuntimeException("should not reach here");

0 commit comments

Comments
 (0)