hotspot/test/compiler/intrinsics/mathexact/sanity/MathIntrinsic.java
author dpochepk
Fri, 06 Nov 2015 14:54:02 +0300
changeset 34155 8d9e0cbf93a2
parent 31962 d05e0a4d1b43
child 40059 c2304140ed64
permissions -rw-r--r--
8138689: use package for /compiler/whitebox common classes Summary: Moved CompilerWhiteBoxTest to package, updating tests accordingly Reviewed-by: iignatyev
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     1
/*
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     4
 *
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     8
 *
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    14
 *
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    18
 *
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    21
 * questions.
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    22
 */
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    23
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    24
import java.lang.reflect.Executable;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    25
import java.util.concurrent.Callable;
34155
8d9e0cbf93a2 8138689: use package for /compiler/whitebox common classes
dpochepk
parents: 31962
diff changeset
    26
import compiler.whitebox.CompilerWhiteBoxTest;
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    27
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    28
public class MathIntrinsic {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    29
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    30
    enum IntIntrinsic implements CompilerWhiteBoxTest.TestCase {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    31
        Add {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    32
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    33
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    34
                return Class.forName("java.lang.Math").getDeclaredMethod("addExact", int.class, int.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    35
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    36
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    37
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    38
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    39
                return intR = Math.addExact(int1, int2);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    40
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    41
        },
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    42
       Subtract {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    43
            @Override
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    44
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    45
                return Class.forName("java.lang.Math").getDeclaredMethod("subtractExact", int.class, int.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    46
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    47
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    48
            @Override
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    49
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    50
                return intR = Math.subtractExact(int1, int2);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    51
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    52
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    53
        Multiply {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    54
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    55
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    56
                return Class.forName("java.lang.Math").getDeclaredMethod("multiplyExact", int.class, int.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    57
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    58
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    59
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    60
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    61
                return intR = Math.multiplyExact(int1, int2);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    62
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    63
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    64
        Increment {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    65
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    66
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    67
                return Class.forName("java.lang.Math").getDeclaredMethod("incrementExact", int.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    68
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    69
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    70
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    71
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    72
                return intR = Math.incrementExact(int1);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    73
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    74
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    75
        Decrement {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    76
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    77
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    78
                return Class.forName("java.lang.Math").getDeclaredMethod("decrementExact", int.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    79
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    80
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    81
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    82
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    83
                return intR = Math.decrementExact(int1);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    84
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    85
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    86
        Negate {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    87
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    88
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    89
                return Class.forName("java.lang.Math").getDeclaredMethod("negateExact", int.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    90
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    91
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    92
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    93
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    94
                return intR = Math.negateExact(int1);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    95
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    96
        };
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
    97
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    98
        protected int int1;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
    99
        protected int int2;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   100
        protected int intR;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   101
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   102
        abstract Executable testMethod() throws NoSuchMethodException, ClassNotFoundException;
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   103
        abstract Object execMathMethod();
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   104
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   105
        public Executable getTestMethod() {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   106
            try {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   107
                return testMethod();
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   108
            } catch (NoSuchMethodException e) {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   109
                throw new RuntimeException("Test bug, no such method: " + e);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   110
            } catch (ClassNotFoundException e) {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   111
                throw new RuntimeException("Test bug, no such class: " + e);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   112
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   113
        }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   114
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   115
        @Override
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   116
        public Executable getExecutable() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   117
            try {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   118
                return getClass().getDeclaredMethod("execMathMethod");
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   119
            } catch (NoSuchMethodException e) {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   120
                throw new RuntimeException("Test bug, no such method: " + e);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   121
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   122
        }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   123
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   124
        @Override
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   125
        public Callable<Integer> getCallable() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   126
            return null;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   127
        }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   128
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   129
        @Override
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   130
        public boolean isOsr() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   131
            return false;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   132
        }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   133
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   134
    }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   135
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   136
    enum LongIntrinsic implements CompilerWhiteBoxTest.TestCase {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   137
        Add {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   138
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   139
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   140
                return Class.forName("java.lang.Math").getDeclaredMethod("addExact", long.class, long.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   141
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   142
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   143
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   144
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   145
                return longR = Math.addExact(long1, long2);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   146
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   147
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   148
        Subtract {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   149
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   150
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   151
                return Class.forName("java.lang.Math").getDeclaredMethod("subtractExact", long.class, long.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   152
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   153
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   154
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   155
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   156
                return longR = Math.subtractExact(long1, long2);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   157
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   158
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   159
        Multiply {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   160
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   161
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   162
                return Class.forName("java.lang.Math").getDeclaredMethod("multiplyExact", long.class, long.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   163
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   164
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   165
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   166
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   167
                return longR = Math.multiplyExact(long1, long2);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   168
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   169
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   170
        Increment {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   171
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   172
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   173
                return Class.forName("java.lang.Math").getDeclaredMethod("incrementExact", long.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   174
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   175
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   176
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   177
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   178
                return longR = Math.incrementExact(long1);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   179
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   180
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   181
        Decrement {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   182
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   183
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   184
                return Class.forName("java.lang.Math").getDeclaredMethod("decrementExact", long.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   185
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   186
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   187
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   188
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   189
                return longR = Math.decrementExact(long1);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   190
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   191
        },
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   192
        Negate {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   193
            @Override
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   194
            Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   195
                return Class.forName("java.lang.Math").getDeclaredMethod("negateExact", long.class);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   196
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   197
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   198
            @Override
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   199
            Object execMathMethod() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   200
                return longR = Math.negateExact(long1);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   201
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   202
        };
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   203
        protected long long1;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   204
        protected long long2;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   205
        protected long longR;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   206
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   207
        abstract Executable testMethod() throws NoSuchMethodException, ClassNotFoundException;
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   208
        abstract Object execMathMethod();
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   209
31962
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   210
        public Executable getTestMethod() {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   211
            try {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   212
                return testMethod();
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   213
            } catch (NoSuchMethodException e) {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   214
                throw new RuntimeException("Test bug, no such method: " + e);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   215
            } catch (ClassNotFoundException e) {
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   216
                throw new RuntimeException("Test bug, no such class: " + e);
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   217
            }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   218
        }
d05e0a4d1b43 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 22214
diff changeset
   219
22214
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   220
        @Override
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   221
        public Executable getExecutable() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   222
            try {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   223
                return getClass().getDeclaredMethod("execMathMethod");
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   224
            } catch (NoSuchMethodException e) {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   225
                throw new RuntimeException("Test bug, no such method: " + e);
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   226
            }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   227
        }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   228
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   229
        @Override
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   230
        public Callable<Integer> getCallable() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   231
            return null;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   232
        }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   233
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   234
        @Override
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   235
        public boolean isOsr() {
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   236
            return false;
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   237
        }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   238
    }
c551021e75b2 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
diff changeset
   239
}