RFR: 8334431: C2 SuperWord: fix performance regression due to store-to-load-forwarding failures [v2]

Emanuel Peter epeter at openjdk.org
Tue Nov 19 13:58:14 UTC 2024


On Tue, 19 Nov 2024 12:46:16 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> @dean-long I tried that with `@param`, but then they are not constants... sadly. And they need to be constants. Let me know if you find some better way though ;)
>
> @eme64 FYI you can make param a constant using this pattern:
> 
>     static final MutableCallSite MUTABLE_CONSTANT = new MutableCallSite(MethodType.methodType(int.class));
>     static final MethodHandle MUTABLE_CONSTANT_HANDLE = MUTABLE_CONSTANT.dynamicInvoker();
> 
>     static {
>         MethodHandle init = MethodHandles.constant(int.class, 1);
>         MUTABLE_CONSTANT.setTarget(init);
>     }
> 
>     @Param({"1", "2"})
>     int size;
> 
>     @Setup(Level.Iteration)
>     public void setup() throws Throwable {
>         if (size != (int) MUTABLE_CONSTANT_HANDLE.invokeExact()) {
>             MethodHandle constant = MethodHandles.constant(int.class, size);
>             MUTABLE_CONSTANT.setTarget(constant);
>         }
>     }
> 
>     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
>     private int test() throws Throwable {
>         return (int) MUTABLE_CONSTANT_HANDLE.invokeExact();
>     }
> 
>     @Benchmark
>     public void run() throws Throwable {
>         test();
>     }

@merykitty nice trick. It seems to work :)

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

PR Comment: https://git.openjdk.org/jdk/pull/21521#issuecomment-2485789391


More information about the hotspot-compiler-dev mailing list