author | duke |
Wed, 05 Jul 2017 20:10:48 +0200 | |
changeset 27963 | 88d7c7c376e9 |
parent 7397 | 5b173b4ca846 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
7397 | 2 |
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef CPU_X86_VM_JNITYPES_X86_HPP |
26 |
#define CPU_X86_VM_JNITYPES_X86_HPP |
|
27 |
||
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "oops/oop.hpp" |
|
30 |
#include "prims/jni.h" |
|
31 |
||
1 | 32 |
// This file holds platform-dependent routines used to write primitive jni |
33 |
// types to the array of arguments passed into JavaCalls::call |
|
34 |
||
35 |
class JNITypes : AllStatic { |
|
36 |
// These functions write a java primitive type (in native format) |
|
37 |
// to a java stack slot array to be passed as an argument to JavaCalls:calls. |
|
38 |
// I.e., they are functionally 'push' operations if they have a 'pos' |
|
39 |
// formal parameter. Note that jlong's and jdouble's are written |
|
40 |
// _in reverse_ of the order in which they appear in the interpreter |
|
41 |
// stack. This is because call stubs (see stubGenerator_sparc.cpp) |
|
42 |
// reverse the argument list constructed by JavaCallArguments (see |
|
43 |
// javaCalls.hpp). |
|
44 |
||
45 |
private: |
|
46 |
||
47 |
#ifndef AMD64 |
|
48 |
// 32bit Helper routines. |
|
49 |
static inline void put_int2r(jint *from, intptr_t *to) { *(jint *)(to++) = from[1]; |
|
50 |
*(jint *)(to ) = from[0]; } |
|
51 |
static inline void put_int2r(jint *from, intptr_t *to, int& pos) { put_int2r(from, to + pos); pos += 2; } |
|
52 |
#endif // AMD64 |
|
53 |
||
54 |
public: |
|
55 |
// Ints are stored in native format in one JavaCallArgument slot at *to. |
|
56 |
static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; } |
|
57 |
static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; } |
|
58 |
static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; } |
|
59 |
||
60 |
#ifdef AMD64 |
|
61 |
// Longs are stored in native format in one JavaCallArgument slot at |
|
62 |
// *(to+1). |
|
63 |
static inline void put_long(jlong from, intptr_t *to) { |
|
64 |
*(jlong*) (to + 1) = from; |
|
65 |
} |
|
66 |
||
67 |
static inline void put_long(jlong from, intptr_t *to, int& pos) { |
|
68 |
*(jlong*) (to + 1 + pos) = from; |
|
69 |
pos += 2; |
|
70 |
} |
|
71 |
||
72 |
static inline void put_long(jlong *from, intptr_t *to, int& pos) { |
|
73 |
*(jlong*) (to + 1 + pos) = *from; |
|
74 |
pos += 2; |
|
75 |
} |
|
76 |
#else |
|
77 |
// Longs are stored in big-endian word format in two JavaCallArgument slots at *to. |
|
78 |
// The high half is in *to and the low half in *(to+1). |
|
79 |
static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, to); } |
|
80 |
static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } |
|
81 |
static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } |
|
82 |
#endif // AMD64 |
|
83 |
||
84 |
// Oops are stored in native format in one JavaCallArgument slot at *to. |
|
85 |
static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; } |
|
86 |
static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; } |
|
87 |
static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; } |
|
88 |
||
89 |
// Floats are stored in native format in one JavaCallArgument slot at *to. |
|
90 |
static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; } |
|
91 |
static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; } |
|
92 |
static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; } |
|
93 |
||
94 |
#undef _JNI_SLOT_OFFSET |
|
95 |
#ifdef AMD64 |
|
96 |
#define _JNI_SLOT_OFFSET 1 |
|
97 |
// Doubles are stored in native word format in one JavaCallArgument |
|
98 |
// slot at *(to+1). |
|
99 |
static inline void put_double(jdouble from, intptr_t *to) { |
|
100 |
*(jdouble*) (to + 1) = from; |
|
101 |
} |
|
102 |
||
103 |
static inline void put_double(jdouble from, intptr_t *to, int& pos) { |
|
104 |
*(jdouble*) (to + 1 + pos) = from; |
|
105 |
pos += 2; |
|
106 |
} |
|
107 |
||
108 |
static inline void put_double(jdouble *from, intptr_t *to, int& pos) { |
|
109 |
*(jdouble*) (to + 1 + pos) = *from; |
|
110 |
pos += 2; |
|
111 |
} |
|
112 |
#else |
|
113 |
#define _JNI_SLOT_OFFSET 0 |
|
114 |
// Doubles are stored in big-endian word format in two JavaCallArgument slots at *to. |
|
115 |
// The high half is in *to and the low half in *(to+1). |
|
116 |
static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, to); } |
|
117 |
static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } |
|
118 |
static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } |
|
119 |
#endif // AMD64 |
|
120 |
||
121 |
||
122 |
// The get_xxx routines, on the other hand, actually _do_ fetch |
|
123 |
// java primitive types from the interpreter stack. |
|
124 |
// No need to worry about alignment on Intel. |
|
125 |
static inline jint get_int (intptr_t *from) { return *(jint *) from; } |
|
126 |
static inline jlong get_long (intptr_t *from) { return *(jlong *) (from + _JNI_SLOT_OFFSET); } |
|
127 |
static inline oop get_obj (intptr_t *from) { return *(oop *) from; } |
|
128 |
static inline jfloat get_float (intptr_t *from) { return *(jfloat *) from; } |
|
129 |
static inline jdouble get_double(intptr_t *from) { return *(jdouble *)(from + _JNI_SLOT_OFFSET); } |
|
130 |
#undef _JNI_SLOT_OFFSET |
|
131 |
}; |
|
7397 | 132 |
|
133 |
#endif // CPU_X86_VM_JNITYPES_X86_HPP |