Thu, 08 Apr 2010 10:55:40 +0200
6941529: SharedRuntime::raw_exception_handler_for_return_address must reset thread MethodHandle flag
Summary: During testing a bug was hit when an exception returned to the interpreter and the SP was wrong.
Reviewed-by: kvn, never
1 /*
2 * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
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 it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
25 // Inline interpreter functions for IA32
27 inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { return op1 + op2; }
28 inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { return op1 - op2; }
29 inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; }
30 inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; }
31 inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { return fmod(op1, op2); }
33 inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { return -op; }
35 inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, jfloat op2, int32_t direction) {
36 return ( op1 < op2 ? -1 :
37 op1 > op2 ? 1 :
38 op1 == op2 ? 0 :
39 (direction == -1 || direction == 1) ? direction : 0);
41 }
43 inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], const uint32_t from[2]) {
44 // x86 can do unaligned copies but not 64bits at a time
45 to[0] = from[0]; to[1] = from[1];
46 }
48 // The long operations depend on compiler support for "long long" on x86
50 inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) {
51 return op1 + op2;
52 }
54 inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) {
55 return op1 & op2;
56 }
58 inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
59 // QQQ what about check and throw...
60 return op1 / op2;
61 }
63 inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) {
64 return op1 * op2;
65 }
67 inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) {
68 return op1 | op2;
69 }
71 inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) {
72 return op1 - op2;
73 }
75 inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) {
76 return op1 ^ op2;
77 }
79 inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
80 return op1 % op2;
81 }
83 inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) {
84 // CVM did this 0x3f mask, is the really needed??? QQQ
85 return ((unsigned long long) op1) >> (op2 & 0x3F);
86 }
88 inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) {
89 return op1 >> (op2 & 0x3F);
90 }
92 inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) {
93 return op1 << (op2 & 0x3F);
94 }
96 inline jlong BytecodeInterpreter::VMlongNeg(jlong op) {
97 return -op;
98 }
100 inline jlong BytecodeInterpreter::VMlongNot(jlong op) {
101 return ~op;
102 }
104 inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) {
105 return (op <= 0);
106 }
108 inline int32_t BytecodeInterpreter::VMlongGez(jlong op) {
109 return (op >= 0);
110 }
112 inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) {
113 return (op == 0);
114 }
116 inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) {
117 return (op1 == op2);
118 }
120 inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) {
121 return (op1 != op2);
122 }
124 inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) {
125 return (op1 >= op2);
126 }
128 inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) {
129 return (op1 <= op2);
130 }
132 inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) {
133 return (op1 < op2);
134 }
136 inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) {
137 return (op1 > op2);
138 }
140 inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) {
141 return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0);
142 }
144 // Long conversions
146 inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) {
147 return (jdouble) val;
148 }
150 inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) {
151 return (jfloat) val;
152 }
154 inline jint BytecodeInterpreter::VMlong2Int(jlong val) {
155 return (jint) val;
156 }
158 // Double Arithmetic
160 inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
161 return op1 + op2;
162 }
164 inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) {
165 // Divide by zero... QQQ
166 return op1 / op2;
167 }
169 inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) {
170 return op1 * op2;
171 }
173 inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) {
174 return -op;
175 }
177 inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) {
178 return fmod(op1, op2);
179 }
181 inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) {
182 return op1 - op2;
183 }
185 inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction) {
186 return ( op1 < op2 ? -1 :
187 op1 > op2 ? 1 :
188 op1 == op2 ? 0 :
189 (direction == -1 || direction == 1) ? direction : 0);
190 }
192 // Double Conversions
194 inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) {
195 return (jfloat) val;
196 }
198 // Float Conversions
200 inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
201 return (jdouble) op;
202 }
204 // Integer Arithmetic
206 inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) {
207 return op1 + op2;
208 }
210 inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) {
211 return op1 & op2;
212 }
214 inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
215 /* it's possible we could catch this special case implicitly */
216 if ((juint)op1 == 0x80000000 && op2 == -1) return op1;
217 else return op1 / op2;
218 }
220 inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) {
221 return op1 * op2;
222 }
224 inline jint BytecodeInterpreter::VMintNeg(jint op) {
225 return -op;
226 }
228 inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) {
229 return op1 | op2;
230 }
232 inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
233 /* it's possible we could catch this special case implicitly */
234 if ((juint)op1 == 0x80000000 && op2 == -1) return 0;
235 else return op1 % op2;
236 }
238 inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) {
239 return op1 << op2;
240 }
242 inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) {
243 return op1 >> op2; // QQ op2 & 0x1f??
244 }
246 inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) {
247 return op1 - op2;
248 }
250 inline jint BytecodeInterpreter::VMintUshr(jint op1, jint op2) {
251 return ((juint) op1) >> op2; // QQ op2 & 0x1f??
252 }
254 inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) {
255 return op1 ^ op2;
256 }
258 inline jdouble BytecodeInterpreter::VMint2Double(jint val) {
259 return (jdouble) val;
260 }
262 inline jfloat BytecodeInterpreter::VMint2Float(jint val) {
263 return (jfloat) val;
264 }
266 inline jlong BytecodeInterpreter::VMint2Long(jint val) {
267 return (jlong) val;
268 }
270 inline jchar BytecodeInterpreter::VMint2Char(jint val) {
271 return (jchar) val;
272 }
274 inline jshort BytecodeInterpreter::VMint2Short(jint val) {
275 return (jshort) val;
276 }
278 inline jbyte BytecodeInterpreter::VMint2Byte(jint val) {
279 return (jbyte) val;
280 }