Path: blob/master/src/hotspot/cpu/zero/bytecodeInterpreter_zero.inline.hpp
40931 views
/*1* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright 2007, 2010 Red Hat, Inc.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef CPU_ZERO_BYTECODEINTERPRETER_ZERO_INLINE_HPP26#define CPU_ZERO_BYTECODEINTERPRETER_ZERO_INLINE_HPP2728// Inline interpreter functions for zero2930inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) {31return op1 + op2;32}3334inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) {35return op1 - op2;36}3738inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) {39return op1 * op2;40}4142inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) {43return op1 / op2;44}4546inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) {47return fmod(op1, op2);48}4950inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) {51return -op;52}5354inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1,55jfloat op2,56int32_t direction) {57return ( op1 < op2 ? -1 :58op1 > op2 ? 1 :59op1 == op2 ? 0 :60(direction == -1 || direction == 1) ? direction : 0);6162}6364inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2],65const uint32_t from[2]) {66*(uint64_t *) to = *(uint64_t *) from;67}6869inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {70return op1 + op2;71}7273inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {74return op1 & op2;75}7677inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {78/* it's possible we could catch this special case implicitly */79if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return op1;80else return op1 / op2;81}8283inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {84return op1 * op2;85}8687inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {88return op1 | op2;89}9091inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {92return op1 - op2;93}9495inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {96return op1 ^ op2;97}9899inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {100/* it's possible we could catch this special case implicitly */101if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return 0;102else return op1 % op2;103}104105inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {106return ((unsigned long long) op1) >> (op2 & 0x3F);107}108109inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {110return op1 >> (op2 & 0x3F);111}112113inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {114return op1 << (op2 & 0x3F);115}116117inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {118return -op;119}120121inline jlong BytecodeInterpreter::VMlongNot(jlong op) {122return ~op;123}124125inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {126return (op <= 0);127}128129inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {130return (op >= 0);131}132133inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {134return (op == 0);135}136137inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {138return (op1 == op2);139}140141inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {142return (op1 != op2);143}144145inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {146return (op1 >= op2);147}148149inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {150return (op1 <= op2);151}152153inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {154return (op1 < op2);155}156157inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {158return (op1 > op2);159}160161inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {162return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);163}164165// Long conversions166167inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {168return (jdouble) val;169}170171inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {172return (jfloat) val;173}174175inline jint BytecodeInterpreter::VMlong2Int(jlong val) {176return (jint) val;177}178179// Double Arithmetic180181inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {182return op1 + op2;183}184185inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {186// Divide by zero... QQQ187return op1 / op2;188}189190inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {191return op1 * op2;192}193194inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {195return -op;196}197198inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {199return fmod(op1, op2);200}201202inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {203return op1 - op2;204}205206inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1,207jdouble op2,208int32_t direction) {209return ( op1 < op2 ? -1 :210op1 > op2 ? 1 :211op1 == op2 ? 0 :212(direction == -1 || direction == 1) ? direction : 0);213}214215// Double Conversions216217inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {218return (jfloat) val;219}220221// Float Conversions222223inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {224return (jdouble) op;225}226227// Integer Arithmetic228229inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {230return op1 + op2;231}232233inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {234return op1 & op2;235}236237inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {238/* it's possible we could catch this special case implicitly */239if (op1 == (jint) 0x80000000 && op2 == -1) return op1;240else return op1 / op2;241}242243inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {244return op1 * op2;245}246247inline jint BytecodeInterpreter::VMintNeg(jint op) {248return -op;249}250251inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {252return op1 | op2;253}254255inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {256/* it's possible we could catch this special case implicitly */257if (op1 == (jint) 0x80000000 && op2 == -1) return 0;258else return op1 % op2;259}260261inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {262return op1 << (op2 & 0x1F);263}264265inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {266return op1 >> (op2 & 0x1F);267}268269inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {270return op1 - op2;271}272273inline juint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {274return ((juint) op1) >> (op2 & 0x1F);275}276277inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {278return op1 ^ op2;279}280281inline jdouble BytecodeInterpreter::VMint2Double(jint val) {282return (jdouble) val;283}284285inline jfloat BytecodeInterpreter::VMint2Float(jint val) {286return (jfloat) val;287}288289inline jlong BytecodeInterpreter::VMint2Long(jint val) {290return (jlong) val;291}292293inline jchar BytecodeInterpreter::VMint2Char(jint val) {294return (jchar) val;295}296297inline jshort BytecodeInterpreter::VMint2Short(jint val) {298return (jshort) val;299}300301inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {302return (jbyte) val;303}304305#endif // CPU_ZERO_BYTECODEINTERPRETER_ZERO_INLINE_HPP306307308