Classfile API is missing CodeBuilder hook for various instructions-consuming computation tools
Brian Goetz
brian.goetz at oracle.com
Fri Aug 19 15:03:33 UTC 2022
On 8/19/2022 10:30 AM, Adam Sotona wrote:
>
> These tools are helpers for specific use cases and they do not
> represent transformations, but rather they collect and provide
> information necessary for building code.
>
> For example I need to know actual stack when I plan to use
> stack-to-locals (and back) function in my generated code.
>
> Another example (which we may embed) is to count max stack when the
> generator is off.
>
> Optional custom logging of the exact instructions dropped to
> CodeBuilder is another requested use case.
>
> All of the above are expensive operations, so they should be applied
> on user request only.
>
That's what I thought. So, since they are only applied when you really
need them, can't these be treated as "generate the classfile, and then
traverse it as a classfile with the API we already have?" This seems
like it would work in all the cases when we *can* generate a classfile,
which leaves the cases where we would fail to generate a classfile and
therefore have nothing to analyze, which is probably a non-zero but
not-large fraction of the cases, right?
> This API does not have much value for transformations, where user can
> easily listen to each transformed CodeElement and compute whatever is
> necessary. However when building code using various “magic” (like
> blocks, constants auto-detection, and other conveniences…) it is
> important to see what instructions it really builds into.
>
I think you misunderstood my question. I didn't mean "is this useful in
transformation". I meant that, we *already* have composable transforms,
where the output of one activity is piped into another; there's a lot of
similarity here (and they'll use the same underlying plumbing.) I was
suggesting that you could think of teeing as being a (likely no-op)
transformation on the building that is already in progress.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220819/6b661701/attachment-0001.htm>
More information about the classfile-api-dev
mailing list