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