378 int MethodHandles::adapter_conversion_ops_supported_mask() {
379 return ((1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY)
380 |(1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW)
381 |(1<<sun_dyn_AdapterMethodHandle::OP_CHECK_CAST)
382 |(1<<sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM)
383 |(1<<sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM)
384 |(1<<sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS)
385 |(1<<sun_dyn_AdapterMethodHandle::OP_ROT_ARGS)
386 |(1<<sun_dyn_AdapterMethodHandle::OP_DUP_ARGS)
387 |(1<<sun_dyn_AdapterMethodHandle::OP_DROP_ARGS)
388 //|(1<<sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
389 );
390 // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
391 }
392
393 //------------------------------------------------------------------------------
394 // MethodHandles::generate_method_handle_stub
395 //
396 // Generate an "entry" field for a method handle.
397 // This determines how the method handle will respond to calls.
398 void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) {
399 // Here is the register state during an interpreted call,
400 // as set up by generate_method_handle_interpreter_entry():
401 // - G5: garbage temp (was MethodHandle.invoke methodOop, unused)
402 // - G3: receiver method handle
403 // - O5_savedSP: sender SP (must preserve)
404
405 const Register O0_argslot = O0;
406 const Register O1_scratch = O1;
407 const Register O2_scratch = O2;
408 const Register O3_scratch = O3;
409 const Register G5_index = G5;
410
411 // Argument registers for _raise_exception.
412 const Register O0_code = O0;
413 const Register O1_actual = O1;
414 const Register O2_required = O2;
415
416 guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
417
418 // Some handy addresses:
430 Address G3_amh_conversion(G3_method_handle, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes());
431
432 const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
433
434 if (have_entry(ek)) {
435 __ nop(); // empty stubs make SG sick
436 return;
437 }
438
439 address interp_entry = __ pc();
440
441 trace_method_handle(_masm, entry_name(ek));
442
443 switch ((int) ek) {
444 case _raise_exception:
445 {
446 // Not a real MH entry, but rather shared code for raising an
447 // exception. Since we use a C2I adapter to set up the
448 // interpreter state, arguments are expected in compiler
449 // argument registers.
450 methodHandle mh(raise_exception_method());
451 address c2i_entry = methodOopDesc::make_adapters(mh, CATCH);
452
453 __ mov(O5_savedSP, SP); // Cut the stack back to where the caller started.
454
455 Label L_no_method;
456 // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
457 __ set(AddressLiteral((address) &_raise_exception_method), G5_method);
458 __ ld_ptr(Address(G5_method, 0), G5_method);
459 __ tst(G5_method);
460 __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
461 __ delayed()->nop();
462
463 const int jobject_oop_offset = 0;
464 __ ld_ptr(Address(G5_method, jobject_oop_offset), G5_method);
465 __ tst(G5_method);
466 __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
467 __ delayed()->nop();
468
469 __ verify_oop(G5_method);
470 __ jump_to(AddressLiteral(c2i_entry), O3_scratch);
471 __ delayed()->nop();
|
378 int MethodHandles::adapter_conversion_ops_supported_mask() {
379 return ((1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY)
380 |(1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW)
381 |(1<<sun_dyn_AdapterMethodHandle::OP_CHECK_CAST)
382 |(1<<sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM)
383 |(1<<sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM)
384 |(1<<sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS)
385 |(1<<sun_dyn_AdapterMethodHandle::OP_ROT_ARGS)
386 |(1<<sun_dyn_AdapterMethodHandle::OP_DUP_ARGS)
387 |(1<<sun_dyn_AdapterMethodHandle::OP_DROP_ARGS)
388 //|(1<<sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
389 );
390 // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
391 }
392
393 //------------------------------------------------------------------------------
394 // MethodHandles::generate_method_handle_stub
395 //
396 // Generate an "entry" field for a method handle.
397 // This determines how the method handle will respond to calls.
398 void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) {
399 // Here is the register state during an interpreted call,
400 // as set up by generate_method_handle_interpreter_entry():
401 // - G5: garbage temp (was MethodHandle.invoke methodOop, unused)
402 // - G3: receiver method handle
403 // - O5_savedSP: sender SP (must preserve)
404
405 const Register O0_argslot = O0;
406 const Register O1_scratch = O1;
407 const Register O2_scratch = O2;
408 const Register O3_scratch = O3;
409 const Register G5_index = G5;
410
411 // Argument registers for _raise_exception.
412 const Register O0_code = O0;
413 const Register O1_actual = O1;
414 const Register O2_required = O2;
415
416 guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
417
418 // Some handy addresses:
430 Address G3_amh_conversion(G3_method_handle, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes());
431
432 const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
433
434 if (have_entry(ek)) {
435 __ nop(); // empty stubs make SG sick
436 return;
437 }
438
439 address interp_entry = __ pc();
440
441 trace_method_handle(_masm, entry_name(ek));
442
443 switch ((int) ek) {
444 case _raise_exception:
445 {
446 // Not a real MH entry, but rather shared code for raising an
447 // exception. Since we use a C2I adapter to set up the
448 // interpreter state, arguments are expected in compiler
449 // argument registers.
450 assert(raise_exception_method(), "must be set");
451 address c2i_entry = raise_exception_method()->get_c2i_entry();
452 assert(c2i_entry, "method must be linked");
453
454 __ mov(O5_savedSP, SP); // Cut the stack back to where the caller started.
455
456 Label L_no_method;
457 // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
458 __ set(AddressLiteral((address) &_raise_exception_method), G5_method);
459 __ ld_ptr(Address(G5_method, 0), G5_method);
460 __ tst(G5_method);
461 __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
462 __ delayed()->nop();
463
464 const int jobject_oop_offset = 0;
465 __ ld_ptr(Address(G5_method, jobject_oop_offset), G5_method);
466 __ tst(G5_method);
467 __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
468 __ delayed()->nop();
469
470 __ verify_oop(G5_method);
471 __ jump_to(AddressLiteral(c2i_entry), O3_scratch);
472 __ delayed()->nop();
|