-
Enhancement
-
Resolution: Fixed
-
P1
-
9
-
b74
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8135567 | emb-9 | Zoltan Majo | P1 | Resolved | Fixed | team |
There is need to indicate java methods which are intrinsified by JVM:
- If such methods are modified corresponding code in JVM should also be modified if needed (we had cases in the past when intrinsics stop working and we get performance regression because signature of java method was modified without notifying Hotspot group).
- Intrinsics assume that all validation checks are done by java code. We want all calls to intrinsified methods precede by clearly related parameter validation function.
- Intrinsified java method preferably should be 'private' (which is effectively 'final').
- Intrinsified java method preferably should be 'static' (to discourage coupling of JVM to JDK-defined object layouts).
- JVM can add restriction to intrinsify only annotated methods to enforce annotation and presence of validation checks in java code.
For future maintainers, the above rules should be explained clearly in the javadoc for @HotSpotIntrinsicCandidate.
Here are suggested changes:
http://cr.openjdk.java.net/~kvn/AnnotationIntrinsic/webrev.jdk/
http://cr.openjdk.java.net/~kvn/AnnotationIntrinsic/webrev.hotspot/
The example of usage:
diff -r dd8d2a336f90 src/java.base/share/classes/java/math/BigInteger.java
--- a/src/java.base/share/classes/java/math/BigInteger.java Fri Mar 20 11:42:31 2015 -0700
+++ b/src/java.base/share/classes/java/math/BigInteger.java Thu Mar 26 12:23:06 2015 -0700
@@ -2857,6 +2857,33 @@
* Multiply an array by one word k and add to result, return the carry
*/
static int mulAdd(int[] out, int[] in, int offset, int len, int k) {
+ implMulAddCheck(out, in, offset, len, k);
+ return implMulAdd(out, in, offset, len, k);
+ }
+
+ /**
+ * Parameters validation.
+ */
+ private static void implMulAddCheck(int[] out, int[] in, int offset, int len, int k) {
+ if (len > in.length) {
+ throw newIllegalArgumentException("input length is out of bound: " + len + " > " + in.length);
+ }
+ if (offset < 0) {
+ throw newIllegalArgumentException("input offset is invalid: " + offset);
+ }
+ if (offset > (out.length - 1)) {
+ throw newIllegalArgumentException("input offset is out of bound: " + offset + " > " + (out.length - 1));
+ }
+ if (len > (out.length - offset)) {
+ throw newIllegalArgumentException("input len is out of bound: " + len + " > " + (out.length - offset));
+ }
+ }
+
+ /**
+ * Java Runtime may use intrinsic for this method.
+ */
+ @HotSpotIntrinsicCandidate
+ private static int implMulAdd(int[] out, int[] in, int offset, int len, int k) {
long kLong = k & LONG_MASK;
long carry = 0;
- backported by
-
JDK-8135567 Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
- Resolved
- relates to
-
JDK-8137173 @HotSpotIntrinsicCandidate is not Oracle-specific
- Resolved
-
JDK-8169529 AArch64: Revert old JDK-8167595 changes after JDK-8159035 fix is pushed
- Resolved
-
JDK-8132854 Adjust tier 1 and 2 definitions for nio-related intrinsics
- Resolved
-
JDK-8132855 Adjust tier 1 and 2 definitions for security-related intrinsics
- Resolved
-
JDK-8131326 Enable CheckIntrinsics in all types of builds
- Resolved
-
JDK-8179098 Crypto AES/ECB encryption/decryption performance regression (introduced in jdk9b73)
- Resolved