Classfile API is missing CodeBuilder hook for various instructions-consuming computation tools
Brian Goetz
brian.goetz at oracle.com
Fri Aug 19 13:39:38 UTC 2022
Before we start to do architectural surgery, let's back up a bit and try
to distill some requirements and goals. What problems led you here?
Are these tools we expect people to run full-time, or mostly for
debugging when something goes wrong? Can they be applied to ordinary
classfiles, or do they have to work during building? Could this be
framed as a kind of transform, instead of a new concept?
On 8/19/2022 2:34 AM, Adam Sotona wrote:
>
> Hi,
>
> I’ve started working on various helper tools that can give user
> answers during code building.
>
> Answers to questions like:
>
> * What is actual instructions count
> * What is actual/max depts of the stack
> * Which locals have been used
> * What kinds or exact types are at locals
> * What kinds or exact types are on stack
> * Show me a log of all instructions
> * …
>
> Each of this question has specific use case and calculation of each
> answer scarifies different amount of resources.
>
> Unfortunately implementation of tool answering any of the above
> questions requires:
>
> - either heavy use of BufferedCodeBuilder (and complicate existing
> building or transformation blocks a lot)
>
> - or hacking into CodeBuilder(s) implementation
>
> I would like to propose a similar approach as Linux “tee” tool does,
> so user can attach another consumer of the CodeElements passed to the
> CodeBuilder.
>
> It might be just a single method in CodeBuilder:
>
> defaultvoid*tee*(Consumer<CodeElement> secondListener,
> Consumer<CodeBuilder> handler) {
>
> handler.accept(newTeeCodeBuilder(this, secondListener));
>
> }
>
> Use case may then look for example like this:
>
> varstackCounter = ...//custom computation tool
> /codeBuilder/./tee/(stackCounter, cb -> {
> ... //block of instructions to be counted
> });
> stackCounter./actual/();
> stackCounter./max/();
>
> What do you think about this CodeBuilder hook for various
> instructions-consuming computation tools?
>
> Thanks,
>
> Adam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220819/f500a6da/attachment-0001.htm>
More information about the classfile-api-dev
mailing list