Mercurial > hg > truffle
annotate src/cpu/zero/vm/jniTypes_zero.hpp @ 1669:cc3fdfeb54b0 hs19-b05
Merge
author | trims |
---|---|
date | Thu, 29 Jul 2010 23:14:56 -0700 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
1010 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1010
diff
changeset
|
2 * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. |
1010 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1010
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1010
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1010
diff
changeset
|
21 * questions. |
1010 | 22 * |
23 */ | |
24 | |
25 // This file holds platform-dependent routines used to write primitive jni | |
26 // types to the array of arguments passed into JavaCalls::call | |
27 | |
28 class JNITypes : AllStatic { | |
29 // These functions write a java primitive type (in native format) | |
30 // to a java stack slot array to be passed as an argument to JavaCalls:calls. | |
31 // I.e., they are functionally 'push' operations if they have a 'pos' | |
32 // formal parameter. Note that jlong's and jdouble's are written | |
33 // _in reverse_ of the order in which they appear in the interpreter | |
34 // stack. This is because call stubs (see stubGenerator_zero.cpp) | |
35 // reverse the argument list constructed by JavaCallArguments (see | |
36 // javaCalls.hpp). | |
37 | |
38 private: | |
39 // Helper routines. | |
40 static inline void put_int2 (jint *from, jint *to) { to[0] = from[0]; to[1] = from[1]; } | |
41 static inline void put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; } | |
42 static inline void put_int2r(jint *from, jint *to) { to[0] = from[1]; to[1] = from[0]; } | |
43 static inline void put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; } | |
44 | |
45 public: | |
46 // Ints are stored in native format in one JavaCallArgument slot at *to. | |
47 static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; } | |
48 static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; } | |
49 static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; } | |
50 | |
51 #ifdef _LP64 | |
52 // Longs are stored in native format in one JavaCallArgument slot at *(to+1). | |
53 static inline void put_long(jlong from, intptr_t *to) { *(jlong *)(to + 1 + 0) = from; } | |
54 static inline void put_long(jlong from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = from; pos += 2; } | |
55 static inline void put_long(jlong *from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = *from; pos += 2; } | |
56 #else | |
57 // Longs are stored in reversed native word format in two JavaCallArgument slots at *to. | |
58 // The high half is in *(to+1) and the low half in *to. | |
59 static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); } | |
60 static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); } | |
61 static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); } | |
62 #endif | |
63 | |
64 // Oops are stored in native format in one JavaCallArgument slot at *to. | |
65 static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; } | |
66 static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; } | |
67 static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; } | |
68 | |
69 // Floats are stored in native format in one JavaCallArgument slot at *to. | |
70 static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; } | |
71 static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; } | |
72 static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; } | |
73 | |
74 #ifdef _LP64 | |
75 // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1). | |
76 static inline void put_double(jdouble from, intptr_t *to) { *(jdouble *)(to + 1 + 0) = from; } | |
77 static inline void put_double(jdouble from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = from; pos += 2; } | |
78 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; } | |
79 #else | |
80 // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to. | |
81 static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); } | |
82 static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); } | |
83 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); } | |
84 #endif | |
85 | |
86 // The get_xxx routines, on the other hand, actually _do_ fetch | |
87 // java primitive types from the interpreter stack. | |
88 static inline jint get_int(intptr_t *from) { return *(jint *)from; } | |
89 | |
90 #ifdef _LP64 | |
91 static inline jlong get_long(intptr_t *from) { return *(jlong *)from; } | |
92 #else | |
93 static inline jlong get_long(intptr_t *from) { return ((jlong)(*( signed int *)((jint *)from )) << 32) | | |
94 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); } | |
95 #endif | |
96 | |
97 static inline oop get_obj(intptr_t *from) { return *(oop *)from; } | |
98 static inline jfloat get_float(intptr_t *from) { return *(jfloat *)from; } | |
99 | |
100 #ifdef _LP64 | |
101 static inline jdouble get_double(intptr_t *from) { return *(jdouble *)from; } | |
102 #else | |
103 static inline jdouble get_double(intptr_t *from) { jlong jl = ((jlong)(*( signed int *)((jint *)from )) << 32) | | |
104 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); | |
105 return *(jdouble *)&jl; } | |
106 #endif | |
107 | |
108 }; |