< prev index next >

src/cpu/x86/vm/methodHandles_x86.cpp

Print this page




  36 
  37 #ifdef PRODUCT
  38 #define BLOCK_COMMENT(str) /* nothing */
  39 #define STOP(error) stop(error)
  40 #else
  41 #define BLOCK_COMMENT(str) __ block_comment(str)
  42 #define STOP(error) block_comment(error); __ stop(error)
  43 #endif
  44 
  45 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
  46 
  47 void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) {
  48   if (VerifyMethodHandles)
  49     verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
  50                  "MH argument is a Class");
  51   __ movptr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset_in_bytes()));
  52 }
  53 
  54 #ifdef ASSERT
  55 static int check_nonzero(const char* xname, int x) {
  56   assert(x != 0, err_msg("%s should be nonzero", xname));
  57   return x;
  58 }
  59 #define NONZERO(x) check_nonzero(#x, x)
  60 #else //ASSERT
  61 #define NONZERO(x) (x)
  62 #endif //ASSERT
  63 
  64 #ifdef ASSERT
  65 void MethodHandles::verify_klass(MacroAssembler* _masm,
  66                                  Register obj, SystemDictionary::WKID klass_id,
  67                                  const char* error_message) {
  68   Klass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
  69   KlassHandle klass = SystemDictionary::well_known_klass(klass_id);
  70   Register temp = rdi;
  71   Register temp2 = noreg;
  72   LP64_ONLY(temp2 = rscratch1);  // used by MacroAssembler::cmpptr
  73   Label L_ok, L_bad;
  74   BLOCK_COMMENT("verify_klass {");
  75   __ verify_oop(obj);
  76   __ testptr(obj, obj);


 439       Register rbx_index = rbx_method;
 440       __ movptr(rbx_index, member_vmindex);
 441       if (VerifyMethodHandles) {
 442         Label L;
 443         __ cmpl(rbx_index, 0);
 444         __ jcc(Assembler::greaterEqual, L);
 445         __ STOP("invalid vtable index for MH.invokeInterface");
 446         __ bind(L);
 447       }
 448 
 449       // given intf, index, and recv klass, dispatch to the implementation method
 450       __ lookup_interface_method(temp1_recv_klass, temp3_intf,
 451                                  // note: next two args must be the same:
 452                                  rbx_index, rbx_method,
 453                                  temp2,
 454                                  L_incompatible_class_change_error);
 455       break;
 456     }
 457 
 458     default:
 459       fatal(err_msg_res("unexpected intrinsic %d: %s", iid, vmIntrinsics::name_at(iid)));
 460       break;
 461     }
 462 
 463     // Live at this point:
 464     //   rbx_method
 465     //   rsi/r13 (if interpreted)
 466 
 467     // After figuring out which concrete method to call, jump into it.
 468     // Note that this works in the interpreter with no data motion.
 469     // But the compiled version will require that rcx_recv be shifted out.
 470     __ verify_method_ptr(rbx_method);
 471     jump_from_method_handle(_masm, rbx_method, temp1, for_compiler_entry);
 472 
 473     if (iid == vmIntrinsics::_linkToInterface) {
 474       __ bind(L_incompatible_class_change_error);
 475       __ jump(RuntimeAddress(StubRoutines::throw_IncompatibleClassChangeError_entry()));
 476     }
 477   }
 478 }
 479 




  36 
  37 #ifdef PRODUCT
  38 #define BLOCK_COMMENT(str) /* nothing */
  39 #define STOP(error) stop(error)
  40 #else
  41 #define BLOCK_COMMENT(str) __ block_comment(str)
  42 #define STOP(error) block_comment(error); __ stop(error)
  43 #endif
  44 
  45 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
  46 
  47 void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) {
  48   if (VerifyMethodHandles)
  49     verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
  50                  "MH argument is a Class");
  51   __ movptr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset_in_bytes()));
  52 }
  53 
  54 #ifdef ASSERT
  55 static int check_nonzero(const char* xname, int x) {
  56   assert(x != 0, "%s should be nonzero", xname);
  57   return x;
  58 }
  59 #define NONZERO(x) check_nonzero(#x, x)
  60 #else //ASSERT
  61 #define NONZERO(x) (x)
  62 #endif //ASSERT
  63 
  64 #ifdef ASSERT
  65 void MethodHandles::verify_klass(MacroAssembler* _masm,
  66                                  Register obj, SystemDictionary::WKID klass_id,
  67                                  const char* error_message) {
  68   Klass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
  69   KlassHandle klass = SystemDictionary::well_known_klass(klass_id);
  70   Register temp = rdi;
  71   Register temp2 = noreg;
  72   LP64_ONLY(temp2 = rscratch1);  // used by MacroAssembler::cmpptr
  73   Label L_ok, L_bad;
  74   BLOCK_COMMENT("verify_klass {");
  75   __ verify_oop(obj);
  76   __ testptr(obj, obj);


 439       Register rbx_index = rbx_method;
 440       __ movptr(rbx_index, member_vmindex);
 441       if (VerifyMethodHandles) {
 442         Label L;
 443         __ cmpl(rbx_index, 0);
 444         __ jcc(Assembler::greaterEqual, L);
 445         __ STOP("invalid vtable index for MH.invokeInterface");
 446         __ bind(L);
 447       }
 448 
 449       // given intf, index, and recv klass, dispatch to the implementation method
 450       __ lookup_interface_method(temp1_recv_klass, temp3_intf,
 451                                  // note: next two args must be the same:
 452                                  rbx_index, rbx_method,
 453                                  temp2,
 454                                  L_incompatible_class_change_error);
 455       break;
 456     }
 457 
 458     default:
 459       fatal("unexpected intrinsic %d: %s", iid, vmIntrinsics::name_at(iid));
 460       break;
 461     }
 462 
 463     // Live at this point:
 464     //   rbx_method
 465     //   rsi/r13 (if interpreted)
 466 
 467     // After figuring out which concrete method to call, jump into it.
 468     // Note that this works in the interpreter with no data motion.
 469     // But the compiled version will require that rcx_recv be shifted out.
 470     __ verify_method_ptr(rbx_method);
 471     jump_from_method_handle(_masm, rbx_method, temp1, for_compiler_entry);
 472 
 473     if (iid == vmIntrinsics::_linkToInterface) {
 474       __ bind(L_incompatible_class_change_error);
 475       __ jump(RuntimeAddress(StubRoutines::throw_IncompatibleClassChangeError_entry()));
 476     }
 477   }
 478 }
 479 


< prev index next >