< prev index next >

test/hotspot/jtreg/compiler/intrinsics/sha/cli/SHAOptionsBase.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 2016, 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  */


  57     protected static final String SHA1_INTRINSICS_ARE_NOT_AVAILABLE
  58             = "Intrinsics for SHA-1 crypto hash functions not available on this CPU.";
  59     protected static final String SHA256_INTRINSICS_ARE_NOT_AVAILABLE
  60             = "Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.";
  61     protected static final String SHA512_INTRINSICS_ARE_NOT_AVAILABLE
  62             = "Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.";
  63 
  64     private final TestCase[] testCases;
  65 
  66     /**
  67      * Returns warning message that should occur in VM output if an option with
  68      * the name {@code optionName} was turned on and CPU does not support
  69      * required instructions.
  70      *
  71      * @param optionName The name of the option for which warning message should
  72      *                   be returned.
  73      * @return A warning message that will be printed out to VM output if CPU
  74      *         instructions required by the option are not supported.
  75      */
  76     public static String getWarningForUnsupportedCPU(String optionName) {
  77         if (Platform.isAArch64() || Platform.isS390x() || Platform.isSparc()
  78             || Platform.isX64() || Platform.isX86() || Platform.isPPC()) {
  79             switch (optionName) {
  80             case SHAOptionsBase.USE_SHA_OPTION:
  81                 return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
  82             case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
  83                 return SHAOptionsBase.SHA1_INTRINSICS_ARE_NOT_AVAILABLE;
  84             case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
  85                 return SHAOptionsBase.SHA256_INTRINSICS_ARE_NOT_AVAILABLE;
  86             case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
  87                 return SHAOptionsBase.SHA512_INTRINSICS_ARE_NOT_AVAILABLE;
  88             default:
  89                 throw new Error("Unexpected option " + optionName);
  90             }
  91         } else {
  92             throw new Error("Support for CPUs different from AARCH64, S390x,"
  93                             + " SPARC, X86, and PPC is not implemented");
  94         }
  95     }
  96 
  97     /**
  98      * Returns the predicate indicating whether or not CPU instructions required
  99      * by the option with name {@code optionName} are available.
 100      *
 101      * @param optionName The name of the option for which a predicate should be
 102      *                   returned.
 103      * @return The predicate on availability of CPU instructions required by the
 104      *         option.
 105      */
 106     public static BooleanSupplier getPredicateForOption(String optionName) {
 107         switch (optionName) {
 108             case SHAOptionsBase.USE_SHA_OPTION:
 109                 return IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE;
 110             case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
 111                 return IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE;
 112             case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
 113                 return IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE;


   1 /*
   2  * Copyright (c) 2014, 2019, 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  */


  57     protected static final String SHA1_INTRINSICS_ARE_NOT_AVAILABLE
  58             = "Intrinsics for SHA-1 crypto hash functions not available on this CPU.";
  59     protected static final String SHA256_INTRINSICS_ARE_NOT_AVAILABLE
  60             = "Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.";
  61     protected static final String SHA512_INTRINSICS_ARE_NOT_AVAILABLE
  62             = "Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.";
  63 
  64     private final TestCase[] testCases;
  65 
  66     /**
  67      * Returns warning message that should occur in VM output if an option with
  68      * the name {@code optionName} was turned on and CPU does not support
  69      * required instructions.
  70      *
  71      * @param optionName The name of the option for which warning message should
  72      *                   be returned.
  73      * @return A warning message that will be printed out to VM output if CPU
  74      *         instructions required by the option are not supported.
  75      */
  76     public static String getWarningForUnsupportedCPU(String optionName) {


  77         switch (optionName) {
  78         case SHAOptionsBase.USE_SHA_OPTION:
  79             return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
  80         case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
  81             return SHAOptionsBase.SHA1_INTRINSICS_ARE_NOT_AVAILABLE;
  82         case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
  83             return SHAOptionsBase.SHA256_INTRINSICS_ARE_NOT_AVAILABLE;
  84         case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
  85             return SHAOptionsBase.SHA512_INTRINSICS_ARE_NOT_AVAILABLE;
  86         default:
  87             throw new Error("Unexpected option " + optionName);




  88         }
  89     }
  90 
  91     /**
  92      * Returns the predicate indicating whether or not CPU instructions required
  93      * by the option with name {@code optionName} are available.
  94      *
  95      * @param optionName The name of the option for which a predicate should be
  96      *                   returned.
  97      * @return The predicate on availability of CPU instructions required by the
  98      *         option.
  99      */
 100     public static BooleanSupplier getPredicateForOption(String optionName) {
 101         switch (optionName) {
 102             case SHAOptionsBase.USE_SHA_OPTION:
 103                 return IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE;
 104             case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
 105                 return IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE;
 106             case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
 107                 return IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE;


< prev index next >