src/cpu/zero/vm/bytecodeInterpreter_zero.inline.hpp

Tue, 20 Aug 2013 10:57:50 -0700

author
twisti
date
Tue, 20 Aug 2013 10:57:50 -0700
changeset 5545
e16282db4946
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

8022956: Clang: enable return type warnings on BSD
Reviewed-by: coleenp, sla

     1 /*
     2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2007, 2010 Red Hat, Inc.
     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_ZERO_VM_BYTECODEINTERPRETER_ZERO_INLINE_HPP
    27 #define CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_INLINE_HPP
    29 // Inline interpreter functions for zero
    31 inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) {
    32   return op1 + op2;
    33 }
    35 inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) {
    36   return op1 - op2;
    37 }
    39 inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) {
    40   return op1 * op2;
    41 }
    43 inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) {
    44   return op1 / op2;
    45 }
    47 inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) {
    48   return fmod(op1, op2);
    49 }
    51 inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) {
    52   return -op;
    53 }
    55 inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat  op1,
    56                                                    jfloat  op2,
    57                                                    int32_t direction) {
    58   return ( op1 < op2 ? -1 :
    59                op1 > op2 ? 1 :
    60                    op1 == op2 ? 0 :
    61                        (direction == -1 || direction == 1) ? direction : 0);
    63 }
    65 inline void BytecodeInterpreter::VMmemCopy64(uint32_t       to[2],
    66                                              const uint32_t from[2]) {
    67   *(uint64_t *) to = *(uint64_t *) from;
    68 }
    70 inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
    71   return op1 + op2;
    72 }
    74 inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
    75   return op1 & op2;
    76 }
    78 inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
    79   /* it's possible we could catch this special case implicitly */
    80   if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return op1;
    81   else return op1 / op2;
    82 }
    84 inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
    85   return op1 * op2;
    86 }
    88 inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
    89   return op1 | op2;
    90 }
    92 inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
    93   return op1 - op2;
    94 }
    96 inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
    97   return op1 ^ op2;
    98 }
   100 inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
   101   /* it's possible we could catch this special case implicitly */
   102   if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return 0;
   103   else return op1 % op2;
   104 }
   106 inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
   107   return ((unsigned long long) op1) >> (op2 & 0x3F);
   108 }
   110 inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
   111   return op1 >> (op2 & 0x3F);
   112 }
   114 inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
   115   return op1 << (op2 & 0x3F);
   116 }
   118 inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
   119   return -op;
   120 }
   122 inline jlong BytecodeInterpreter::VMlongNot(jlong op) {
   123   return ~op;
   124 }
   126 inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
   127   return (op <= 0);
   128 }
   130 inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
   131   return (op >= 0);
   132 }
   134 inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
   135   return (op == 0);
   136 }
   138 inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
   139   return (op1 == op2);
   140 }
   142 inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
   143   return (op1 != op2);
   144 }
   146 inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
   147   return (op1 >= op2);
   148 }
   150 inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
   151   return (op1 <= op2);
   152 }
   154 inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
   155   return (op1 < op2);
   156 }
   158 inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
   159   return (op1 > op2);
   160 }
   162 inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
   163   return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
   164 }
   166 // Long conversions
   168 inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
   169   return (jdouble) val;
   170 }
   172 inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
   173   return (jfloat) val;
   174 }
   176 inline jint BytecodeInterpreter::VMlong2Int(jlong val) {
   177   return (jint) val;
   178 }
   180 // Double Arithmetic
   182 inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
   183   return op1 + op2;
   184 }
   186 inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
   187   // Divide by zero... QQQ
   188   return op1 / op2;
   189 }
   191 inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
   192   return op1 * op2;
   193 }
   195 inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
   196   return -op;
   197 }
   199 inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
   200   return fmod(op1, op2);
   201 }
   203 inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
   204   return op1 - op2;
   205 }
   207 inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1,
   208                                                     jdouble op2,
   209                                                     int32_t direction) {
   210   return ( op1 < op2 ? -1 :
   211                op1 > op2 ? 1 :
   212                    op1 == op2 ? 0 :
   213                        (direction == -1 || direction == 1) ? direction : 0);
   214 }
   216 // Double Conversions
   218 inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
   219   return (jfloat) val;
   220 }
   222 // Float Conversions
   224 inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
   225   return (jdouble) op;
   226 }
   228 // Integer Arithmetic
   230 inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
   231   return op1 + op2;
   232 }
   234 inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
   235   return op1 & op2;
   236 }
   238 inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
   239   /* it's possible we could catch this special case implicitly */
   240   if (op1 == (jint) 0x80000000 && op2 == -1) return op1;
   241   else return op1 / op2;
   242 }
   244 inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
   245   return op1 * op2;
   246 }
   248 inline jint BytecodeInterpreter::VMintNeg(jint op) {
   249   return -op;
   250 }
   252 inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
   253   return op1 | op2;
   254 }
   256 inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
   257   /* it's possible we could catch this special case implicitly */
   258   if (op1 == (jint) 0x80000000 && op2 == -1) return 0;
   259   else return op1 % op2;
   260 }
   262 inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
   263   return op1 << (op2 & 0x1F);
   264 }
   266 inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
   267   return op1 >> (op2 & 0x1F);
   268 }
   270 inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
   271   return op1 - op2;
   272 }
   274 inline juint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
   275   return ((juint) op1) >> (op2 & 0x1F);
   276 }
   278 inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
   279   return op1 ^ op2;
   280 }
   282 inline jdouble BytecodeInterpreter::VMint2Double(jint val) {
   283   return (jdouble) val;
   284 }
   286 inline jfloat BytecodeInterpreter::VMint2Float(jint val) {
   287   return (jfloat) val;
   288 }
   290 inline jlong BytecodeInterpreter::VMint2Long(jint val) {
   291   return (jlong) val;
   292 }
   294 inline jchar BytecodeInterpreter::VMint2Char(jint val) {
   295   return (jchar) val;
   296 }
   298 inline jshort BytecodeInterpreter::VMint2Short(jint val) {
   299   return (jshort) val;
   300 }
   302 inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
   303   return (jbyte) val;
   304 }
   306 #endif // CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_INLINE_HPP

mercurial