Trying out the API for qbicc
Michael van Acken
michael.van.acken at gmail.com
Thu Jul 28 04:12:49 UTC 2022
Am Mi., 27. Juli 2022 um 22:34 Uhr schrieb Brian Goetz <
brian.goetz at oracle.com>:
>
> Obviously this is wandering dangerously close to the bikeshed borderline,
>> however one other real-world advantage is that an enum constant in a more
>> specific `*Opcode` subtype type can store more useful information about
>> itself that a consumer could use; for example, the opcode constant for
>> `IFEQ` could have a method `complement` which yields `IFNE`, which can be
>> useful for simplifying some code generators (and I can think of specific
>> cases both within qbicc and within Quarkus where this would have been
>> useful).
>>
>>
>> This method exists in the library as an Opcode -> Opcode method.
>>
>
> Ah yes, I found it in `BytecodeHelpers`, excellent. That's in the `impl`
> subpackage though, so it doesn't feel very "public". Perhaps that class
> could be moved into the `jdk.classfile` package?
>
>
> Yes, we've been conservative about what we expose, since its easier to
> expose something hidden than vice versa.
>
> What other transforms on opcodes go along with this?
>
I'm using two related transforms.
First, a "swap sides" for comparisons mapping e.g. the LT variants to their
GT companions
while being identity for EQ and NE. I use this to slide null and integer
zero to the right hand side.
Then the second step takes two operand compares against null/zero and maps
them to
their one operand counterparts.
-- mva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220728/14145159/attachment-0001.htm>
More information about the classfile-api-dev
mailing list