80 new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" }, null),
81 // x86 variants
82 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" }, null),
83 new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" }, null),
84 new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" }, null),
85 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null),
86 new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null)))))))));
87
88 public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE
89 = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha512" }, null),
90 new OrPredicate(new CPUSpecificPredicate("s390.*", new String[] { "sha512" }, null),
91 new OrPredicate(new CPUSpecificPredicate("ppc64.*", new String[] { "sha" }, null),
92 new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" }, null),
93 // x86 variants
94 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" }, null),
95 new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" }, null),
96 new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" }, null),
97 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null),
98 new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null)))))))));
99
100 public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE
101 = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE,
102 new OrPredicate(
103 IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE,
104 IntrinsicPredicates.SHA512_INSTRUCTION_AVAILABLE));
105
106 public static BooleanSupplier isMD5IntrinsicAvailable() {
107 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
108 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.MD5", "implCompress0"));
109 }
110
111 public static BooleanSupplier isSHA1IntrinsicAvailable() {
112 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
113 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA", "implCompress0"));
114 }
115
116 public static BooleanSupplier isSHA256IntrinsicAvailable() {
117 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
118 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA2", "implCompress0"));
119 }
120
121 public static BooleanSupplier isSHA512IntrinsicAvailable() {
122 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
123 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA5", "implCompress0"));
124 }
125
126 private static BooleanSupplier isIntrinsicAvailable(String klass, String method) {
127 try {
128 Method m = Class.forName(klass).getDeclaredMethod(method, byte[].class, int.class);
129 return () -> WHITE_BOX.isIntrinsicAvailable(m, (int)IntrinsicPredicates.TIERED_MAX_LEVEL);
130 } catch (Exception e) {
131 throw new RuntimeException("Intrinsified method " + klass + "::" + method + " not found!");
132 }
133 };
134 }
|
80 new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" }, null),
81 // x86 variants
82 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" }, null),
83 new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" }, null),
84 new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" }, null),
85 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null),
86 new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null)))))))));
87
88 public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE
89 = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha512" }, null),
90 new OrPredicate(new CPUSpecificPredicate("s390.*", new String[] { "sha512" }, null),
91 new OrPredicate(new CPUSpecificPredicate("ppc64.*", new String[] { "sha" }, null),
92 new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" }, null),
93 // x86 variants
94 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" }, null),
95 new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" }, null),
96 new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" }, null),
97 new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null),
98 new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null)))))))));
99
100 public static final BooleanSupplier SHA3_INSTRUCTION_AVAILABLE
101 // sha3 is only implemented on aarch64 for now
102 = new CPUSpecificPredicate("aarch64.*", new String[] {"sha3" }, null);
103
104 public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE
105 = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE,
106 new OrPredicate(IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE,
107 new OrPredicate(IntrinsicPredicates.SHA512_INSTRUCTION_AVAILABLE, IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE)));
108
109 public static BooleanSupplier isMD5IntrinsicAvailable() {
110 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
111 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.MD5", "implCompress0"));
112 }
113
114 public static BooleanSupplier isSHA1IntrinsicAvailable() {
115 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
116 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA", "implCompress0"));
117 }
118
119 public static BooleanSupplier isSHA256IntrinsicAvailable() {
120 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
121 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA2", "implCompress0"));
122 }
123
124 public static BooleanSupplier isSHA512IntrinsicAvailable() {
125 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
126 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA5", "implCompress0"));
127 }
128
129 public static BooleanSupplier isSHA3IntrinsicAvailable() {
130 return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
131 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA3", "implCompress0"));
132 }
133
134 private static BooleanSupplier isIntrinsicAvailable(String klass, String method) {
135 try {
136 Method m = Class.forName(klass).getDeclaredMethod(method, byte[].class, int.class);
137 return () -> WHITE_BOX.isIntrinsicAvailable(m, (int)IntrinsicPredicates.TIERED_MAX_LEVEL);
138 } catch (Exception e) {
139 throw new RuntimeException("Intrinsified method " + klass + "::" + method + " not found!");
140 }
141 };
142 }
|