[lworld] RFR: 8374006: [lworld] Improve field accessor methods in InlineTypeNode
Marc Chevalier
mchevalier at openjdk.org
Fri Jan 16 13:57:00 UTC 2026
This PR remove from `InlineTypeNode` the methods:
int field_offset(uint index) const;
uint field_index(int offset) const;
ciType* field_type(uint index) const;
bool field_is_flat(uint index) const;
bool field_is_null_free(uint index) const;
bool field_is_volatile(uint index) const;
int field_null_marker_offset(uint index) const;
in favor of a single
ciField* field(uint index) const;
from which we directly access the various properties we are interested in.
I've called it `field` as suggested in the original discussion. I've started with `declared_nonstatic_field_at` to be consistent with `ciInstanceKlass` and to avoid ambiguity wrt which kind of fields we are talking about, but this name is rather long... Since we are only talking about the declared fields, and we have no easy getter for `nonstatic_field_at`, then I think it's ok to have a shorter name. Also, in the context of a `InlineTypeNode`, the "non-static" part of the long name seems rather redundant.
The other question is what we should do with asserts? Methods `field_is_flat`, `field_is_null_free` and `field_is_volatile` had the assert
assert(!field->is_flat() || field->type()->is_inlinetype(), "must be an inline type");
and `field_null_marker_offset` had
assert(field->is_flat(), "must be an inline type");
I've tried to propagate them to the call-site of such functions, and where it makes a bit of sense, and not subsumed by surrounding `if()` and `assert`. Let me know if it seems unnecessary or not well-placed in some cases.
Tested with tier1,tier2,tier3,hs-precheckin-comp,hs-comp-stress,valhalla-comp-stress. Looks fine, but it doesn't seem too risky.
Thanks,
Marc
-------------
Commit messages:
- Cleanup
- InlineTypeNode::field(uint) const
Changes: https://git.openjdk.org/valhalla/pull/1922/files
Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1922&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8374006
Stats: 134 lines in 4 files changed: 36 ins; 39 del; 59 mod
Patch: https://git.openjdk.org/valhalla/pull/1922.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1922/head:pull/1922
PR: https://git.openjdk.org/valhalla/pull/1922
More information about the valhalla-dev
mailing list