src/share/vm/c1/c1_CodeStubs.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/c1

src/share/vm/c1/c1_CodeStubs.hpp

Print this page
rev 5100 : 7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
Summary: Do patching rather bailing out for unlinked call with appendix
Reviewed-by: twisti, kvn


 347   virtual void emit_code(LIR_Assembler* e);
 348   virtual void visit(LIR_OpVisitState* visitor) {
 349     assert(_obj_reg->is_illegal(), "unused");
 350     if (_compute_lock) {
 351       visitor->do_temp(_lock_reg);
 352     } else {
 353       visitor->do_input(_lock_reg);
 354     }
 355   }
 356 #ifndef PRODUCT
 357   virtual void print_name(outputStream* out) const { out->print("MonitorExitStub"); }
 358 #endif // PRODUCT
 359 };
 360 
 361 
 362 class PatchingStub: public CodeStub {
 363  public:
 364   enum PatchID {
 365     access_field_id,
 366     load_klass_id,
 367     load_mirror_id

 368   };
 369   enum constants {
 370     patch_info_size = 3
 371   };
 372  private:
 373   PatchID       _id;
 374   address       _pc_start;
 375   int           _bytes_to_copy;
 376   Label         _patched_code_entry;
 377   Label         _patch_site_entry;
 378   Label         _patch_site_continuation;
 379   Register      _obj;
 380   CodeEmitInfo* _info;
 381   int           _index;  // index of the patchable oop or Klass* in nmethod oop or metadata table if needed
 382   static int    _patch_info_offset;
 383 
 384   void align_patch_site(MacroAssembler* masm);
 385 
 386  public:
 387   static int patch_info_offset() { return _patch_info_offset; }


 400   }
 401 
 402   void install(MacroAssembler* masm, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
 403     _info = info;
 404     _obj = obj;
 405     masm->bind(_patch_site_continuation);
 406     _bytes_to_copy = masm->pc() - pc_start();
 407     if (_id == PatchingStub::access_field_id) {
 408       // embed a fixed offset to handle long patches which need to be offset by a word.
 409       // the patching code will just add the field offset field to this offset so
 410       // that we can refernce either the high or low word of a double word field.
 411       int field_offset = 0;
 412       switch (patch_code) {
 413       case lir_patch_low:         field_offset = lo_word_offset_in_bytes; break;
 414       case lir_patch_high:        field_offset = hi_word_offset_in_bytes; break;
 415       case lir_patch_normal:      field_offset = 0;                       break;
 416       default: ShouldNotReachHere();
 417       }
 418       NativeMovRegMem* n_move = nativeMovRegMem_at(pc_start());
 419       n_move->set_offset(field_offset);
 420     } else if (_id == load_klass_id || _id == load_mirror_id) {
 421       assert(_obj != noreg, "must have register object for load_klass/load_mirror");
 422 #ifdef ASSERT
 423       // verify that we're pointing at a NativeMovConstReg
 424       nativeMovConstReg_at(pc_start());
 425 #endif
 426     } else {
 427       ShouldNotReachHere();
 428     }
 429     assert(_bytes_to_copy <= (masm->pc() - pc_start()), "not enough bytes");
 430   }
 431 
 432   address pc_start() const                       { return _pc_start; }
 433   PatchID id() const                             { return _id; }
 434 
 435   virtual void emit_code(LIR_Assembler* e);
 436   virtual CodeEmitInfo* info() const             { return _info; }
 437   virtual void visit(LIR_OpVisitState* visitor) {
 438     visitor->do_slow_case(_info);
 439   }
 440 #ifndef PRODUCT




 347   virtual void emit_code(LIR_Assembler* e);
 348   virtual void visit(LIR_OpVisitState* visitor) {
 349     assert(_obj_reg->is_illegal(), "unused");
 350     if (_compute_lock) {
 351       visitor->do_temp(_lock_reg);
 352     } else {
 353       visitor->do_input(_lock_reg);
 354     }
 355   }
 356 #ifndef PRODUCT
 357   virtual void print_name(outputStream* out) const { out->print("MonitorExitStub"); }
 358 #endif // PRODUCT
 359 };
 360 
 361 
 362 class PatchingStub: public CodeStub {
 363  public:
 364   enum PatchID {
 365     access_field_id,
 366     load_klass_id,
 367     load_mirror_id,
 368     load_appendix_id
 369   };
 370   enum constants {
 371     patch_info_size = 3
 372   };
 373  private:
 374   PatchID       _id;
 375   address       _pc_start;
 376   int           _bytes_to_copy;
 377   Label         _patched_code_entry;
 378   Label         _patch_site_entry;
 379   Label         _patch_site_continuation;
 380   Register      _obj;
 381   CodeEmitInfo* _info;
 382   int           _index;  // index of the patchable oop or Klass* in nmethod oop or metadata table if needed
 383   static int    _patch_info_offset;
 384 
 385   void align_patch_site(MacroAssembler* masm);
 386 
 387  public:
 388   static int patch_info_offset() { return _patch_info_offset; }


 401   }
 402 
 403   void install(MacroAssembler* masm, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
 404     _info = info;
 405     _obj = obj;
 406     masm->bind(_patch_site_continuation);
 407     _bytes_to_copy = masm->pc() - pc_start();
 408     if (_id == PatchingStub::access_field_id) {
 409       // embed a fixed offset to handle long patches which need to be offset by a word.
 410       // the patching code will just add the field offset field to this offset so
 411       // that we can refernce either the high or low word of a double word field.
 412       int field_offset = 0;
 413       switch (patch_code) {
 414       case lir_patch_low:         field_offset = lo_word_offset_in_bytes; break;
 415       case lir_patch_high:        field_offset = hi_word_offset_in_bytes; break;
 416       case lir_patch_normal:      field_offset = 0;                       break;
 417       default: ShouldNotReachHere();
 418       }
 419       NativeMovRegMem* n_move = nativeMovRegMem_at(pc_start());
 420       n_move->set_offset(field_offset);
 421     } else if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
 422       assert(_obj != noreg, "must have register object for load_klass/load_mirror");
 423 #ifdef ASSERT
 424       // verify that we're pointing at a NativeMovConstReg
 425       nativeMovConstReg_at(pc_start());
 426 #endif
 427     } else {
 428       ShouldNotReachHere();
 429     }
 430     assert(_bytes_to_copy <= (masm->pc() - pc_start()), "not enough bytes");
 431   }
 432 
 433   address pc_start() const                       { return _pc_start; }
 434   PatchID id() const                             { return _id; }
 435 
 436   virtual void emit_code(LIR_Assembler* e);
 437   virtual CodeEmitInfo* info() const             { return _info; }
 438   virtual void visit(LIR_OpVisitState* visitor) {
 439     visitor->do_slow_case(_info);
 440   }
 441 #ifndef PRODUCT


src/share/vm/c1/c1_CodeStubs.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File