[code-reflection] RFR: Implement shift ops

Adam Sotona asotona at openjdk.org
Mon Apr 15 16:15:56 UTC 2024


On Wed, 10 Apr 2024 15:31:15 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

> This PR implements the three shift operations. There are a few points to discuss:
> - naming: I chose the names as the operators are called in the JLS, but e.g. for comparisons we currently have short names. The Compiler also uses a different naming scheme here. Which way do we want to go here?
> - shift operations are different from other binary ops as their operands undergo unary numeric promotion rather than binary numeric promotion. However, on bytecode level the rhs will always be an int anyway. I'm currently handling that in the bytecode generator, and the model is close to the JLS otherwise. Any objections here?
> - I reworked the testing to allow for combinations of different types, as that's important for the current design of shifts (especially `int shift long` should result in an int again)
> 
> I also noticed that I missed assignment operators when I did and, or, xor before. I left it out here as well, as this needs additional care, at least for the interpreter. Code like
> 
> void m(byte b) {
>     b *= 2;
> }
> 
> doesn't run when using the interpreter currently. Should I add assignment operator handling here anyway?

The `BooleanType` added to `BytecodeGenerator` is just a temporary quick fix.
I agree to go with what you have.
To revisit types, implicit and explicit conversions, boxing and unboxing in `BytecodeGenerator` is next on my ToDo list.

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

PR Comment: https://git.openjdk.org/babylon/pull/49#issuecomment-2057228734


More information about the babylon-dev mailing list