0N/A/*
1879N/A * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef CPU_SPARC_VM_BYTECODEINTERPRETER_SPARC_INLINE_HPP
1879N/A#define CPU_SPARC_VM_BYTECODEINTERPRETER_SPARC_INLINE_HPP
1879N/A
0N/A// Inline interpreter functions for sparc
0N/A
0N/Ainline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; }
0N/Ainline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; }
0N/Ainline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; }
0N/Ainline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; }
0N/Ainline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return fmod(op1, op2); }
0N/A
0N/Ainline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; }
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) {
0N/A return ( op1 < op2 ? -1 :
0N/A op1 > op2 ? 1 :
0N/A op1 == op2 ? 0 :
0N/A (direction == -1 || direction == 1) ? direction : 0);
0N/A
0N/A}
0N/A
0N/Ainline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) {
0N/A // x86 can do unaligned copies but not 64bits at a time
0N/A to[0] = from[0]; to[1] = from[1];
0N/A}
0N/A
0N/A// The long operations depend on compiler support for "long long" on x86
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
0N/A return op1 + op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
0N/A return op1 & op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
0N/A // QQQ what about check and throw...
0N/A return op1 / op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
0N/A return op1 * op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
0N/A return op1 | op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
0N/A return op1 - op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
0N/A return op1 ^ op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
0N/A return op1 % op2;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
0N/A // CVM did this 0x3f mask, is the really needed??? QQQ
0N/A return ((unsigned long long) op1) >> (op2 & 0x3F);
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
0N/A return op1 >> (op2 & 0x3F);
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
0N/A return op1 << (op2 & 0x3F);
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
0N/A return -op;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMlongNot(jlong op) {
0N/A return ~op;
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
0N/A return (op <= 0);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
0N/A return (op >= 0);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
0N/A return (op == 0);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
0N/A return (op1 == op2);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
0N/A return (op1 != op2);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
0N/A return (op1 >= op2);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
0N/A return (op1 <= op2);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
0N/A return (op1 < op2);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
0N/A return (op1 > op2);
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
0N/A return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
0N/A}
0N/A
0N/A// Long conversions
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
0N/A return (jdouble) val;
0N/A}
0N/A
0N/Ainline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
0N/A return (jfloat) val;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMlong2Int(jlong val) {
0N/A return (jint) val;
0N/A}
0N/A
0N/A// Double Arithmetic
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
0N/A return op1 + op2;
0N/A}
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
0N/A // Divide by zero... QQQ
0N/A return op1 / op2;
0N/A}
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
0N/A return op1 * op2;
0N/A}
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
0N/A return -op;
0N/A}
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
0N/A return fmod(op1, op2);
0N/A}
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
0N/A return op1 - op2;
0N/A}
0N/A
0N/Ainline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) {
0N/A return ( op1 < op2 ? -1 :
0N/A op1 > op2 ? 1 :
0N/A op1 == op2 ? 0 :
0N/A (direction == -1 || direction == 1) ? direction : 0);
0N/A}
0N/A
0N/A// Double Conversions
0N/A
0N/Ainline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
0N/A return (jfloat) val;
0N/A}
0N/A
0N/A// Float Conversions
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
0N/A return (jdouble) op;
0N/A}
0N/A
0N/A// Integer Arithmetic
0N/A
0N/Ainline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
0N/A return op1 + op2;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
0N/A return op1 & op2;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
0N/A /* it's possible we could catch this special case implicitly */
0N/A if (op1 == 0x80000000 && op2 == -1) return op1;
0N/A else return op1 / op2;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
0N/A return op1 * op2;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintNeg(jint op) {
0N/A return -op;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
0N/A return op1 | op2;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
0N/A /* it's possible we could catch this special case implicitly */
0N/A if (op1 == 0x80000000 && op2 == -1) return 0;
0N/A else return op1 % op2;
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
1601N/A return op1 << (op2 & 0x1f);
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
1601N/A return op1 >> (op2 & 0x1f);
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
0N/A return op1 - op2;
0N/A}
0N/A
1601N/Ainline juint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
1601N/A return ((juint) op1) >> (op2 & 0x1f);
0N/A}
0N/A
0N/Ainline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
0N/A return op1 ^ op2;
0N/A}
0N/A
0N/Ainline jdouble BytecodeInterpreter::VMint2Double(jint val) {
0N/A return (jdouble) val;
0N/A}
0N/A
0N/Ainline jfloat BytecodeInterpreter::VMint2Float(jint val) {
0N/A return (jfloat) val;
0N/A}
0N/A
0N/Ainline jlong BytecodeInterpreter::VMint2Long(jint val) {
0N/A return (jlong) val;
0N/A}
0N/A
0N/Ainline jchar BytecodeInterpreter::VMint2Char(jint val) {
0N/A return (jchar) val;
0N/A}
0N/A
0N/Ainline jshort BytecodeInterpreter::VMint2Short(jint val) {
0N/A return (jshort) val;
0N/A}
0N/A
0N/Ainline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
0N/A return (jbyte) val;
0N/A}
0N/A
0N/A// The implementations are platform dependent. We have to worry about alignment
0N/A// issues on some machines which can change on the same platform depending on
0N/A// whether it is an LP64 machine also.
0N/A
0N/A// We know that on LP32 mode that longs/doubles are the only thing that gives
0N/A// us alignment headaches. We also know that the worst we have is 32bit alignment
0N/A// so thing are not really too bad.
0N/A// (Also sparcworks compiler does the right thing for free if we don't use -arch..
0N/A// switches. Only gcc gives us a hard time. In LP64 mode I think we have no issue
0N/A// with alignment.
0N/A
0N/A#ifdef _GNU_SOURCE
0N/A #define ALIGN_CONVERTER /* Needs alignment converter */
0N/A#else
0N/A #undef ALIGN_CONVERTER /* No alignment converter */
0N/A#endif /* _GNU_SOURCE */
0N/A
0N/A#ifdef ALIGN_CONVERTER
0N/Aclass u8_converter {
0N/A
0N/A private:
0N/A
0N/A public:
0N/A static jdouble get_jdouble(address p) {
0N/A VMJavaVal64 tmp;
0N/A tmp.v[0] = ((uint32_t*)p)[0];
0N/A tmp.v[1] = ((uint32_t*)p)[1];
0N/A return tmp.d;
0N/A }
0N/A
0N/A static void put_jdouble(address p, jdouble d) {
0N/A VMJavaVal64 tmp;
0N/A tmp.d = d;
0N/A ((uint32_t*)p)[0] = tmp.v[0];
0N/A ((uint32_t*)p)[1] = tmp.v[1];
0N/A }
0N/A
0N/A static jlong get_jlong(address p) {
0N/A VMJavaVal64 tmp;
0N/A tmp.v[0] = ((uint32_t*)p)[0];
0N/A tmp.v[1] = ((uint32_t*)p)[1];
0N/A return tmp.l;
0N/A }
0N/A
0N/A static void put_jlong(address p, jlong l) {
0N/A VMJavaVal64 tmp;
0N/A tmp.l = l;
0N/A ((uint32_t*)p)[0] = tmp.v[0];
0N/A ((uint32_t*)p)[1] = tmp.v[1];
0N/A }
0N/A};
0N/A#endif /* ALIGN_CONVERTER */
1879N/A
1879N/A#endif // CPU_SPARC_VM_BYTECODEINTERPRETER_SPARC_INLINE_HPP