author | eosterlund |
Sat, 05 May 2018 22:19:19 +0200 | |
changeset 50023 | bdb627563075 |
parent 49480 | d7df2dd501ce |
child 54523 | 5df03f58d25b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49359
59f6547e151f
8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1998, 2018, 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" |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
27 |
#include "interpreter/interp_masm.hpp" |
7397 | 28 |
#include "interpreter/interpreter.hpp" |
29 |
#include "interpreter/interpreterRuntime.hpp" |
|
30 |
#include "memory/allocation.inline.hpp" |
|
49359
59f6547e151f
8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents:
47216
diff
changeset
|
31 |
#include "memory/universe.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
32 |
#include "oops/method.hpp" |
7397 | 33 |
#include "oops/oop.inline.hpp" |
34 |
#include "runtime/handles.inline.hpp" |
|
35 |
#include "runtime/icache.hpp" |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49359
diff
changeset
|
36 |
#include "runtime/interfaceSupport.inline.hpp" |
7397 | 37 |
#include "runtime/signature.hpp" |
1 | 38 |
|
39 |
||
40 |
#define __ _masm-> |
|
41 |
||
42 |
||
43 |
// Implementation of SignatureHandlerGenerator |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
44 |
InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator( |
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
45 |
const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) { |
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
46 |
_masm = new MacroAssembler(buffer); |
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
47 |
} |
1 | 48 |
|
49 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_word(int size_of_arg, int offset_in_arg) { |
|
50 |
Argument jni_arg(jni_offset() + offset_in_arg, false); |
|
51 |
Register Rtmp = O0; |
|
52 |
__ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); |
|
53 |
||
54 |
__ store_argument(Rtmp, jni_arg); |
|
55 |
} |
|
56 |
||
57 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_long() { |
|
58 |
Argument jni_arg(jni_offset(), false); |
|
59 |
Register Rtmp = O0; |
|
60 |
||
61 |
__ ldx(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); |
|
62 |
__ store_long_argument(Rtmp, jni_arg); |
|
63 |
} |
|
64 |
||
65 |
||
66 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() { |
|
67 |
Argument jni_arg(jni_offset(), false); |
|
68 |
FloatRegister Rtmp = F0; |
|
69 |
__ ldf(FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); |
|
70 |
__ store_float_argument(Rtmp, jni_arg); |
|
71 |
} |
|
72 |
||
73 |
||
74 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_double() { |
|
75 |
Argument jni_arg(jni_offset(), false); |
|
76 |
FloatRegister Rtmp = F0; |
|
77 |
__ ldf(FloatRegisterImpl::D, Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); |
|
78 |
__ store_double_argument(Rtmp, jni_arg); |
|
79 |
} |
|
80 |
||
81 |
void InterpreterRuntime::SignatureHandlerGenerator::pass_object() { |
|
82 |
Argument jni_arg(jni_offset(), false); |
|
83 |
Argument java_arg( offset(), true); |
|
84 |
Register Rtmp1 = O0; |
|
85 |
Register Rtmp2 = jni_arg.is_register() ? jni_arg.as_register() : O0; |
|
86 |
Register Rtmp3 = G3_scratch; |
|
87 |
||
88 |
// the handle for a receiver will never be null |
|
89 |
bool do_NULL_check = offset() != 0 || is_static(); |
|
90 |
||
2571 | 91 |
Address h_arg = Address(Llocals, Interpreter::local_offset_in_bytes(offset())); |
1 | 92 |
__ ld_ptr(h_arg, Rtmp1); |
93 |
if (!do_NULL_check) { |
|
2571 | 94 |
__ add(h_arg.base(), h_arg.disp(), Rtmp2); |
1 | 95 |
} else { |
96 |
if (Rtmp1 == Rtmp2) |
|
97 |
__ tst(Rtmp1); |
|
98 |
else __ addcc(G0, Rtmp1, Rtmp2); // optimize mov/test pair |
|
99 |
Label L; |
|
100 |
__ brx(Assembler::notZero, true, Assembler::pt, L); |
|
2571 | 101 |
__ delayed()->add(h_arg.base(), h_arg.disp(), Rtmp2); |
1 | 102 |
__ bind(L); |
103 |
} |
|
104 |
__ store_ptr_argument(Rtmp2, jni_arg); // this is often a no-op |
|
105 |
} |
|
106 |
||
107 |
||
108 |
void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) { |
|
109 |
||
110 |
// generate code to handle arguments |
|
111 |
iterate(fingerprint); |
|
112 |
||
113 |
// return result handler |
|
2571 | 114 |
AddressLiteral result_handler(Interpreter::result_handler(method()->result_type())); |
115 |
__ sethi(result_handler, Lscratch); |
|
1 | 116 |
__ retl(); |
2571 | 117 |
__ delayed()->add(Lscratch, result_handler.low10(), Lscratch); |
1 | 118 |
|
119 |
__ flush(); |
|
120 |
} |
|
121 |
||
122 |
||
123 |
// Implementation of SignatureHandlerLibrary |
|
124 |
||
125 |
void SignatureHandlerLibrary::pd_set_handler(address handler) {} |
|
126 |
||
127 |
||
128 |
class SlowSignatureHandler: public NativeSignatureIterator { |
|
129 |
private: |
|
130 |
address _from; |
|
131 |
intptr_t* _to; |
|
132 |
intptr_t* _RegArgSignature; // Signature of first Arguments to be passed in Registers |
|
133 |
uint _argcount; |
|
134 |
||
135 |
enum { // We need to differenciate float from non floats in reg args |
|
136 |
non_float = 0, |
|
137 |
float_sig = 1, |
|
138 |
double_sig = 2, |
|
139 |
long_sig = 3 |
|
140 |
}; |
|
141 |
||
142 |
virtual void pass_int() { |
|
143 |
*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); |
|
5419 | 144 |
_from -= Interpreter::stackElementSize; |
1 | 145 |
add_signature( non_float ); |
146 |
} |
|
147 |
||
148 |
virtual void pass_object() { |
|
149 |
// pass address of from |
|
150 |
intptr_t *from_addr = (intptr_t*)(_from + Interpreter::local_offset_in_bytes(0)); |
|
151 |
*_to++ = (*from_addr == 0) ? NULL : (intptr_t) from_addr; |
|
5419 | 152 |
_from -= Interpreter::stackElementSize; |
1 | 153 |
add_signature( non_float ); |
154 |
} |
|
155 |
||
156 |
virtual void pass_float() { |
|
157 |
*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); |
|
5419 | 158 |
_from -= Interpreter::stackElementSize; |
1 | 159 |
add_signature( float_sig ); |
160 |
} |
|
161 |
||
162 |
virtual void pass_double() { |
|
163 |
*_to++ = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); |
|
5419 | 164 |
_from -= 2*Interpreter::stackElementSize; |
1 | 165 |
add_signature( double_sig ); |
166 |
} |
|
167 |
||
168 |
virtual void pass_long() { |
|
169 |
_to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); |
|
170 |
_to += 1; |
|
5419 | 171 |
_from -= 2*Interpreter::stackElementSize; |
1 | 172 |
add_signature( long_sig ); |
173 |
} |
|
174 |
||
175 |
virtual void add_signature( intptr_t sig_type ) { |
|
176 |
if ( _argcount < (sizeof (intptr_t))*4 ) { |
|
177 |
*_RegArgSignature |= (sig_type << (_argcount*2) ); |
|
178 |
_argcount++; |
|
179 |
} |
|
180 |
} |
|
181 |
||
182 |
||
183 |
public: |
|
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46381
diff
changeset
|
184 |
SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to, intptr_t *RegArgSig) : NativeSignatureIterator(method) { |
1 | 185 |
_from = from; |
186 |
_to = to; |
|
187 |
_RegArgSignature = RegArgSig; |
|
188 |
*_RegArgSignature = 0; |
|
189 |
_argcount = method->is_static() ? 2 : 1; |
|
190 |
} |
|
191 |
}; |
|
192 |
||
193 |
||
194 |
IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler( |
|
195 |
JavaThread* thread, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
196 |
Method* method, |
1 | 197 |
intptr_t* from, |
198 |
intptr_t* to )) |
|
199 |
methodHandle m(thread, method); |
|
200 |
assert(m->is_native(), "sanity check"); |
|
201 |
// handle arguments |
|
202 |
// Warning: We use reg arg slot 00 temporarily to return the RegArgSignature |
|
203 |
// back to the code that pops the arguments into the CPU registers |
|
27471 | 204 |
SlowSignatureHandler(m, (address)from, m->is_static() ? to+2 : to+1, to).iterate((uint64_t)CONST64(-1)); |
1 | 205 |
// return result handler |
206 |
return Interpreter::result_handler(m->result_type()); |
|
207 |
IRT_END |