Skip to content

Commit 06223af

Browse files
committed
[GR-66392] Support conditional invocation plugin in runtime compilation.
PullRequest: graal/21446
2 parents fb525c7 + b4ec2e0 commit 06223af

File tree

94 files changed

+1496
-1239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1496
-1239
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/CheckGraalIntrinsics.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@
4848
import jdk.graal.compiler.hotspot.meta.UnimplementedGraalIntrinsics;
4949
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
5050
import jdk.graal.compiler.nodes.graphbuilderconf.InvocationPlugin;
51+
import jdk.graal.compiler.nodes.graphbuilderconf.InvocationPlugin.ConditionalInvocationPlugin;
5152
import jdk.graal.compiler.nodes.graphbuilderconf.InvocationPlugins;
5253
import jdk.graal.compiler.options.OptionValues;
5354
import jdk.graal.compiler.runtime.RuntimeProvider;
5455
import jdk.graal.compiler.test.GraalTest;
56+
import jdk.vm.ci.code.Architecture;
5557
import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
5658
import jdk.vm.ci.hotspot.VMIntrinsicMethod;
5759
import jdk.vm.ci.meta.MetaAccessProvider;
@@ -144,6 +146,16 @@ public interface Refiner {
144146
public final GraalHotSpotVMConfig config = rt.getVMConfig();
145147
public final UnimplementedGraalIntrinsics unimplementedGraalIntrinsics = new UnimplementedGraalIntrinsics(rt.getTarget().arch);
146148

149+
private static boolean isApplicable(InvocationPlugin plugin, Architecture arch) {
150+
if (plugin == null) {
151+
return false;
152+
}
153+
if (plugin instanceof ConditionalInvocationPlugin conditionalInvocationPlugin) {
154+
return conditionalInvocationPlugin.isApplicable(arch);
155+
}
156+
return true;
157+
}
158+
147159
@Test
148160
public void test() throws ClassNotFoundException, NoSuchFieldException {
149161
HotSpotProviders providers = rt.getHostBackend().getProviders();
@@ -170,12 +182,10 @@ public void test() throws ClassNotFoundException, NoSuchFieldException {
170182

171183
InvocationPlugin plugin = invocationPlugins.lookupInvocation(method, Graal.getRequiredCapability(OptionValues.class));
172184
String m = String.format("%s.%s%s", intrinsic.declaringClass, intrinsic.name, intrinsic.descriptor);
173-
if (plugin == null) {
174-
if (method != null) {
175-
IntrinsicMethod intrinsicMethod = providers.getConstantReflection().getMethodHandleAccess().lookupMethodHandleIntrinsic(method);
176-
if (intrinsicMethod != null) {
177-
continue;
178-
}
185+
if (!isApplicable(plugin, providers.getLowerer().getTarget().arch)) {
186+
IntrinsicMethod intrinsicMethod = providers.getConstantReflection().getMethodHandleAccess().lookupMethodHandleIntrinsic(method);
187+
if (intrinsicMethod != null) {
188+
continue;
179189
}
180190
if (!unimplementedGraalIntrinsics.isDocumented(m) && isIntrinsicAvailable(intrinsic) && isIntrinsicSupportedByC2(intrinsic)) {
181191
missing.add(m);

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/ArrayUtilsIndexOfWithMaskTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@ public class ArrayUtilsIndexOfWithMaskTest extends GraalCompilerTest {
4242

4343
@Override
4444
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
45-
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins, getReplacements());
45+
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins);
4646
super.registerInvocationPlugins(invocationPlugins);
4747
}
4848

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/ArrayUtilsRegionEqualsWithMaskConstantTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class ArrayUtilsRegionEqualsWithMaskConstantTest extends GraalCompilerTes
5858

5959
@Override
6060
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
61-
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins, getReplacements());
61+
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins);
6262
super.registerInvocationPlugins(invocationPlugins);
6363
}
6464

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/ArrayUtilsRegionEqualsWithMaskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ArrayUtilsRegionEqualsWithMaskTest extends GraalCompilerTest {
4141

4242
@Override
4343
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
44-
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins, getReplacements());
44+
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins);
4545
super.registerInvocationPlugins(invocationPlugins);
4646
}
4747

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/ArrayUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ArrayUtilsTest extends GraalCompilerTest {
4141

4242
@Override
4343
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
44-
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins, getReplacements());
44+
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins);
4545
super.registerInvocationPlugins(invocationPlugins);
4646
}
4747

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/ExactMathTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ExactMathTest extends TruffleCompilerImplTest {
4141

4242
@Override
4343
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
44-
TruffleGraphBuilderPlugins.registerExactMathPlugins(invocationPlugins, getTypes(), getReplacements(), getLowerer());
44+
TruffleGraphBuilderPlugins.registerExactMathPlugins(invocationPlugins, getTypes());
4545
super.registerInvocationPlugins(invocationPlugins);
4646
}
4747

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/strings/TStringTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected void addConstantParameterBinding(GraphBuilderConfiguration conf, Objec
6262

6363
@Override
6464
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
65-
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins, getReplacements());
65+
TruffleInvocationPlugins.register(getBackend().getTarget().arch, invocationPlugins);
6666
super.registerInvocationPlugins(invocationPlugins);
6767
}
6868

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64BaseAssembler.java

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -52,8 +52,6 @@
5252

5353
import java.util.EnumSet;
5454

55-
import org.graalvm.collections.EconomicSet;
56-
5755
import jdk.graal.compiler.asm.Assembler;
5856
import jdk.graal.compiler.core.common.Stride;
5957
import jdk.graal.compiler.debug.GraalError;
@@ -308,35 +306,6 @@ public final boolean supports(CPUFeature feature) {
308306
return getFeatures().contains(feature);
309307
}
310308

311-
public final boolean supports(String feature) {
312-
try {
313-
return getFeatures().contains(AMD64.CPUFeature.valueOf(feature));
314-
} catch (IllegalArgumentException e) {
315-
return false;
316-
}
317-
}
318-
319-
/**
320-
* Mitigates exception throwing by recording unknown CPU feature names.
321-
*/
322-
private final EconomicSet<String> unknownFeatures = EconomicSet.create();
323-
324-
/**
325-
* Determines if the CPU feature denoted by {@code name} is supported. This name based look up
326-
* is for features only available in later JVMCI releases.
327-
*/
328-
public final boolean supportsCPUFeature(String name) {
329-
if (unknownFeatures.contains(name)) {
330-
return false;
331-
}
332-
try {
333-
return supports(CPUFeature.valueOf(name));
334-
} catch (IllegalArgumentException e) {
335-
unknownFeatures.add(name);
336-
return false;
337-
}
338-
}
339-
340309
protected static boolean inRC(RegisterCategory rc, Register r) {
341310
return r.getRegisterCategory().equals(rc);
342311
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/aarch64/AArch64LIRGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ public void emitArrayCopyWithConversion(EnumSet<?> runtimeCheckedCPUFeatures, Va
633633
}
634634

635635
@Override
636-
public void emitArrayFill(JavaKind kind, EnumSet<?> runtimeCheckedCPUFeatures, Value array, Value arrayBaseOffset, Value length, Value value) {
636+
public void emitArrayFill(JavaKind kind, Value array, Value arrayBaseOffset, Value length, Value value) {
637637
append(new AArch64ArrayFillOp(kind, emitConvertNullToZero(array), asAllocatable(arrayBaseOffset), asAllocatable(length), asAllocatable(value)));
638638
}
639639

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/aarch64/AArch64LoweringProviderMixin.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ default boolean supportsBulkZeroingOfEden() {
4747
return true;
4848
}
4949

50-
@Override
51-
default boolean supportsRounding() {
52-
return true;
53-
}
54-
5550
@Override
5651
default boolean writesStronglyOrdered() {
5752
/* AArch64 only requires a weak memory model. */
@@ -88,14 +83,4 @@ default boolean supportsFoldingExtendIntoAccess(ExtendableMemoryAccess access, M
8883
}
8984
return false;
9085
}
91-
92-
@Override
93-
default boolean supportsFloatToUnsignedConvert() {
94-
return true;
95-
}
96-
97-
@Override
98-
default boolean supportsUnsignedToFloatConvert() {
99-
return true;
100-
}
10186
}

0 commit comments

Comments
 (0)