<div dir="ltr">Unfortunately not yet, and I am busy recently so cannot provide one until the weekends. I think this approach would work best for cases where we generate completely new class files, such as j.l.invoke, Proxy, and MethodHandleProxies. It probably won't make too much of a difference if we don't pass ClassDesc in directly.<div><br></div><div>Also, the points you've mentioned before, that MethodType and Class should have their dedicated, validated fast-paths for Descriptor conversion, would probably have a similar boosts.</div><div>In Class::descriptorString(), there's an extra allocation of the internal name from String::replace. We might have less allocation and better performance if we can avoid that allocation by moving the replacement to be done on the StringBuilder's array instead.</div><div><br></div><div>For your previous descriptor to internal name conversion, I think we might add some fast-path conversions for frequently-occuring ClassDesc like Object to directly return "java/lang/Object" than to compute substring, to simulate the existing fast-paths in j.l.invoke generation.</div><div><br></div><div>However, all these are speculation; we need benchmark to show their effectiveness in dedicated scenarios (in addition to the corpus transformation, say addition of new CF elements, spinning new class files, removing CF elements)</div><div><br></div><div>Chen Liang</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 3, 2024 at 7:58 AM Adam Sotona <<a href="mailto:adam.sotona@oracle.com" target="_blank">adam.sotona@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"><div>
<div lang="en-CZ">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Hi Chen,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">It looks promising, do you have some benchmark numbers?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Adam</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<div id="m_-4749564263068333577m_-7132608100388783835mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">From:
</span></b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">classfile-api-dev <<a href="mailto:classfile-api-dev-retn@openjdk.org" target="_blank">classfile-api-dev-retn@openjdk.org</a>> on behalf of <a href="mailto:liangchenblue@gmail.com" target="_blank">liangchenblue@gmail.com</a> <<a href="mailto:liangchenblue@gmail.com" target="_blank">liangchenblue@gmail.com</a>><br>
<b>Date: </b>Sunday, 24 December 2023 at 17:11<br>
<b>To: </b>classfile-api-dev <<a href="mailto:classfile-api-dev@openjdk.org" target="_blank">classfile-api-dev@openjdk.org</a>><br>
<b>Subject: </b>Using descriptor than internal name hashes for CP ClassEntry<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Hi,<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Since we are using ClassDesc quite often to represent Class constants in Class-File API, yet it's costly to hash them (as they are internal names in CP but descriptors in ClassDesc), that Adam has created
shortcuts to speed up fetching of Object CE from CD_Object, I have thought of a new tactic to hash ClassEntry by full descriptor than by internal name alone.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">I have made a prototype at <a href="https://github.com/liachmodded/jdk/commit/2932a560b0029352f1309883b3c5eecfb3d2c771" target="_blank">https://github.com/liachmodded/jdk/commit/2932a560b0029352f1309883b3c5eecfb3d2c771</a><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">The idea is that hashing CE as descriptors is easier than creating substrings for hashing; substring hashing is hard to compute, but appending and prepending and hash is much easier.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Does this look like a good idea? I only included a test to confirm its correctness, but haven't got time to bench it against, say, the port of java.lang,invoke or ProxyGenerator.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Chen<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div></blockquote></div>