<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Heh.</p>
<p>Note that this is also mentioned (in better words than mine) in
the dlassfile API JEP [1]:</p>
<p>
<blockquote type="cite">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 <em>replay</em>,
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.</blockquote>
<br>
Maurizio<br>
</p>
<p>[1] - <a class="moz-txt-link-freetext" href="https://openjdk.org/jeps/466">https://openjdk.org/jeps/466</a><br>
</p>
<div class="moz-cite-prefix">On 26/07/2024 17:32, Øystein Myhre
Andersen wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAKV_CfX+7NUQddQ2Trf+gLDZ8ScSDCdUJdSVyQYBA=J+bL=xtQ@mail.gmail.com">
<div dir="ltr">Really, that's how it's supposed to work.<br>
Then I learned something new today.<br>
<br>
Thank you !<br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, Jul 26, 2024 at
5:17 PM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I
think this is as expected? E.g. by default the classfile API
will <br>
consider all jumps to be "short jumps" (e.g. "goto" instead of
"goto_w").<br>
<br>
If that fails (e.g. because the code is too big), code
generation is <br>
"replayed", this time using "long jumps" (e.g. "goto_w"
instead of "goto").<br>
<br>
This is why you see the consumer being called twice.<br>
<br>
Maurizio<br>
<br>
On 26/07/2024 10:35, Øystein Myhre Andersen wrote:<br>
> The attached code contains the building of a class with
one method '_STM'.<br>
> When the method gets too big, more than 32,767 bytes, a
weird <br>
> situation occurs.<br>
><br>
> Look at lines 93-94: Here the size of the code can be
changed.<br>
> When the code is greater than 32,767 (caseBlockSize =
13000)<br>
> the Method 'buildMethod_STM' is called twice with
different <br>
> CodeBuilders !!!<br>
><br>
> When caseBlockSize = 10000 everything is OK.<br>
><br>
> There must be something wrong here.<br>
><br>
> - Øystein Myhre Andersen<br>
</blockquote>
</div>
</blockquote>
</body>
</html>