RFR: 8334431: C2 SuperWord: fix performance regression due to store-to-load-forwarding failures [v2]
Quan Anh Mai
qamai at openjdk.org
Tue Nov 19 12:49:45 UTC 2024
On Tue, 19 Nov 2024 08:17:18 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Why does the benchmark need to have so many methods, to make sure the different values are treated as constants? I’m not sure, but JMH might turn @Param values into constants. If so, then your benchmark can be greatly simplified.
>
> @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();
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21521#issuecomment-2485621523
More information about the hotspot-compiler-dev
mailing list