On Mon, 4 Sep 2023 12:19:42 GMT, Martin Doerr <mdo...@openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java line 398: >> >>> 396: bindings.add(Binding.cast(type, int.class)); >>> 397: type = int.class; >>> 398: } >> >> Part of the casts are handled here with explicit cast bindings, but the >> widening from int -> long, and narrowing from long -> int are handled >> implicitly as part of the ShiftLeft implementation. I'd much prefer if all >> the type conversions are handled with explicit cast bindings. This would >> also semantically simplify the shift operator, since it would just handle >> the actual shifting. > > I guess we would need to add additional bindings for that? Is is worth adding > more just for a big endian corner case? Or can that be done with the existing > ones? A `Cast` case for int -> long and long -> int would need to be added. Given the existing setup, that should only be a few lines of code for each. (See e.g. for int -> long https://github.com/openjdk/jdk/compare/master...JornVernee:jdk:I2L). I don't think the cost is that high. > Is is worth adding more just for a big endian corner case? I think it's worth it in order to have a cleaner contract for the shift ops, should we want to use them for anything else in the future, but also just to make them easier to understand for future readers. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15417#discussion_r1314892030