[code-reflection] RFR: Missing conversion for some unary operators
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Apr 18 18:03:08 UTC 2024
On Thu, 18 Apr 2024 16:34:50 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> `ReflectMethods` is missing the logic for converting operands for unary operators `!` and `-`.
>
> I've fixed calling the correct `value` method (the one with a target type).
>
> When running tests, it seems like the test `CoreBinaryOpsTest` fails.
>
> This failure also occurs w/o my patch, so it seems unrelated.
>
> The problem is likely due to another missing conversion - e.g. for this code:
>
>
> @CodeReflection
> static int leftShiftIL(int left, long right) {
> return left << right;
> }
>
>
> We get this model:
>
>
> func @"leftShiftIL" (%0 : int, %1 : long)int -> {
> %2 : Var<int> = var %0 @"left";
> %3 : Var<long> = var %1 @"right";
> %4 : int = var.load %2;
> %5 : long = var.load %3;
> %6 : int = lshl %4 %5;
> return %6;
> };
>
>
> This seems to want to do a shift between an int and a long (so should use a long shift, whose result is also long). But there's no conversion on the way in and also on the way out.
>
> Since this is unrelated with the fix here, I'd suggest to integrate this in the meantime.
> I didn't have time to check the test yet but Paul mentioned a test failure here [#48 (comment)](https://github.com/openjdk/babylon/pull/48#discussion_r1566513665). `int << long` however actually is an `int` shift and the result is also an `int`. The current code model is near to the JLS, but we will probably change it as Paul was leaning towards a model where binary ops are always consistent in their inputs.
Yes, this is an int shift ,but the second operand needs to be truncated to an int. I've added comment on this in #49
-------------
PR Comment: https://git.openjdk.org/babylon/pull/55#issuecomment-2064766569
More information about the babylon-dev
mailing list