Thu, 07 Sep 2017 09:12:16 +0800
#5745 [Code Reorganization] code cleanup and code style fix
This is a huge patch, but only code cleanup, code style fix and useless code deletion are included, for example:
tab -> two spaces, deleted spacees at the end of a line, delete useless comments.
This patch also included:
Declaration and definition of class MacroAssembler is moved from assembler_mips.h/cpp to macroAssembler_mips.h/cpp
1 /*
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, 2016, Loongson Technology. 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 */
26 #ifndef CPU_MIPS_VM_BYTECODEINTERPRETER_MIPS_INLINE_HPP
27 #define CPU_MIPS_VM_BYTECODEINTERPRETER_MIPS_INLINE_HPP
29 // Inline interpreter functions for IA32
31 inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; }
32 inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; }
33 inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; }
34 inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; }
35 inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return fmod(op1, op2); }
37 inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; }
39 inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) {
40 return ( op1 < op2 ? -1 :
41 op1 > op2 ? 1 :
42 op1 == op2 ? 0 :
43 (direction == -1 || direction == 1) ? direction : 0);
45 }
47 inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) {
48 // x86 can do unaligned copies but not 64bits at a time
49 to[0] = from[0]; to[1] = from[1];
50 }
52 // The long operations depend on compiler support for "long long" on x86
54 inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
55 return op1 + op2;
56 }
58 inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
59 return op1 & op2;
60 }
62 inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
63 // QQQ what about check and throw...
64 return op1 / op2;
65 }
67 inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
68 return op1 * op2;
69 }
71 inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
72 return op1 | op2;
73 }
75 inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
76 return op1 - op2;
77 }
79 inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
80 return op1 ^ op2;
81 }
83 inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
84 return op1 % op2;
85 }
87 inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
88 // CVM did this 0x3f mask, is the really needed??? QQQ
89 return ((unsigned long long) op1) >> (op2 & 0x3F);
90 }
92 inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
93 return op1 >> (op2 & 0x3F);
94 }
96 inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
97 return op1 << (op2 & 0x3F);
98 }
100 inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
101 return -op;
102 }
104 inline jlong BytecodeInterpreter::VMlongNot(jlong op) {
105 return ~op;
106 }
108 inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
109 return (op <= 0);
110 }
112 inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
113 return (op >= 0);
114 }
116 inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
117 return (op == 0);
118 }
120 inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
121 return (op1 == op2);
122 }
124 inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
125 return (op1 != op2);
126 }
128 inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
129 return (op1 >= op2);
130 }
132 inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
133 return (op1 <= op2);
134 }
136 inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
137 return (op1 < op2);
138 }
140 inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
141 return (op1 > op2);
142 }
144 inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
145 return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
146 }
148 // Long conversions
150 inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
151 return (jdouble) val;
152 }
154 inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
155 return (jfloat) val;
156 }
158 inline jint BytecodeInterpreter::VMlong2Int(jlong val) {
159 return (jint) val;
160 }
162 // Double Arithmetic
164 inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
165 return op1 + op2;
166 }
168 inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
169 // Divide by zero... QQQ
170 return op1 / op2;
171 }
173 inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
174 return op1 * op2;
175 }
177 inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
178 return -op;
179 }
181 inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
182 return fmod(op1, op2);
183 }
185 inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
186 return op1 - op2;
187 }
189 inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) {
190 return ( op1 < op2 ? -1 :
191 op1 > op2 ? 1 :
192 op1 == op2 ? 0 :
193 (direction == -1 || direction == 1) ? direction : 0);
194 }
196 // Double Conversions
198 inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
199 return (jfloat) val;
200 }
202 // Float Conversions
204 inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
205 return (jdouble) op;
206 }
208 // Integer Arithmetic
210 inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
211 return op1 + op2;
212 }
214 inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
215 return op1 & op2;
216 }
218 inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
219 /* it's possible we could catch this special case implicitly */
220 if ((juint)op1 == 0x80000000 && op2 == -1) return op1;
221 else return op1 / op2;
222 }
224 inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
225 return op1 * op2;
226 }
228 inline jint BytecodeInterpreter::VMintNeg(jint op) {
229 return -op;
230 }
232 inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
233 return op1 | op2;
234 }
236 inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
237 /* it's possible we could catch this special case implicitly */
238 if ((juint)op1 == 0x80000000 && op2 == -1) return 0;
239 else return op1 % op2;
240 }
242 inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
243 return op1 << op2;
244 }
246 inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
247 return op1 >> (op2 & 0x1f); // QQ op2 & 0x1f??
248 }
250 inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
251 return op1 - op2;
252 }
254 inline jint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
255 return ((juint) op1) >> (op2 & 0x1f); // QQ op2 & 0x1f??
256 }
258 inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
259 return op1 ^ op2;
260 }
262 inline jdouble BytecodeInterpreter::VMint2Double(jint val) {
263 return (jdouble) val;
264 }
266 inline jfloat BytecodeInterpreter::VMint2Float(jint val) {
267 return (jfloat) val;
268 }
270 inline jlong BytecodeInterpreter::VMint2Long(jint val) {
271 return (jlong) val;
272 }
274 inline jchar BytecodeInterpreter::VMint2Char(jint val) {
275 return (jchar) val;
276 }
278 inline jshort BytecodeInterpreter::VMint2Short(jint val) {
279 return (jshort) val;
280 }
282 inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
283 return (jbyte) val;
284 }
286 #endif // CPU_MIPS_VM_BYTECODEINTERPRETER_MIPS_INLINE_HPP