Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp
40930 views
1
/*
2
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2012, 2018 SAP SE. 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"
27
#include "asm/macroAssembler.inline.hpp"
28
#include "c1/c1_Defs.hpp"
29
#include "c1/c1_MacroAssembler.hpp"
30
#include "c1/c1_Runtime1.hpp"
31
#include "ci/ciUtilities.hpp"
32
#include "compiler/oopMap.hpp"
33
#include "gc/shared/cardTable.hpp"
34
#include "gc/shared/cardTableBarrierSet.hpp"
35
#include "interpreter/interpreter.hpp"
36
#include "nativeInst_ppc.hpp"
37
#include "oops/compiledICHolder.hpp"
38
#include "oops/oop.inline.hpp"
39
#include "prims/jvmtiExport.hpp"
40
#include "register_ppc.hpp"
41
#include "runtime/sharedRuntime.hpp"
42
#include "runtime/signature.hpp"
43
#include "runtime/vframeArray.hpp"
44
#include "utilities/align.hpp"
45
#include "utilities/macros.hpp"
46
#include "utilities/powerOfTwo.hpp"
47
#include "vmreg_ppc.inline.hpp"
48
49
// Implementation of StubAssembler
50
51
int StubAssembler::call_RT(Register oop_result1, Register metadata_result,
52
address entry_point, int number_of_arguments) {
53
set_num_rt_args(0); // Nothing on stack
54
assert(!(oop_result1->is_valid() || metadata_result->is_valid()) ||
55
oop_result1 != metadata_result, "registers must be different");
56
57
// Currently no stack banging. We assume that there are enough
58
// StackShadowPages (which have been banged in generate_stack_overflow_check)
59
// for the stub frame and the runtime frames.
60
61
set_last_Java_frame(R1_SP, noreg);
62
63
// ARG1 must hold thread address.
64
mr(R3_ARG1, R16_thread);
65
66
address return_pc = call_c_with_frame_resize(entry_point, /*No resize, we have a C compatible frame.*/0);
67
68
reset_last_Java_frame();
69
70
// Check for pending exceptions.
71
{
72
ld(R0, in_bytes(Thread::pending_exception_offset()), R16_thread);
73
cmpdi(CCR0, R0, 0);
74
75
// This used to conditionally jump to forward_exception however it is
76
// possible if we relocate that the branch will not reach. So we must jump
77
// around so we can always reach.
78
79
Label ok;
80
beq(CCR0, ok);
81
82
// Make sure that the vm_results are cleared.
83
if (oop_result1->is_valid() || metadata_result->is_valid()) {
84
li(R0, 0);
85
if (oop_result1->is_valid()) {
86
std(R0, in_bytes(JavaThread::vm_result_offset()), R16_thread);
87
}
88
if (metadata_result->is_valid()) {
89
std(R0, in_bytes(JavaThread::vm_result_2_offset()), R16_thread);
90
}
91
}
92
93
if (frame_size() == no_frame_size) {
94
ShouldNotReachHere(); // We always have a frame size.
95
//pop_frame(); // pop the stub frame
96
//ld(R0, _abi0(lr), R1_SP);
97
//mtlr(R0);
98
//load_const_optimized(R0, StubRoutines::forward_exception_entry());
99
//mtctr(R0);
100
//bctr();
101
} else if (_stub_id == Runtime1::forward_exception_id) {
102
should_not_reach_here();
103
} else {
104
// keep stub frame for next call_RT
105
//load_const_optimized(R0, Runtime1::entry_for(Runtime1::forward_exception_id));
106
add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(Runtime1::entry_for(Runtime1::forward_exception_id)));
107
mtctr(R0);
108
bctr();
109
}
110
111
bind(ok);
112
}
113
114
// Get oop results if there are any and reset the values in the thread.
115
if (oop_result1->is_valid()) {
116
get_vm_result(oop_result1);
117
}
118
if (metadata_result->is_valid()) {
119
get_vm_result_2(metadata_result);
120
}
121
122
return (int)(return_pc - code_section()->start());
123
}
124
125
126
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1) {
127
mr_if_needed(R4_ARG2, arg1);
128
return call_RT(oop_result1, metadata_result, entry, 1);
129
}
130
131
132
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2) {
133
mr_if_needed(R4_ARG2, arg1);
134
mr_if_needed(R5_ARG3, arg2); assert(arg2 != R4_ARG2, "smashed argument");
135
return call_RT(oop_result1, metadata_result, entry, 2);
136
}
137
138
139
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2, Register arg3) {
140
mr_if_needed(R4_ARG2, arg1);
141
mr_if_needed(R5_ARG3, arg2); assert(arg2 != R4_ARG2, "smashed argument");
142
mr_if_needed(R6_ARG4, arg3); assert(arg3 != R4_ARG2 && arg3 != R5_ARG3, "smashed argument");
143
return call_RT(oop_result1, metadata_result, entry, 3);
144
}
145
146
147
// Implementation of Runtime1
148
149
#define __ sasm->
150
151
static int cpu_reg_save_offsets[FrameMap::nof_cpu_regs];
152
static int fpu_reg_save_offsets[FrameMap::nof_fpu_regs];
153
static int frame_size_in_bytes = -1;
154
155
static OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers) {
156
assert(frame_size_in_bytes > frame::abi_reg_args_size, "init");
157
sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
158
int frame_size_in_slots = frame_size_in_bytes / sizeof(jint);
159
OopMap* oop_map = new OopMap(frame_size_in_slots, 0);
160
161
int i;
162
for (i = 0; i < FrameMap::nof_cpu_regs; i++) {
163
Register r = as_Register(i);
164
if (FrameMap::reg_needs_save(r)) {
165
int sp_offset = cpu_reg_save_offsets[i];
166
oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset>>2), r->as_VMReg());
167
oop_map->set_callee_saved(VMRegImpl::stack2reg((sp_offset>>2) + 1), r->as_VMReg()->next());
168
}
169
}
170
171
if (save_fpu_registers) {
172
for (i = 0; i < FrameMap::nof_fpu_regs; i++) {
173
FloatRegister r = as_FloatRegister(i);
174
int sp_offset = fpu_reg_save_offsets[i];
175
oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset>>2), r->as_VMReg());
176
oop_map->set_callee_saved(VMRegImpl::stack2reg((sp_offset>>2) + 1), r->as_VMReg()->next());
177
}
178
}
179
180
return oop_map;
181
}
182
183
static OopMap* save_live_registers(StubAssembler* sasm, bool save_fpu_registers = true,
184
Register ret_pc = noreg, int stack_preserve = 0) {
185
if (ret_pc == noreg) {
186
ret_pc = R0;
187
__ mflr(ret_pc);
188
}
189
__ std(ret_pc, _abi0(lr), R1_SP); // C code needs pc in C1 method.
190
__ push_frame(frame_size_in_bytes + stack_preserve, R0);
191
192
// Record volatile registers as callee-save values in an OopMap so
193
// their save locations will be propagated to the caller frame's
194
// RegisterMap during StackFrameStream construction (needed for
195
// deoptimization; see compiledVFrame::create_stack_value).
196
// OopMap frame sizes are in c2 stack slot sizes (sizeof(jint)).
197
198
int i;
199
for (i = 0; i < FrameMap::nof_cpu_regs; i++) {
200
Register r = as_Register(i);
201
if (FrameMap::reg_needs_save(r)) {
202
int sp_offset = cpu_reg_save_offsets[i];
203
__ std(r, sp_offset, R1_SP);
204
}
205
}
206
207
if (save_fpu_registers) {
208
for (i = 0; i < FrameMap::nof_fpu_regs; i++) {
209
FloatRegister r = as_FloatRegister(i);
210
int sp_offset = fpu_reg_save_offsets[i];
211
__ stfd(r, sp_offset, R1_SP);
212
}
213
}
214
215
return generate_oop_map(sasm, save_fpu_registers);
216
}
217
218
static void restore_live_registers(StubAssembler* sasm, Register result1, Register result2,
219
bool restore_fpu_registers = true) {
220
for (int i = 0; i < FrameMap::nof_cpu_regs; i++) {
221
Register r = as_Register(i);
222
if (FrameMap::reg_needs_save(r) && r != result1 && r != result2) {
223
int sp_offset = cpu_reg_save_offsets[i];
224
__ ld(r, sp_offset, R1_SP);
225
}
226
}
227
228
if (restore_fpu_registers) {
229
for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
230
FloatRegister r = as_FloatRegister(i);
231
int sp_offset = fpu_reg_save_offsets[i];
232
__ lfd(r, sp_offset, R1_SP);
233
}
234
}
235
236
__ pop_frame();
237
__ ld(R0, _abi0(lr), R1_SP);
238
__ mtlr(R0);
239
}
240
241
242
void Runtime1::initialize_pd() {
243
int i;
244
int sp_offset = frame::abi_reg_args_size;
245
246
for (i = 0; i < FrameMap::nof_cpu_regs; i++) {
247
Register r = as_Register(i);
248
if (FrameMap::reg_needs_save(r)) {
249
cpu_reg_save_offsets[i] = sp_offset;
250
sp_offset += BytesPerWord;
251
}
252
}
253
254
for (i = 0; i < FrameMap::nof_fpu_regs; i++) {
255
fpu_reg_save_offsets[i] = sp_offset;
256
sp_offset += BytesPerWord;
257
}
258
frame_size_in_bytes = align_up(sp_offset, frame::alignment_in_bytes);
259
}
260
261
262
OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) {
263
// Make a frame and preserve the caller's caller-save registers.
264
OopMap* oop_map = save_live_registers(sasm);
265
266
int call_offset;
267
if (!has_argument) {
268
call_offset = __ call_RT(noreg, noreg, target);
269
} else {
270
call_offset = __ call_RT(noreg, noreg, target, R4_ARG2);
271
}
272
OopMapSet* oop_maps = new OopMapSet();
273
oop_maps->add_gc_map(call_offset, oop_map);
274
275
__ should_not_reach_here();
276
return oop_maps;
277
}
278
279
static OopMapSet* generate_exception_throw_with_stack_parms(StubAssembler* sasm, address target,
280
int stack_parms) {
281
// Make a frame and preserve the caller's caller-save registers.
282
const int parm_size_in_bytes = align_up(stack_parms << LogBytesPerWord, frame::alignment_in_bytes);
283
const int padding = parm_size_in_bytes - (stack_parms << LogBytesPerWord);
284
OopMap* oop_map = save_live_registers(sasm, true, noreg, parm_size_in_bytes);
285
286
int call_offset = 0;
287
switch (stack_parms) {
288
case 3:
289
__ ld(R6_ARG4, frame_size_in_bytes + padding + 16, R1_SP);
290
case 2:
291
__ ld(R5_ARG3, frame_size_in_bytes + padding + 8, R1_SP);
292
case 1:
293
__ ld(R4_ARG2, frame_size_in_bytes + padding + 0, R1_SP);
294
case 0:
295
call_offset = __ call_RT(noreg, noreg, target);
296
break;
297
default: Unimplemented(); break;
298
}
299
OopMapSet* oop_maps = new OopMapSet();
300
oop_maps->add_gc_map(call_offset, oop_map);
301
302
__ should_not_reach_here();
303
return oop_maps;
304
}
305
306
307
OopMapSet* Runtime1::generate_stub_call(StubAssembler* sasm, Register result, address target,
308
Register arg1, Register arg2, Register arg3) {
309
// Make a frame and preserve the caller's caller-save registers.
310
OopMap* oop_map = save_live_registers(sasm);
311
312
int call_offset;
313
if (arg1 == noreg) {
314
call_offset = __ call_RT(result, noreg, target);
315
} else if (arg2 == noreg) {
316
call_offset = __ call_RT(result, noreg, target, arg1);
317
} else if (arg3 == noreg) {
318
call_offset = __ call_RT(result, noreg, target, arg1, arg2);
319
} else {
320
call_offset = __ call_RT(result, noreg, target, arg1, arg2, arg3);
321
}
322
OopMapSet* oop_maps = new OopMapSet();
323
oop_maps->add_gc_map(call_offset, oop_map);
324
325
restore_live_registers(sasm, result, noreg);
326
__ blr();
327
return oop_maps;
328
}
329
330
static OopMapSet* stub_call_with_stack_parms(StubAssembler* sasm, Register result, address target,
331
int stack_parms, bool do_return = true) {
332
// Make a frame and preserve the caller's caller-save registers.
333
const int parm_size_in_bytes = align_up(stack_parms << LogBytesPerWord, frame::alignment_in_bytes);
334
const int padding = parm_size_in_bytes - (stack_parms << LogBytesPerWord);
335
OopMap* oop_map = save_live_registers(sasm, true, noreg, parm_size_in_bytes);
336
337
int call_offset = 0;
338
switch (stack_parms) {
339
case 3:
340
__ ld(R6_ARG4, frame_size_in_bytes + padding + 16, R1_SP);
341
case 2:
342
__ ld(R5_ARG3, frame_size_in_bytes + padding + 8, R1_SP);
343
case 1:
344
__ ld(R4_ARG2, frame_size_in_bytes + padding + 0, R1_SP);
345
case 0:
346
call_offset = __ call_RT(result, noreg, target);
347
break;
348
default: Unimplemented(); break;
349
}
350
OopMapSet* oop_maps = new OopMapSet();
351
oop_maps->add_gc_map(call_offset, oop_map);
352
353
restore_live_registers(sasm, result, noreg);
354
if (do_return) __ blr();
355
return oop_maps;
356
}
357
358
359
OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
360
// Make a frame and preserve the caller's caller-save registers.
361
OopMap* oop_map = save_live_registers(sasm);
362
363
// Call the runtime patching routine, returns non-zero if nmethod got deopted.
364
int call_offset = __ call_RT(noreg, noreg, target);
365
OopMapSet* oop_maps = new OopMapSet();
366
oop_maps->add_gc_map(call_offset, oop_map);
367
__ cmpdi(CCR0, R3_RET, 0);
368
369
// Re-execute the patched instruction or, if the nmethod was deoptmized,
370
// return to the deoptimization handler entry that will cause re-execution
371
// of the current bytecode.
372
DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
373
assert(deopt_blob != NULL, "deoptimization blob must have been created");
374
375
// Return to the deoptimization handler entry for unpacking and rexecute.
376
// If we simply returned the we'd deopt as if any call we patched had just
377
// returned.
378
379
restore_live_registers(sasm, noreg, noreg);
380
// Return if patching routine returned 0.
381
__ bclr(Assembler::bcondCRbiIs1, Assembler::bi0(CCR0, Assembler::equal), Assembler::bhintbhBCLRisReturn);
382
383
address stub = deopt_blob->unpack_with_reexecution();
384
//__ load_const_optimized(R0, stub);
385
__ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
386
__ mtctr(R0);
387
__ bctr();
388
389
return oop_maps;
390
}
391
392
OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
393
OopMapSet* oop_maps = NULL;
394
395
// For better readability.
396
const bool must_gc_arguments = true;
397
const bool dont_gc_arguments = false;
398
399
// Stub code & info for the different stubs.
400
switch (id) {
401
case forward_exception_id:
402
{
403
oop_maps = generate_handle_exception(id, sasm);
404
}
405
break;
406
407
case new_instance_id:
408
case fast_new_instance_id:
409
case fast_new_instance_init_check_id:
410
{
411
if (id == new_instance_id) {
412
__ set_info("new_instance", dont_gc_arguments);
413
} else if (id == fast_new_instance_id) {
414
__ set_info("fast new_instance", dont_gc_arguments);
415
} else {
416
assert(id == fast_new_instance_init_check_id, "bad StubID");
417
__ set_info("fast new_instance init check", dont_gc_arguments);
418
}
419
420
// We don't support eden allocation.
421
422
oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_instance), R4_ARG2);
423
}
424
break;
425
426
case counter_overflow_id:
427
// Bci and method are on stack.
428
oop_maps = stub_call_with_stack_parms(sasm, noreg, CAST_FROM_FN_PTR(address, counter_overflow), 2);
429
break;
430
431
case new_type_array_id:
432
case new_object_array_id:
433
{
434
if (id == new_type_array_id) {
435
__ set_info("new_type_array", dont_gc_arguments);
436
} else {
437
__ set_info("new_object_array", dont_gc_arguments);
438
}
439
440
#ifdef ASSERT
441
// Assert object type is really an array of the proper kind.
442
{
443
int tag = (id == new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value;
444
Label ok;
445
__ lwz(R0, in_bytes(Klass::layout_helper_offset()), R4_ARG2);
446
__ srawi(R0, R0, Klass::_lh_array_tag_shift);
447
__ cmpwi(CCR0, R0, tag);
448
__ beq(CCR0, ok);
449
__ stop("assert(is an array klass)");
450
__ should_not_reach_here();
451
__ bind(ok);
452
}
453
#endif // ASSERT
454
455
// We don't support eden allocation.
456
457
if (id == new_type_array_id) {
458
oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_type_array), R4_ARG2, R5_ARG3);
459
} else {
460
oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_object_array), R4_ARG2, R5_ARG3);
461
}
462
}
463
break;
464
465
case new_multi_array_id:
466
{
467
// R4: klass
468
// R5: rank
469
// R6: address of 1st dimension
470
__ set_info("new_multi_array", dont_gc_arguments);
471
oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_multi_array), R4_ARG2, R5_ARG3, R6_ARG4);
472
}
473
break;
474
475
case register_finalizer_id:
476
{
477
__ set_info("register_finalizer", dont_gc_arguments);
478
// This code is called via rt_call. Hence, caller-save registers have been saved.
479
Register t = R11_scratch1;
480
481
// Load the klass and check the has finalizer flag.
482
__ load_klass(t, R3_ARG1);
483
__ lwz(t, in_bytes(Klass::access_flags_offset()), t);
484
__ testbitdi(CCR0, R0, t, exact_log2(JVM_ACC_HAS_FINALIZER));
485
// Return if has_finalizer bit == 0 (CR0.eq).
486
__ bclr(Assembler::bcondCRbiIs1, Assembler::bi0(CCR0, Assembler::equal), Assembler::bhintbhBCLRisReturn);
487
488
__ mflr(R0);
489
__ std(R0, _abi0(lr), R1_SP);
490
__ push_frame(frame::abi_reg_args_size, R0); // Empty dummy frame (no callee-save regs).
491
sasm->set_frame_size(frame::abi_reg_args_size / BytesPerWord);
492
OopMap* oop_map = new OopMap(frame::abi_reg_args_size / sizeof(jint), 0);
493
int call_offset = __ call_RT(noreg, noreg,
494
CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), R3_ARG1);
495
oop_maps = new OopMapSet();
496
oop_maps->add_gc_map(call_offset, oop_map);
497
498
__ pop_frame();
499
__ ld(R0, _abi0(lr), R1_SP);
500
__ mtlr(R0);
501
__ blr();
502
}
503
break;
504
505
case throw_range_check_failed_id:
506
{
507
__ set_info("range_check_failed", dont_gc_arguments); // Arguments will be discarded.
508
oop_maps = generate_exception_throw_with_stack_parms(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), 2);
509
}
510
break;
511
512
case throw_index_exception_id:
513
{
514
__ set_info("index_range_check_failed", dont_gc_arguments); // Arguments will be discarded.
515
oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true);
516
}
517
break;
518
519
case throw_div0_exception_id:
520
{
521
__ set_info("throw_div0_exception", dont_gc_arguments);
522
oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false);
523
}
524
break;
525
526
case throw_null_pointer_exception_id:
527
{
528
__ set_info("throw_null_pointer_exception", dont_gc_arguments);
529
oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false);
530
}
531
break;
532
533
case handle_exception_nofpu_id:
534
case handle_exception_id:
535
{
536
__ set_info("handle_exception", dont_gc_arguments);
537
oop_maps = generate_handle_exception(id, sasm);
538
}
539
break;
540
541
case handle_exception_from_callee_id:
542
{
543
__ set_info("handle_exception_from_callee", dont_gc_arguments);
544
oop_maps = generate_handle_exception(id, sasm);
545
}
546
break;
547
548
case unwind_exception_id:
549
{
550
const Register Rexception = R3 /*LIRGenerator::exceptionOopOpr()*/,
551
Rexception_pc = R4 /*LIRGenerator::exceptionPcOpr()*/,
552
Rexception_save = R31, Rcaller_sp = R30;
553
__ set_info("unwind_exception", dont_gc_arguments);
554
555
__ ld(Rcaller_sp, 0, R1_SP);
556
__ push_frame_reg_args(0, R0); // dummy frame for C call
557
__ mr(Rexception_save, Rexception); // save over C call
558
__ ld(Rexception_pc, _abi0(lr), Rcaller_sp); // return pc
559
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), R16_thread, Rexception_pc);
560
__ verify_not_null_oop(Rexception_save);
561
__ mtctr(R3_RET);
562
__ ld(Rexception_pc, _abi0(lr), Rcaller_sp); // return pc
563
__ mr(R1_SP, Rcaller_sp); // Pop both frames at once.
564
__ mr(Rexception, Rexception_save); // restore
565
__ mtlr(Rexception_pc);
566
__ bctr();
567
}
568
break;
569
570
case throw_array_store_exception_id:
571
{
572
__ set_info("throw_array_store_exception", dont_gc_arguments);
573
oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true);
574
}
575
break;
576
577
case throw_class_cast_exception_id:
578
{
579
__ set_info("throw_class_cast_exception", dont_gc_arguments);
580
oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true);
581
}
582
break;
583
584
case throw_incompatible_class_change_error_id:
585
{
586
__ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments);
587
oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false);
588
}
589
break;
590
591
case slow_subtype_check_id:
592
{ // Support for uint StubRoutine::partial_subtype_check( Klass sub, Klass super );
593
const Register sub_klass = R5,
594
super_klass = R4,
595
temp1_reg = R6,
596
temp2_reg = R0;
597
__ check_klass_subtype_slow_path(sub_klass, super_klass, temp1_reg, temp2_reg); // returns with CR0.eq if successful
598
__ crandc(CCR0, Assembler::equal, CCR0, Assembler::equal); // failed: CR0.ne
599
__ blr();
600
}
601
break;
602
603
case monitorenter_nofpu_id:
604
case monitorenter_id:
605
{
606
__ set_info("monitorenter", dont_gc_arguments);
607
608
int save_fpu_registers = (id == monitorenter_id);
609
// Make a frame and preserve the caller's caller-save registers.
610
OopMap* oop_map = save_live_registers(sasm, save_fpu_registers);
611
612
int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), R4_ARG2, R5_ARG3);
613
614
oop_maps = new OopMapSet();
615
oop_maps->add_gc_map(call_offset, oop_map);
616
617
restore_live_registers(sasm, noreg, noreg, save_fpu_registers);
618
__ blr();
619
}
620
break;
621
622
case monitorexit_nofpu_id:
623
case monitorexit_id:
624
{
625
// note: Really a leaf routine but must setup last java sp
626
// => use call_RT for now (speed can be improved by
627
// doing last java sp setup manually).
628
__ set_info("monitorexit", dont_gc_arguments);
629
630
int save_fpu_registers = (id == monitorexit_id);
631
// Make a frame and preserve the caller's caller-save registers.
632
OopMap* oop_map = save_live_registers(sasm, save_fpu_registers);
633
634
int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), R4_ARG2);
635
636
oop_maps = new OopMapSet();
637
oop_maps->add_gc_map(call_offset, oop_map);
638
639
restore_live_registers(sasm, noreg, noreg, save_fpu_registers);
640
__ blr();
641
}
642
break;
643
644
case deoptimize_id:
645
{
646
__ set_info("deoptimize", dont_gc_arguments);
647
__ std(R0, -8, R1_SP); // Pass trap_request on stack.
648
oop_maps = stub_call_with_stack_parms(sasm, noreg, CAST_FROM_FN_PTR(address, deoptimize), 1, /*do_return*/ false);
649
650
DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
651
assert(deopt_blob != NULL, "deoptimization blob must have been created");
652
address stub = deopt_blob->unpack_with_reexecution();
653
//__ load_const_optimized(R0, stub);
654
__ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
655
__ mtctr(R0);
656
__ bctr();
657
}
658
break;
659
660
case access_field_patching_id:
661
{
662
__ set_info("access_field_patching", dont_gc_arguments);
663
oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching));
664
}
665
break;
666
667
case load_klass_patching_id:
668
{
669
__ set_info("load_klass_patching", dont_gc_arguments);
670
oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching));
671
}
672
break;
673
674
case load_mirror_patching_id:
675
{
676
__ set_info("load_mirror_patching", dont_gc_arguments);
677
oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching));
678
}
679
break;
680
681
case load_appendix_patching_id:
682
{
683
__ set_info("load_appendix_patching", dont_gc_arguments);
684
oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching));
685
}
686
break;
687
688
case dtrace_object_alloc_id:
689
{ // O0: object
690
__ unimplemented("stub dtrace_object_alloc_id");
691
__ set_info("dtrace_object_alloc", dont_gc_arguments);
692
// // We can't gc here so skip the oopmap but make sure that all
693
// // the live registers get saved.
694
// save_live_registers(sasm);
695
//
696
// __ save_thread(L7_thread_cache);
697
// __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc),
698
// relocInfo::runtime_call_type);
699
// __ delayed()->mov(I0, O0);
700
// __ restore_thread(L7_thread_cache);
701
//
702
// restore_live_registers(sasm);
703
// __ ret();
704
// __ delayed()->restore();
705
}
706
break;
707
708
case predicate_failed_trap_id:
709
{
710
__ set_info("predicate_failed_trap", dont_gc_arguments);
711
OopMap* oop_map = save_live_registers(sasm);
712
713
int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap));
714
715
oop_maps = new OopMapSet();
716
oop_maps->add_gc_map(call_offset, oop_map);
717
718
DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
719
assert(deopt_blob != NULL, "deoptimization blob must have been created");
720
restore_live_registers(sasm, noreg, noreg);
721
722
address stub = deopt_blob->unpack_with_reexecution();
723
//__ load_const_optimized(R0, stub);
724
__ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
725
__ mtctr(R0);
726
__ bctr();
727
}
728
break;
729
730
default:
731
{
732
__ set_info("unimplemented entry", dont_gc_arguments);
733
__ mflr(R0);
734
__ std(R0, _abi0(lr), R1_SP);
735
__ push_frame(frame::abi_reg_args_size, R0); // empty dummy frame
736
sasm->set_frame_size(frame::abi_reg_args_size / BytesPerWord);
737
OopMap* oop_map = new OopMap(frame::abi_reg_args_size / sizeof(jint), 0);
738
739
__ load_const_optimized(R4_ARG2, (int)id);
740
int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), R4_ARG2);
741
742
oop_maps = new OopMapSet();
743
oop_maps->add_gc_map(call_offset, oop_map);
744
__ should_not_reach_here();
745
}
746
break;
747
}
748
return oop_maps;
749
}
750
751
752
OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) {
753
__ block_comment("generate_handle_exception");
754
755
// Save registers, if required.
756
OopMapSet* oop_maps = new OopMapSet();
757
OopMap* oop_map = NULL;
758
const Register Rexception = R3 /*LIRGenerator::exceptionOopOpr()*/,
759
Rexception_pc = R4 /*LIRGenerator::exceptionPcOpr()*/;
760
761
switch (id) {
762
case forward_exception_id:
763
// We're handling an exception in the context of a compiled frame.
764
// The registers have been saved in the standard places. Perform
765
// an exception lookup in the caller and dispatch to the handler
766
// if found. Otherwise unwind and dispatch to the callers
767
// exception handler.
768
oop_map = generate_oop_map(sasm, true);
769
// Transfer the pending exception to the exception_oop.
770
// Also load the PC which is typically at SP + frame_size_in_bytes +_abi0(lr),
771
// but we support additional slots in the frame for parameter passing.
772
__ ld(Rexception_pc, 0, R1_SP);
773
__ ld(Rexception, in_bytes(JavaThread::pending_exception_offset()), R16_thread);
774
__ li(R0, 0);
775
__ ld(Rexception_pc, _abi0(lr), Rexception_pc);
776
__ std(R0, in_bytes(JavaThread::pending_exception_offset()), R16_thread);
777
break;
778
case handle_exception_nofpu_id:
779
case handle_exception_id:
780
// At this point all registers MAY be live.
781
oop_map = save_live_registers(sasm, id != handle_exception_nofpu_id, Rexception_pc);
782
break;
783
case handle_exception_from_callee_id:
784
// At this point all registers except exception oop and exception pc are dead.
785
oop_map = new OopMap(frame_size_in_bytes / sizeof(jint), 0);
786
sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
787
__ std(Rexception_pc, _abi0(lr), R1_SP);
788
__ push_frame(frame_size_in_bytes, R0);
789
break;
790
default: ShouldNotReachHere();
791
}
792
793
__ verify_not_null_oop(Rexception);
794
795
#ifdef ASSERT
796
// Check that fields in JavaThread for exception oop and issuing pc are
797
// empty before writing to them.
798
__ ld(R0, in_bytes(JavaThread::exception_oop_offset()), R16_thread);
799
__ cmpdi(CCR0, R0, 0);
800
__ asm_assert_eq("exception oop already set");
801
__ ld(R0, in_bytes(JavaThread::exception_pc_offset() ), R16_thread);
802
__ cmpdi(CCR0, R0, 0);
803
__ asm_assert_eq("exception pc already set");
804
#endif
805
806
// Save the exception and issuing pc in the thread.
807
__ std(Rexception, in_bytes(JavaThread::exception_oop_offset()), R16_thread);
808
__ std(Rexception_pc, in_bytes(JavaThread::exception_pc_offset() ), R16_thread);
809
810
int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc));
811
oop_maps->add_gc_map(call_offset, oop_map);
812
813
__ mtctr(R3_RET);
814
815
// Note: if nmethod has been deoptimized then regardless of
816
// whether it had a handler or not we will deoptimize
817
// by entering the deopt blob with a pending exception.
818
819
// Restore the registers that were saved at the beginning, remove
820
// the frame and jump to the exception handler.
821
switch (id) {
822
case forward_exception_id:
823
case handle_exception_nofpu_id:
824
case handle_exception_id:
825
restore_live_registers(sasm, noreg, noreg, id != handle_exception_nofpu_id);
826
__ bctr();
827
break;
828
case handle_exception_from_callee_id: {
829
__ pop_frame();
830
__ ld(Rexception_pc, _abi0(lr), R1_SP);
831
__ mtlr(Rexception_pc);
832
__ bctr();
833
break;
834
}
835
default: ShouldNotReachHere();
836
}
837
838
return oop_maps;
839
}
840
841
const char *Runtime1::pd_name_for_address(address entry) {
842
return "<unknown function>";
843
}
844
845
#undef __
846
847