author | prr |
Wed, 15 Apr 2015 14:28:43 -0700 | |
changeset 30465 | a77083748efc |
parent 27471 | 6e56277909f1 |
child 46381 | 020219e46c86 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
2 |
* Copyright (c) 1998, 2012, 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:
5419
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5419
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:
5419
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
13728
diff
changeset
|
26 |
#include "asm/macroAssembler.inline.hpp" |
7397 | 27 |
#include "interpreter/interpreter.hpp" |
28 |
#include "interpreter/interpreterRuntime.hpp" |
|
29 |
#include "memory/allocation.inline.hpp" |
|
30 |
#include "memory/universe.inline.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
31 |
#include "oops/method.hpp" |
7397 | 32 |
#include "oops/oop.inline.hpp" |
33 |
#include "runtime/handles.inline.hpp" |
|
34 |
#include "runtime/icache.hpp" |
|
35 |
#include "runtime/interfaceSupport.hpp" |
|
36 |
#include "runtime/signature.hpp" |
|
1 | 37 |
|
38 |
||
39 |
#define __ _masm-> |
|
40 |
||
41 |
||
42 |
// Implementation of SignatureHandlerGenerator |
|
43 |
||
44 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_word(int size_of_arg, int offset_in_arg) { |
|
45 |
Argument jni_arg(jni_offset() + offset_in_arg, false); |
|
46 |
Register Rtmp = O0; |
|
47 |
__ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); |
|
48 |
||
49 |
__ store_argument(Rtmp, jni_arg); |
|
50 |
} |
|
51 |
||
52 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_long() { |
|
53 |
Argument jni_arg(jni_offset(), false); |
|
54 |
Register Rtmp = O0; |
|
55 |
||
56 |
#ifdef _LP64 |
|
57 |
__ ldx(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); |
|
58 |
__ store_long_argument(Rtmp, jni_arg); |
|
59 |
#else |
|
60 |
__ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); |
|
61 |
__ store_argument(Rtmp, jni_arg); |
|
62 |
__ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 0), Rtmp); |
|
63 |
Argument successor(jni_arg.successor()); |
|
64 |
__ store_argument(Rtmp, successor); |
|
65 |
#endif |
|
66 |
} |
|
67 |
||
68 |
||
69 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() { |
|
70 |
Argument jni_arg(jni_offset(), false); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
71 |
#ifdef _LP64 |
1 | 72 |
FloatRegister Rtmp = F0; |
73 |
__ ldf(FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); |
|
74 |
__ store_float_argument(Rtmp, jni_arg); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
75 |
#else |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
76 |
Register Rtmp = O0; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
77 |
__ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
78 |
__ store_argument(Rtmp, jni_arg); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
79 |
#endif |
1 | 80 |
} |
81 |
||
82 |
||
83 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_double() { |
|
84 |
Argument jni_arg(jni_offset(), false); |
|
85 |
#ifdef _LP64 |
|
86 |
FloatRegister Rtmp = F0; |
|
87 |
__ ldf(FloatRegisterImpl::D, Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); |
|
88 |
__ store_double_argument(Rtmp, jni_arg); |
|
89 |
#else |
|
90 |
Register Rtmp = O0; |
|
91 |
__ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); |
|
92 |
__ store_argument(Rtmp, jni_arg); |
|
93 |
__ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); |
|
94 |
Argument successor(jni_arg.successor()); |
|
95 |
__ store_argument(Rtmp, successor); |
|
96 |
#endif |
|
97 |
} |
|
98 |
||
99 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_object() { |
|
100 |
Argument jni_arg(jni_offset(), false); |
|
101 |
Argument java_arg( offset(), true); |
|
102 |
Register Rtmp1 = O0; |
|
103 |
Register Rtmp2 = jni_arg.is_register() ? jni_arg.as_register() : O0; |
|
104 |
Register Rtmp3 = G3_scratch; |
|
105 |
||
106 |
// the handle for a receiver will never be null |
|
107 |
bool do_NULL_check = offset() != 0 || is_static(); |
|
108 |
||
2571 | 109 |
Address h_arg = Address(Llocals, Interpreter::local_offset_in_bytes(offset())); |
1 | 110 |
__ ld_ptr(h_arg, Rtmp1); |
111 |
if (!do_NULL_check) { |
|
2571 | 112 |
__ add(h_arg.base(), h_arg.disp(), Rtmp2); |
1 | 113 |
} else { |
114 |
if (Rtmp1 == Rtmp2) |
|
115 |
__ tst(Rtmp1); |
|
116 |
else __ addcc(G0, Rtmp1, Rtmp2); // optimize mov/test pair |
|
117 |
Label L; |
|
118 |
__ brx(Assembler::notZero, true, Assembler::pt, L); |
|
2571 | 119 |
__ delayed()->add(h_arg.base(), h_arg.disp(), Rtmp2); |
1 | 120 |
__ bind(L); |
121 |
} |
|
122 |
__ store_ptr_argument(Rtmp2, jni_arg); // this is often a no-op |
|
123 |
} |
|
124 |
||
125 |
||
126 |
void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) { |
|
127 |
||
128 |
// generate code to handle arguments |
|
129 |
iterate(fingerprint); |
|
130 |
||
131 |
// return result handler |
|
2571 | 132 |
AddressLiteral result_handler(Interpreter::result_handler(method()->result_type())); |
133 |
__ sethi(result_handler, Lscratch); |
|
1 | 134 |
__ retl(); |
2571 | 135 |
__ delayed()->add(Lscratch, result_handler.low10(), Lscratch); |
1 | 136 |
|
137 |
__ flush(); |
|
138 |
} |
|
139 |
||
140 |
||
141 |
// Implementation of SignatureHandlerLibrary |
|
142 |
||
143 |
void SignatureHandlerLibrary::pd_set_handler(address handler) {} |
|
144 |
||
145 |
||
146 |
class SlowSignatureHandler: public NativeSignatureIterator { |
|
147 |
private: |
|
148 |
address _from; |
|
149 |
intptr_t* _to; |
|
150 |
intptr_t* _RegArgSignature; // Signature of first Arguments to be passed in Registers |
|
151 |
uint _argcount; |
|
152 |
||
153 |
enum { // We need to differenciate float from non floats in reg args |
|
154 |
non_float = 0, |
|
155 |
float_sig = 1, |
|
156 |
double_sig = 2, |
|
157 |
long_sig = 3 |
|
158 |
}; |
|
159 |
||
160 |
virtual void pass_int() { |
|
161 |
*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); |
|
5419 | 162 |
_from -= Interpreter::stackElementSize; |
1 | 163 |
add_signature( non_float ); |
164 |
} |
|
165 |
||
166 |
virtual void pass_object() { |
|
167 |
// pass address of from |
|
168 |
intptr_t *from_addr = (intptr_t*)(_from + Interpreter::local_offset_in_bytes(0)); |
|
169 |
*_to++ = (*from_addr == 0) ? NULL : (intptr_t) from_addr; |
|
5419 | 170 |
_from -= Interpreter::stackElementSize; |
1 | 171 |
add_signature( non_float ); |
172 |
} |
|
173 |
||
174 |
#ifdef _LP64 |
|
175 |
virtual void pass_float() { |
|
176 |
*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); |
|
5419 | 177 |
_from -= Interpreter::stackElementSize; |
1 | 178 |
add_signature( float_sig ); |
179 |
} |
|
180 |
||
181 |
virtual void pass_double() { |
|
182 |
*_to++ = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); |
|
5419 | 183 |
_from -= 2*Interpreter::stackElementSize; |
1 | 184 |
add_signature( double_sig ); |
185 |
} |
|
186 |
||
187 |
virtual void pass_long() { |
|
188 |
_to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); |
|
189 |
_to += 1; |
|
5419 | 190 |
_from -= 2*Interpreter::stackElementSize; |
1 | 191 |
add_signature( long_sig ); |
192 |
} |
|
193 |
#else |
|
194 |
// pass_double() is pass_long() and pass_float() only _LP64 |
|
195 |
virtual void pass_long() { |
|
196 |
_to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); |
|
197 |
_to[1] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(0)); |
|
198 |
_to += 2; |
|
5419 | 199 |
_from -= 2*Interpreter::stackElementSize; |
1 | 200 |
add_signature( non_float ); |
201 |
} |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
202 |
|
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
203 |
virtual void pass_float() { |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
204 |
*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
205 |
_from -= Interpreter::stackElementSize; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
206 |
add_signature( non_float ); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
207 |
} |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
208 |
|
1 | 209 |
#endif // _LP64 |
210 |
||
211 |
virtual void add_signature( intptr_t sig_type ) { |
|
212 |
if ( _argcount < (sizeof (intptr_t))*4 ) { |
|
213 |
*_RegArgSignature |= (sig_type << (_argcount*2) ); |
|
214 |
_argcount++; |
|
215 |
} |
|
216 |
} |
|
217 |
||
218 |
||
219 |
public: |
|
220 |
SlowSignatureHandler(methodHandle method, address from, intptr_t* to, intptr_t *RegArgSig) : NativeSignatureIterator(method) { |
|
221 |
_from = from; |
|
222 |
_to = to; |
|
223 |
_RegArgSignature = RegArgSig; |
|
224 |
*_RegArgSignature = 0; |
|
225 |
_argcount = method->is_static() ? 2 : 1; |
|
226 |
} |
|
227 |
}; |
|
228 |
||
229 |
||
230 |
IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler( |
|
231 |
JavaThread* thread, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
232 |
Method* method, |
1 | 233 |
intptr_t* from, |
234 |
intptr_t* to )) |
|
235 |
methodHandle m(thread, method); |
|
236 |
assert(m->is_native(), "sanity check"); |
|
237 |
// handle arguments |
|
238 |
// Warning: We use reg arg slot 00 temporarily to return the RegArgSignature |
|
239 |
// back to the code that pops the arguments into the CPU registers |
|
27471 | 240 |
SlowSignatureHandler(m, (address)from, m->is_static() ? to+2 : to+1, to).iterate((uint64_t)CONST64(-1)); |
1 | 241 |
// return result handler |
242 |
return Interpreter::result_handler(m->result_type()); |
|
243 |
IRT_END |