annotate src/cpu/sparc/vm/bytecodeInterpreter_sparc.inline.hpp @ 196:d1605aabd0a1 jdk7-b30

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