1010N/A/*
1879N/A * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
1649N/A * Copyright 2007, 2010 Red Hat, Inc.
1010N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1010N/A *
1010N/A * This code is free software; you can redistribute it and/or modify it
1010N/A * under the terms of the GNU General Public License version 2 only, as
1010N/A * published by the Free Software Foundation.
1010N/A *
1010N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1010N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1010N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1010N/A * version 2 for more details (a copy is included in the LICENSE file that
1010N/A * accompanied this code).
1010N/A *
1010N/A * You should have received a copy of the GNU General Public License version
1010N/A * 2 along with this work; if not, write to the Free Software Foundation,
1010N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1010N/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.
1010N/A *
1010N/A */
1010N/A
1879N/A#ifndef CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_INLINE_HPP
1879N/A#define CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_INLINE_HPP
1879N/A
1010N/A// Inline interpreter functions for zero
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) {
1010N/A return op1 + op2;
1010N/A}
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) {
1010N/A return op1 - op2;
1010N/A}
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) {
1010N/A return op1 * op2;
1010N/A}
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) {
1010N/A return op1 / op2;
1010N/A}
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) {
1010N/A return fmod(op1, op2);
1010N/A}
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) {
1010N/A return -op;
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1,
1010N/A jfloat op2,
1010N/A int32_t direction) {
1010N/A return ( op1 < op2 ? -1 :
1010N/A op1 > op2 ? 1 :
1010N/A op1 == op2 ? 0 :
1010N/A (direction == -1 || direction == 1) ? direction : 0);
1010N/A
1010N/A}
1010N/A
1010N/Ainline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2],
1010N/A const uint32_t from[2]) {
1010N/A *(uint64_t *) to = *(uint64_t *) from;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
1010N/A return op1 + op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
1010N/A return op1 & op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
1010N/A /* it's possible we could catch this special case implicitly */
1010N/A if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return op1;
1010N/A else return op1 / op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
1010N/A return op1 * op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
1010N/A return op1 | op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
1010N/A return op1 - op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
1010N/A return op1 ^ op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
1010N/A /* it's possible we could catch this special case implicitly */
1010N/A if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return 0;
1010N/A else return op1 % op2;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
1010N/A return ((unsigned long long) op1) >> (op2 & 0x3F);
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
1010N/A return op1 >> (op2 & 0x3F);
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
1010N/A return op1 << (op2 & 0x3F);
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
1010N/A return -op;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMlongNot(jlong op) {
1010N/A return ~op;
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
1010N/A return (op <= 0);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
1010N/A return (op >= 0);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
1010N/A return (op == 0);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
1010N/A return (op1 == op2);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
1010N/A return (op1 != op2);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
1010N/A return (op1 >= op2);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
1010N/A return (op1 <= op2);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
1010N/A return (op1 < op2);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
1010N/A return (op1 > op2);
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
1010N/A return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
1010N/A}
1010N/A
1010N/A// Long conversions
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
1010N/A return (jdouble) val;
1010N/A}
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
1010N/A return (jfloat) val;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMlong2Int(jlong val) {
1010N/A return (jint) val;
1010N/A}
1010N/A
1010N/A// Double Arithmetic
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
1010N/A return op1 + op2;
1010N/A}
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
1010N/A // Divide by zero... QQQ
1010N/A return op1 / op2;
1010N/A}
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
1010N/A return op1 * op2;
1010N/A}
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
1010N/A return -op;
1010N/A}
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
1010N/A return fmod(op1, op2);
1010N/A}
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
1010N/A return op1 - op2;
1010N/A}
1010N/A
1010N/Ainline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1,
1010N/A jdouble op2,
1010N/A int32_t direction) {
1010N/A return ( op1 < op2 ? -1 :
1010N/A op1 > op2 ? 1 :
1010N/A op1 == op2 ? 0 :
1010N/A (direction == -1 || direction == 1) ? direction : 0);
1010N/A}
1010N/A
1010N/A// Double Conversions
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
1010N/A return (jfloat) val;
1010N/A}
1010N/A
1010N/A// Float Conversions
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
1010N/A return (jdouble) op;
1010N/A}
1010N/A
1010N/A// Integer Arithmetic
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
1010N/A return op1 + op2;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
1010N/A return op1 & op2;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
1010N/A /* it's possible we could catch this special case implicitly */
1010N/A if (op1 == (jint) 0x80000000 && op2 == -1) return op1;
1010N/A else return op1 / op2;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
1010N/A return op1 * op2;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintNeg(jint op) {
1010N/A return -op;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
1010N/A return op1 | op2;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
1010N/A /* it's possible we could catch this special case implicitly */
1010N/A if (op1 == (jint) 0x80000000 && op2 == -1) return 0;
1010N/A else return op1 % op2;
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
1010N/A return op1 << (op2 & 0x1F);
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
1010N/A return op1 >> (op2 & 0x1F);
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
1010N/A return op1 - op2;
1010N/A}
1010N/A
1649N/Ainline juint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
1010N/A return ((juint) op1) >> (op2 & 0x1F);
1010N/A}
1010N/A
1010N/Ainline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
1010N/A return op1 ^ op2;
1010N/A}
1010N/A
1010N/Ainline jdouble BytecodeInterpreter::VMint2Double(jint val) {
1010N/A return (jdouble) val;
1010N/A}
1010N/A
1010N/Ainline jfloat BytecodeInterpreter::VMint2Float(jint val) {
1010N/A return (jfloat) val;
1010N/A}
1010N/A
1010N/Ainline jlong BytecodeInterpreter::VMint2Long(jint val) {
1010N/A return (jlong) val;
1010N/A}
1010N/A
1010N/Ainline jchar BytecodeInterpreter::VMint2Char(jint val) {
1010N/A return (jchar) val;
1010N/A}
1010N/A
1010N/Ainline jshort BytecodeInterpreter::VMint2Short(jint val) {
1010N/A return (jshort) val;
1010N/A}
1010N/A
1010N/Ainline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
1010N/A return (jbyte) val;
1010N/A}
1879N/A
1879N/A#endif // CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_INLINE_HPP