changeset 52907:23dd48526a07 datum

adding more record related methods to InstanceKlass
author vromero
date Tue, 23 Oct 2018 23:18:04 -0400
parents 5df8e3b41af0
children 4dbbe4e4d001
files src/hotspot/share/classfile/classFileParser.cpp src/hotspot/share/oops/instanceKlass.cpp src/hotspot/share/oops/instanceKlass.hpp src/hotspot/share/oops/recordParamInfo.hpp
diffstat 4 files changed, 43 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classFileParser.cpp	Tue Oct 23 23:17:49 2018 -0400
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Tue Oct 23 23:18:04 2018 -0400
@@ -3789,7 +3789,7 @@
   this_klass->set_nest_host_index(_nest_host);
   this_klass->set_local_interfaces(_local_interfaces);
   this_klass->set_annotations(_combined_annotations);
-  this_klass->set_recordParams(_record_params, record_params_count);
+  this_klass->set_record_params(_record_params, record_params_count);
   // Delay the setting of _transitive_interfaces until after initialize_supers() in
   // fill_instance_klass(). It is because the _transitive_interfaces may be shared with
   // its _super. If an OOM occurs while loading the current klass, its _super field
--- a/src/hotspot/share/oops/instanceKlass.cpp	Tue Oct 23 23:17:49 2018 -0400
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Tue Oct 23 23:18:04 2018 -0400
@@ -564,6 +564,12 @@
   }
   set_nest_members(NULL);
 
+  if (record_params() != NULL &&
+      record_params() != Universe::the_empty_short_array()) {
+    MetadataFactory::free_array<jushort>(loader_data, record_params());
+  }
+  set_record_params(NULL, 0);
+
   // We should deallocate the Annotations instance if it's not in shared spaces.
   if (annotations() != NULL && !annotations()->is_shared()) {
     MetadataFactory::free_metadata(loader_data, annotations());
@@ -2270,7 +2276,7 @@
   }
 
   it->push(&_nest_members);
-  it->push(&_recordParams);
+  it->push(&_record_params);
 }
 
 void InstanceKlass::remove_unshareable_info() {
--- a/src/hotspot/share/oops/instanceKlass.hpp	Tue Oct 23 23:17:49 2018 -0400
+++ b/src/hotspot/share/oops/instanceKlass.hpp	Tue Oct 23 23:18:04 2018 -0400
@@ -35,6 +35,7 @@
 #include "oops/fieldInfo.hpp"
 #include "oops/instanceOop.hpp"
 #include "oops/klassVtable.hpp"
+#include "oops/recordParamInfo.hpp"
 #include "runtime/handles.hpp"
 #include "runtime/os.hpp"
 #include "utilities/accessFlags.hpp"
@@ -188,7 +189,7 @@
   // if this class is unloaded.
   Symbol*         _array_name;
 
-  Array<u2>*      _recordParams;
+  Array<u2>*      _record_params;
 
   // Number of heapOopSize words used by non-static fields in this klass
   // (including inherited fields but after header_size()).
@@ -433,6 +434,8 @@
   friend class fieldDescriptor;
   FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
 
+  RecordParamInfo* record_param(int index) const { return RecordParamInfo::from_record_params_array(_fields, index); }
+
  public:
   int     field_offset      (int index) const { return field(index)->offset(); }
   int     field_access_flags(int index) const { return field(index)->access_flags(); }
@@ -461,12 +464,18 @@
   jushort nest_host_index() const { return _nest_host_index; }
   void set_nest_host_index(u2 i)  { _nest_host_index = i; }
 
+  // record parameters
+  int     record_param_access_flags(int index) const { return record_param(index)->access_flags(); }
+  Symbol* record_param_name(int index) const { return record_param(index)->name(constants()); }
+  Symbol* record_param_signature(int index) const { return record_param(index)->signature(constants()); }
+  Symbol* record_param_descriptor(int index) const { return record_param(index)->signature(constants()); }
+
   int record_params_count() const       { return (int)_record_params_count; }
 
-  Array<u2>* recordParams() const       { return _recordParams; }
-  void set_recordParams(Array<u2>* recordParams, u2 record_params_count) {
-    guarantee(_recordParams == NULL || recordParams == NULL, "Just checking");
-    _recordParams = recordParams;
+  Array<u2>* record_params() const       { return _record_params; }
+  void set_record_params(Array<u2>* record_params, u2 record_params_count) {
+    guarantee(_record_params == NULL || record_params == NULL, "Just checking");
+    _record_params = record_params;
     _record_params_count = record_params_count;
   }
 
--- a/src/hotspot/share/oops/recordParamInfo.hpp	Tue Oct 23 23:17:49 2018 -0400
+++ b/src/hotspot/share/oops/recordParamInfo.hpp	Tue Oct 23 23:18:04 2018 -0400
@@ -55,6 +55,27 @@
   u2 name_index() const                          { return _shorts[name_index_offset];        }
   u2 descriptor_index() const                    { return _shorts[descriptor_index_offset];  }
   u2 signature_index() const                     { return _shorts[signature_index_offset];   }
+public:
+  static RecordParamInfo* from_record_params_array(Array<u2>* record_params, int index) {
+    return ((RecordParamInfo*)record_params->adr_at(index * param_slots));
+  }
+  static RecordParamInfo* from_record_param_array(u2* record_params, int index) {
+    return ((RecordParamInfo*)(record_params + index * param_slots));
+  }
+
+  u2 access_flags() const                        { return _shorts[access_flags_offset];      }
+
+  Symbol* name(const constantPoolHandle& cp) const {
+    return cp->symbol_at(name_index());
+  }
+
+  Symbol* signature(const constantPoolHandle& cp) const {
+    return cp->symbol_at(signature_index());
+  }
+
+  Symbol* descriptor(const constantPoolHandle& cp) const {
+    return cp->symbol_at(descriptor_index());
+  }
 };
 
 #endif // SHARE_VM_OOPS_RECORDPARAMINFO_HPP