On Thu, 19 Sep 2024 14:14:59 GMT, Chen Liang <li...@openjdk.org> wrote:
>> This PR changes proxy code gen to avoid generating >> `Class.forName("java.lang.Object")`, instead emitting an ldc for the class >> literal, `ldc(CD_Object)`, java code equivalent `Object.class`. >> >> More types could profitably use `ldc(ClassDesc/-Entry)`, taking cues from >> `InvokerBytecodeGenerator.isStaticallyInvocable`, but just addressing the >> `Object` methods gets rid of most `Class.forName` emits. It's not terribly >> important for throughput performance since these are called in the generated >> `clinit`, so getting a quick win with few additional checks is a good >> starting point. >> >> Added a few unrelated minor refactors/improvements, guided by diagnostic >> runs of the now fixed microbenchmark. > > src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 833: > >> 831: cob.ldc(objectCE); >> 832: } else { >> 833: cob.ldc(cl.getName()) > > This `Class.forName` is only necessary in a very small number of cases, > namely when the overridden interface method has an unaccessible parameter > type, usually a package-private type not accessible to the implementing > class. Maybe we can always directly ldc if the class is `public`. Yeah, I'm just not sure what rules are quite right here. Wouldn't want to inadvertently regress this again, and not sure we have tests for all eventualities, so I started this off with the most conservative yet most beneficial improvement. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21090#discussion_r1766973606