533 }
534
535 public static boolean isIntrinsicName(GraalHotSpotVMConfig config, String className, String name) {
536 for (VMIntrinsicMethod intrinsic : config.getStore().getIntrinsics()) {
537 if (className.equals(intrinsic.declaringClass)) {
538 if (name.equals(intrinsic.name)) {
539 return true;
540 }
541 }
542 }
543 return false;
544 }
545
546 private static void registerAESPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
547 if (config.useAESIntrinsics) {
548 assert config.aescryptEncryptBlockStub != 0L;
549 assert config.aescryptDecryptBlockStub != 0L;
550 assert config.cipherBlockChainingEncryptAESCryptStub != 0L;
551 assert config.cipherBlockChainingDecryptAESCryptStub != 0L;
552 String arch = config.osArch;
553 String decryptSuffix = "";
554
555 Registration r = new Registration(plugins, "com.sun.crypto.provider.CipherBlockChaining", replacements);
556
557 Pair<String, String> cbcEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implEncrypt", "encrypt");
558 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcEncryptName, Receiver.class, byte[].class, int.class, int.class,
559 byte[].class, int.class);
560
561 Pair<String, String> cbcDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implDecrypt", "decrypt");
562 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcDecryptName, cbcDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, int.class,
563 byte[].class, int.class);
564
565 r = new Registration(plugins, "com.sun.crypto.provider.AESCrypt", replacements);
566
567 Pair<String, String> aesEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implEncryptBlock", "encryptBlock");
568 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesEncryptName, Receiver.class, byte[].class, int.class, byte[].class, int.class);
569
570 Pair<String, String> aesDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implDecryptBlock", "decryptBlock");
571 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesDecryptName, aesDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, byte[].class, int.class);
572 }
573 }
574
575 private static void registerAndCheckMismatch(Registration r, Class<?> substitutionClass, Pair<String, String> intrinsicNames, Type... argumentTypes) {
576 try {
577 r.registerMethodSubstitution(substitutionClass, intrinsicNames.getLeft(), argumentTypes);
578 } catch (NoSuchMethodError e) {
579 throw new GraalError(e, "Found method named '%s' instead of '%s' in class '%s'. This is most likely because the JVMCI JDK in %s was built on an incompatible base JDK.",
580 intrinsicNames.getRight(), intrinsicNames.getLeft(), r.getDeclaringType().getTypeName(), Services.getSavedProperties().get("java.home"));
581 }
582 }
583
584 private static void registerAndCheckMismatch(Registration r, Class<?> substitutionClass, Pair<String, String> intrinsicNames, String substituteName, Type... argumentTypes) {
585 try {
586 r.registerMethodSubstitution(substitutionClass, intrinsicNames.getLeft(), substituteName, argumentTypes);
587 } catch (NoSuchMethodError e) {
588 throw new GraalError(e, "Found method named '%s' instead of '%s' in class '%s'. This is most likely because the JVMCI JDK in %s was built on an incompatible base JDK.",
589 intrinsicNames.getRight(), intrinsicNames.getLeft(), r.getDeclaringType().getTypeName(), Services.getSavedProperties().get("java.home"));
590 }
591 }
|
533 }
534
535 public static boolean isIntrinsicName(GraalHotSpotVMConfig config, String className, String name) {
536 for (VMIntrinsicMethod intrinsic : config.getStore().getIntrinsics()) {
537 if (className.equals(intrinsic.declaringClass)) {
538 if (name.equals(intrinsic.name)) {
539 return true;
540 }
541 }
542 }
543 return false;
544 }
545
546 private static void registerAESPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
547 if (config.useAESIntrinsics) {
548 assert config.aescryptEncryptBlockStub != 0L;
549 assert config.aescryptDecryptBlockStub != 0L;
550 assert config.cipherBlockChainingEncryptAESCryptStub != 0L;
551 assert config.cipherBlockChainingDecryptAESCryptStub != 0L;
552 String arch = config.osArch;
553
554 Registration r = new Registration(plugins, "com.sun.crypto.provider.CipherBlockChaining", replacements);
555
556 Pair<String, String> cbcEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implEncrypt", "encrypt");
557 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcEncryptName, Receiver.class, byte[].class, int.class, int.class,
558 byte[].class, int.class);
559
560 Pair<String, String> cbcDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implDecrypt", "decrypt");
561 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcDecryptName, cbcDecryptName.getLeft(), Receiver.class, byte[].class, int.class, int.class,
562 byte[].class, int.class);
563
564 r = new Registration(plugins, "com.sun.crypto.provider.AESCrypt", replacements);
565
566 Pair<String, String> aesEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implEncryptBlock", "encryptBlock");
567 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesEncryptName, Receiver.class, byte[].class, int.class, byte[].class, int.class);
568
569 Pair<String, String> aesDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implDecryptBlock", "decryptBlock");
570 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesDecryptName, aesDecryptName.getLeft(), Receiver.class, byte[].class, int.class, byte[].class, int.class);
571 }
572 }
573
574 private static void registerAndCheckMismatch(Registration r, Class<?> substitutionClass, Pair<String, String> intrinsicNames, Type... argumentTypes) {
575 try {
576 r.registerMethodSubstitution(substitutionClass, intrinsicNames.getLeft(), argumentTypes);
577 } catch (NoSuchMethodError e) {
578 throw new GraalError(e, "Found method named '%s' instead of '%s' in class '%s'. This is most likely because the JVMCI JDK in %s was built on an incompatible base JDK.",
579 intrinsicNames.getRight(), intrinsicNames.getLeft(), r.getDeclaringType().getTypeName(), Services.getSavedProperties().get("java.home"));
580 }
581 }
582
583 private static void registerAndCheckMismatch(Registration r, Class<?> substitutionClass, Pair<String, String> intrinsicNames, String substituteName, Type... argumentTypes) {
584 try {
585 r.registerMethodSubstitution(substitutionClass, intrinsicNames.getLeft(), substituteName, argumentTypes);
586 } catch (NoSuchMethodError e) {
587 throw new GraalError(e, "Found method named '%s' instead of '%s' in class '%s'. This is most likely because the JVMCI JDK in %s was built on an incompatible base JDK.",
588 intrinsicNames.getRight(), intrinsicNames.getLeft(), r.getDeclaringType().getTypeName(), Services.getSavedProperties().get("java.home"));
589 }
590 }
|