[foreign-jextract] RFR: 8252563: Field VarHandle generation in --source mode is missing the PathElement.groupElement argument

Jorn Vernee jvernee at openjdk.java.net
Tue Sep 1 12:25:46 UTC 2020


Hi,

This PR fixes an issue where var handles in structs were not being created based on the layout of the parent struct,
and were not using a PathElement.groupElement(...) argument to look up the right struct field, in --source mode,
resulting in the created var handle not having the right offset. The core change is found in
SourceConstantHelper#emitVarHandleField.

To try and clear things up a bit, I've also split the addVarHandle method in ConstantHelper into addGlobalVarHandle,
and addFieldVarHandle with only the applicable parameter types, at least at the ConstantHelper level, so that calling
code doesn't have to pass a bunch of nulls when calling addVarHandle for a global variable (the nulls being for the
parent layout and field name).

To test this change, I've re-used the existing LibStructTest by running the test twice; once under the existing jtreg
jextract driver that uses the binary constant helper, and once under a new jtreg jextract driver that first generates
sources and then compiles them.

Thanks,
Jorn

-------------

Commit messages:
 - Fix issue with struct field var handles not having the right fields offset in source mode
 - Source Test for structs

Changes: https://git.openjdk.java.net/panama-foreign/pull/297/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=297&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8252563
  Stats: 160 lines in 8 files changed: 116 ins; 1 del; 43 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/297.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/297/head:pull/297

PR: https://git.openjdk.java.net/panama-foreign/pull/297


More information about the panama-dev mailing list