hotspot/src/cpu/sparc/vm/bytecodeInterpreter_sparc.inline.hpp
author twisti
Fri, 13 Feb 2009 09:09:35 -0800
changeset 2031 24e034f56dcb
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6800154: Add comments to long_by_long_mulhi() for better understandability Summary: This patch adds a comment pointing to the Hacker's Delight version of the algorithm plus a verbatim copy of it. Furthermore it adds inline comments. Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// Inline interpreter functions for sparc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return fmod(op1, op2); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  return ( op1 < op2 ? -1 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
               op1 > op2 ? 1 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
                   op1 == op2 ? 0 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
                       (direction == -1 || direction == 1) ? direction : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // x86 can do unaligned copies but not 64bits at a time
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  to[0] = from[0]; to[1] = from[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// The long operations depend on compiler support for "long long" on x86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  return op1 + op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  return op1 & op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // QQQ what about check and throw...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  return op1 / op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  return op1 * op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  return op1 | op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  return op1 - op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  return op1 ^ op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  return op1 % op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // CVM did this 0x3f mask, is the really needed??? QQQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  return ((unsigned long long) op1) >> (op2 & 0x3F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  return op1 >> (op2 & 0x3F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  return op1 << (op2 & 0x3F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  return -op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
inline jlong BytecodeInterpreter::VMlongNot(jlong op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  return ~op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  return (op <= 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  return (op >= 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  return (op == 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  return (op1 == op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  return (op1 != op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  return (op1 >= op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  return (op1 <= op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  return (op1 < op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  return (op1 > op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// Long conversions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  return (jdouble) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  return (jfloat) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
inline jint BytecodeInterpreter::VMlong2Int(jlong val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  return (jint) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
// Double Arithmetic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  return op1 + op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // Divide by zero... QQQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  return op1 / op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  return op1 * op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  return -op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  return fmod(op1, op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  return op1 - op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  return ( op1 < op2 ? -1 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
               op1 > op2 ? 1 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
                   op1 == op2 ? 0 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
                       (direction == -1 || direction == 1) ? direction : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
// Double Conversions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  return (jfloat) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
// Float Conversions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  return (jdouble) op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
// Integer Arithmetic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  return op1 + op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  return op1 & op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  /* it's possible we could catch this special case implicitly */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  if (op1 == 0x80000000 && op2 == -1) return op1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  else return op1 / op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  return op1 * op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
inline jint BytecodeInterpreter::VMintNeg(jint op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  return -op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  return op1 | op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  /* it's possible we could catch this special case implicitly */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  if (op1 == 0x80000000 && op2 == -1) return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  else return op1 % op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  return op1 <<  op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  return op1 >>  op2; // QQ op2 & 0x1f??
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  return op1 - op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
inline jint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  return ((juint) op1) >> op2; // QQ op2 & 0x1f??
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  return op1 ^ op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
inline jdouble BytecodeInterpreter::VMint2Double(jint val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  return (jdouble) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
inline jfloat BytecodeInterpreter::VMint2Float(jint val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  return (jfloat) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
inline jlong BytecodeInterpreter::VMint2Long(jint val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  return (jlong) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
inline jchar BytecodeInterpreter::VMint2Char(jint val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  return (jchar) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
inline jshort BytecodeInterpreter::VMint2Short(jint val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  return (jshort) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  return (jbyte) val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
// The implementations are platform dependent. We have to worry about alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// issues on some machines which can change on the same platform depending on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
// whether it is an LP64 machine also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
// We know that on LP32 mode that longs/doubles are the only thing that gives
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// us alignment headaches. We also know that the worst we have is 32bit alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// so thing are not really too bad.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// (Also sparcworks compiler does the right thing for free if we don't use -arch..
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
// switches. Only gcc gives us a hard time. In LP64 mode I think we have no issue
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
// with alignment.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
#ifdef _GNU_SOURCE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  #define ALIGN_CONVERTER        /* Needs alignment converter */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  #undef ALIGN_CONVERTER        /* No alignment converter */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
#endif /* _GNU_SOURCE */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
#ifdef ALIGN_CONVERTER
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
class u8_converter {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  static jdouble get_jdouble(address p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    VMJavaVal64 tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    tmp.v[0] = ((uint32_t*)p)[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    tmp.v[1] = ((uint32_t*)p)[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    return tmp.d;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  static void put_jdouble(address p, jdouble d) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    VMJavaVal64 tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    tmp.d = d;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    ((uint32_t*)p)[0] = tmp.v[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    ((uint32_t*)p)[1] = tmp.v[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  static jlong get_jlong(address p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    VMJavaVal64 tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    tmp.v[0] = ((uint32_t*)p)[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    tmp.v[1] = ((uint32_t*)p)[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    return tmp.l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  static void put_jlong(address p, jlong l) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    VMJavaVal64 tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    tmp.l = l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    ((uint32_t*)p)[0] = tmp.v[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    ((uint32_t*)p)[1] = tmp.v[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
#endif /* ALIGN_CONVERTER */