duke@435: /* stefank@2314: * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef CPU_X86_VM_BYTECODEINTERPRETER_X86_INLINE_HPP stefank@2314: #define CPU_X86_VM_BYTECODEINTERPRETER_X86_INLINE_HPP stefank@2314: duke@435: // Inline interpreter functions for IA32 duke@435: duke@435: inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; } duke@435: inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; } duke@435: inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; } duke@435: inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; } duke@435: inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return fmod(op1, op2); } duke@435: duke@435: inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) { duke@435: return ( op1 < op2 ? -1 : duke@435: op1 > op2 ? 1 : duke@435: op1 == op2 ? 0 : duke@435: (direction == -1 || direction == 1) ? direction : 0); duke@435: duke@435: } duke@435: duke@435: inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) { duke@435: // x86 can do unaligned copies but not 64bits at a time duke@435: to[0] = from[0]; to[1] = from[1]; duke@435: } duke@435: duke@435: // The long operations depend on compiler support for "long long" on x86 duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) { duke@435: return op1 + op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) { duke@435: return op1 & op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) { duke@435: // QQQ what about check and throw... duke@435: return op1 / op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) { duke@435: return op1 * op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) { duke@435: return op1 | op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) { duke@435: return op1 - op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) { duke@435: return op1 ^ op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) { duke@435: return op1 % op2; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) { duke@435: // CVM did this 0x3f mask, is the really needed??? QQQ duke@435: return ((unsigned long long) op1) >> (op2 & 0x3F); duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) { duke@435: return op1 >> (op2 & 0x3F); duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) { duke@435: return op1 << (op2 & 0x3F); duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongNeg(jlong op) { duke@435: return -op; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMlongNot(jlong op) { duke@435: return ~op; duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) { duke@435: return (op <= 0); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongGez(jlong op) { duke@435: return (op >= 0); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) { duke@435: return (op == 0); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) { duke@435: return (op1 == op2); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) { duke@435: return (op1 != op2); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) { duke@435: return (op1 >= op2); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) { duke@435: return (op1 <= op2); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) { duke@435: return (op1 < op2); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) { duke@435: return (op1 > op2); duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) { duke@435: return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0); duke@435: } duke@435: duke@435: // Long conversions duke@435: duke@435: inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) { duke@435: return (jdouble) val; duke@435: } duke@435: duke@435: inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) { duke@435: return (jfloat) val; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMlong2Int(jlong val) { duke@435: return (jint) val; duke@435: } duke@435: duke@435: // Double Arithmetic duke@435: duke@435: inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) { duke@435: return op1 + op2; duke@435: } duke@435: duke@435: inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) { duke@435: // Divide by zero... QQQ duke@435: return op1 / op2; duke@435: } duke@435: duke@435: inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) { duke@435: return op1 * op2; duke@435: } duke@435: duke@435: inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) { duke@435: return -op; duke@435: } duke@435: duke@435: inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) { duke@435: return fmod(op1, op2); duke@435: } duke@435: duke@435: inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) { duke@435: return op1 - op2; duke@435: } duke@435: duke@435: inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) { duke@435: return ( op1 < op2 ? -1 : duke@435: op1 > op2 ? 1 : duke@435: op1 == op2 ? 0 : duke@435: (direction == -1 || direction == 1) ? direction : 0); duke@435: } duke@435: duke@435: // Double Conversions duke@435: duke@435: inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) { duke@435: return (jfloat) val; duke@435: } duke@435: duke@435: // Float Conversions duke@435: duke@435: inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) { duke@435: return (jdouble) op; duke@435: } duke@435: duke@435: // Integer Arithmetic duke@435: duke@435: inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) { duke@435: return op1 + op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) { duke@435: return op1 & op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) { duke@435: /* it's possible we could catch this special case implicitly */ coleenp@955: if ((juint)op1 == 0x80000000 && op2 == -1) return op1; duke@435: else return op1 / op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) { duke@435: return op1 * op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintNeg(jint op) { duke@435: return -op; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) { duke@435: return op1 | op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) { duke@435: /* it's possible we could catch this special case implicitly */ coleenp@955: if ((juint)op1 == 0x80000000 && op2 == -1) return 0; duke@435: else return op1 % op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) { bobv@2036: return op1 << op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) { bobv@2036: return op1 >> (op2 & 0x1f); duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) { duke@435: return op1 - op2; duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintUshr(jint op1, jint op2) { bobv@2036: return ((juint) op1) >> (op2 & 0x1f); duke@435: } duke@435: duke@435: inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) { duke@435: return op1 ^ op2; duke@435: } duke@435: duke@435: inline jdouble BytecodeInterpreter::VMint2Double(jint val) { duke@435: return (jdouble) val; duke@435: } duke@435: duke@435: inline jfloat BytecodeInterpreter::VMint2Float(jint val) { duke@435: return (jfloat) val; duke@435: } duke@435: duke@435: inline jlong BytecodeInterpreter::VMint2Long(jint val) { duke@435: return (jlong) val; duke@435: } duke@435: duke@435: inline jchar BytecodeInterpreter::VMint2Char(jint val) { duke@435: return (jchar) val; duke@435: } duke@435: duke@435: inline jshort BytecodeInterpreter::VMint2Short(jint val) { duke@435: return (jshort) val; duke@435: } duke@435: duke@435: inline jbyte BytecodeInterpreter::VMint2Byte(jint val) { duke@435: return (jbyte) val; duke@435: } stefank@2314: stefank@2314: #endif // CPU_X86_VM_BYTECODEINTERPRETER_X86_INLINE_HPP