< prev index next >

test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java

Print this page

  1 /*
  2  * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */

 51      */
 52     private static final BooleanSupplier COMPILABLE_BY_C2 = () -> {
 53         boolean isTiered = IntrinsicPredicates.WHITE_BOX.getBooleanVMFlag(
 54                 "TieredCompilation");
 55         long tieredMaxLevel = IntrinsicPredicates.WHITE_BOX.getIntxVMFlag(
 56                 "TieredStopAtLevel");
 57         boolean maxLevelIsReachable = (tieredMaxLevel
 58                 == IntrinsicPredicates.TIERED_MAX_LEVEL);
 59         return Platform.isServer() && !Platform.isEmulatedClient() && (!isTiered || maxLevelIsReachable);
 60     };
 61 
 62     public static final BooleanSupplier MD5_INSTRUCTION_AVAILABLE
 63             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", null, null),
 64               // x86 variants
 65               new OrPredicate(new CPUSpecificPredicate("amd64.*",   null, null),
 66               new OrPredicate(new CPUSpecificPredicate("i386.*",    null, null),
 67                               new CPUSpecificPredicate("x86.*",     null, null))));
 68 
 69     public static final BooleanSupplier SHA1_INSTRUCTION_AVAILABLE
 70             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" }, null),

 71               new OrPredicate(new CPUSpecificPredicate("s390.*",    new String[] { "sha1" }, null),
 72               // x86 variants
 73               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "sha" },  null),
 74               new OrPredicate(new CPUSpecificPredicate("i386.*",    new String[] { "sha" },  null),
 75                               new CPUSpecificPredicate("x86.*",     new String[] { "sha" },  null)))));
 76 
 77     public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE
 78             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha256"       }, null),

 79               new OrPredicate(new CPUSpecificPredicate("s390.*",    new String[] { "sha256"       }, null),
 80               new OrPredicate(new CPUSpecificPredicate("ppc64.*",   new String[] { "sha"          }, null),
 81               new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha"          }, null),
 82               // x86 variants
 83               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "sha"          }, null),
 84               new OrPredicate(new CPUSpecificPredicate("i386.*",    new String[] { "sha"          }, null),
 85               new OrPredicate(new CPUSpecificPredicate("x86.*",     new String[] { "sha"          }, null),
 86               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "avx2", "bmi2" }, null),
 87                               new CPUSpecificPredicate("x86_64",    new String[] { "avx2", "bmi2" }, null)))))))));
 88 
 89     public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE
 90             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha512"       }, null),

 91               new OrPredicate(new CPUSpecificPredicate("s390.*",    new String[] { "sha512"       }, null),
 92               new OrPredicate(new CPUSpecificPredicate("ppc64.*",   new String[] { "sha"          }, null),
 93               new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha"          }, null),
 94               // x86 variants
 95               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "sha"          }, null),
 96               new OrPredicate(new CPUSpecificPredicate("i386.*",    new String[] { "sha"          }, null),
 97               new OrPredicate(new CPUSpecificPredicate("x86.*",     new String[] { "sha"          }, null),
 98               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "avx2", "bmi2" }, null),
 99                               new CPUSpecificPredicate("x86_64",    new String[] { "avx2", "bmi2" }, null)))))))));
100 
101     public static final BooleanSupplier SHA3_INSTRUCTION_AVAILABLE
102             // sha3 is only implemented on aarch64 for now
103             = new CPUSpecificPredicate("aarch64.*", new String[] {"sha3"          }, null);
104 
105     public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE
106             = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE,
107               new OrPredicate(IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE,
108               new OrPredicate(IntrinsicPredicates.SHA512_INSTRUCTION_AVAILABLE, IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE)));
109 
110     public static BooleanSupplier isMD5IntrinsicAvailable() {
111         return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
112                                 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.MD5", "implCompress0"));
113     }
114 
115     public static BooleanSupplier isSHA1IntrinsicAvailable() {
116         return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
117                                 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA", "implCompress0"));
118     }
119 

  1 /*
  2  * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */

 51      */
 52     private static final BooleanSupplier COMPILABLE_BY_C2 = () -> {
 53         boolean isTiered = IntrinsicPredicates.WHITE_BOX.getBooleanVMFlag(
 54                 "TieredCompilation");
 55         long tieredMaxLevel = IntrinsicPredicates.WHITE_BOX.getIntxVMFlag(
 56                 "TieredStopAtLevel");
 57         boolean maxLevelIsReachable = (tieredMaxLevel
 58                 == IntrinsicPredicates.TIERED_MAX_LEVEL);
 59         return Platform.isServer() && !Platform.isEmulatedClient() && (!isTiered || maxLevelIsReachable);
 60     };
 61 
 62     public static final BooleanSupplier MD5_INSTRUCTION_AVAILABLE
 63             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", null, null),
 64               // x86 variants
 65               new OrPredicate(new CPUSpecificPredicate("amd64.*",   null, null),
 66               new OrPredicate(new CPUSpecificPredicate("i386.*",    null, null),
 67                               new CPUSpecificPredicate("x86.*",     null, null))));
 68 
 69     public static final BooleanSupplier SHA1_INSTRUCTION_AVAILABLE
 70             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" }, null),
 71               new OrPredicate(new CPUSpecificPredicate("riscv64.*", new String[] { "sha1" }, null),
 72               new OrPredicate(new CPUSpecificPredicate("s390.*",    new String[] { "sha1" }, null),
 73               // x86 variants
 74               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "sha" },  null),
 75               new OrPredicate(new CPUSpecificPredicate("i386.*",    new String[] { "sha" },  null),
 76                               new CPUSpecificPredicate("x86.*",     new String[] { "sha" },  null))))));
 77 
 78     public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE
 79             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha256"       }, null),
 80               new OrPredicate(new CPUSpecificPredicate("riscv64.*", new String[] { "sha256"       }, null),
 81               new OrPredicate(new CPUSpecificPredicate("s390.*",    new String[] { "sha256"       }, null),
 82               new OrPredicate(new CPUSpecificPredicate("ppc64.*",   new String[] { "sha"          }, null),
 83               new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha"          }, null),
 84               // x86 variants
 85               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "sha"          }, null),
 86               new OrPredicate(new CPUSpecificPredicate("i386.*",    new String[] { "sha"          }, null),
 87               new OrPredicate(new CPUSpecificPredicate("x86.*",     new String[] { "sha"          }, null),
 88               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "avx2", "bmi2" }, null),
 89                               new CPUSpecificPredicate("x86_64",    new String[] { "avx2", "bmi2" }, null))))))))));
 90 
 91     public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE
 92             = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha512"       }, null),
 93               new OrPredicate(new CPUSpecificPredicate("riscv64.*", new String[] { "sha512"       }, null),
 94               new OrPredicate(new CPUSpecificPredicate("s390.*",    new String[] { "sha512"       }, null),
 95               new OrPredicate(new CPUSpecificPredicate("ppc64.*",   new String[] { "sha"          }, null),
 96               new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha"          }, null),
 97               // x86 variants
 98               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "sha"          }, null),
 99               new OrPredicate(new CPUSpecificPredicate("i386.*",    new String[] { "sha"          }, null),
100               new OrPredicate(new CPUSpecificPredicate("x86.*",     new String[] { "sha"          }, null),
101               new OrPredicate(new CPUSpecificPredicate("amd64.*",   new String[] { "avx2", "bmi2" }, null),
102                               new CPUSpecificPredicate("x86_64",    new String[] { "avx2", "bmi2" }, null))))))))));
103 
104     public static final BooleanSupplier SHA3_INSTRUCTION_AVAILABLE
105             // sha3 is only implemented on aarch64 for now
106             = new CPUSpecificPredicate("aarch64.*", new String[] {"sha3"          }, null);
107 
108     public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE
109             = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE,
110               new OrPredicate(IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE,
111               new OrPredicate(IntrinsicPredicates.SHA512_INSTRUCTION_AVAILABLE, IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE)));
112 
113     public static BooleanSupplier isMD5IntrinsicAvailable() {
114         return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
115                                 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.MD5", "implCompress0"));
116     }
117 
118     public static BooleanSupplier isSHA1IntrinsicAvailable() {
119         return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2,
120                                 IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA", "implCompress0"));
121     }
122 
< prev index next >