1 /*
  2  * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
  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 "asm/macroAssembler.hpp"
 27 #include "classfile/javaClasses.inline.hpp"
 28 #include "classfile/vmClasses.hpp"
 29 #include "compiler/disassembler.hpp"
 30 #include "interpreter/interpreter.hpp"
 31 #include "interpreter/interpreterRuntime.hpp"
 32 #include "memory/allocation.inline.hpp"
 33 #include "prims/jvmtiExport.hpp"
 34 #include "prims/methodHandles.hpp"
 35 #include "runtime/flags/flagSetting.hpp"
 36 #include "runtime/frame.inline.hpp"
 37 #include "runtime/stubRoutines.hpp"
 38 
 39 #define __ Disassembler::hook<MacroAssembler>(__FILE__, __LINE__, _masm)->
 40 
 41 #ifdef PRODUCT
 42 #define BLOCK_COMMENT(str) /* nothing */
 43 #else
 44 #define BLOCK_COMMENT(str) __ block_comment(str)
 45 #endif
 46 
 47 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
 48 
 49 void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) {
 50   if (VerifyMethodHandles)
 51     verify_klass(_masm, klass_reg, VM_CLASS_ID(java_lang_Class),
 52                  "MH argument is a Class");
 53   __ ldr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset()));
 54 }
 55 
 56 #ifdef ASSERT
 57 static int check_nonzero(const char* xname, int x) {
 58   assert(x != 0, "%s should be nonzero", xname);
 59   return x;
 60 }
 61 #define NONZERO(x) check_nonzero(#x, x)
 62 #else //ASSERT
 63 #define NONZERO(x) (x)
 64 #endif //PRODUCT
 65 
 66 #ifdef ASSERT
 67 void MethodHandles::verify_klass(MacroAssembler* _masm,
 68                                  Register obj, vmClassID klass_id,
 69                                  const char* error_message) {
 70   InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id);
 71   Klass* klass = vmClasses::klass_at(klass_id);
 72   Register temp = rscratch2;
 73   Register temp2 = rscratch1; // used by MacroAssembler::cmpptr
 74   Label L_ok, L_bad;
 75   BLOCK_COMMENT("verify_klass {");
 76   __ verify_oop(obj);
 77   __ cbz(obj, L_bad);
 78   __ push(RegSet::of(temp, temp2), sp);
 79   __ load_klass(temp, obj);
 80   __ cmpptr(temp, ExternalAddress((address) klass_addr));
 81   __ br(Assembler::EQ, L_ok);
 82   intptr_t super_check_offset = klass->super_check_offset();
 83   __ ldr(temp, Address(temp, super_check_offset));
 84   __ cmpptr(temp, ExternalAddress((address) klass_addr));
 85   __ br(Assembler::EQ, L_ok);
 86   __ pop(RegSet::of(temp, temp2), sp);
 87   __ bind(L_bad);
 88   __ stop(error_message);
 89   __ BIND(L_ok);
 90   __ pop(RegSet::of(temp, temp2), sp);
 91   BLOCK_COMMENT("} verify_klass");
 92 }
 93 
 94 void MethodHandles::verify_ref_kind(MacroAssembler* _masm, int ref_kind, Register member_reg, Register temp) {  }
 95 
 96 void MethodHandles::verify_method(MacroAssembler* _masm, Register method, vmIntrinsics::ID iid) {
 97   BLOCK_COMMENT("verify_method {");
 98   __ verify_method_ptr(method);
 99   if (VerifyMethodHandles) {
100     Label L_ok;
101     assert_different_registers(method, rscratch1, rscratch2);
102     const Register method_holder = rscratch1;
103     __ load_method_holder(method_holder, method);
104 
105     switch (iid) {
106       case vmIntrinsicID::_invokeBasic:
107         // Require compiled LambdaForm class to be fully initialized.
108         __ lea(rscratch2, Address(method_holder, InstanceKlass::init_state_offset()));
109         __ ldarb(rscratch2, rscratch2);
110         __ cmp(rscratch2, InstanceKlass::fully_initialized);
111         __ br(Assembler::EQ, L_ok);
112         break;
113 
114       case vmIntrinsicID::_linkToStatic:
115         __ clinit_barrier(method_holder, rscratch2, &L_ok);
116         break;
117 
118       case vmIntrinsicID::_linkToVirtual:
119       case vmIntrinsicID::_linkToSpecial:
120       case vmIntrinsicID::_linkToInterface:
121         // Class initialization check is too strong here. Just ensure that class initialization has been initiated.
122         __ lea(rscratch2, Address(method_holder, InstanceKlass::init_state_offset()));
123         __ ldarb(rscratch2, rscratch2);
124         __ cmp(rscratch2, InstanceKlass::being_initialized);
125         __ br(Assembler::GE, L_ok);
126 
127         // init_state check failed, but it may be an abstract interface method
128         __ ldrh(rscratch2, Address(method, Method::access_flags_offset()));
129         __ tbnz(rscratch2, exact_log2(JVM_ACC_ABSTRACT), L_ok);
130         break;
131 
132       default:
133         fatal("unexpected intrinsic %d: %s", vmIntrinsics::as_int(iid), vmIntrinsics::name_at(iid));
134     }
135 
136     // Method holder init state check failed for a concrete method.
137     __ stop("Method holder klass is not initialized");
138     __ bind(L_ok);
139   }
140   BLOCK_COMMENT("} verify_method");
141 }
142 #endif //ASSERT
143 
144 void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register temp,
145                                             bool for_compiler_entry, vmIntrinsics::ID iid) {
146   assert(method == rmethod, "interpreter calling convention");
147   Label L_no_such_method;
148   __ cbz(rmethod, L_no_such_method);
149   verify_method(_masm, method, iid);
150 
151   if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
152     Label run_compiled_code;
153     // JVMTI events, such as single-stepping, are implemented partly by avoiding running
154     // compiled code in threads for which the event is enabled.  Check here for
155     // interp_only_mode if these events CAN be enabled.
156 
157     __ ldrw(rscratch1, Address(rthread, JavaThread::interp_only_mode_offset()));
158     __ cbzw(rscratch1, run_compiled_code);
159     __ ldr(rscratch1, Address(method, Method::interpreter_entry_offset()));
160     __ br(rscratch1);
161     __ BIND(run_compiled_code);
162   }
163 
164   // The following jump might pass an inline type argument that was erased to Object as oop to a
165   // callee that expects inline type arguments to be passed as fields. We need to call the compiled
166   // value entry (_code->inline_entry_point() or _adapter->c2i_inline_entry()) which will take care
167   // of translating between the calling conventions.
168   const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_inline_offset() :
169                                                      Method::from_interpreted_offset();
170   __ ldr(rscratch1,Address(method, entry_offset));
171   __ br(rscratch1);
172   __ bind(L_no_such_method);
173   __ far_jump(RuntimeAddress(SharedRuntime::throw_AbstractMethodError_entry()));
174 }
175 
176 void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
177                                         Register recv, Register method_temp,
178                                         Register temp2,
179                                         bool for_compiler_entry) {
180   BLOCK_COMMENT("jump_to_lambda_form {");
181   // This is the initial entry point of a lazy method handle.
182   // After type checking, it picks up the invoker from the LambdaForm.
183   assert_different_registers(recv, method_temp, temp2);
184   assert(recv != noreg, "required register");
185   assert(method_temp == rmethod, "required register for loading method");
186 
187   // Load the invoker, as MH -> MH.form -> LF.vmentry
188   __ verify_oop(recv);
189   __ load_heap_oop(method_temp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset())), temp2, rscratch2);
190   __ verify_oop(method_temp);
191   __ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset())), temp2, rscratch2);
192   __ verify_oop(method_temp);
193   __ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset())), temp2, rscratch2);
194   __ verify_oop(method_temp);
195   __ access_load_at(T_ADDRESS, IN_HEAP, method_temp, Address(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset())), noreg, noreg);
196 
197   if (VerifyMethodHandles && !for_compiler_entry) {
198     // make sure recv is already on stack
199     __ ldr(temp2, Address(method_temp, Method::const_offset()));
200     __ load_sized_value(temp2,
201                         Address(temp2, ConstMethod::size_of_parameters_offset()),
202                         sizeof(u2), /*is_signed*/ false);
203     // assert(sizeof(u2) == sizeof(Method::_size_of_parameters), "");
204     Label L;
205     __ ldr(rscratch1, __ argument_address(temp2, -1));
206     __ cmpoop(recv, rscratch1);
207     __ br(Assembler::EQ, L);
208     __ ldr(r0, __ argument_address(temp2, -1));
209     __ hlt(0);
210     __ BIND(L);
211   }
212 
213   jump_from_method_handle(_masm, method_temp, temp2, for_compiler_entry, vmIntrinsics::_invokeBasic);
214   BLOCK_COMMENT("} jump_to_lambda_form");
215 }
216 
217 // Code generation
218 address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm,
219                                                                 vmIntrinsics::ID iid) {
220   const bool not_for_compiler_entry = false;  // this is the interpreter entry
221   assert(is_signature_polymorphic(iid), "expected invoke iid");
222   if (iid == vmIntrinsics::_invokeGeneric ||
223       iid == vmIntrinsics::_compiledLambdaForm) {
224     // Perhaps surprisingly, the symbolic references visible to Java are not directly used.
225     // They are linked to Java-generated adapters via MethodHandleNatives.linkMethod.
226     // They all allow an appendix argument.
227     __ hlt(0);           // empty stubs make SG sick
228     return nullptr;
229   }
230 
231   // No need in interpreter entry for linkToNative for now.
232   // Interpreter calls compiled entry through i2c.
233   if (iid == vmIntrinsics::_linkToNative) {
234     __ hlt(0);
235     return nullptr;
236   }
237 
238   // r19_sender_sp: sender SP (must preserve; see prepare_to_jump_from_interpreted)
239   // rmethod: Method*
240   // r3: argument locator (parameter slot count, added to rsp)
241   // r1: used as temp to hold mh or receiver
242   // r0, r11: garbage temps, blown away
243   Register argp   = r3;   // argument list ptr, live on error paths
244   Register temp   = r0;
245   Register mh     = r1;   // MH receiver; dies quickly and is recycled
246 
247   // here's where control starts out:
248   __ align(CodeEntryAlignment);
249   address entry_point = __ pc();
250 
251   if (VerifyMethodHandles) {
252     assert(Method::intrinsic_id_size_in_bytes() == 2, "assuming Method::_intrinsic_id is u2");
253 
254     Label L;
255     BLOCK_COMMENT("verify_intrinsic_id {");
256     __ ldrh(rscratch1, Address(rmethod, Method::intrinsic_id_offset()));
257     __ subs(zr, rscratch1, (int) iid);
258     __ br(Assembler::EQ, L);
259     if (iid == vmIntrinsics::_linkToVirtual ||
260         iid == vmIntrinsics::_linkToSpecial) {
261       // could do this for all kinds, but would explode assembly code size
262       trace_method_handle(_masm, "bad Method*::intrinsic_id");
263     }
264     __ hlt(0);
265     __ bind(L);
266     BLOCK_COMMENT("} verify_intrinsic_id");
267   }
268 
269   // First task:  Find out how big the argument list is.
270   Address r3_first_arg_addr;
271   int ref_kind = signature_polymorphic_intrinsic_ref_kind(iid);
272   assert(ref_kind != 0 || iid == vmIntrinsics::_invokeBasic, "must be _invokeBasic or a linkTo intrinsic");
273   if (ref_kind == 0 || MethodHandles::ref_kind_has_receiver(ref_kind)) {
274     __ ldr(argp, Address(rmethod, Method::const_offset()));
275     __ load_sized_value(argp,
276                         Address(argp, ConstMethod::size_of_parameters_offset()),
277                         sizeof(u2), /*is_signed*/ false);
278     // assert(sizeof(u2) == sizeof(Method::_size_of_parameters), "");
279     r3_first_arg_addr = __ argument_address(argp, -1);
280   } else {
281     DEBUG_ONLY(argp = noreg);
282   }
283 
284   if (!is_signature_polymorphic_static(iid)) {
285     __ ldr(mh, r3_first_arg_addr);
286     DEBUG_ONLY(argp = noreg);
287   }
288 
289   // r3_first_arg_addr is live!
290 
291   trace_method_handle_interpreter_entry(_masm, iid);
292   if (iid == vmIntrinsics::_invokeBasic) {
293     generate_method_handle_dispatch(_masm, iid, mh, noreg, not_for_compiler_entry);
294 
295   } else {
296     // Adjust argument list by popping the trailing MemberName argument.
297     Register recv = noreg;
298     if (MethodHandles::ref_kind_has_receiver(ref_kind)) {
299       // Load the receiver (not the MH; the actual MemberName's receiver) up from the interpreter stack.
300       __ ldr(recv = r2, r3_first_arg_addr);
301     }
302     DEBUG_ONLY(argp = noreg);
303     Register rmember = rmethod;  // MemberName ptr; incoming method ptr is dead now
304     __ pop(rmember);             // extract last argument
305     generate_method_handle_dispatch(_masm, iid, recv, rmember, not_for_compiler_entry);
306   }
307 
308   return entry_point;
309 }
310 
311 void MethodHandles::jump_to_native_invoker(MacroAssembler* _masm, Register nep_reg, Register temp_target) {
312   BLOCK_COMMENT("jump_to_native_invoker {");
313   assert_different_registers(nep_reg, temp_target);
314   assert(nep_reg != noreg, "required register");
315 
316   // Load the invoker, as NEP -> .invoker
317   __ verify_oop(nep_reg);
318   __ access_load_at(T_ADDRESS, IN_HEAP, temp_target,
319                     Address(nep_reg, NONZERO(jdk_internal_foreign_abi_NativeEntryPoint::downcall_stub_address_offset_in_bytes())),
320                     noreg, noreg);
321 
322   __ br(temp_target);
323   BLOCK_COMMENT("} jump_to_native_invoker");
324 }
325 
326 
327 void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
328                                                     vmIntrinsics::ID iid,
329                                                     Register receiver_reg,
330                                                     Register member_reg,
331                                                     bool for_compiler_entry) {
332   assert(is_signature_polymorphic(iid), "expected invoke iid");
333   // temps used in this code are not used in *either* compiled or interpreted calling sequences
334   Register temp1 = r10;
335   Register temp2 = r11;
336   Register temp3 = r14;
337   if (for_compiler_entry) {
338     assert(receiver_reg == (iid == vmIntrinsics::_linkToStatic || iid == vmIntrinsics::_linkToNative ? noreg : j_rarg0), "only valid assignment");
339     assert_different_registers(temp1,        j_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4, j_rarg5, j_rarg6, j_rarg7);
340     assert_different_registers(temp2,        j_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4, j_rarg5, j_rarg6, j_rarg7);
341     assert_different_registers(temp3,        j_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4, j_rarg5, j_rarg6, j_rarg7);
342   }
343 
344   assert_different_registers(temp1, temp2, temp3, receiver_reg);
345   assert_different_registers(temp1, temp2, temp3, member_reg);
346 
347   if (iid == vmIntrinsics::_invokeBasic) {
348     // indirect through MH.form.vmentry.vmtarget
349     jump_to_lambda_form(_masm, receiver_reg, rmethod, temp1, for_compiler_entry);
350 
351   } else if (iid == vmIntrinsics::_linkToNative) {
352     assert(for_compiler_entry, "only compiler entry is supported");
353     jump_to_native_invoker(_masm, member_reg, temp1);
354   } else {
355     // The method is a member invoker used by direct method handles.
356     if (VerifyMethodHandles) {
357       // make sure the trailing argument really is a MemberName (caller responsibility)
358       verify_klass(_masm, member_reg, VM_CLASS_ID(java_lang_invoke_MemberName),
359                    "MemberName required for invokeVirtual etc.");
360     }
361 
362     Address member_clazz(    member_reg, NONZERO(java_lang_invoke_MemberName::clazz_offset()));
363     Address member_vmindex(  member_reg, NONZERO(java_lang_invoke_MemberName::vmindex_offset()));
364     Address member_vmtarget( member_reg, NONZERO(java_lang_invoke_MemberName::method_offset()));
365     Address vmtarget_method( rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()));
366 
367     Register temp1_recv_klass = temp1;
368     if (iid != vmIntrinsics::_linkToStatic) {
369       __ verify_oop(receiver_reg);
370       if (iid == vmIntrinsics::_linkToSpecial) {
371         // Don't actually load the klass; just null-check the receiver.
372         __ null_check(receiver_reg);
373       } else {
374         // load receiver klass itself
375         __ load_klass(temp1_recv_klass, receiver_reg);
376         __ verify_klass_ptr(temp1_recv_klass);
377       }
378       BLOCK_COMMENT("check_receiver {");
379       // The receiver for the MemberName must be in receiver_reg.
380       // Check the receiver against the MemberName.clazz
381       if (VerifyMethodHandles && iid == vmIntrinsics::_linkToSpecial) {
382         // Did not load it above...
383         __ load_klass(temp1_recv_klass, receiver_reg);
384         __ verify_klass_ptr(temp1_recv_klass);
385       }
386       if (VerifyMethodHandles && iid != vmIntrinsics::_linkToInterface) {
387         Label L_ok;
388         Register temp2_defc = temp2;
389         __ load_heap_oop(temp2_defc, member_clazz, temp3, rscratch2);
390         load_klass_from_Class(_masm, temp2_defc);
391         __ verify_klass_ptr(temp2_defc);
392         __ check_klass_subtype(temp1_recv_klass, temp2_defc, temp3, L_ok);
393         // If we get here, the type check failed!
394         __ hlt(0);
395         // __ STOP("receiver class disagrees with MemberName.clazz");
396         __ bind(L_ok);
397       }
398       BLOCK_COMMENT("} check_receiver");
399     }
400     if (iid == vmIntrinsics::_linkToSpecial ||
401         iid == vmIntrinsics::_linkToStatic) {
402       DEBUG_ONLY(temp1_recv_klass = noreg);  // these guys didn't load the recv_klass
403     }
404 
405     // Live registers at this point:
406     //  member_reg - MemberName that was the trailing argument
407     //  temp1_recv_klass - klass of stacked receiver, if needed
408     //  r19 - interpreter linkage (if interpreted)
409     //  r1 ... r0 - compiler arguments (if compiled)
410 
411     Label L_incompatible_class_change_error;
412     switch (iid) {
413     case vmIntrinsics::_linkToSpecial:
414       if (VerifyMethodHandles) {
415         verify_ref_kind(_masm, JVM_REF_invokeSpecial, member_reg, temp3);
416       }
417       __ load_heap_oop(rmethod, member_vmtarget, temp3, rscratch2);
418       __ access_load_at(T_ADDRESS, IN_HEAP, rmethod, vmtarget_method, noreg, noreg);
419       break;
420 
421     case vmIntrinsics::_linkToStatic:
422       if (VerifyMethodHandles) {
423         verify_ref_kind(_masm, JVM_REF_invokeStatic, member_reg, temp3);
424       }
425       __ load_heap_oop(rmethod, member_vmtarget, temp3, rscratch2);
426       __ access_load_at(T_ADDRESS, IN_HEAP, rmethod, vmtarget_method, noreg, noreg);
427       break;
428 
429     case vmIntrinsics::_linkToVirtual:
430     {
431       // same as TemplateTable::invokevirtual,
432       // minus the CP setup and profiling:
433 
434       if (VerifyMethodHandles) {
435         verify_ref_kind(_masm, JVM_REF_invokeVirtual, member_reg, temp3);
436       }
437 
438       // pick out the vtable index from the MemberName, and then we can discard it:
439       Register temp2_index = temp2;
440       __ access_load_at(T_ADDRESS, IN_HEAP, temp2_index, member_vmindex, noreg, noreg);
441 
442       if (VerifyMethodHandles) {
443         Label L_index_ok;
444         __ cmpw(temp2_index, 0U);
445         __ br(Assembler::GE, L_index_ok);
446         __ hlt(0);
447         __ BIND(L_index_ok);
448       }
449 
450       // Note:  The verifier invariants allow us to ignore MemberName.clazz and vmtarget
451       // at this point.  And VerifyMethodHandles has already checked clazz, if needed.
452 
453       // get target Method* & entry point
454       __ lookup_virtual_method(temp1_recv_klass, temp2_index, rmethod);
455       break;
456     }
457 
458     case vmIntrinsics::_linkToInterface:
459     {
460       // same as TemplateTable::invokeinterface
461       // (minus the CP setup and profiling, with different argument motion)
462       if (VerifyMethodHandles) {
463         verify_ref_kind(_masm, JVM_REF_invokeInterface, member_reg, temp3);
464       }
465 
466       Register temp3_intf = temp3;
467       __ load_heap_oop(temp3_intf, member_clazz, temp2, rscratch2);
468       load_klass_from_Class(_masm, temp3_intf);
469       __ verify_klass_ptr(temp3_intf);
470 
471       Register rindex = rmethod;
472       __ access_load_at(T_ADDRESS, IN_HEAP, rindex, member_vmindex, noreg, noreg);
473       if (VerifyMethodHandles) {
474         Label L;
475         __ cmpw(rindex, 0U);
476         __ br(Assembler::GE, L);
477         __ hlt(0);
478         __ bind(L);
479       }
480 
481       // given intf, index, and recv klass, dispatch to the implementation method
482       __ lookup_interface_method(temp1_recv_klass, temp3_intf,
483                                  // note: next two args must be the same:
484                                  rindex, rmethod,
485                                  temp2,
486                                  L_incompatible_class_change_error);
487       break;
488     }
489 
490     default:
491       fatal("unexpected intrinsic %d: %s", vmIntrinsics::as_int(iid), vmIntrinsics::name_at(iid));
492       break;
493     }
494 
495     // live at this point:  rmethod, r19_sender_sp (if interpreted)
496 
497     // After figuring out which concrete method to call, jump into it.
498     // Note that this works in the interpreter with no data motion.
499     // But the compiled version will require that r2_recv be shifted out.
500     jump_from_method_handle(_masm, rmethod, temp1, for_compiler_entry, iid);
501     if (iid == vmIntrinsics::_linkToInterface) {
502       __ bind(L_incompatible_class_change_error);
503       __ far_jump(RuntimeAddress(SharedRuntime::throw_IncompatibleClassChangeError_entry()));
504     }
505   }
506 }
507 
508 #ifndef PRODUCT
509 void trace_method_handle_stub(const char* adaptername,
510                               oopDesc* mh,
511                               intptr_t* saved_regs,
512                               intptr_t* entry_sp) {  }
513 
514 // The stub wraps the arguments in a struct on the stack to avoid
515 // dealing with the different calling conventions for passing 6
516 // arguments.
517 struct MethodHandleStubArguments {
518   const char* adaptername;
519   oopDesc* mh;
520   intptr_t* saved_regs;
521   intptr_t* entry_sp;
522 };
523 void trace_method_handle_stub_wrapper(MethodHandleStubArguments* args) {  }
524 
525 void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {  }
526 #endif //PRODUCT