Multiple method build in classBuilder
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Jul 26 16:44:22 UTC 2024
Heh.
Note that this is also mentioned (in better words than mine) in the
dlassfile API JEP [1]:
> This is more specific and transparent [...]. Yet there is already a
> powerful hidden benefit: By capturing the sequence of operations in a
> lambda we get the possibility of /replay/, which enables the library
> to do work that previously the client had to do. For example, branch
> offsets can be either short or long. If clients generate instructions
> imperatively then they have to compute the size of each branch's
> offset when generating the branch, which is complex and error prone.
> But if the client provides a lambda that takes a builder then the
> library can optimistically try to generate the method with short
> offsets and, if that fails, discard the generated state and re-invoke
> the lambda with different code generation parameters.
Maurizio
[1] - https://openjdk.org/jeps/466
On 26/07/2024 17:32, Øystein Myhre Andersen wrote:
> Really, that's how it's supposed to work.
> Then I learned something new today.
>
> Thank you !
>
> On Fri, Jul 26, 2024 at 5:17 PM Maurizio Cimadamore
> <maurizio.cimadamore at oracle.com> wrote:
>
> I think this is as expected? E.g. by default the classfile API will
> consider all jumps to be "short jumps" (e.g. "goto" instead of
> "goto_w").
>
> If that fails (e.g. because the code is too big), code generation is
> "replayed", this time using "long jumps" (e.g. "goto_w" instead of
> "goto").
>
> This is why you see the consumer being called twice.
>
> Maurizio
>
> On 26/07/2024 10:35, Øystein Myhre Andersen wrote:
> > The attached code contains the building of a class with one
> method '_STM'.
> > When the method gets too big, more than 32,767 bytes, a weird
> > situation occurs.
> >
> > Look at lines 93-94: Here the size of the code can be changed.
> > When the code is greater than 32,767 (caseBlockSize = 13000)
> > the Method 'buildMethod_STM' is called twice with different
> > CodeBuilders !!!
> >
> > When caseBlockSize = 10000 everything is OK.
> >
> > There must be something wrong here.
> >
> > - Øystein Myhre Andersen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20240726/0c5e577f/attachment-0001.htm>
More information about the classfile-api-dev
mailing list