src/cpu/ppc/vm/bytecodeInterpreter_ppc.inline.hpp

Wed, 15 Apr 2020 11:49:55 +0800

author
aoqi
date
Wed, 15 Apr 2020 11:49:55 +0800
changeset 9852
70aa912cebe5
parent 0
f90c822e73f8
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2012, 2013 SAP AG. 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  */
    26 #ifndef CPU_PPC_VM_BYTECODEINTERPRETER_PPC_INLINE_HPP
    27 #define CPU_PPC_VM_BYTECODEINTERPRETER_PPC_INLINE_HPP
    29 #ifdef CC_INTERP
    31 // Inline interpreter functions for ppc.
    33 #include <math.h>
    35 inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; }
    36 inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; }
    37 inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; }
    38 inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; }
    39 inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return (jfloat)fmod((double)op1, (double)op2); }
    41 inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; }
    43 inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) {
    44   return ( op1 < op2 ? -1 :
    45                op1 > op2 ? 1 :
    46                    op1 == op2 ? 0 :
    47                        (direction == -1 || direction == 1) ? direction : 0);
    49 }
    51 inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) {
    52   to[0] = from[0]; to[1] = from[1];
    53 }
    55 // The long operations depend on compiler support for "long long" on ppc.
    57 inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
    58   return op1 + op2;
    59 }
    61 inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
    62   return op1 & op2;
    63 }
    65 inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
    66   if (op1 == min_jlong && op2 == -1) return op1;
    67   return op1 / op2;
    68 }
    70 inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
    71   return op1 * op2;
    72 }
    74 inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
    75   return op1 | op2;
    76 }
    78 inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
    79   return op1 - op2;
    80 }
    82 inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
    83   return op1 ^ op2;
    84 }
    86 inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
    87   if (op1 == min_jlong && op2 == -1) return 0;
    88   return op1 % op2;
    89 }
    91 inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
    92   return ((uint64_t) op1) >> (op2 & 0x3F);
    93 }
    95 inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
    96   return op1 >> (op2 & 0x3F);
    97 }
    99 inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
   100   return op1 << (op2 & 0x3F);
   101 }
   103 inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
   104   return -op;
   105 }
   107 inline jlong BytecodeInterpreter::VMlongNot(jlong op) {
   108   return ~op;
   109 }
   111 inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
   112   return (op <= 0);
   113 }
   115 inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
   116   return (op >= 0);
   117 }
   119 inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
   120   return (op == 0);
   121 }
   123 inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
   124   return (op1 == op2);
   125 }
   127 inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
   128   return (op1 != op2);
   129 }
   131 inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
   132   return (op1 >= op2);
   133 }
   135 inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
   136   return (op1 <= op2);
   137 }
   139 inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
   140   return (op1 < op2);
   141 }
   143 inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
   144   return (op1 > op2);
   145 }
   147 inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
   148   return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
   149 }
   151 // Long conversions
   153 inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
   154   return (jdouble) val;
   155 }
   157 inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
   158   return (jfloat) val;
   159 }
   161 inline jint BytecodeInterpreter::VMlong2Int(jlong val) {
   162   return (jint) val;
   163 }
   165 // Double Arithmetic
   167 inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
   168   return op1 + op2;
   169 }
   171 inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
   172   return op1 / op2;
   173 }
   175 inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
   176   return op1 * op2;
   177 }
   179 inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
   180   return -op;
   181 }
   183 inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
   184   return fmod(op1, op2);
   185 }
   187 inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
   188   return op1 - op2;
   189 }
   191 inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) {
   192   return ( op1 < op2 ? -1 :
   193                op1 > op2 ? 1 :
   194                    op1 == op2 ? 0 :
   195                        (direction == -1 || direction == 1) ? direction : 0);
   196 }
   198 // Double Conversions
   200 inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
   201   return (jfloat) val;
   202 }
   204 // Float Conversions
   206 inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
   207   return (jdouble) op;
   208 }
   210 // Integer Arithmetic
   212 inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
   213   return op1 + op2;
   214 }
   216 inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
   217   return op1 & op2;
   218 }
   220 inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
   221   /* it's possible we could catch this special case implicitly */
   222   if ((juint)op1 == 0x80000000 && op2 == -1) return op1;
   223   else return op1 / op2;
   224 }
   226 inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
   227   return op1 * op2;
   228 }
   230 inline jint BytecodeInterpreter::VMintNeg(jint op) {
   231   return -op;
   232 }
   234 inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
   235   return op1 | op2;
   236 }
   238 inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
   239   /* it's possible we could catch this special case implicitly */
   240   if ((juint)op1 == 0x80000000 && op2 == -1) return 0;
   241   else return op1 % op2;
   242 }
   244 inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
   245   return op1 <<  (op2 & 0x1f);
   246 }
   248 inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
   249   return op1 >>  (op2 & 0x1f);
   250 }
   252 inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
   253   return op1 - op2;
   254 }
   256 inline juint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
   257   return ((juint) op1) >> (op2 & 0x1f);
   258 }
   260 inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
   261   return op1 ^ op2;
   262 }
   264 inline jdouble BytecodeInterpreter::VMint2Double(jint val) {
   265   return (jdouble) val;
   266 }
   268 inline jfloat BytecodeInterpreter::VMint2Float(jint val) {
   269   return (jfloat) val;
   270 }
   272 inline jlong BytecodeInterpreter::VMint2Long(jint val) {
   273   return (jlong) val;
   274 }
   276 inline jchar BytecodeInterpreter::VMint2Char(jint val) {
   277   return (jchar) val;
   278 }
   280 inline jshort BytecodeInterpreter::VMint2Short(jint val) {
   281   return (jshort) val;
   282 }
   284 inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
   285   return (jbyte) val;
   286 }
   288 #endif // CC_INTERP
   290 #endif // CPU_PPC_VM_BYTECODEINTERPRETER_PPC_INLINE_HPP

mercurial