Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 90ada6a

Browse files
committedApr 23, 2020
8238048: Close alignment gaps in InstanceKlass
Moved fields around and some constant fields into ConstantPool Reviewed-by: cjplummer, dlong, iklam
1 parent 37e5aec commit 90ada6a

File tree

20 files changed

+184
-157
lines changed

20 files changed

+184
-157
lines changed
 

‎src/hotspot/share/classfile/bytecodeAssembler.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
5858
_orig->copy_cp_to(1, _orig->length() - 1, cp_h, 1, CHECK_NULL);
5959

6060
// Preserve dynamic constant information from the original pool
61-
if (_orig->has_dynamic_constant()) {
62-
cp->set_has_dynamic_constant();
63-
}
61+
cp->copy_fields(_orig);
6462

6563
for (int i = 0; i < _entries.length(); ++i) {
6664
BytecodeCPEntry entry = _entries.at(i);

‎src/hotspot/share/jvmci/vmStructs_jvmci.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@
116116
nonstatic_field(ConstantPool, _tags, Array<u1>*) \
117117
nonstatic_field(ConstantPool, _pool_holder, InstanceKlass*) \
118118
nonstatic_field(ConstantPool, _length, int) \
119-
nonstatic_field(ConstantPool, _flags, int) \
119+
nonstatic_field(ConstantPool, _flags, u2) \
120+
nonstatic_field(ConstantPool, _source_file_name_index, u2) \
120121
\
121122
nonstatic_field(ConstMethod, _constants, ConstantPool*) \
122123
nonstatic_field(ConstMethod, _flags, u2) \
@@ -155,10 +156,9 @@
155156
\
156157
nonstatic_field(InstanceKlass, _fields, Array<u2>*) \
157158
nonstatic_field(InstanceKlass, _constants, ConstantPool*) \
158-
nonstatic_field(InstanceKlass, _source_file_name_index, u2) \
159159
nonstatic_field(InstanceKlass, _init_state, u1) \
160160
nonstatic_field(InstanceKlass, _init_thread, Thread*) \
161-
nonstatic_field(InstanceKlass, _misc_flags, u4) \
161+
nonstatic_field(InstanceKlass, _misc_flags, u2) \
162162
nonstatic_field(InstanceKlass, _annotations, Annotations*) \
163163
\
164164
volatile_nonstatic_field(JavaFrameAnchor, _last_Java_sp, intptr_t*) \

‎src/hotspot/share/oops/constantPool.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, T
6565
return new (loader_data, size, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags);
6666
}
6767

68+
void ConstantPool::copy_fields(const ConstantPool* orig) {
69+
// Preserve dynamic constant information from the original pool
70+
if (orig->has_dynamic_constant()) {
71+
set_has_dynamic_constant();
72+
}
73+
74+
// Copy class version
75+
set_major_version(orig->major_version());
76+
set_minor_version(orig->minor_version());
77+
78+
set_source_file_name_index(orig->source_file_name_index());
79+
set_generic_signature_index(orig->generic_signature_index());
80+
}
81+
6882
#ifdef ASSERT
6983

7084
// MetaspaceObj allocation invariant is calloc equivalent memory

‎src/hotspot/share/oops/constantPool.hpp

+39-4
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,26 @@ class ConstantPool : public Metadata {
110110
// save space on 64-bit platforms.
111111
Array<Klass*>* _resolved_klasses;
112112

113+
u2 _major_version; // major version number of class file
114+
u2 _minor_version; // minor version number of class file
115+
116+
// Constant pool index to the utf8 entry of the Generic signature,
117+
// or 0 if none.
118+
u2 _generic_signature_index;
119+
// Constant pool index to the utf8 entry for the name of source file
120+
// containing this klass, 0 if not specified.
121+
u2 _source_file_name_index;
122+
113123
enum {
114124
_has_preresolution = 1, // Flags
115125
_on_stack = 2,
116126
_is_shared = 4,
117127
_has_dynamic_constant = 8
118128
};
119129

120-
int _flags; // old fashioned bit twiddling
121-
int _length; // number of elements in the array
130+
u2 _flags; // old fashioned bit twiddling
131+
132+
int _length; // number of elements in the array
122133

123134
union {
124135
// set for CDS to restore resolved references
@@ -135,8 +146,8 @@ class ConstantPool : public Metadata {
135146

136147
void set_operands(Array<u2>* operands) { _operands = operands; }
137148

138-
int flags() const { return _flags; }
139-
void set_flags(int f) { _flags = f; }
149+
u2 flags() const { return _flags; }
150+
void set_flags(u2 f) { _flags = f; }
140151

141152
private:
142153
intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(ConstantPool)); }
@@ -189,6 +200,30 @@ class ConstantPool : public Metadata {
189200
_flags |= _has_preresolution;
190201
}
191202

203+
// minor and major version numbers of class file
204+
u2 major_version() const { return _major_version; }
205+
void set_major_version(u2 major_version) { _major_version = major_version; }
206+
u2 minor_version() const { return _minor_version; }
207+
void set_minor_version(u2 minor_version) { _minor_version = minor_version; }
208+
209+
// generics support
210+
Symbol* generic_signature() const {
211+
return (_generic_signature_index == 0) ?
212+
(Symbol*)NULL : symbol_at(_generic_signature_index);
213+
}
214+
u2 generic_signature_index() const { return _generic_signature_index; }
215+
void set_generic_signature_index(u2 sig_index) { _generic_signature_index = sig_index; }
216+
217+
// source file name
218+
Symbol* source_file_name() const {
219+
return (_source_file_name_index == 0) ?
220+
(Symbol*)NULL : symbol_at(_source_file_name_index);
221+
}
222+
u2 source_file_name_index() const { return _source_file_name_index; }
223+
void set_source_file_name_index(u2 sourcefile_index) { _source_file_name_index = sourcefile_index; }
224+
225+
void copy_fields(const ConstantPool* orig);
226+
192227
// Redefine classes support. If a method refering to this constant pool
193228
// is on the executing stack, or as a handle in vm code, this constant pool
194229
// can't be removed from the set of previous versions saved in the instance

‎src/hotspot/share/oops/instanceClassLoaderKlass.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class InstanceClassLoaderKlass: public InstanceKlass {
4343
static const KlassID ID = InstanceClassLoaderKlassID;
4444

4545
private:
46-
InstanceClassLoaderKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_class_loader, ID) {}
46+
InstanceClassLoaderKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_kind_class_loader, ID) {}
4747

4848
public:
4949
InstanceClassLoaderKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }

‎src/hotspot/share/oops/instanceKlass.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par
442442
ik = new (loader_data, size, THREAD) InstanceClassLoaderKlass(parser);
443443
} else {
444444
// normal
445-
ik = new (loader_data, size, THREAD) InstanceKlass(parser, InstanceKlass::_misc_kind_other);
445+
ik = new (loader_data, size, THREAD) InstanceKlass(parser, InstanceKlass::_kind_other);
446446
}
447447
} else {
448448
// reference
@@ -483,15 +483,15 @@ Array<int>* InstanceKlass::create_new_default_vtable_indices(int len, TRAPS) {
483483
InstanceKlass::InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id) :
484484
Klass(id),
485485
_nest_members(NULL),
486-
_nest_host_index(0),
487486
_nest_host(NULL),
488487
_record_components(NULL),
489488
_static_field_size(parser.static_field_size()),
490489
_nonstatic_oop_map_size(nonstatic_oop_map_size(parser.total_oop_map_count())),
491490
_itable_len(parser.itable_size()),
492-
_init_thread(NULL),
491+
_nest_host_index(0),
493492
_init_state(allocated),
494-
_reference_type(parser.reference_type())
493+
_reference_type(parser.reference_type()),
494+
_init_thread(NULL)
495495
{
496496
set_vtable_length(parser.vtable_size());
497497
set_kind(kind);

0 commit comments

Comments
 (0)
This repository has been archived.