[foreign-memaccess+abi] RFR: 8291873: Implement return value normalization in Java [v2]
Jorn Vernee
jvernee at openjdk.org
Thu Sep 15 12:40:18 UTC 2022
> This patch moves value normalization code from the downcall stub (where it was hard coded) to Java, and also adds it for upcall arguments where it was missing.
>
> There is a slight change in behavior with this. The previous hard-coded conversion from a native value to Java `boolean` checked if the least significant byte was non-zero, i.e. `boolean result = value & 0xFF != 0`. While the new conversion only looks at the least significant bit, i.e. `boolean result = value & 0b1 != 0`. I think the new behavior is more correct. It means that the Linker will just do the "dumb" thing when mapping anything to `boolean`, and the native representation is really expected to be like a Java `boolean` i.e. only using the least significant bit. On the other hand I think it means that e.g. jextract will have to map the C `bool` as `byte` and then do a non-zero check to convert to `boolean`.
Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
Non-zero byte test
-------------
Changes:
- all: https://git.openjdk.org/panama-foreign/pull/720/files
- new: https://git.openjdk.org/panama-foreign/pull/720/files/9bd45af4..c873109f
Webrevs:
- full: https://webrevs.openjdk.org/?repo=panama-foreign&pr=720&range=01
- incr: https://webrevs.openjdk.org/?repo=panama-foreign&pr=720&range=00-01
Stats: 64 lines in 2 files changed: 47 ins; 0 del; 17 mod
Patch: https://git.openjdk.org/panama-foreign/pull/720.diff
Fetch: git fetch https://git.openjdk.org/panama-foreign pull/720/head:pull/720
PR: https://git.openjdk.org/panama-foreign/pull/720
More information about the panama-dev
mailing list