8238048: Close alignment gaps in InstanceKlass
Moved fields around and some constant fields into ConstantPool Reviewed-by: cjplummer, dlong, iklam
This commit is contained in:
parent
37e5aec119
commit
90ada6a314
@ -58,9 +58,7 @@ ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
|
||||
_orig->copy_cp_to(1, _orig->length() - 1, cp_h, 1, CHECK_NULL);
|
||||
|
||||
// Preserve dynamic constant information from the original pool
|
||||
if (_orig->has_dynamic_constant()) {
|
||||
cp->set_has_dynamic_constant();
|
||||
}
|
||||
cp->copy_fields(_orig);
|
||||
|
||||
for (int i = 0; i < _entries.length(); ++i) {
|
||||
BytecodeCPEntry entry = _entries.at(i);
|
||||
|
@ -116,7 +116,8 @@
|
||||
nonstatic_field(ConstantPool, _tags, Array<u1>*) \
|
||||
nonstatic_field(ConstantPool, _pool_holder, InstanceKlass*) \
|
||||
nonstatic_field(ConstantPool, _length, int) \
|
||||
nonstatic_field(ConstantPool, _flags, int) \
|
||||
nonstatic_field(ConstantPool, _flags, u2) \
|
||||
nonstatic_field(ConstantPool, _source_file_name_index, u2) \
|
||||
\
|
||||
nonstatic_field(ConstMethod, _constants, ConstantPool*) \
|
||||
nonstatic_field(ConstMethod, _flags, u2) \
|
||||
@ -155,10 +156,9 @@
|
||||
\
|
||||
nonstatic_field(InstanceKlass, _fields, Array<u2>*) \
|
||||
nonstatic_field(InstanceKlass, _constants, ConstantPool*) \
|
||||
nonstatic_field(InstanceKlass, _source_file_name_index, u2) \
|
||||
nonstatic_field(InstanceKlass, _init_state, u1) \
|
||||
nonstatic_field(InstanceKlass, _init_thread, Thread*) \
|
||||
nonstatic_field(InstanceKlass, _misc_flags, u4) \
|
||||
nonstatic_field(InstanceKlass, _misc_flags, u2) \
|
||||
nonstatic_field(InstanceKlass, _annotations, Annotations*) \
|
||||
\
|
||||
volatile_nonstatic_field(JavaFrameAnchor, _last_Java_sp, intptr_t*) \
|
||||
|
@ -65,6 +65,20 @@ ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, T
|
||||
return new (loader_data, size, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags);
|
||||
}
|
||||
|
||||
void ConstantPool::copy_fields(const ConstantPool* orig) {
|
||||
// Preserve dynamic constant information from the original pool
|
||||
if (orig->has_dynamic_constant()) {
|
||||
set_has_dynamic_constant();
|
||||
}
|
||||
|
||||
// Copy class version
|
||||
set_major_version(orig->major_version());
|
||||
set_minor_version(orig->minor_version());
|
||||
|
||||
set_source_file_name_index(orig->source_file_name_index());
|
||||
set_generic_signature_index(orig->generic_signature_index());
|
||||
}
|
||||
|
||||
#ifdef ASSERT
|
||||
|
||||
// MetaspaceObj allocation invariant is calloc equivalent memory
|
||||
|
@ -110,6 +110,16 @@ class ConstantPool : public Metadata {
|
||||
// save space on 64-bit platforms.
|
||||
Array<Klass*>* _resolved_klasses;
|
||||
|
||||
u2 _major_version; // major version number of class file
|
||||
u2 _minor_version; // minor version number of class file
|
||||
|
||||
// Constant pool index to the utf8 entry of the Generic signature,
|
||||
// or 0 if none.
|
||||
u2 _generic_signature_index;
|
||||
// Constant pool index to the utf8 entry for the name of source file
|
||||
// containing this klass, 0 if not specified.
|
||||
u2 _source_file_name_index;
|
||||
|
||||
enum {
|
||||
_has_preresolution = 1, // Flags
|
||||
_on_stack = 2,
|
||||
@ -117,8 +127,9 @@ class ConstantPool : public Metadata {
|
||||
_has_dynamic_constant = 8
|
||||
};
|
||||
|
||||
int _flags; // old fashioned bit twiddling
|
||||
int _length; // number of elements in the array
|
||||
u2 _flags; // old fashioned bit twiddling
|
||||
|
||||
int _length; // number of elements in the array
|
||||
|
||||
union {
|
||||
// set for CDS to restore resolved references
|
||||
@ -135,8 +146,8 @@ class ConstantPool : public Metadata {
|
||||
|
||||
void set_operands(Array<u2>* operands) { _operands = operands; }
|
||||
|
||||
int flags() const { return _flags; }
|
||||
void set_flags(int f) { _flags = f; }
|
||||
u2 flags() const { return _flags; }
|
||||
void set_flags(u2 f) { _flags = f; }
|
||||
|
||||
private:
|
||||
intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(ConstantPool)); }
|
||||
@ -189,6 +200,30 @@ class ConstantPool : public Metadata {
|
||||
_flags |= _has_preresolution;
|
||||
}
|
||||
|
||||
// minor and major version numbers of class file
|
||||
u2 major_version() const { return _major_version; }
|
||||
void set_major_version(u2 major_version) { _major_version = major_version; }
|
||||
u2 minor_version() const { return _minor_version; }
|
||||
void set_minor_version(u2 minor_version) { _minor_version = minor_version; }
|
||||
|
||||
// generics support
|
||||
Symbol* generic_signature() const {
|
||||
return (_generic_signature_index == 0) ?
|
||||
(Symbol*)NULL : symbol_at(_generic_signature_index);
|
||||
}
|
||||
u2 generic_signature_index() const { return _generic_signature_index; }
|
||||
void set_generic_signature_index(u2 sig_index) { _generic_signature_index = sig_index; }
|
||||
|
||||
// source file name
|
||||
Symbol* source_file_name() const {
|
||||
return (_source_file_name_index == 0) ?
|
||||
(Symbol*)NULL : symbol_at(_source_file_name_index);
|
||||
}
|
||||
u2 source_file_name_index() const { return _source_file_name_index; }
|
||||
void set_source_file_name_index(u2 sourcefile_index) { _source_file_name_index = sourcefile_index; }
|
||||
|
||||
void copy_fields(const ConstantPool* orig);
|
||||
|
||||
// Redefine classes support. If a method refering to this constant pool
|
||||
// is on the executing stack, or as a handle in vm code, this constant pool
|
||||
// can't be removed from the set of previous versions saved in the instance
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
static const KlassID ID = InstanceClassLoaderKlassID;
|
||||
|
||||
private:
|
||||
InstanceClassLoaderKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_class_loader, ID) {}
|
||||
InstanceClassLoaderKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_kind_class_loader, ID) {}
|
||||
|
||||
public:
|
||||
InstanceClassLoaderKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
|
||||
|
@ -442,7 +442,7 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par
|
||||
ik = new (loader_data, size, THREAD) InstanceClassLoaderKlass(parser);
|
||||
} else {
|
||||
// normal
|
||||
ik = new (loader_data, size, THREAD) InstanceKlass(parser, InstanceKlass::_misc_kind_other);
|
||||
ik = new (loader_data, size, THREAD) InstanceKlass(parser, InstanceKlass::_kind_other);
|
||||
}
|
||||
} else {
|
||||
// reference
|
||||
@ -483,15 +483,15 @@ Array<int>* InstanceKlass::create_new_default_vtable_indices(int len, TRAPS) {
|
||||
InstanceKlass::InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id) :
|
||||
Klass(id),
|
||||
_nest_members(NULL),
|
||||
_nest_host_index(0),
|
||||
_nest_host(NULL),
|
||||
_record_components(NULL),
|
||||
_static_field_size(parser.static_field_size()),
|
||||
_nonstatic_oop_map_size(nonstatic_oop_map_size(parser.total_oop_map_count())),
|
||||
_itable_len(parser.itable_size()),
|
||||
_init_thread(NULL),
|
||||
_nest_host_index(0),
|
||||
_init_state(allocated),
|
||||
_reference_type(parser.reference_type())
|
||||
_reference_type(parser.reference_type()),
|
||||
_init_thread(NULL)
|
||||
{
|
||||
set_vtable_length(parser.vtable_size());
|
||||
set_kind(kind);
|
||||
|
@ -191,10 +191,6 @@ class InstanceKlass: public Klass {
|
||||
// has not been validated.
|
||||
Array<jushort>* _nest_members;
|
||||
|
||||
// The NestHost attribute. The class info index for the class
|
||||
// that is the nest-host of this class. This data has not been validated.
|
||||
jushort _nest_host_index;
|
||||
|
||||
// Resolved nest-host klass: either true nest-host or self if we are not
|
||||
// nested, or an error occurred resolving or validating the nominated
|
||||
// nest-host. Can also be set directly by JDK API's that establish nest
|
||||
@ -217,60 +213,63 @@ 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
|
||||
// Constant pool index to the utf8 entry of the Generic signature,
|
||||
// or 0 if none.
|
||||
u2 _generic_signature_index;
|
||||
// Constant pool index to the utf8 entry for the name of source file
|
||||
// containing this klass, 0 if not specified.
|
||||
u2 _source_file_name_index;
|
||||
|
||||
int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
|
||||
int _itable_len; // length of Java itable (in words)
|
||||
|
||||
// The NestHost attribute. The class info index for the class
|
||||
// that is the nest-host of this class. This data has not been validated.
|
||||
u2 _nest_host_index;
|
||||
u2 _this_class_index; // constant pool entry
|
||||
|
||||
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 _itable_len; // length of Java itable (in words)
|
||||
volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
|
||||
|
||||
// _is_marked_dependent can be set concurrently, thus cannot be part of the
|
||||
// _misc_flags.
|
||||
bool _is_marked_dependent; // used for marking during flushing and deoptimization
|
||||
|
||||
// The low two bits of _misc_flags contains the kind field.
|
||||
// Class states are defined as ClassState (see above).
|
||||
// Place the _init_state here to utilize the unused 2-byte after
|
||||
// _idnum_allocated_count.
|
||||
u1 _init_state; // state of class
|
||||
|
||||
// This can be used to quickly discriminate among the four kinds of
|
||||
// InstanceKlass.
|
||||
// InstanceKlass. This should be an enum (?)
|
||||
static const unsigned _kind_other = 0; // concrete InstanceKlass
|
||||
static const unsigned _kind_reference = 1; // InstanceRefKlass
|
||||
static const unsigned _kind_class_loader = 2; // InstanceClassLoaderKlass
|
||||
static const unsigned _kind_mirror = 3; // InstanceMirrorKlass
|
||||
|
||||
static const unsigned _misc_kind_field_size = 2;
|
||||
static const unsigned _misc_kind_field_pos = 0;
|
||||
static const unsigned _misc_kind_field_mask = (1u << _misc_kind_field_size) - 1u;
|
||||
u1 _reference_type; // reference type
|
||||
u1 _kind; // kind of InstanceKlass
|
||||
|
||||
static const unsigned _misc_kind_other = 0; // concrete InstanceKlass
|
||||
static const unsigned _misc_kind_reference = 1; // InstanceRefKlass
|
||||
static const unsigned _misc_kind_class_loader = 2; // InstanceClassLoaderKlass
|
||||
static const unsigned _misc_kind_mirror = 3; // InstanceMirrorKlass
|
||||
|
||||
// Start after _misc_kind field.
|
||||
enum {
|
||||
_misc_rewritten = 1 << 2, // methods rewritten.
|
||||
_misc_has_nonstatic_fields = 1 << 3, // for sizing with UseCompressedOops
|
||||
_misc_should_verify_class = 1 << 4, // allow caching of preverification
|
||||
_misc_is_unsafe_anonymous = 1 << 5, // has embedded _unsafe_anonymous_host field
|
||||
_misc_is_contended = 1 << 6, // marked with contended annotation
|
||||
_misc_has_nonstatic_concrete_methods = 1 << 7, // class/superclass/implemented interfaces has non-static, concrete methods
|
||||
_misc_declares_nonstatic_concrete_methods = 1 << 8, // directly declares non-static, concrete methods
|
||||
_misc_has_been_redefined = 1 << 9, // class has been redefined
|
||||
_misc_has_passed_fingerprint_check = 1 << 10, // when this class was loaded, the fingerprint computed from its
|
||||
_misc_rewritten = 1 << 0, // methods rewritten.
|
||||
_misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
|
||||
_misc_should_verify_class = 1 << 2, // allow caching of preverification
|
||||
_misc_is_unsafe_anonymous = 1 << 3, // has embedded _unsafe_anonymous_host field
|
||||
_misc_is_contended = 1 << 4, // marked with contended annotation
|
||||
_misc_has_nonstatic_concrete_methods = 1 << 5, // class/superclass/implemented interfaces has non-static, concrete methods
|
||||
_misc_declares_nonstatic_concrete_methods = 1 << 6, // directly declares non-static, concrete methods
|
||||
_misc_has_been_redefined = 1 << 7, // class has been redefined
|
||||
_misc_has_passed_fingerprint_check = 1 << 8, // when this class was loaded, the fingerprint computed from its
|
||||
// code source was found to be matching the value recorded by AOT.
|
||||
_misc_is_scratch_class = 1 << 11, // class is the redefined scratch class
|
||||
_misc_is_shared_boot_class = 1 << 12, // defining class loader is boot class loader
|
||||
_misc_is_shared_platform_class = 1 << 13, // defining class loader is platform class loader
|
||||
_misc_is_shared_app_class = 1 << 14, // defining class loader is app class loader
|
||||
_misc_has_resolved_methods = 1 << 15, // resolved methods table entries added for this class
|
||||
_misc_is_being_redefined = 1 << 16, // used for locking redefinition
|
||||
_misc_has_contended_annotations = 1 << 17 // has @Contended annotation
|
||||
_misc_is_scratch_class = 1 << 9, // class is the redefined scratch class
|
||||
_misc_is_shared_boot_class = 1 << 10, // defining class loader is boot class loader
|
||||
_misc_is_shared_platform_class = 1 << 11, // defining class loader is platform class loader
|
||||
_misc_is_shared_app_class = 1 << 12, // defining class loader is app class loader
|
||||
_misc_has_resolved_methods = 1 << 13, // resolved methods table entries added for this class
|
||||
_misc_is_being_redefined = 1 << 14, // used for locking redefinition
|
||||
_misc_has_contended_annotations = 1 << 15 // has @Contended annotation
|
||||
};
|
||||
u2 shared_loader_type_bits() const {
|
||||
return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
|
||||
}
|
||||
u4 _misc_flags;
|
||||
u2 _minor_version; // minor version number of class file
|
||||
u2 _major_version; // major version number of class file
|
||||
u2 _misc_flags; // There is more space in access_flags for more flags.
|
||||
|
||||
Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization)
|
||||
OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
|
||||
JNIid* _jni_ids; // First JNI identifier for static fields in this class
|
||||
@ -287,15 +286,6 @@ class InstanceKlass: public Klass {
|
||||
JvmtiCachedClassFileData* _cached_class_file;
|
||||
#endif
|
||||
|
||||
volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
|
||||
|
||||
// Class states are defined as ClassState (see above).
|
||||
// Place the _init_state here to utilize the unused 2-byte after
|
||||
// _idnum_allocated_count.
|
||||
u1 _init_state; // state of class
|
||||
u1 _reference_type; // reference type
|
||||
|
||||
u2 _this_class_index; // constant pool entry
|
||||
#if INCLUDE_JVMTI
|
||||
JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
|
||||
#endif
|
||||
@ -730,22 +720,15 @@ public:
|
||||
}
|
||||
|
||||
// source file name
|
||||
Symbol* source_file_name() const {
|
||||
return (_source_file_name_index == 0) ?
|
||||
(Symbol*)NULL : _constants->symbol_at(_source_file_name_index);
|
||||
}
|
||||
u2 source_file_name_index() const {
|
||||
return _source_file_name_index;
|
||||
}
|
||||
void set_source_file_name_index(u2 sourcefile_index) {
|
||||
_source_file_name_index = sourcefile_index;
|
||||
}
|
||||
Symbol* source_file_name() const { return _constants->source_file_name(); }
|
||||
u2 source_file_name_index() const { return _constants->source_file_name_index(); }
|
||||
void set_source_file_name_index(u2 sourcefile_index) { _constants->set_source_file_name_index(sourcefile_index); }
|
||||
|
||||
// minor and major version numbers of class file
|
||||
u2 minor_version() const { return _minor_version; }
|
||||
void set_minor_version(u2 minor_version) { _minor_version = minor_version; }
|
||||
u2 major_version() const { return _major_version; }
|
||||
void set_major_version(u2 major_version) { _major_version = major_version; }
|
||||
u2 minor_version() const { return _constants->minor_version(); }
|
||||
void set_minor_version(u2 minor_version) { _constants->set_minor_version(minor_version); }
|
||||
u2 major_version() const { return _constants->major_version(); }
|
||||
void set_major_version(u2 major_version) { _constants->set_major_version(major_version); }
|
||||
|
||||
// source debug extension
|
||||
const char* source_debug_extension() const { return _source_debug_extension; }
|
||||
@ -852,24 +835,20 @@ public:
|
||||
private:
|
||||
|
||||
void set_kind(unsigned kind) {
|
||||
assert(kind <= _misc_kind_field_mask, "Invalid InstanceKlass kind");
|
||||
unsigned fmask = _misc_kind_field_mask << _misc_kind_field_pos;
|
||||
unsigned flags = _misc_flags & ~fmask;
|
||||
_misc_flags = (flags | (kind << _misc_kind_field_pos));
|
||||
_kind = (u1)kind;
|
||||
}
|
||||
|
||||
bool is_kind(unsigned desired) const {
|
||||
unsigned kind = (_misc_flags >> _misc_kind_field_pos) & _misc_kind_field_mask;
|
||||
return kind == desired;
|
||||
return _kind == (u1)desired;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// Other is anything that is not one of the more specialized kinds of InstanceKlass.
|
||||
bool is_other_instance_klass() const { return is_kind(_misc_kind_other); }
|
||||
bool is_reference_instance_klass() const { return is_kind(_misc_kind_reference); }
|
||||
bool is_mirror_instance_klass() const { return is_kind(_misc_kind_mirror); }
|
||||
bool is_class_loader_instance_klass() const { return is_kind(_misc_kind_class_loader); }
|
||||
bool is_other_instance_klass() const { return is_kind(_kind_other); }
|
||||
bool is_reference_instance_klass() const { return is_kind(_kind_reference); }
|
||||
bool is_mirror_instance_klass() const { return is_kind(_kind_mirror); }
|
||||
bool is_class_loader_instance_klass() const { return is_kind(_kind_class_loader); }
|
||||
|
||||
#if INCLUDE_JVMTI
|
||||
|
||||
@ -943,16 +922,9 @@ public:
|
||||
void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; }
|
||||
|
||||
// generics support
|
||||
Symbol* generic_signature() const {
|
||||
return (_generic_signature_index == 0) ?
|
||||
(Symbol*)NULL : _constants->symbol_at(_generic_signature_index);
|
||||
}
|
||||
u2 generic_signature_index() const {
|
||||
return _generic_signature_index;
|
||||
}
|
||||
void set_generic_signature_index(u2 sig_index) {
|
||||
_generic_signature_index = sig_index;
|
||||
}
|
||||
Symbol* generic_signature() const { return _constants->generic_signature(); }
|
||||
u2 generic_signature_index() const { return _constants->generic_signature_index(); }
|
||||
void set_generic_signature_index(u2 sig_index) { _constants->set_generic_signature_index(sig_index); }
|
||||
|
||||
u2 enclosing_method_data(int offset) const;
|
||||
u2 enclosing_method_class_index() const {
|
||||
|
@ -50,7 +50,7 @@ class InstanceMirrorKlass: public InstanceKlass {
|
||||
private:
|
||||
static int _offset_of_static_fields;
|
||||
|
||||
InstanceMirrorKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_mirror, ID) {}
|
||||
InstanceMirrorKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_kind_mirror, ID) {}
|
||||
|
||||
public:
|
||||
InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
|
||||
|
@ -53,7 +53,7 @@ class InstanceRefKlass: public InstanceKlass {
|
||||
static const KlassID ID = InstanceRefKlassID;
|
||||
|
||||
private:
|
||||
InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_reference, ID) {}
|
||||
InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_kind_reference, ID) {}
|
||||
|
||||
public:
|
||||
InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
|
||||
|
@ -117,6 +117,9 @@ class Klass : public Metadata {
|
||||
// Klass identifier used to implement devirtualized oop closure dispatching.
|
||||
const KlassID _id;
|
||||
|
||||
// vtable length
|
||||
int _vtable_len;
|
||||
|
||||
// The fields _super_check_offset, _secondary_super_cache, _secondary_supers
|
||||
// and _primary_supers all help make fast subtype checks. See big discussion
|
||||
// in doc/server_compiler/checktype.txt
|
||||
@ -136,7 +139,7 @@ class Klass : public Metadata {
|
||||
// Ordered list of all primary supertypes
|
||||
Klass* _primary_supers[_primary_super_limit];
|
||||
// java/lang/Class instance mirroring this class
|
||||
OopHandle _java_mirror;
|
||||
OopHandle _java_mirror;
|
||||
// Superclass
|
||||
Klass* _super;
|
||||
// First subclass (NULL if none); _subklass->next_sibling() is next one
|
||||
@ -162,9 +165,6 @@ class Klass : public Metadata {
|
||||
markWord _prototype_header; // Used when biased locking is both enabled and disabled for this type
|
||||
jint _biased_lock_revocation_count;
|
||||
|
||||
// vtable length
|
||||
int _vtable_len;
|
||||
|
||||
private:
|
||||
// This is an index into FileMapHeader::_shared_path_table[], to
|
||||
// associate this class with the JAR file where it's loaded from during
|
||||
@ -179,6 +179,7 @@ private:
|
||||
_has_raw_archived_mirror = 1
|
||||
};
|
||||
#endif
|
||||
|
||||
// The _archived_mirror is set at CDS dump time pointing to the cached mirror
|
||||
// in the open archive heap region when archiving java object is supported.
|
||||
CDS_JAVA_HEAP_ONLY(narrowOop _archived_mirror;)
|
||||
|
@ -1432,6 +1432,7 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
|
||||
ConstantPool* cp_oop = ConstantPool::allocate(loader_data, cp_length, CHECK_(empty));
|
||||
cp = constantPoolHandle(THREAD, cp_oop);
|
||||
}
|
||||
cp->copy_fields(holder->constants());
|
||||
cp->set_pool_holder(holder);
|
||||
cp->symbol_at_put(_imcp_invoke_name, name);
|
||||
cp->symbol_at_put(_imcp_invoke_signature, signature);
|
||||
|
@ -1699,10 +1699,9 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite(
|
||||
return JVMTI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
if (old_cp->has_dynamic_constant()) {
|
||||
merge_cp->set_has_dynamic_constant();
|
||||
scratch_cp->set_has_dynamic_constant();
|
||||
}
|
||||
// Save fields from the old_cp.
|
||||
merge_cp->copy_fields(old_cp());
|
||||
scratch_cp->copy_fields(old_cp());
|
||||
|
||||
log_info(redefine, class, constantpool)("merge_cp_len=%d, index_map_len=%d", merge_cp_length, _index_map_count);
|
||||
|
||||
@ -3373,9 +3372,7 @@ void VM_RedefineClasses::set_new_constant_pool(
|
||||
// reference to the cp holder is needed for copy_operands()
|
||||
smaller_cp->set_pool_holder(scratch_class);
|
||||
|
||||
if (scratch_cp->has_dynamic_constant()) {
|
||||
smaller_cp->set_has_dynamic_constant();
|
||||
}
|
||||
smaller_cp->copy_fields(scratch_cp());
|
||||
|
||||
scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD);
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
@ -4254,16 +4251,6 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
|
||||
|
||||
swap_annotations(the_class, scratch_class);
|
||||
|
||||
// Replace minor version number of class file
|
||||
u2 old_minor_version = the_class->minor_version();
|
||||
the_class->set_minor_version(scratch_class->minor_version());
|
||||
scratch_class->set_minor_version(old_minor_version);
|
||||
|
||||
// Replace major version number of class file
|
||||
u2 old_major_version = the_class->major_version();
|
||||
the_class->set_major_version(scratch_class->major_version());
|
||||
scratch_class->set_major_version(old_major_version);
|
||||
|
||||
// Replace CP indexes for class and name+type of enclosing method
|
||||
u2 old_class_idx = the_class->enclosing_method_class_index();
|
||||
u2 old_method_idx = the_class->enclosing_method_method_index();
|
||||
|
@ -210,6 +210,10 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
nonstatic_field(ConstantPool, _operands, Array<u2>*) \
|
||||
nonstatic_field(ConstantPool, _resolved_klasses, Array<Klass*>*) \
|
||||
nonstatic_field(ConstantPool, _length, int) \
|
||||
nonstatic_field(ConstantPool, _minor_version, u2) \
|
||||
nonstatic_field(ConstantPool, _major_version, u2) \
|
||||
nonstatic_field(ConstantPool, _generic_signature_index, u2) \
|
||||
nonstatic_field(ConstantPool, _source_file_name_index, u2) \
|
||||
nonstatic_field(ConstantPoolCache, _resolved_references, OopHandle) \
|
||||
nonstatic_field(ConstantPoolCache, _reference_map, Array<u2>*) \
|
||||
nonstatic_field(ConstantPoolCache, _length, int) \
|
||||
@ -222,7 +226,6 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
nonstatic_field(InstanceKlass, _fields, Array<u2>*) \
|
||||
nonstatic_field(InstanceKlass, _java_fields_count, u2) \
|
||||
nonstatic_field(InstanceKlass, _constants, ConstantPool*) \
|
||||
nonstatic_field(InstanceKlass, _source_file_name_index, u2) \
|
||||
nonstatic_field(InstanceKlass, _source_debug_extension, const char*) \
|
||||
nonstatic_field(InstanceKlass, _inner_classes, Array<jushort>*) \
|
||||
nonstatic_field(InstanceKlass, _nonstatic_field_size, int) \
|
||||
@ -230,9 +233,7 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
nonstatic_field(InstanceKlass, _static_oop_field_count, u2) \
|
||||
nonstatic_field(InstanceKlass, _nonstatic_oop_map_size, int) \
|
||||
nonstatic_field(InstanceKlass, _is_marked_dependent, bool) \
|
||||
nonstatic_field(InstanceKlass, _misc_flags, u4) \
|
||||
nonstatic_field(InstanceKlass, _minor_version, u2) \
|
||||
nonstatic_field(InstanceKlass, _major_version, u2) \
|
||||
nonstatic_field(InstanceKlass, _misc_flags, u2) \
|
||||
nonstatic_field(InstanceKlass, _init_state, u1) \
|
||||
nonstatic_field(InstanceKlass, _init_thread, Thread*) \
|
||||
nonstatic_field(InstanceKlass, _itable_len, int) \
|
||||
@ -241,7 +242,6 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
nonstatic_field(InstanceKlass, _jni_ids, JNIid*) \
|
||||
nonstatic_field(InstanceKlass, _osr_nmethods_head, nmethod*) \
|
||||
JVMTI_ONLY(nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*)) \
|
||||
nonstatic_field(InstanceKlass, _generic_signature_index, u2) \
|
||||
volatile_nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \
|
||||
volatile_nonstatic_field(InstanceKlass, _idnum_allocated_count, u2) \
|
||||
nonstatic_field(InstanceKlass, _annotations, Annotations*) \
|
||||
|
@ -92,6 +92,10 @@ public class ConstantPool extends Metadata implements ClassConstants {
|
||||
poolHolder = new MetadataField(type.getAddressField("_pool_holder"), 0);
|
||||
length = new CIntField(type.getCIntegerField("_length"), 0);
|
||||
resolved_klasses = type.getAddressField("_resolved_klasses");
|
||||
majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0);
|
||||
minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0);
|
||||
sourceFileNameIndex = new CIntField(type.getCIntegerField("_source_file_name_index"), 0);
|
||||
genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0);
|
||||
headerSize = type.getSize();
|
||||
elementSize = 0;
|
||||
// fetch constants:
|
||||
@ -112,6 +116,10 @@ public class ConstantPool extends Metadata implements ClassConstants {
|
||||
private static AddressField resolved_klasses;
|
||||
private static MetadataField poolHolder;
|
||||
private static CIntField length; // number of elements in oop
|
||||
private static CIntField majorVersion;
|
||||
private static CIntField minorVersion;
|
||||
private static CIntField genericSignatureIndex;
|
||||
private static CIntField sourceFileNameIndex;
|
||||
|
||||
private static long headerSize;
|
||||
private static long elementSize;
|
||||
@ -131,6 +139,20 @@ public class ConstantPool extends Metadata implements ClassConstants {
|
||||
public Oop getResolvedReferences() {
|
||||
return getCache().getResolvedReferences();
|
||||
}
|
||||
public long majorVersion() { return majorVersion.getValue(this); }
|
||||
public long minorVersion() { return minorVersion.getValue(this); }
|
||||
|
||||
public Symbol getGenericSignature() {
|
||||
long index = genericSignatureIndex.getValue(this);
|
||||
if (index != 0) {
|
||||
return getSymbolAt(index);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Symbol getSourceFileName() { return getSymbolAt(sourceFileNameIndex.getValue(this)); }
|
||||
|
||||
public KlassArray getResolvedKlasses() {
|
||||
return new KlassArray(resolved_klasses.getValue(getAddress()));
|
||||
}
|
||||
|
@ -95,7 +95,6 @@ public class InstanceKlass extends Klass {
|
||||
constants = new MetadataField(type.getAddressField("_constants"), 0);
|
||||
sourceDebugExtension = type.getAddressField("_source_debug_extension");
|
||||
innerClasses = type.getAddressField("_inner_classes");
|
||||
sourceFileNameIndex = new CIntField(type.getCIntegerField("_source_file_name_index"), 0);
|
||||
nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0);
|
||||
staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0);
|
||||
staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0);
|
||||
@ -106,10 +105,7 @@ public class InstanceKlass extends Klass {
|
||||
if (VM.getVM().isJvmtiSupported()) {
|
||||
breakpoints = type.getAddressField("_breakpoints");
|
||||
}
|
||||
genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0);
|
||||
miscFlags = new CIntField(type.getCIntegerField("_misc_flags"), 0);
|
||||
majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0);
|
||||
minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0);
|
||||
headerSize = type.getSize();
|
||||
|
||||
// read field offset constants
|
||||
@ -169,7 +165,6 @@ public class InstanceKlass extends Klass {
|
||||
private static MetadataField constants;
|
||||
private static AddressField sourceDebugExtension;
|
||||
private static AddressField innerClasses;
|
||||
private static CIntField sourceFileNameIndex;
|
||||
private static CIntField nonstaticFieldSize;
|
||||
private static CIntField staticFieldSize;
|
||||
private static CIntField staticOopFieldCount;
|
||||
@ -178,10 +173,7 @@ public class InstanceKlass extends Klass {
|
||||
private static CIntField initState;
|
||||
private static CIntField itableLen;
|
||||
private static AddressField breakpoints;
|
||||
private static CIntField genericSignatureIndex;
|
||||
private static CIntField miscFlags;
|
||||
private static CIntField majorVersion;
|
||||
private static CIntField minorVersion;
|
||||
|
||||
// type safe enum for ClassState from instanceKlass.hpp
|
||||
public static class ClassState {
|
||||
@ -427,23 +419,16 @@ public class InstanceKlass extends Klass {
|
||||
return allFieldsCount;
|
||||
}
|
||||
public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); }
|
||||
public Symbol getSourceFileName() { return getConstants().getSymbolAt(sourceFileNameIndex.getValue(this)); }
|
||||
public Symbol getSourceFileName() { return getConstants().getSourceFileName(); }
|
||||
public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); }
|
||||
public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); }
|
||||
public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); }
|
||||
public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); }
|
||||
public boolean getIsMarkedDependent() { return isMarkedDependent.getValue(this) != 0; }
|
||||
public long getItableLen() { return itableLen.getValue(this); }
|
||||
public long majorVersion() { return majorVersion.getValue(this); }
|
||||
public long minorVersion() { return minorVersion.getValue(this); }
|
||||
public Symbol getGenericSignature() {
|
||||
long index = genericSignatureIndex.getValue(this);
|
||||
if (index != 0) {
|
||||
return getConstants().getSymbolAt(index);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public long majorVersion() { return getConstants().majorVersion(); }
|
||||
public long minorVersion() { return getConstants().minorVersion(); }
|
||||
public Symbol getGenericSignature() { return getConstants().getGenericSignature(); }
|
||||
|
||||
// "size helper" == instance size in words
|
||||
public long getSizeHelper() {
|
||||
|
@ -799,6 +799,14 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getSourceFileName() {
|
||||
final int sourceFileNameIndex = UNSAFE.getChar(getMetaspaceConstantPool() + config().constantPoolSourceFileNameIndexOffset);
|
||||
if (sourceFileNameIndex == 0) {
|
||||
return null;
|
||||
}
|
||||
return lookupUtf8(sourceFileNameIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
HotSpotResolvedObjectType holder = getHolder();
|
||||
|
@ -817,12 +817,10 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
|
||||
|
||||
@Override
|
||||
public String getSourceFileName() {
|
||||
HotSpotVMConfig config = config();
|
||||
final int sourceFileNameIndex = UNSAFE.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset);
|
||||
if (sourceFileNameIndex == 0) {
|
||||
return null;
|
||||
if (isArray()) {
|
||||
throw new JVMCIError("Cannot call getSourceFileName() on an array klass type: %s", this);
|
||||
}
|
||||
return getConstantPool().lookupUtf8(sourceFileNameIndex);
|
||||
return getConstantPool().getSourceFileName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,12 +96,11 @@ class HotSpotVMConfig extends HotSpotVMConfigAccess {
|
||||
final int vtableEntrySize = getFieldValue("CompilerToVM::Data::sizeof_vtableEntry", Integer.class, "int");
|
||||
final int vtableEntryMethodOffset = getFieldOffset("vtableEntry::_method", Integer.class, "Method*");
|
||||
|
||||
final int instanceKlassSourceFileNameIndexOffset = getFieldOffset("InstanceKlass::_source_file_name_index", Integer.class, "u2");
|
||||
final int instanceKlassInitStateOffset = getFieldOffset("InstanceKlass::_init_state", Integer.class, "u1");
|
||||
final int instanceKlassConstantsOffset = getFieldOffset("InstanceKlass::_constants", Integer.class, "ConstantPool*");
|
||||
final int instanceKlassFieldsOffset = getFieldOffset("InstanceKlass::_fields", Integer.class, "Array<u2>*");
|
||||
final int instanceKlassAnnotationsOffset = getFieldOffset("InstanceKlass::_annotations", Integer.class, "Annotations*");
|
||||
final int instanceKlassMiscFlagsOffset = getFieldOffset("InstanceKlass::_misc_flags", Integer.class, "u4");
|
||||
final int instanceKlassMiscFlagsOffset = getFieldOffset("InstanceKlass::_misc_flags", Integer.class, "u2");
|
||||
final int klassVtableStartOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_start_offset", Integer.class, "int");
|
||||
final int klassVtableLengthOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_length_offset", Integer.class, "int");
|
||||
|
||||
@ -228,10 +227,11 @@ class HotSpotVMConfig extends HotSpotVMConfigAccess {
|
||||
final int constantPoolTagsOffset = getFieldOffset("ConstantPool::_tags", Integer.class, "Array<u1>*");
|
||||
final int constantPoolHolderOffset = getFieldOffset("ConstantPool::_pool_holder", Integer.class, "InstanceKlass*");
|
||||
final int constantPoolLengthOffset = getFieldOffset("ConstantPool::_length", Integer.class, "int");
|
||||
final int constantPoolFlagsOffset = getFieldOffset("ConstantPool::_flags", Integer.class, "int");
|
||||
final int constantPoolFlagsOffset = getFieldOffset("ConstantPool::_flags", Integer.class, "u2");
|
||||
|
||||
final int constantPoolCpCacheIndexTag = getConstant("ConstantPool::CPCACHE_INDEX_TAG", Integer.class);
|
||||
final int constantPoolHasDynamicConstant = getConstant("ConstantPool::_has_dynamic_constant", Integer.class);
|
||||
final int constantPoolSourceFileNameIndexOffset = getFieldOffset("ConstantPool::_source_file_name_index", Integer.class, "u2");
|
||||
|
||||
final int jvmConstantUtf8 = getConstant("JVM_CONSTANT_Utf8", Integer.class);
|
||||
final int jvmConstantInteger = getConstant("JVM_CONSTANT_Integer", Integer.class);
|
||||
|
@ -918,6 +918,13 @@ public class TestResolvedJavaType extends TypeUniverse {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSourceFileNameTest() {
|
||||
Class<?> c = Object.class;
|
||||
ResolvedJavaType type = metaAccess.lookupJavaType(c);
|
||||
assertEquals(type.getSourceFileName(), "Object.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void memberClassesTest() {
|
||||
for (Class<?> c : classes) {
|
||||
@ -1020,7 +1027,6 @@ public class TestResolvedJavaType extends TypeUniverse {
|
||||
"getObjectHub",
|
||||
"hasFinalizableSubclass",
|
||||
"hasFinalizer",
|
||||
"getSourceFileName",
|
||||
"isLocal",
|
||||
"isJavaLangObject",
|
||||
"isMember",
|
||||
|
@ -66,7 +66,7 @@ public class TestIntConstant {
|
||||
"CollectedHeap::G1 3",
|
||||
"RUNNABLE 2",
|
||||
"Deoptimization::Reason_class_check 4",
|
||||
"InstanceKlass::_misc_is_unsafe_anonymous 32",
|
||||
"InstanceKlass::_misc_is_unsafe_anonymous 8",
|
||||
"_thread_uninitialized 0"));
|
||||
expStrMap.put("intConstant _temp_constant", List.of(
|
||||
"intConstant _temp_constant 45"));
|
||||
|
Loading…
Reference in New Issue
Block a user