[code-reflection] RFR: Implement shift ops
Hannes Greule
hgreule at openjdk.org
Wed Apr 10 15:35:34 UTC 2024
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?
-------------
Commit messages:
- cleanup
- bytecode + mixed type interpreter methods
- remove compound assignment for now
- start shift ops
Changes: https://git.openjdk.org/babylon/pull/49/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=49&range=00
Stats: 313 lines in 5 files changed: 278 ins; 3 del; 32 mod
Patch: https://git.openjdk.org/babylon/pull/49.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/49/head:pull/49
PR: https://git.openjdk.org/babylon/pull/49
More information about the babylon-dev
mailing list