Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp
32285 views
1
/*
2
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3
* Copyright 2012, 2014 SAP AG. 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 "interpreter/interpreter.hpp"
29
#include "memory/allocation.inline.hpp"
30
#include "prims/methodHandles.hpp"
31
32
#define __ _masm->
33
34
#ifdef CC_INTERP
35
#define EXCEPTION_ENTRY StubRoutines::throw_NullPointerException_at_call_entry()
36
#else
37
#define EXCEPTION_ENTRY Interpreter::throw_NullPointerException_entry()
38
#endif
39
40
#ifdef PRODUCT
41
#define BLOCK_COMMENT(str) // nothing
42
#else
43
#define BLOCK_COMMENT(str) __ block_comment(str)
44
#endif
45
46
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
47
48
// Workaround for C++ overloading nastiness on '0' for RegisterOrConstant.
49
inline static RegisterOrConstant constant(int value) {
50
return RegisterOrConstant(value);
51
}
52
53
void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp_reg, Register temp2_reg) {
54
if (VerifyMethodHandles)
55
verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class), temp_reg, temp2_reg,
56
"MH argument is a Class");
57
__ ld(klass_reg, java_lang_Class::klass_offset_in_bytes(), klass_reg);
58
}
59
60
#ifdef ASSERT
61
static int check_nonzero(const char* xname, int x) {
62
assert(x != 0, err_msg("%s should be nonzero", xname));
63
return x;
64
}
65
#define NONZERO(x) check_nonzero(#x, x)
66
#else //ASSERT
67
#define NONZERO(x) (x)
68
#endif //ASSERT
69
70
#ifdef ASSERT
71
void MethodHandles::verify_klass(MacroAssembler* _masm,
72
Register obj_reg, SystemDictionary::WKID klass_id,
73
Register temp_reg, Register temp2_reg,
74
const char* error_message) {
75
Klass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
76
KlassHandle klass = SystemDictionary::well_known_klass(klass_id);
77
Label L_ok, L_bad;
78
BLOCK_COMMENT("verify_klass {");
79
__ verify_oop(obj_reg);
80
__ cmpdi(CCR0, obj_reg, 0);
81
__ beq(CCR0, L_bad);
82
__ load_klass(temp_reg, obj_reg);
83
__ load_const_optimized(temp2_reg, (address) klass_addr);
84
__ ld(temp2_reg, 0, temp2_reg);
85
__ cmpd(CCR0, temp_reg, temp2_reg);
86
__ beq(CCR0, L_ok);
87
__ ld(temp_reg, klass->super_check_offset(), temp_reg);
88
__ cmpd(CCR0, temp_reg, temp2_reg);
89
__ beq(CCR0, L_ok);
90
__ BIND(L_bad);
91
__ stop(error_message);
92
__ BIND(L_ok);
93
BLOCK_COMMENT("} verify_klass");
94
}
95
96
void MethodHandles::verify_ref_kind(MacroAssembler* _masm, int ref_kind, Register member_reg, Register temp) {
97
Label L;
98
BLOCK_COMMENT("verify_ref_kind {");
99
__ load_sized_value(temp, NONZERO(java_lang_invoke_MemberName::flags_offset_in_bytes()), member_reg,
100
sizeof(u4), /*is_signed*/ false);
101
// assert(sizeof(u4) == sizeof(java.lang.invoke.MemberName.flags), "");
102
__ srwi( temp, temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT);
103
__ andi(temp, temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK);
104
__ cmpwi(CCR1, temp, ref_kind);
105
__ beq(CCR1, L);
106
{ char* buf = NEW_C_HEAP_ARRAY(char, 100, mtInternal);
107
jio_snprintf(buf, 100, "verify_ref_kind expected %x", ref_kind);
108
if (ref_kind == JVM_REF_invokeVirtual ||
109
ref_kind == JVM_REF_invokeSpecial)
110
// could do this for all ref_kinds, but would explode assembly code size
111
trace_method_handle(_masm, buf);
112
__ stop(buf);
113
}
114
BLOCK_COMMENT("} verify_ref_kind");
115
__ BIND(L);
116
}
117
118
#endif // ASSERT
119
120
void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register target, Register temp,
121
bool for_compiler_entry) {
122
Label L_no_such_method;
123
assert(method == R19_method, "interpreter calling convention");
124
assert_different_registers(method, target, temp);
125
126
if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
127
Label run_compiled_code;
128
// JVMTI events, such as single-stepping, are implemented partly by avoiding running
129
// compiled code in threads for which the event is enabled. Check here for
130
// interp_only_mode if these events CAN be enabled.
131
__ verify_thread();
132
__ lwz(temp, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread);
133
__ cmplwi(CCR0, temp, 0);
134
__ beq(CCR0, run_compiled_code);
135
// Null method test is replicated below in compiled case,
136
// it might be able to address across the verify_thread()
137
__ cmplwi(CCR0, R19_method, 0);
138
__ beq(CCR0, L_no_such_method);
139
__ ld(target, in_bytes(Method::interpreter_entry_offset()), R19_method);
140
__ mtctr(target);
141
__ bctr();
142
__ BIND(run_compiled_code);
143
}
144
145
// Compiled case, either static or fall-through from runtime conditional
146
__ cmplwi(CCR0, R19_method, 0);
147
__ beq(CCR0, L_no_such_method);
148
149
const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_offset() :
150
Method::from_interpreted_offset();
151
__ ld(target, in_bytes(entry_offset), R19_method);
152
__ mtctr(target);
153
__ bctr();
154
155
__ bind(L_no_such_method);
156
assert(StubRoutines::throw_AbstractMethodError_entry() != NULL, "not yet generated!");
157
__ load_const_optimized(target, StubRoutines::throw_AbstractMethodError_entry());
158
__ mtctr(target);
159
__ bctr();
160
}
161
162
163
void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
164
Register recv, Register method_temp,
165
Register temp2, Register temp3,
166
bool for_compiler_entry) {
167
BLOCK_COMMENT("jump_to_lambda_form {");
168
// This is the initial entry point of a lazy method handle.
169
// After type checking, it picks up the invoker from the LambdaForm.
170
assert_different_registers(recv, method_temp, temp2); // temp3 is only passed on
171
assert(method_temp == R19_method, "required register for loading method");
172
173
// Load the invoker, as MH -> MH.form -> LF.vmentry
174
__ verify_oop(recv);
175
__ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes()), recv);
176
__ verify_oop(method_temp);
177
__ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes()), method_temp);
178
__ verify_oop(method_temp);
179
// the following assumes that a Method* is normally compressed in the vmtarget field:
180
__ ld(method_temp, NONZERO(java_lang_invoke_MemberName::vmtarget_offset_in_bytes()), method_temp);
181
182
if (VerifyMethodHandles && !for_compiler_entry) {
183
// make sure recv is already on stack
184
__ ld(temp2, in_bytes(Method::const_offset()), method_temp);
185
__ load_sized_value(temp2, in_bytes(ConstMethod::size_of_parameters_offset()), temp2,
186
sizeof(u2), /*is_signed*/ false);
187
// assert(sizeof(u2) == sizeof(ConstMethod::_size_of_parameters), "");
188
Label L;
189
__ ld(temp2, __ argument_offset(temp2, temp2, 0), CC_INTERP_ONLY(R17_tos) NOT_CC_INTERP(R15_esp));
190
__ cmpd(CCR1, temp2, recv);
191
__ beq(CCR1, L);
192
__ stop("receiver not on stack");
193
__ BIND(L);
194
}
195
196
jump_from_method_handle(_masm, method_temp, temp2, temp3, for_compiler_entry);
197
BLOCK_COMMENT("} jump_to_lambda_form");
198
}
199
200
201
202
// Code generation
203
address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm,
204
vmIntrinsics::ID iid) {
205
const bool not_for_compiler_entry = false; // this is the interpreter entry
206
assert(is_signature_polymorphic(iid), "expected invoke iid");
207
if (iid == vmIntrinsics::_invokeGeneric ||
208
iid == vmIntrinsics::_compiledLambdaForm) {
209
// Perhaps surprisingly, the symbolic references visible to Java are not directly used.
210
// They are linked to Java-generated adapters via MethodHandleNatives.linkMethod.
211
// They all allow an appendix argument.
212
__ stop("Should not reach here"); // empty stubs make SG sick
213
return NULL;
214
}
215
216
Register argbase = CC_INTERP_ONLY(R17_tos) NOT_CC_INTERP(R15_esp); // parameter (preserved)
217
Register argslot = R3;
218
Register temp1 = R6;
219
Register param_size = R7;
220
221
// here's where control starts out:
222
__ align(CodeEntryAlignment);
223
address entry_point = __ pc();
224
225
if (VerifyMethodHandles) {
226
Label L;
227
BLOCK_COMMENT("verify_intrinsic_id {");
228
__ load_sized_value(temp1, Method::intrinsic_id_offset_in_bytes(), R19_method,
229
sizeof(u1), /*is_signed*/ false);
230
// assert(sizeof(u1) == sizeof(Method::_intrinsic_id), "");
231
__ cmpwi(CCR1, temp1, (int) iid);
232
__ beq(CCR1, L);
233
if (iid == vmIntrinsics::_linkToVirtual ||
234
iid == vmIntrinsics::_linkToSpecial) {
235
// could do this for all kinds, but would explode assembly code size
236
trace_method_handle(_masm, "bad Method*:intrinsic_id");
237
}
238
__ stop("bad Method*::intrinsic_id");
239
__ BIND(L);
240
BLOCK_COMMENT("} verify_intrinsic_id");
241
}
242
243
// First task: Find out how big the argument list is.
244
int ref_kind = signature_polymorphic_intrinsic_ref_kind(iid);
245
assert(ref_kind != 0 || iid == vmIntrinsics::_invokeBasic, "must be _invokeBasic or a linkTo intrinsic");
246
if (ref_kind == 0 || MethodHandles::ref_kind_has_receiver(ref_kind)) {
247
__ ld(param_size, in_bytes(Method::const_offset()), R19_method);
248
__ load_sized_value(param_size, in_bytes(ConstMethod::size_of_parameters_offset()), param_size,
249
sizeof(u2), /*is_signed*/ false);
250
// assert(sizeof(u2) == sizeof(ConstMethod::_size_of_parameters), "");
251
} else {
252
DEBUG_ONLY(param_size = noreg);
253
}
254
255
Register tmp_mh = noreg;
256
if (!is_signature_polymorphic_static(iid)) {
257
__ ld(tmp_mh = temp1, __ argument_offset(param_size, param_size, 0), argbase);
258
DEBUG_ONLY(param_size = noreg);
259
}
260
261
if (TraceMethodHandles) {
262
if (tmp_mh != noreg)
263
__ mr(R23_method_handle, tmp_mh); // make stub happy
264
trace_method_handle_interpreter_entry(_masm, iid);
265
}
266
267
if (iid == vmIntrinsics::_invokeBasic) {
268
generate_method_handle_dispatch(_masm, iid, tmp_mh, noreg, not_for_compiler_entry);
269
270
} else {
271
// Adjust argument list by popping the trailing MemberName argument.
272
Register tmp_recv = noreg;
273
if (MethodHandles::ref_kind_has_receiver(ref_kind)) {
274
// Load the receiver (not the MH; the actual MemberName's receiver) up from the interpreter stack.
275
__ ld(tmp_recv = temp1, __ argument_offset(param_size, param_size, 0), argbase);
276
DEBUG_ONLY(param_size = noreg);
277
}
278
Register R19_member = R19_method; // MemberName ptr; incoming method ptr is dead now
279
__ ld(R19_member, RegisterOrConstant((intptr_t)8), argbase);
280
__ add(argbase, Interpreter::stackElementSize, argbase);
281
generate_method_handle_dispatch(_masm, iid, tmp_recv, R19_member, not_for_compiler_entry);
282
}
283
284
return entry_point;
285
}
286
287
void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
288
vmIntrinsics::ID iid,
289
Register receiver_reg,
290
Register member_reg,
291
bool for_compiler_entry) {
292
assert(is_signature_polymorphic(iid), "expected invoke iid");
293
Register temp1 = (for_compiler_entry ? R25_tmp5 : R7);
294
Register temp2 = (for_compiler_entry ? R22_tmp2 : R8);
295
Register temp3 = (for_compiler_entry ? R23_tmp3 : R9);
296
Register temp4 = (for_compiler_entry ? R24_tmp4 : R10);
297
if (receiver_reg != noreg) assert_different_registers(temp1, temp2, temp3, temp4, receiver_reg);
298
if (member_reg != noreg) assert_different_registers(temp1, temp2, temp3, temp4, member_reg);
299
300
if (iid == vmIntrinsics::_invokeBasic) {
301
// indirect through MH.form.vmentry.vmtarget
302
jump_to_lambda_form(_masm, receiver_reg, R19_method, temp1, temp2, for_compiler_entry);
303
} else {
304
// The method is a member invoker used by direct method handles.
305
if (VerifyMethodHandles) {
306
// make sure the trailing argument really is a MemberName (caller responsibility)
307
verify_klass(_masm, member_reg, SystemDictionary::WK_KLASS_ENUM_NAME(MemberName_klass),
308
temp1, temp2,
309
"MemberName required for invokeVirtual etc.");
310
}
311
312
Register temp1_recv_klass = temp1;
313
if (iid != vmIntrinsics::_linkToStatic) {
314
__ verify_oop(receiver_reg);
315
if (iid == vmIntrinsics::_linkToSpecial) {
316
// Don't actually load the klass; just null-check the receiver.
317
__ null_check_throw(receiver_reg, -1, temp1, EXCEPTION_ENTRY);
318
} else {
319
// load receiver klass itself
320
__ null_check_throw(receiver_reg, oopDesc::klass_offset_in_bytes(), temp1, EXCEPTION_ENTRY);
321
__ load_klass(temp1_recv_klass, receiver_reg);
322
__ verify_klass_ptr(temp1_recv_klass);
323
}
324
BLOCK_COMMENT("check_receiver {");
325
// The receiver for the MemberName must be in receiver_reg.
326
// Check the receiver against the MemberName.clazz
327
if (VerifyMethodHandles && iid == vmIntrinsics::_linkToSpecial) {
328
// Did not load it above...
329
__ load_klass(temp1_recv_klass, receiver_reg);
330
__ verify_klass_ptr(temp1_recv_klass);
331
}
332
if (VerifyMethodHandles && iid != vmIntrinsics::_linkToInterface) {
333
Label L_ok;
334
Register temp2_defc = temp2;
335
__ load_heap_oop_not_null(temp2_defc, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg);
336
load_klass_from_Class(_masm, temp2_defc, temp3, temp4);
337
__ verify_klass_ptr(temp2_defc);
338
__ check_klass_subtype(temp1_recv_klass, temp2_defc, temp3, temp4, L_ok);
339
// If we get here, the type check failed!
340
__ stop("receiver class disagrees with MemberName.clazz");
341
__ BIND(L_ok);
342
}
343
BLOCK_COMMENT("} check_receiver");
344
}
345
if (iid == vmIntrinsics::_linkToSpecial ||
346
iid == vmIntrinsics::_linkToStatic) {
347
DEBUG_ONLY(temp1_recv_klass = noreg); // these guys didn't load the recv_klass
348
}
349
350
// Live registers at this point:
351
// member_reg - MemberName that was the trailing argument
352
// temp1_recv_klass - klass of stacked receiver, if needed
353
// O5_savedSP - interpreter linkage (if interpreted)
354
// O0..O5 - compiler arguments (if compiled)
355
356
Label L_incompatible_class_change_error;
357
switch (iid) {
358
case vmIntrinsics::_linkToSpecial:
359
if (VerifyMethodHandles) {
360
verify_ref_kind(_masm, JVM_REF_invokeSpecial, member_reg, temp2);
361
}
362
__ ld(R19_method, NONZERO(java_lang_invoke_MemberName::vmtarget_offset_in_bytes()), member_reg);
363
break;
364
365
case vmIntrinsics::_linkToStatic:
366
if (VerifyMethodHandles) {
367
verify_ref_kind(_masm, JVM_REF_invokeStatic, member_reg, temp2);
368
}
369
__ ld(R19_method, NONZERO(java_lang_invoke_MemberName::vmtarget_offset_in_bytes()), member_reg);
370
break;
371
372
case vmIntrinsics::_linkToVirtual:
373
{
374
// same as TemplateTable::invokevirtual,
375
// minus the CP setup and profiling:
376
377
if (VerifyMethodHandles) {
378
verify_ref_kind(_masm, JVM_REF_invokeVirtual, member_reg, temp2);
379
}
380
381
// pick out the vtable index from the MemberName, and then we can discard it:
382
Register temp2_index = temp2;
383
__ ld(temp2_index, NONZERO(java_lang_invoke_MemberName::vmindex_offset_in_bytes()), member_reg);
384
385
if (VerifyMethodHandles) {
386
Label L_index_ok;
387
__ cmpdi(CCR1, temp2_index, 0);
388
__ bge(CCR1, L_index_ok);
389
__ stop("no virtual index");
390
__ BIND(L_index_ok);
391
}
392
393
// Note: The verifier invariants allow us to ignore MemberName.clazz and vmtarget
394
// at this point. And VerifyMethodHandles has already checked clazz, if needed.
395
396
// get target Method* & entry point
397
__ lookup_virtual_method(temp1_recv_klass, temp2_index, R19_method);
398
break;
399
}
400
401
case vmIntrinsics::_linkToInterface:
402
{
403
// same as TemplateTable::invokeinterface
404
// (minus the CP setup and profiling, with different argument motion)
405
if (VerifyMethodHandles) {
406
verify_ref_kind(_masm, JVM_REF_invokeInterface, member_reg, temp2);
407
}
408
409
Register temp2_intf = temp2;
410
__ load_heap_oop_not_null(temp2_intf, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg);
411
load_klass_from_Class(_masm, temp2_intf, temp3, temp4);
412
__ verify_klass_ptr(temp2_intf);
413
414
Register vtable_index = R19_method;
415
__ ld(vtable_index, NONZERO(java_lang_invoke_MemberName::vmindex_offset_in_bytes()), member_reg);
416
if (VerifyMethodHandles) {
417
Label L_index_ok;
418
__ cmpdi(CCR1, vtable_index, 0);
419
__ bge(CCR1, L_index_ok);
420
__ stop("invalid vtable index for MH.invokeInterface");
421
__ BIND(L_index_ok);
422
}
423
424
// given intf, index, and recv klass, dispatch to the implementation method
425
__ lookup_interface_method(temp1_recv_klass, temp2_intf,
426
// note: next two args must be the same:
427
vtable_index, R19_method,
428
temp3, temp4,
429
L_incompatible_class_change_error);
430
break;
431
}
432
433
default:
434
fatal(err_msg_res("unexpected intrinsic %d: %s", iid, vmIntrinsics::name_at(iid)));
435
break;
436
}
437
438
// Live at this point:
439
// R19_method
440
// O5_savedSP (if interpreted)
441
442
// After figuring out which concrete method to call, jump into it.
443
// Note that this works in the interpreter with no data motion.
444
// But the compiled version will require that rcx_recv be shifted out.
445
__ verify_method_ptr(R19_method);
446
jump_from_method_handle(_masm, R19_method, temp1, temp2, for_compiler_entry);
447
448
if (iid == vmIntrinsics::_linkToInterface) {
449
__ BIND(L_incompatible_class_change_error);
450
__ load_const_optimized(temp1, StubRoutines::throw_IncompatibleClassChangeError_entry());
451
__ mtctr(temp1);
452
__ bctr();
453
}
454
}
455
}
456
457
#ifndef PRODUCT
458
void trace_method_handle_stub(const char* adaptername,
459
oopDesc* mh,
460
intptr_t* entry_sp,
461
intptr_t* saved_regs) {
462
463
bool has_mh = (strstr(adaptername, "/static") == NULL &&
464
strstr(adaptername, "linkTo") == NULL); // static linkers don't have MH
465
const char* mh_reg_name = has_mh ? "R23_method_handle" : "G23";
466
tty->print_cr("MH %s %s=" INTPTR_FORMAT " sp=" INTPTR_FORMAT,
467
adaptername, mh_reg_name, (intptr_t) mh, (intptr_t) entry_sp);
468
469
if (Verbose) {
470
tty->print_cr("Registers:");
471
const int abi_offset = frame::abi_reg_args_size / 8;
472
for (int i = R3->encoding(); i <= R12->encoding(); i++) {
473
Register r = as_Register(i);
474
int count = i - R3->encoding();
475
// The registers are stored in reverse order on the stack (by save_volatile_gprs(R1_SP, abi_reg_args_size)).
476
tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[abi_offset + count]);
477
if ((count + 1) % 4 == 0) {
478
tty->cr();
479
} else {
480
tty->print(", ");
481
}
482
}
483
tty->cr();
484
485
{
486
// dumping last frame with frame::describe
487
488
JavaThread* p = JavaThread::active();
489
490
ResourceMark rm;
491
PRESERVE_EXCEPTION_MARK; // may not be needed by safer and unexpensive here
492
FrameValues values;
493
494
// Note: We want to allow trace_method_handle from any call site.
495
// While trace_method_handle creates a frame, it may be entered
496
// without a PC on the stack top (e.g. not just after a call).
497
// Walking that frame could lead to failures due to that invalid PC.
498
// => carefully detect that frame when doing the stack walking
499
500
// Current C frame
501
frame cur_frame = os::current_frame();
502
503
// Robust search of trace_calling_frame (independant of inlining).
504
// Assumes saved_regs comes from a pusha in the trace_calling_frame.
505
assert(cur_frame.sp() < saved_regs, "registers not saved on stack ?");
506
frame trace_calling_frame = os::get_sender_for_C_frame(&cur_frame);
507
while (trace_calling_frame.fp() < saved_regs) {
508
trace_calling_frame = os::get_sender_for_C_frame(&trace_calling_frame);
509
}
510
511
// Safely create a frame and call frame::describe.
512
intptr_t *dump_sp = trace_calling_frame.sender_sp();
513
514
frame dump_frame = frame(dump_sp);
515
dump_frame.describe(values, 1);
516
517
values.describe(-1, saved_regs, "raw top of stack");
518
519
tty->print_cr("Stack layout:");
520
values.print(p);
521
}
522
523
if (has_mh && mh->is_oop()) {
524
mh->print();
525
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
526
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0)
527
java_lang_invoke_MethodHandle::form(mh)->print();
528
}
529
}
530
}
531
}
532
533
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
534
if (!TraceMethodHandles) return;
535
536
BLOCK_COMMENT("trace_method_handle {");
537
538
int nbytes_save = 10 * 8; // 10 volatile gprs
539
__ save_LR_CR(R0);
540
__ mr(R0, R1_SP); // saved_sp
541
assert(Assembler::is_simm(-nbytes_save, 16), "Overwriting R0");
542
// Push_frame_reg_args only uses R0 if nbytes_save is wider than 16 bit.
543
__ push_frame_reg_args(nbytes_save, R0);
544
__ save_volatile_gprs(R1_SP, frame::abi_reg_args_size); // Except R0.
545
546
__ load_const(R3_ARG1, (address)adaptername);
547
__ mr(R4_ARG2, R23_method_handle);
548
__ mr(R5_ARG3, R0); // saved_sp
549
__ mr(R6_ARG4, R1_SP);
550
__ call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub));
551
552
__ restore_volatile_gprs(R1_SP, 112); // Except R0.
553
__ pop_frame();
554
__ restore_LR_CR(R0);
555
556
BLOCK_COMMENT("} trace_method_handle");
557
}
558
#endif // PRODUCT
559
560