annotate src/cpu/sparc/vm/jniTypes_sparc.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 1998-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 // This file holds platform-dependent routines used to write primitive jni
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // types to the array of arguments passed into JavaCalls::call
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class JNITypes : AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // These functions write a java primitive type (in native format)
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // to a java stack slot array to be passed as an argument to JavaCalls:calls.
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // I.e., they are functionally 'push' operations if they have a 'pos'
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // formal parameter. Note that jlong's and jdouble's are written
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // _in reverse_ of the order in which they appear in the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // stack. This is because call stubs (see stubGenerator_sparc.cpp)
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // reverse the argument list constructed by JavaCallArguments (see
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // javaCalls.hpp).
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Helper routines.
a61af66fc99e Initial load
duke
parents:
diff changeset
40 static inline void put_int2 (jint *from, jint *to) { to[0] = from[0]; to[1] = from[1]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
41 static inline void put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static inline void put_int2r(jint *from, jint *to) { to[0] = from[1]; to[1] = from[0]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static inline void put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // Ints are stored in native format in one JavaCallArgument slot at *to.
a61af66fc99e Initial load
duke
parents:
diff changeset
47 static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
48 static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Longs are stored in native format in one JavaCallArgument slot at *(to+1).
a61af66fc99e Initial load
duke
parents:
diff changeset
53 static inline void put_long(jlong from, intptr_t *to) { *(jlong *)(to + 1 + 0) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 static inline void put_long(jlong from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = from; pos += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static inline void put_long(jlong *from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = *from; pos += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Longs are stored in reversed native word format in two JavaCallArgument slots at *to.
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // The high half is in *(to+1) and the low half in *to.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Oops are stored in native format in one JavaCallArgument slot at *to.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Floats are stored in native format in one JavaCallArgument slot at *to.
a61af66fc99e Initial load
duke
parents:
diff changeset
70 static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1).
a61af66fc99e Initial load
duke
parents:
diff changeset
76 static inline void put_double(jdouble from, intptr_t *to) { *(jdouble *)(to + 1 + 0) = from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 static inline void put_double(jdouble from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = from; pos += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to.
a61af66fc99e Initial load
duke
parents:
diff changeset
81 static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // The get_xxx routines, on the other hand, actually _do_ fetch
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // java primitive types from the interpreter stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
88 static inline jint get_int(intptr_t *from) { return *(jint *)from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
91 static inline jlong get_long(intptr_t *from) { return *(jlong *)from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
93 static inline jlong get_long(intptr_t *from) { return ((jlong)(*( signed int *)((jint *)from )) << 32) |
a61af66fc99e Initial load
duke
parents:
diff changeset
94 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 static inline oop get_obj(intptr_t *from) { return *(oop *)from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 static inline jfloat get_float(intptr_t *from) { return *(jfloat *)from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
101 static inline jdouble get_double(intptr_t *from) { return *(jdouble *)from; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
103 static inline jdouble get_double(intptr_t *from) { jlong jl = ((jlong)(*( signed int *)((jint *)from )) << 32) |
a61af66fc99e Initial load
duke
parents:
diff changeset
104 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return *(jdouble *)&jl; }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 };