comparison src/cpu/ppc/vm/bytecodeInterpreter_ppc.inline.hpp @ 14408:ec28f9c041ff

8019972: PPC64 (part 9): platform files for interpreter only VM. Summary: With this change the HotSpot core build works on Linux/PPC64. The VM succesfully executes simple test programs. Reviewed-by: kvn
author goetz
date Fri, 02 Aug 2013 16:46:45 +0200
parents
children
comparison
equal deleted inserted replaced
14407:94c202aa2646 14408:ec28f9c041ff
1 /*
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2012, 2013 SAP AG. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef CPU_PPC_VM_BYTECODEINTERPRETER_PPC_INLINE_HPP
27 #define CPU_PPC_VM_BYTECODEINTERPRETER_PPC_INLINE_HPP
28
29 #ifdef CC_INTERP
30
31 // Inline interpreter functions for ppc.
32
33 #include <math.h>
34
35 inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; }
36 inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; }
37 inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; }
38 inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; }
39 inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return (jfloat)fmod((double)op1, (double)op2); }
40
41 inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; }
42
43 inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) {
44 return ( op1 < op2 ? -1 :
45 op1 > op2 ? 1 :
46 op1 == op2 ? 0 :
47 (direction == -1 || direction == 1) ? direction : 0);
48
49 }
50
51 inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) {
52 to[0] = from[0]; to[1] = from[1];
53 }
54
55 // The long operations depend on compiler support for "long long" on ppc.
56
57 inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
58 return op1 + op2;
59 }
60
61 inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
62 return op1 & op2;
63 }
64
65 inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
66 if (op1 == min_jlong && op2 == -1) return op1;
67 return op1 / op2;
68 }
69
70 inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
71 return op1 * op2;
72 }
73
74 inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
75 return op1 | op2;
76 }
77
78 inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
79 return op1 - op2;
80 }
81
82 inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
83 return op1 ^ op2;
84 }
85
86 inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
87 if (op1 == min_jlong && op2 == -1) return 0;
88 return op1 % op2;
89 }
90
91 inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
92 return ((uint64_t) op1) >> (op2 & 0x3F);
93 }
94
95 inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
96 return op1 >> (op2 & 0x3F);
97 }
98
99 inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
100 return op1 << (op2 & 0x3F);
101 }
102
103 inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
104 return -op;
105 }
106
107 inline jlong BytecodeInterpreter::VMlongNot(jlong op) {
108 return ~op;
109 }
110
111 inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
112 return (op <= 0);
113 }
114
115 inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
116 return (op >= 0);
117 }
118
119 inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
120 return (op == 0);
121 }
122
123 inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
124 return (op1 == op2);
125 }
126
127 inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
128 return (op1 != op2);
129 }
130
131 inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
132 return (op1 >= op2);
133 }
134
135 inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
136 return (op1 <= op2);
137 }
138
139 inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
140 return (op1 < op2);
141 }
142
143 inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
144 return (op1 > op2);
145 }
146
147 inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
148 return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
149 }
150
151 // Long conversions
152
153 inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
154 return (jdouble) val;
155 }
156
157 inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
158 return (jfloat) val;
159 }
160
161 inline jint BytecodeInterpreter::VMlong2Int(jlong val) {
162 return (jint) val;
163 }
164
165 // Double Arithmetic
166
167 inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
168 return op1 + op2;
169 }
170
171 inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
172 return op1 / op2;
173 }
174
175 inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
176 return op1 * op2;
177 }
178
179 inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
180 return -op;
181 }
182
183 inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
184 return fmod(op1, op2);
185 }
186
187 inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
188 return op1 - op2;
189 }
190
191 inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) {
192 return ( op1 < op2 ? -1 :
193 op1 > op2 ? 1 :
194 op1 == op2 ? 0 :
195 (direction == -1 || direction == 1) ? direction : 0);
196 }
197
198 // Double Conversions
199
200 inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
201 return (jfloat) val;
202 }
203
204 // Float Conversions
205
206 inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
207 return (jdouble) op;
208 }
209
210 // Integer Arithmetic
211
212 inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
213 return op1 + op2;
214 }
215
216 inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
217 return op1 & op2;
218 }
219
220 inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
221 /* it's possible we could catch this special case implicitly */
222 if ((juint)op1 == 0x80000000 && op2 == -1) return op1;
223 else return op1 / op2;
224 }
225
226 inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
227 return op1 * op2;
228 }
229
230 inline jint BytecodeInterpreter::VMintNeg(jint op) {
231 return -op;
232 }
233
234 inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
235 return op1 | op2;
236 }
237
238 inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
239 /* it's possible we could catch this special case implicitly */
240 if ((juint)op1 == 0x80000000 && op2 == -1) return 0;
241 else return op1 % op2;
242 }
243
244 inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
245 return op1 << (op2 & 0x1f);
246 }
247
248 inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
249 return op1 >> (op2 & 0x1f);
250 }
251
252 inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
253 return op1 - op2;
254 }
255
256 inline juint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
257 return ((juint) op1) >> (op2 & 0x1f);
258 }
259
260 inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
261 return op1 ^ op2;
262 }
263
264 inline jdouble BytecodeInterpreter::VMint2Double(jint val) {
265 return (jdouble) val;
266 }
267
268 inline jfloat BytecodeInterpreter::VMint2Float(jint val) {
269 return (jfloat) val;
270 }
271
272 inline jlong BytecodeInterpreter::VMint2Long(jint val) {
273 return (jlong) val;
274 }
275
276 inline jchar BytecodeInterpreter::VMint2Char(jint val) {
277 return (jchar) val;
278 }
279
280 inline jshort BytecodeInterpreter::VMint2Short(jint val) {
281 return (jshort) val;
282 }
283
284 inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
285 return (jbyte) val;
286 }
287
288 #endif // CC_INTERP
289
290 #endif // CPU_PPC_VM_BYTECODEINTERPRETER_PPC_INLINE_HPP