Skip to content
Prev Previous commit
Next Next commit
Add comment
  • Loading branch information
fparain committed Oct 27, 2025
commit e9e79fe6f7661a0c3189764cd6bbda4f2be439e4
4 changes: 4 additions & 0 deletions src/hotspot/share/classfile/fieldLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,10 @@ void FieldLayoutBuilder::generate_acmp_maps() {
_nonoop_acmp_map = new GrowableArray<Pair<int,int>>();
_oop_acmp_map = new GrowableArray<int>();
if (_is_empty_inline_class) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not return first before allocating these GrowableArray in resource area?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It streamlines the code in InstanceKlass::fill_instance_klass() by not having to handle the null map case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I can't decide if you need a comment to prevent someone from changing this to have the quick exit. I guess they'll get a crash for the null case.

// last_idx remembers the position of the last insertion in order to speed up the next insertion.
// Local fields are processed in ascending offset order, so an insertion is very likely be performed
// next to the previous insertion. However, in some cases local fields and inherited fields can be
// interleaved, in which case the search of the insertion position cannot depend on the previous insertion.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks.

int last_idx = -1;
if (_super_klass != nullptr && _super_klass != vmClasses::Object_klass()) { // Assumes j.l.Object cannot have fields
last_idx = insert_map_at_offset(_nonoop_acmp_map, _oop_acmp_map, _super_klass, 0, 0, last_idx);
Expand Down