hotspot/src/cpu/aarch64/vm/bytecodeInterpreter_aarch64.inline.hpp
changeset 35214 d86005e0b4c2
parent 35211 3771329165d4
child 35215 f9536fc8548c
equal deleted inserted replaced
35211:3771329165d4 35214:d86005e0b4c2
     1 /*
       
     2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
       
     3  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
       
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     5  *
       
     6  * This code is free software; you can redistribute it and/or modify it
       
     7  * under the terms of the GNU General Public License version 2 only, as
       
     8  * published by the Free Software Foundation.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 2 along with this work; if not, write to the Free Software Foundation,
       
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    19  *
       
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    21  * or visit www.oracle.com if you need additional information or have any
       
    22  * questions.
       
    23  *
       
    24  */
       
    25 
       
    26 #ifndef CPU_AARCH64_VM_BYTECODEINTERPRETER_AARCH64_INLINE_HPP
       
    27 #define CPU_AARCH64_VM_BYTECODEINTERPRETER_AARCH64_INLINE_HPP
       
    28 
       
    29 // Inline interpreter functions for IA32
       
    30 
       
    31 inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; }
       
    32 inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; }
       
    33 inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; }
       
    34 inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; }
       
    35 inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return fmod(op1, op2); }
       
    36 
       
    37 inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; }
       
    38 
       
    39 inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) {
       
    40   return ( op1 < op2 ? -1 :
       
    41                op1 > op2 ? 1 :
       
    42                    op1 == op2 ? 0 :
       
    43                        (direction == -1 || direction == 1) ? direction : 0);
       
    44 
       
    45 }
       
    46 
       
    47 inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) {
       
    48   // x86 can do unaligned copies but not 64bits at a time
       
    49   to[0] = from[0]; to[1] = from[1];
       
    50 }
       
    51 
       
    52 // The long operations depend on compiler support for "long long" on x86
       
    53 
       
    54 inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
       
    55   return op1 + op2;
       
    56 }
       
    57 
       
    58 inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
       
    59   return op1 & op2;
       
    60 }
       
    61 
       
    62 inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
       
    63   // QQQ what about check and throw...
       
    64   return op1 / op2;
       
    65 }
       
    66 
       
    67 inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
       
    68   return op1 * op2;
       
    69 }
       
    70 
       
    71 inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
       
    72   return op1 | op2;
       
    73 }
       
    74 
       
    75 inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
       
    76   return op1 - op2;
       
    77 }
       
    78 
       
    79 inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
       
    80   return op1 ^ op2;
       
    81 }
       
    82 
       
    83 inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
       
    84   return op1 % op2;
       
    85 }
       
    86 
       
    87 inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
       
    88   // CVM did this 0x3f mask, is the really needed??? QQQ
       
    89   return ((unsigned long long) op1) >> (op2 & 0x3F);
       
    90 }
       
    91 
       
    92 inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
       
    93   return op1 >> (op2 & 0x3F);
       
    94 }
       
    95 
       
    96 inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
       
    97   return op1 << (op2 & 0x3F);
       
    98 }
       
    99 
       
   100 inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
       
   101   return -op;
       
   102 }
       
   103 
       
   104 inline jlong BytecodeInterpreter::VMlongNot(jlong op) {
       
   105   return ~op;
       
   106 }
       
   107 
       
   108 inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
       
   109   return (op <= 0);
       
   110 }
       
   111 
       
   112 inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
       
   113   return (op >= 0);
       
   114 }
       
   115 
       
   116 inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
       
   117   return (op == 0);
       
   118 }
       
   119 
       
   120 inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
       
   121   return (op1 == op2);
       
   122 }
       
   123 
       
   124 inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
       
   125   return (op1 != op2);
       
   126 }
       
   127 
       
   128 inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
       
   129   return (op1 >= op2);
       
   130 }
       
   131 
       
   132 inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
       
   133   return (op1 <= op2);
       
   134 }
       
   135 
       
   136 inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
       
   137   return (op1 < op2);
       
   138 }
       
   139 
       
   140 inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
       
   141   return (op1 > op2);
       
   142 }
       
   143 
       
   144 inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
       
   145   return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
       
   146 }
       
   147 
       
   148 // Long conversions
       
   149 
       
   150 inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
       
   151   return (jdouble) val;
       
   152 }
       
   153 
       
   154 inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
       
   155   return (jfloat) val;
       
   156 }
       
   157 
       
   158 inline jint BytecodeInterpreter::VMlong2Int(jlong val) {
       
   159   return (jint) val;
       
   160 }
       
   161 
       
   162 // Double Arithmetic
       
   163 
       
   164 inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
       
   165   return op1 + op2;
       
   166 }
       
   167 
       
   168 inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
       
   169   // Divide by zero... QQQ
       
   170   return op1 / op2;
       
   171 }
       
   172 
       
   173 inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
       
   174   return op1 * op2;
       
   175 }
       
   176 
       
   177 inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
       
   178   return -op;
       
   179 }
       
   180 
       
   181 inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
       
   182   return fmod(op1, op2);
       
   183 }
       
   184 
       
   185 inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
       
   186   return op1 - op2;
       
   187 }
       
   188 
       
   189 inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) {
       
   190   return ( op1 < op2 ? -1 :
       
   191                op1 > op2 ? 1 :
       
   192                    op1 == op2 ? 0 :
       
   193                        (direction == -1 || direction == 1) ? direction : 0);
       
   194 }
       
   195 
       
   196 // Double Conversions
       
   197 
       
   198 inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
       
   199   return (jfloat) val;
       
   200 }
       
   201 
       
   202 // Float Conversions
       
   203 
       
   204 inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
       
   205   return (jdouble) op;
       
   206 }
       
   207 
       
   208 // Integer Arithmetic
       
   209 
       
   210 inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
       
   211   return op1 + op2;
       
   212 }
       
   213 
       
   214 inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
       
   215   return op1 & op2;
       
   216 }
       
   217 
       
   218 inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
       
   219   /* it's possible we could catch this special case implicitly */
       
   220   if ((juint)op1 == 0x80000000 && op2 == -1) return op1;
       
   221   else return op1 / op2;
       
   222 }
       
   223 
       
   224 inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
       
   225   return op1 * op2;
       
   226 }
       
   227 
       
   228 inline jint BytecodeInterpreter::VMintNeg(jint op) {
       
   229   return -op;
       
   230 }
       
   231 
       
   232 inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
       
   233   return op1 | op2;
       
   234 }
       
   235 
       
   236 inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
       
   237   /* it's possible we could catch this special case implicitly */
       
   238   if ((juint)op1 == 0x80000000 && op2 == -1) return 0;
       
   239   else return op1 % op2;
       
   240 }
       
   241 
       
   242 inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
       
   243   return op1 << op2;
       
   244 }
       
   245 
       
   246 inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
       
   247   return op1 >> (op2 & 0x1f);
       
   248 }
       
   249 
       
   250 inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
       
   251   return op1 - op2;
       
   252 }
       
   253 
       
   254 inline jint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
       
   255   return ((juint) op1) >> (op2 & 0x1f);
       
   256 }
       
   257 
       
   258 inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
       
   259   return op1 ^ op2;
       
   260 }
       
   261 
       
   262 inline jdouble BytecodeInterpreter::VMint2Double(jint val) {
       
   263   return (jdouble) val;
       
   264 }
       
   265 
       
   266 inline jfloat BytecodeInterpreter::VMint2Float(jint val) {
       
   267   return (jfloat) val;
       
   268 }
       
   269 
       
   270 inline jlong BytecodeInterpreter::VMint2Long(jint val) {
       
   271   return (jlong) val;
       
   272 }
       
   273 
       
   274 inline jchar BytecodeInterpreter::VMint2Char(jint val) {
       
   275   return (jchar) val;
       
   276 }
       
   277 
       
   278 inline jshort BytecodeInterpreter::VMint2Short(jint val) {
       
   279   return (jshort) val;
       
   280 }
       
   281 
       
   282 inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
       
   283   return (jbyte) val;
       
   284 }
       
   285 
       
   286 #endif // CPU_AARCH64_VM_BYTECODEINTERPRETER_AARCH64_INLINE_HPP