RFR: 8255883: Avoid multiple GeneratedMethodAccessor for same NativeMethod…

Claes Redestad redestad at openjdk.java.net
Thu Nov 5 16:00:59 UTC 2020


On Thu, 5 Nov 2020 14:59:56 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> I do wonder if it makes sense to handle triple-state `int` here: "not yet generated", "generated", "in error"? So that we don't try to generate the accessor over and over again when it is in error?
>
> If we are changing NativeMethodAccessorImpl.invoke then we should probably do NativeConstructorAccessorImpl.newInstance at the same time. Also wondering if we should, while in the area, add "return acc.invoke(obj, args)" after setting the delegate so that it invokes the newly generated accessor.
> 
> Are there resource or other cases that you have observed where generateMethod fails and then succeeds in a subsequent call?
> 
> @cl4es Do you know of any startup tests that might be sensitive to the eager creating of a VarHandle?
> 
> I agree with @shipilev to test before the CAS.

@AlanBateman I had a look and it seems unlikely the eager creation in this `<clinit>` will matter. I can find `NativeMethodAccessorImpl` in the startup profiles only for netty and larger apps, which often already initialize some `VarHandle` or are large enough that the initialization overhead will be lost in the noise.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1070


More information about the core-libs-dev mailing list