author | coleenp |
Mon, 04 Jun 2018 10:18:43 -0400 | |
changeset 50380 | bec342339138 |
parent 50094 | 2f79462aab9b |
child 50519 | 17bde7f98889 |
permissions | -rw-r--r-- |
29184 | 1 |
/* |
49347
edb65305d3ac
8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
29184 | 3 |
* Copyright (c) 2014, Red Hat Inc. All rights reserved. |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
26 |
#include "precompiled.hpp" |
|
50380
bec342339138
8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents:
50094
diff
changeset
|
27 |
#include "asm/macroAssembler.inline.hpp" |
29184 | 28 |
#include "c1/c1_CodeStubs.hpp" |
29 |
#include "c1/c1_FrameMap.hpp" |
|
30 |
#include "c1/c1_LIRAssembler.hpp" |
|
31 |
#include "c1/c1_MacroAssembler.hpp" |
|
32 |
#include "c1/c1_Runtime1.hpp" |
|
33 |
#include "nativeInst_aarch64.hpp" |
|
34 |
#include "runtime/sharedRuntime.hpp" |
|
35 |
#include "vmreg_aarch64.inline.hpp" |
|
36 |
||
37 |
||
38 |
#define __ ce->masm()-> |
|
39 |
||
40 |
void CounterOverflowStub::emit_code(LIR_Assembler* ce) { |
|
41 |
__ bind(_entry); |
|
34200 | 42 |
Metadata *m = _method->as_constant_ptr()->as_metadata(); |
43 |
__ mov_metadata(rscratch1, m); |
|
44 |
ce->store_parameter(rscratch1, 1); |
|
29184 | 45 |
ce->store_parameter(_bci, 0); |
46 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id))); |
|
47 |
ce->add_call_info_here(_info); |
|
48 |
ce->verify_oop_map(_info); |
|
49 |
__ b(_continuation); |
|
50 |
} |
|
51 |
||
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
52 |
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
53 |
: _throw_index_out_of_bounds_exception(false), _index(index), _array(array) { |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
54 |
assert(info != NULL, "must have info"); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
55 |
_info = new CodeEmitInfo(info); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
56 |
} |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
57 |
|
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
58 |
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
59 |
: _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) { |
29184 | 60 |
assert(info != NULL, "must have info"); |
61 |
_info = new CodeEmitInfo(info); |
|
62 |
} |
|
63 |
||
64 |
void RangeCheckStub::emit_code(LIR_Assembler* ce) { |
|
65 |
__ bind(_entry); |
|
66 |
if (_info->deoptimize_on_exception()) { |
|
67 |
address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); |
|
68 |
__ far_call(RuntimeAddress(a)); |
|
69 |
ce->add_call_info_here(_info); |
|
70 |
ce->verify_oop_map(_info); |
|
71 |
debug_only(__ should_not_reach_here()); |
|
72 |
return; |
|
73 |
} |
|
74 |
||
75 |
if (_index->is_cpu_register()) { |
|
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
76 |
__ mov(r22, _index->as_register()); |
29184 | 77 |
} else { |
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
78 |
__ mov(r22, _index->as_jint()); |
29184 | 79 |
} |
80 |
Runtime1::StubID stub_id; |
|
81 |
if (_throw_index_out_of_bounds_exception) { |
|
82 |
stub_id = Runtime1::throw_index_exception_id; |
|
83 |
} else { |
|
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
84 |
assert(_array != NULL, "sanity"); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49906
diff
changeset
|
85 |
__ mov(r23, _array->as_pointer_register()); |
29184 | 86 |
stub_id = Runtime1::throw_range_check_failed_id; |
87 |
} |
|
88 |
__ far_call(RuntimeAddress(Runtime1::entry_for(stub_id)), NULL, rscratch2); |
|
89 |
ce->add_call_info_here(_info); |
|
90 |
ce->verify_oop_map(_info); |
|
91 |
debug_only(__ should_not_reach_here()); |
|
92 |
} |
|
93 |
||
94 |
PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { |
|
95 |
_info = new CodeEmitInfo(info); |
|
96 |
} |
|
97 |
||
98 |
void PredicateFailedStub::emit_code(LIR_Assembler* ce) { |
|
99 |
__ bind(_entry); |
|
100 |
address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); |
|
101 |
__ far_call(RuntimeAddress(a)); |
|
102 |
ce->add_call_info_here(_info); |
|
103 |
ce->verify_oop_map(_info); |
|
104 |
debug_only(__ should_not_reach_here()); |
|
105 |
} |
|
106 |
||
107 |
void DivByZeroStub::emit_code(LIR_Assembler* ce) { |
|
108 |
if (_offset != -1) { |
|
109 |
ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); |
|
110 |
} |
|
111 |
__ bind(_entry); |
|
112 |
__ far_call(Address(Runtime1::entry_for(Runtime1::throw_div0_exception_id), relocInfo::runtime_call_type)); |
|
113 |
ce->add_call_info_here(_info); |
|
114 |
ce->verify_oop_map(_info); |
|
115 |
#ifdef ASSERT |
|
116 |
__ should_not_reach_here(); |
|
117 |
#endif |
|
118 |
} |
|
119 |
||
120 |
||
121 |
||
122 |
// Implementation of NewInstanceStub |
|
123 |
||
124 |
NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) { |
|
125 |
_result = result; |
|
126 |
_klass = klass; |
|
127 |
_klass_reg = klass_reg; |
|
128 |
_info = new CodeEmitInfo(info); |
|
129 |
assert(stub_id == Runtime1::new_instance_id || |
|
130 |
stub_id == Runtime1::fast_new_instance_id || |
|
131 |
stub_id == Runtime1::fast_new_instance_init_check_id, |
|
132 |
"need new_instance id"); |
|
133 |
_stub_id = stub_id; |
|
134 |
} |
|
135 |
||
136 |
||
137 |
||
138 |
void NewInstanceStub::emit_code(LIR_Assembler* ce) { |
|
139 |
assert(__ rsp_offset() == 0, "frame size should be fixed"); |
|
140 |
__ bind(_entry); |
|
141 |
__ mov(r3, _klass_reg->as_register()); |
|
142 |
__ far_call(RuntimeAddress(Runtime1::entry_for(_stub_id))); |
|
143 |
ce->add_call_info_here(_info); |
|
144 |
ce->verify_oop_map(_info); |
|
145 |
assert(_result->as_register() == r0, "result must in r0,"); |
|
146 |
__ b(_continuation); |
|
147 |
} |
|
148 |
||
149 |
||
150 |
// Implementation of NewTypeArrayStub |
|
151 |
||
152 |
// Implementation of NewTypeArrayStub |
|
153 |
||
154 |
NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) { |
|
155 |
_klass_reg = klass_reg; |
|
156 |
_length = length; |
|
157 |
_result = result; |
|
158 |
_info = new CodeEmitInfo(info); |
|
159 |
} |
|
160 |
||
161 |
||
162 |
void NewTypeArrayStub::emit_code(LIR_Assembler* ce) { |
|
163 |
assert(__ rsp_offset() == 0, "frame size should be fixed"); |
|
164 |
__ bind(_entry); |
|
165 |
assert(_length->as_register() == r19, "length must in r19,"); |
|
166 |
assert(_klass_reg->as_register() == r3, "klass_reg must in r3"); |
|
167 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id))); |
|
168 |
ce->add_call_info_here(_info); |
|
169 |
ce->verify_oop_map(_info); |
|
170 |
assert(_result->as_register() == r0, "result must in r0"); |
|
171 |
__ b(_continuation); |
|
172 |
} |
|
173 |
||
174 |
||
175 |
// Implementation of NewObjectArrayStub |
|
176 |
||
177 |
NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) { |
|
178 |
_klass_reg = klass_reg; |
|
179 |
_result = result; |
|
180 |
_length = length; |
|
181 |
_info = new CodeEmitInfo(info); |
|
182 |
} |
|
183 |
||
184 |
||
185 |
void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { |
|
186 |
assert(__ rsp_offset() == 0, "frame size should be fixed"); |
|
187 |
__ bind(_entry); |
|
188 |
assert(_length->as_register() == r19, "length must in r19,"); |
|
189 |
assert(_klass_reg->as_register() == r3, "klass_reg must in r3"); |
|
190 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id))); |
|
191 |
ce->add_call_info_here(_info); |
|
192 |
ce->verify_oop_map(_info); |
|
193 |
assert(_result->as_register() == r0, "result must in r0"); |
|
194 |
__ b(_continuation); |
|
195 |
} |
|
196 |
// Implementation of MonitorAccessStubs |
|
197 |
||
198 |
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info) |
|
199 |
: MonitorAccessStub(obj_reg, lock_reg) |
|
200 |
{ |
|
201 |
_info = new CodeEmitInfo(info); |
|
202 |
} |
|
203 |
||
204 |
||
205 |
void MonitorEnterStub::emit_code(LIR_Assembler* ce) { |
|
206 |
assert(__ rsp_offset() == 0, "frame size should be fixed"); |
|
207 |
__ bind(_entry); |
|
208 |
ce->store_parameter(_obj_reg->as_register(), 1); |
|
209 |
ce->store_parameter(_lock_reg->as_register(), 0); |
|
210 |
Runtime1::StubID enter_id; |
|
211 |
if (ce->compilation()->has_fpu_code()) { |
|
212 |
enter_id = Runtime1::monitorenter_id; |
|
213 |
} else { |
|
214 |
enter_id = Runtime1::monitorenter_nofpu_id; |
|
215 |
} |
|
216 |
__ far_call(RuntimeAddress(Runtime1::entry_for(enter_id))); |
|
217 |
ce->add_call_info_here(_info); |
|
218 |
ce->verify_oop_map(_info); |
|
219 |
__ b(_continuation); |
|
220 |
} |
|
221 |
||
222 |
||
223 |
void MonitorExitStub::emit_code(LIR_Assembler* ce) { |
|
224 |
__ bind(_entry); |
|
225 |
if (_compute_lock) { |
|
226 |
// lock_reg was destroyed by fast unlocking attempt => recompute it |
|
227 |
ce->monitor_address(_monitor_ix, _lock_reg); |
|
228 |
} |
|
229 |
ce->store_parameter(_lock_reg->as_register(), 0); |
|
230 |
// note: non-blocking leaf routine => no call info needed |
|
231 |
Runtime1::StubID exit_id; |
|
232 |
if (ce->compilation()->has_fpu_code()) { |
|
233 |
exit_id = Runtime1::monitorexit_id; |
|
234 |
} else { |
|
235 |
exit_id = Runtime1::monitorexit_nofpu_id; |
|
236 |
} |
|
237 |
__ adr(lr, _continuation); |
|
238 |
__ far_jump(RuntimeAddress(Runtime1::entry_for(exit_id))); |
|
239 |
} |
|
240 |
||
241 |
||
242 |
// Implementation of patching: |
|
243 |
// - Copy the code at given offset to an inlined buffer (first the bytes, then the number of bytes) |
|
244 |
// - Replace original code with a call to the stub |
|
245 |
// At Runtime: |
|
246 |
// - call to stub, jump to runtime |
|
247 |
// - in runtime: preserve all registers (rspecially objects, i.e., source and destination object) |
|
248 |
// - in runtime: after initializing class, restore original code, reexecute instruction |
|
249 |
||
250 |
int PatchingStub::_patch_info_offset = -NativeGeneralJump::instruction_size; |
|
251 |
||
252 |
void PatchingStub::align_patch_site(MacroAssembler* masm) { |
|
253 |
} |
|
254 |
||
255 |
void PatchingStub::emit_code(LIR_Assembler* ce) { |
|
256 |
assert(false, "AArch64 should not use C1 runtime patching"); |
|
257 |
} |
|
258 |
||
259 |
||
260 |
void DeoptimizeStub::emit_code(LIR_Assembler* ce) { |
|
261 |
__ bind(_entry); |
|
35560 | 262 |
ce->store_parameter(_trap_request, 0); |
29184 | 263 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::deoptimize_id))); |
264 |
ce->add_call_info_here(_info); |
|
265 |
DEBUG_ONLY(__ should_not_reach_here()); |
|
266 |
} |
|
267 |
||
268 |
||
269 |
void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { |
|
270 |
address a; |
|
271 |
if (_info->deoptimize_on_exception()) { |
|
272 |
// Deoptimize, do not throw the exception, because it is probably wrong to do it here. |
|
273 |
a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); |
|
274 |
} else { |
|
275 |
a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); |
|
276 |
} |
|
277 |
||
278 |
ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); |
|
279 |
__ bind(_entry); |
|
280 |
__ far_call(RuntimeAddress(a)); |
|
281 |
ce->add_call_info_here(_info); |
|
282 |
ce->verify_oop_map(_info); |
|
283 |
debug_only(__ should_not_reach_here()); |
|
284 |
} |
|
285 |
||
286 |
||
287 |
void SimpleExceptionStub::emit_code(LIR_Assembler* ce) { |
|
288 |
assert(__ rsp_offset() == 0, "frame size should be fixed"); |
|
289 |
||
290 |
__ bind(_entry); |
|
291 |
// pass the object in a scratch register because all other registers |
|
292 |
// must be preserved |
|
293 |
if (_obj->is_cpu_register()) { |
|
294 |
__ mov(rscratch1, _obj->as_register()); |
|
295 |
} |
|
296 |
__ far_call(RuntimeAddress(Runtime1::entry_for(_stub)), NULL, rscratch2); |
|
297 |
ce->add_call_info_here(_info); |
|
298 |
debug_only(__ should_not_reach_here()); |
|
299 |
} |
|
300 |
||
301 |
||
302 |
void ArrayCopyStub::emit_code(LIR_Assembler* ce) { |
|
303 |
//---------------slow case: call to native----------------- |
|
304 |
__ bind(_entry); |
|
305 |
// Figure out where the args should go |
|
306 |
// This should really convert the IntrinsicID to the Method* and signature |
|
307 |
// but I don't know how to do that. |
|
308 |
// |
|
309 |
VMRegPair args[5]; |
|
310 |
BasicType signature[5] = { T_OBJECT, T_INT, T_OBJECT, T_INT, T_INT}; |
|
311 |
SharedRuntime::java_calling_convention(signature, args, 5, true); |
|
312 |
||
313 |
// push parameters |
|
314 |
// (src, src_pos, dest, destPos, length) |
|
315 |
Register r[5]; |
|
316 |
r[0] = src()->as_register(); |
|
317 |
r[1] = src_pos()->as_register(); |
|
318 |
r[2] = dst()->as_register(); |
|
319 |
r[3] = dst_pos()->as_register(); |
|
320 |
r[4] = length()->as_register(); |
|
321 |
||
322 |
// next registers will get stored on the stack |
|
323 |
for (int i = 0; i < 5 ; i++ ) { |
|
324 |
VMReg r_1 = args[i].first(); |
|
325 |
if (r_1->is_stack()) { |
|
326 |
int st_off = r_1->reg2stack() * wordSize; |
|
327 |
__ str (r[i], Address(sp, st_off)); |
|
328 |
} else { |
|
329 |
assert(r[i] == args[i].first()->as_Register(), "Wrong register for arg "); |
|
330 |
} |
|
331 |
} |
|
332 |
||
333 |
ce->align_call(lir_static_call); |
|
334 |
||
335 |
ce->emit_static_call_stub(); |
|
32082
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
336 |
if (ce->compilation()->bailed_out()) { |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
337 |
return; // CodeCache is full |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
338 |
} |
29184 | 339 |
Address resolve(SharedRuntime::get_resolve_static_call_stub(), |
340 |
relocInfo::static_call_type); |
|
32082
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
341 |
address call = __ trampoline_call(resolve); |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
342 |
if (call == NULL) { |
32086
7590882ae33a
8132875: AArch64: Fix error introduced into AArch64 CodeCache by commit for 8130309
adinn
parents:
32082
diff
changeset
|
343 |
ce->bailout("trampoline stub overflow"); |
32082
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
344 |
return; |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
345 |
} |
29184 | 346 |
ce->add_call_info_here(info()); |
347 |
||
348 |
#ifndef PRODUCT |
|
349 |
__ lea(rscratch2, ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt)); |
|
350 |
__ incrementw(Address(rscratch2)); |
|
351 |
#endif |
|
352 |
||
353 |
__ b(_continuation); |
|
354 |
} |
|
355 |
||
356 |
#undef __ |