Skip to content

Commit 211885d

Browse files
committed
svm: further adopt "JDK-8353786: Migrate Vector API math library support to FFM API"
1 parent 0ed087d commit 211885d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_vm_vector_VectorSupport.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
*/
2525
package com.oracle.svm.core.jdk;
2626

27+
import java.util.stream.Collectors;
28+
29+
import org.graalvm.nativeimage.ImageSingletons;
30+
2731
import com.oracle.svm.core.AlwaysInline;
32+
import com.oracle.svm.core.SubstrateTargetDescription;
2833
import com.oracle.svm.core.annotate.Alias;
2934
import com.oracle.svm.core.annotate.AnnotateOriginal;
3035
import com.oracle.svm.core.annotate.Delete;
@@ -33,6 +38,9 @@
3338
import com.oracle.svm.core.annotate.TargetClass;
3439
import com.oracle.svm.core.annotate.TargetElement;
3540

41+
import jdk.graal.compiler.api.replacements.Fold;
42+
import jdk.vm.ci.code.CPUFeatureName;
43+
3644
@TargetClass(className = "jdk.internal.vm.vector.VectorSupport")
3745
final class Target_jdk_internal_vm_vector_VectorSupport {
3846
@Delete
@@ -43,6 +51,24 @@ final class Target_jdk_internal_vm_vector_VectorSupport {
4351
private static int getMaxLaneCount(Class<?> etype) {
4452
return VectorAPISupport.singleton().getMaxLaneCount(etype);
4553
}
54+
55+
/**
56+
* Substitutes the native method with a constant string defined at build time.
57+
*/
58+
@Substitute
59+
@TargetElement(onlyWith = JDKLatest.class)
60+
public static String getCPUFeatures() {
61+
return Helper_jdk_internal_vm_vector_VectorSupport.getCPUFeatures();
62+
}
63+
}
64+
65+
final class Helper_jdk_internal_vm_vector_VectorSupport {
66+
@Fold
67+
public static String getCPUFeatures() {
68+
return ImageSingletons.lookup(SubstrateTargetDescription.class).arch.getFeatures().stream()
69+
.map(CPUFeatureName::name)
70+
.collect(Collectors.joining(","));
71+
}
4672
}
4773

4874
@TargetClass(className = "jdk.incubator.vector.LaneType", onlyWith = VectorAPIEnabled.class)

0 commit comments

Comments
 (0)