提交 bb3ed7d3 编写于 作者: J jiangli

8021948: Change InstanceKlass::_source_file_name and _generic_signature from...

8021948: Change InstanceKlass::_source_file_name and _generic_signature from Symbol* to constant pool indexes.
Summary: Change InstanceKlass::_source_file_name and _generic_signature to u2 fields.
Reviewed-by: coleenp, iklam
上级 26c9d760
...@@ -75,19 +75,19 @@ public class InstanceKlass extends Klass { ...@@ -75,19 +75,19 @@ public class InstanceKlass extends Klass {
javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0); javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0);
constants = new MetadataField(type.getAddressField("_constants"), 0); constants = new MetadataField(type.getAddressField("_constants"), 0);
classLoaderData = type.getAddressField("_class_loader_data"); classLoaderData = type.getAddressField("_class_loader_data");
sourceFileName = type.getAddressField("_source_file_name");
sourceDebugExtension = type.getAddressField("_source_debug_extension"); sourceDebugExtension = type.getAddressField("_source_debug_extension");
innerClasses = type.getAddressField("_inner_classes"); innerClasses = type.getAddressField("_inner_classes");
sourceFileNameIndex = new CIntField(type.getCIntegerField("_source_file_name_index"), 0);
nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0); nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0);
staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0); staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0);
staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0); staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0);
nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0); nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0);
isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0); isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0);
initState = new CIntField(type.getCIntegerField("_init_state"), 0); initState = new CIntField(type.getCIntegerField("_init_state"), 0);
vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0); vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0);
itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0); itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0);
breakpoints = type.getAddressField("_breakpoints"); breakpoints = type.getAddressField("_breakpoints");
genericSignature = type.getAddressField("_generic_signature"); genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0);
majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0); majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0);
minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0); minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0);
headerSize = Oop.alignObjectOffset(type.getSize()); headerSize = Oop.alignObjectOffset(type.getSize());
...@@ -134,9 +134,9 @@ public class InstanceKlass extends Klass { ...@@ -134,9 +134,9 @@ public class InstanceKlass extends Klass {
private static CIntField javaFieldsCount; private static CIntField javaFieldsCount;
private static MetadataField constants; private static MetadataField constants;
private static AddressField classLoaderData; private static AddressField classLoaderData;
private static AddressField sourceFileName;
private static AddressField sourceDebugExtension; private static AddressField sourceDebugExtension;
private static AddressField innerClasses; private static AddressField innerClasses;
private static CIntField sourceFileNameIndex;
private static CIntField nonstaticFieldSize; private static CIntField nonstaticFieldSize;
private static CIntField staticFieldSize; private static CIntField staticFieldSize;
private static CIntField staticOopFieldCount; private static CIntField staticOopFieldCount;
...@@ -146,7 +146,7 @@ public class InstanceKlass extends Klass { ...@@ -146,7 +146,7 @@ public class InstanceKlass extends Klass {
private static CIntField vtableLen; private static CIntField vtableLen;
private static CIntField itableLen; private static CIntField itableLen;
private static AddressField breakpoints; private static AddressField breakpoints;
private static AddressField genericSignature; private static CIntField genericSignatureIndex;
private static CIntField majorVersion; private static CIntField majorVersion;
private static CIntField minorVersion; private static CIntField minorVersion;
...@@ -346,7 +346,7 @@ public class InstanceKlass extends Klass { ...@@ -346,7 +346,7 @@ public class InstanceKlass extends Klass {
public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); }
public ClassLoaderData getClassLoaderData() { return ClassLoaderData.instantiateWrapperFor(classLoaderData.getValue(getAddress())); } public ClassLoaderData getClassLoaderData() { return ClassLoaderData.instantiateWrapperFor(classLoaderData.getValue(getAddress())); }
public Oop getClassLoader() { return getClassLoaderData().getClassLoader(); } public Oop getClassLoader() { return getClassLoaderData().getClassLoader(); }
public Symbol getSourceFileName() { return getSymbol(sourceFileName); } public Symbol getSourceFileName() { return getConstants().getSymbolAt(sourceFileNameIndex.getValue(this)); }
public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); } public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); }
public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); } public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); }
public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); } public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); }
...@@ -354,7 +354,7 @@ public class InstanceKlass extends Klass { ...@@ -354,7 +354,7 @@ public class InstanceKlass extends Klass {
public boolean getIsMarkedDependent() { return isMarkedDependent.getValue(this) != 0; } public boolean getIsMarkedDependent() { return isMarkedDependent.getValue(this) != 0; }
public long getVtableLen() { return vtableLen.getValue(this); } public long getVtableLen() { return vtableLen.getValue(this); }
public long getItableLen() { return itableLen.getValue(this); } public long getItableLen() { return itableLen.getValue(this); }
public Symbol getGenericSignature() { return getSymbol(genericSignature); } public Symbol getGenericSignature() { return getConstants().getSymbolAt(genericSignatureIndex.getValue(this)); }
public long majorVersion() { return majorVersion.getValue(this); } public long majorVersion() { return majorVersion.getValue(this); }
public long minorVersion() { return minorVersion.getValue(this); } public long minorVersion() { return minorVersion.getValue(this); }
......
...@@ -2590,7 +2590,7 @@ void ClassFileParser::parse_classfile_sourcefile_attribute(TRAPS) { ...@@ -2590,7 +2590,7 @@ void ClassFileParser::parse_classfile_sourcefile_attribute(TRAPS) {
valid_symbol_at(sourcefile_index), valid_symbol_at(sourcefile_index),
"Invalid SourceFile attribute at constant pool index %u in class file %s", "Invalid SourceFile attribute at constant pool index %u in class file %s",
sourcefile_index, CHECK); sourcefile_index, CHECK);
set_class_sourcefile(_cp->symbol_at(sourcefile_index)); set_class_sourcefile_index(sourcefile_index);
} }
...@@ -2728,7 +2728,7 @@ void ClassFileParser::parse_classfile_signature_attribute(TRAPS) { ...@@ -2728,7 +2728,7 @@ void ClassFileParser::parse_classfile_signature_attribute(TRAPS) {
valid_symbol_at(signature_index), valid_symbol_at(signature_index),
"Invalid constant pool index %u in Signature attribute in class file %s", "Invalid constant pool index %u in Signature attribute in class file %s",
signature_index, CHECK); signature_index, CHECK);
set_class_generic_signature(_cp->symbol_at(signature_index)); set_class_generic_signature_index(signature_index);
} }
void ClassFileParser::parse_classfile_bootstrap_methods_attribute(u4 attribute_byte_length, TRAPS) { void ClassFileParser::parse_classfile_bootstrap_methods_attribute(u4 attribute_byte_length, TRAPS) {
...@@ -2975,13 +2975,11 @@ void ClassFileParser::parse_classfile_attributes(ClassFileParser::ClassAnnotatio ...@@ -2975,13 +2975,11 @@ void ClassFileParser::parse_classfile_attributes(ClassFileParser::ClassAnnotatio
void ClassFileParser::apply_parsed_class_attributes(instanceKlassHandle k) { void ClassFileParser::apply_parsed_class_attributes(instanceKlassHandle k) {
if (_synthetic_flag) if (_synthetic_flag)
k->set_is_synthetic(); k->set_is_synthetic();
if (_sourcefile != NULL) { if (_sourcefile_index != 0) {
_sourcefile->increment_refcount(); k->set_source_file_name_index(_sourcefile_index);
k->set_source_file_name(_sourcefile);
} }
if (_generic_signature != NULL) { if (_generic_signature_index != 0) {
_generic_signature->increment_refcount(); k->set_generic_signature_index(_generic_signature_index);
k->set_generic_signature(_generic_signature);
} }
if (_sde_buffer != NULL) { if (_sde_buffer != NULL) {
k->set_source_debug_extension(_sde_buffer, _sde_length); k->set_source_debug_extension(_sde_buffer, _sde_length);
......
...@@ -62,8 +62,8 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { ...@@ -62,8 +62,8 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC {
bool _synthetic_flag; bool _synthetic_flag;
int _sde_length; int _sde_length;
char* _sde_buffer; char* _sde_buffer;
Symbol* _sourcefile; u2 _sourcefile_index;
Symbol* _generic_signature; u2 _generic_signature_index;
// Metadata created before the instance klass is created. Must be deallocated // Metadata created before the instance klass is created. Must be deallocated
// if not transferred to the InstanceKlass upon successful class loading // if not transferred to the InstanceKlass upon successful class loading
...@@ -81,16 +81,16 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { ...@@ -81,16 +81,16 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC {
Array<AnnotationArray*>* _fields_type_annotations; Array<AnnotationArray*>* _fields_type_annotations;
InstanceKlass* _klass; // InstanceKlass once created. InstanceKlass* _klass; // InstanceKlass once created.
void set_class_synthetic_flag(bool x) { _synthetic_flag = x; } void set_class_synthetic_flag(bool x) { _synthetic_flag = x; }
void set_class_sourcefile(Symbol* x) { _sourcefile = x; } void set_class_sourcefile_index(u2 x) { _sourcefile_index = x; }
void set_class_generic_signature(Symbol* x) { _generic_signature = x; } void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; } void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; }
void init_parsed_class_attributes(ClassLoaderData* loader_data) { void init_parsed_class_attributes(ClassLoaderData* loader_data) {
_loader_data = loader_data; _loader_data = loader_data;
_synthetic_flag = false; _synthetic_flag = false;
_sourcefile = NULL; _sourcefile_index = 0;
_generic_signature = NULL; _generic_signature_index = 0;
_sde_buffer = NULL; _sde_buffer = NULL;
_sde_length = 0; _sde_length = 0;
// initialize the other flags too: // initialize the other flags too:
......
...@@ -269,7 +269,7 @@ InstanceKlass::InstanceKlass(int vtable_len, ...@@ -269,7 +269,7 @@ InstanceKlass::InstanceKlass(int vtable_len,
set_fields(NULL, 0); set_fields(NULL, 0);
set_constants(NULL); set_constants(NULL);
set_class_loader_data(NULL); set_class_loader_data(NULL);
set_source_file_name(NULL); set_source_file_name_index(0);
set_source_debug_extension(NULL, 0); set_source_debug_extension(NULL, 0);
set_array_name(NULL); set_array_name(NULL);
set_inner_classes(NULL); set_inner_classes(NULL);
...@@ -284,7 +284,7 @@ InstanceKlass::InstanceKlass(int vtable_len, ...@@ -284,7 +284,7 @@ InstanceKlass::InstanceKlass(int vtable_len,
set_osr_nmethods_head(NULL); set_osr_nmethods_head(NULL);
set_breakpoints(NULL); set_breakpoints(NULL);
init_previous_versions(); init_previous_versions();
set_generic_signature(NULL); set_generic_signature_index(0);
release_set_methods_jmethod_ids(NULL); release_set_methods_jmethod_ids(NULL);
release_set_methods_cached_itable_indices(NULL); release_set_methods_cached_itable_indices(NULL);
set_annotations(NULL); set_annotations(NULL);
...@@ -2368,18 +2368,12 @@ void InstanceKlass::release_C_heap_structures() { ...@@ -2368,18 +2368,12 @@ void InstanceKlass::release_C_heap_structures() {
// unreference array name derived from this class name (arrays of an unloaded // unreference array name derived from this class name (arrays of an unloaded
// class can't be referenced anymore). // class can't be referenced anymore).
if (_array_name != NULL) _array_name->decrement_refcount(); if (_array_name != NULL) _array_name->decrement_refcount();
if (_source_file_name != NULL) _source_file_name->decrement_refcount();
if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension, mtClass); if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension, mtClass);
assert(_total_instanceKlass_count >= 1, "Sanity check"); assert(_total_instanceKlass_count >= 1, "Sanity check");
Atomic::dec(&_total_instanceKlass_count); Atomic::dec(&_total_instanceKlass_count);
} }
void InstanceKlass::set_source_file_name(Symbol* n) {
_source_file_name = n;
if (_source_file_name != NULL) _source_file_name->increment_refcount();
}
void InstanceKlass::set_source_debug_extension(char* array, int length) { void InstanceKlass::set_source_debug_extension(char* array, int length) {
if (array == NULL) { if (array == NULL) {
_source_debug_extension = NULL; _source_debug_extension = NULL;
......
...@@ -201,14 +201,10 @@ class InstanceKlass: public Klass { ...@@ -201,14 +201,10 @@ class InstanceKlass: public Klass {
// number_of_inner_classes * 4 + enclosing_method_attribute_size. // number_of_inner_classes * 4 + enclosing_method_attribute_size.
Array<jushort>* _inner_classes; Array<jushort>* _inner_classes;
// Name of source file containing this klass, NULL if not specified.
Symbol* _source_file_name;
// the source debug extension for this klass, NULL if not specified. // the source debug extension for this klass, NULL if not specified.
// Specified as UTF-8 string without terminating zero byte in the classfile, // Specified as UTF-8 string without terminating zero byte in the classfile,
// it is stored in the instanceklass as a NULL-terminated UTF-8 string // it is stored in the instanceklass as a NULL-terminated UTF-8 string
char* _source_debug_extension; char* _source_debug_extension;
// Generic signature, or null if none.
Symbol* _generic_signature;
// Array name derived from this class which needs unreferencing // Array name derived from this class which needs unreferencing
// if this class is unloaded. // if this class is unloaded.
Symbol* _array_name; Symbol* _array_name;
...@@ -217,6 +213,12 @@ class InstanceKlass: public Klass { ...@@ -217,6 +213,12 @@ class InstanceKlass: public Klass {
// (including inherited fields but after header_size()). // (including inherited fields but after header_size()).
int _nonstatic_field_size; int _nonstatic_field_size;
int _static_field_size; // number words used by static fields (oop and non-oop) in this klass 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;
u2 _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 u2 _java_fields_count; // The number of declared Java fields
int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
...@@ -570,8 +572,16 @@ class InstanceKlass: public Klass { ...@@ -570,8 +572,16 @@ class InstanceKlass: public Klass {
} }
// source file name // source file name
Symbol* source_file_name() const { return _source_file_name; } Symbol* source_file_name() const {
void set_source_file_name(Symbol* n); 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;
}
// minor and major version numbers of class file // minor and major version numbers of class file
u2 minor_version() const { return _minor_version; } u2 minor_version() const { return _minor_version; }
...@@ -648,8 +658,16 @@ class InstanceKlass: public Klass { ...@@ -648,8 +658,16 @@ class InstanceKlass: public Klass {
void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; } void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; }
// generics support // generics support
Symbol* generic_signature() const { return _generic_signature; } Symbol* generic_signature() const {
void set_generic_signature(Symbol* sig) { _generic_signature = sig; } 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;
}
u2 enclosing_method_data(int offset); u2 enclosing_method_data(int offset);
u2 enclosing_method_class_index() { u2 enclosing_method_class_index() {
......
...@@ -1554,6 +1554,20 @@ bool VM_RedefineClasses::rewrite_cp_refs(instanceKlassHandle scratch_class, ...@@ -1554,6 +1554,20 @@ bool VM_RedefineClasses::rewrite_cp_refs(instanceKlassHandle scratch_class,
return false; return false;
} }
// rewrite sourc file name index:
u2 source_file_name_idx = scratch_class->source_file_name_index();
if (source_file_name_idx != 0) {
u2 new_source_file_name_idx = find_new_index(source_file_name_idx);
scratch_class->set_source_file_name_index(new_source_file_name_idx);
}
// rewrite class generic signature index:
u2 generic_signature_index = scratch_class->generic_signature_index();
if (generic_signature_index != 0) {
u2 new_generic_signature_index = find_new_index(generic_signature_index);
scratch_class->set_generic_signature_index(new_generic_signature_index);
}
return true; return true;
} // end rewrite_cp_refs() } // end rewrite_cp_refs()
...@@ -3370,7 +3384,8 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, ...@@ -3370,7 +3384,8 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
// Leave arrays of jmethodIDs and itable index cache unchanged // Leave arrays of jmethodIDs and itable index cache unchanged
// Copy the "source file name" attribute from new class version // Copy the "source file name" attribute from new class version
the_class->set_source_file_name(scratch_class->source_file_name()); the_class->set_source_file_name_index(
scratch_class->source_file_name_index());
// Copy the "source debug extension" attribute from new class version // Copy the "source debug extension" attribute from new class version
the_class->set_source_debug_extension( the_class->set_source_debug_extension(
......
...@@ -294,7 +294,7 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary; ...@@ -294,7 +294,7 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary;
nonstatic_field(InstanceKlass, _java_fields_count, u2) \ nonstatic_field(InstanceKlass, _java_fields_count, u2) \
nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ nonstatic_field(InstanceKlass, _constants, ConstantPool*) \
nonstatic_field(InstanceKlass, _class_loader_data, ClassLoaderData*) \ nonstatic_field(InstanceKlass, _class_loader_data, ClassLoaderData*) \
nonstatic_field(InstanceKlass, _source_file_name, Symbol*) \ nonstatic_field(InstanceKlass, _source_file_name_index, u2) \
nonstatic_field(InstanceKlass, _source_debug_extension, char*) \ nonstatic_field(InstanceKlass, _source_debug_extension, char*) \
nonstatic_field(InstanceKlass, _inner_classes, Array<jushort>*) \ nonstatic_field(InstanceKlass, _inner_classes, Array<jushort>*) \
nonstatic_field(InstanceKlass, _nonstatic_field_size, int) \ nonstatic_field(InstanceKlass, _nonstatic_field_size, int) \
...@@ -313,7 +313,7 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary; ...@@ -313,7 +313,7 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary;
nonstatic_field(InstanceKlass, _jni_ids, JNIid*) \ nonstatic_field(InstanceKlass, _jni_ids, JNIid*) \
nonstatic_field(InstanceKlass, _osr_nmethods_head, nmethod*) \ nonstatic_field(InstanceKlass, _osr_nmethods_head, nmethod*) \
nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*) \ nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*) \
nonstatic_field(InstanceKlass, _generic_signature, Symbol*) \ nonstatic_field(InstanceKlass, _generic_signature_index, u2) \
nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \ nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \
nonstatic_field(InstanceKlass, _methods_cached_itable_indices, int*) \ nonstatic_field(InstanceKlass, _methods_cached_itable_indices, int*) \
volatile_nonstatic_field(InstanceKlass, _idnum_allocated_count, u2) \ volatile_nonstatic_field(InstanceKlass, _idnum_allocated_count, u2) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册