< prev index next >

src/hotspot/share/c1/c1_CodeStubs.hpp

Print this page




  42 // usually handle slow cases of operations. All code stubs
  43 // are collected and code is emitted at the end of the
  44 // nmethod.
  45 
  46 class CodeStub: public CompilationResourceObj {
  47  protected:
  48   Label _entry;                                  // label at the stub entry point
  49   Label _continuation;                           // label where stub continues, if any
  50 
  51  public:
  52   CodeStub() {}
  53 
  54   // code generation
  55   void assert_no_unbound_labels()                { assert(!_entry.is_unbound() && !_continuation.is_unbound(), "unbound label"); }
  56   virtual void emit_code(LIR_Assembler* e) = 0;
  57   virtual CodeEmitInfo* info() const             { return NULL; }
  58   virtual bool is_exception_throw_stub() const   { return false; }
  59   virtual bool is_range_check_stub() const       { return false; }
  60   virtual bool is_divbyzero_stub() const         { return false; }
  61   virtual bool is_simple_exception_stub() const  { return false; }

  62 #ifndef PRODUCT
  63   virtual void print_name(outputStream* out) const = 0;
  64 #endif
  65 
  66   // label access
  67   Label* entry()                                 { return &_entry; }
  68   Label* continuation()                          { return &_continuation; }
  69   // for LIR
  70   virtual void visit(LIR_OpVisitState* visit) {
  71 #ifndef PRODUCT
  72     if (LIRTracePeephole && Verbose) {
  73       tty->print("no visitor for ");
  74       print_name(tty);
  75       tty->cr();
  76     }
  77 #endif
  78   }
  79 };
  80 
  81 class CodeStubList: public GrowableArray<CodeStub*> {


 382   Label         _patch_site_continuation;
 383   Register      _obj;
 384   CodeEmitInfo* _info;
 385   int           _index;  // index of the patchable oop or Klass* in nmethod oop or metadata table if needed
 386   static int    _patch_info_offset;
 387 
 388   void align_patch_site(MacroAssembler* masm);
 389 
 390  public:
 391   static int patch_info_offset() { return _patch_info_offset; }
 392 
 393   PatchingStub(MacroAssembler* masm, PatchID id, int index = -1):
 394       _id(id)
 395     , _info(NULL)
 396     , _index(index) {
 397     // force alignment of patch sites so we
 398     // can guarantee atomic writes to the patch site.
 399     align_patch_site(masm);
 400     _pc_start = masm->pc();
 401     masm->bind(_patch_site_entry);







 402   }
 403 
 404   void install(MacroAssembler* masm, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
 405     _info = info;
 406     _obj = obj;
 407     masm->bind(_patch_site_continuation);
 408     _bytes_to_copy = masm->pc() - pc_start();
 409     if (_id == PatchingStub::access_field_id) {
 410       // embed a fixed offset to handle long patches which need to be offset by a word.
 411       // the patching code will just add the field offset field to this offset so
 412       // that we can refernce either the high or low word of a double word field.
 413       int field_offset = 0;
 414       switch (patch_code) {
 415       case lir_patch_low:         field_offset = lo_word_offset_in_bytes; break;
 416       case lir_patch_high:        field_offset = hi_word_offset_in_bytes; break;
 417       case lir_patch_normal:      field_offset = 0;                       break;
 418       default: ShouldNotReachHere();
 419       }
 420       NativeMovRegMem* n_move = nativeMovRegMem_at(pc_start());
 421       n_move->set_offset(field_offset);




  42 // usually handle slow cases of operations. All code stubs
  43 // are collected and code is emitted at the end of the
  44 // nmethod.
  45 
  46 class CodeStub: public CompilationResourceObj {
  47  protected:
  48   Label _entry;                                  // label at the stub entry point
  49   Label _continuation;                           // label where stub continues, if any
  50 
  51  public:
  52   CodeStub() {}
  53 
  54   // code generation
  55   void assert_no_unbound_labels()                { assert(!_entry.is_unbound() && !_continuation.is_unbound(), "unbound label"); }
  56   virtual void emit_code(LIR_Assembler* e) = 0;
  57   virtual CodeEmitInfo* info() const             { return NULL; }
  58   virtual bool is_exception_throw_stub() const   { return false; }
  59   virtual bool is_range_check_stub() const       { return false; }
  60   virtual bool is_divbyzero_stub() const         { return false; }
  61   virtual bool is_simple_exception_stub() const  { return false; }
  62   virtual int nr_immediate_oops_patched() const  { return 0; }
  63 #ifndef PRODUCT
  64   virtual void print_name(outputStream* out) const = 0;
  65 #endif
  66 
  67   // label access
  68   Label* entry()                                 { return &_entry; }
  69   Label* continuation()                          { return &_continuation; }
  70   // for LIR
  71   virtual void visit(LIR_OpVisitState* visit) {
  72 #ifndef PRODUCT
  73     if (LIRTracePeephole && Verbose) {
  74       tty->print("no visitor for ");
  75       print_name(tty);
  76       tty->cr();
  77     }
  78 #endif
  79   }
  80 };
  81 
  82 class CodeStubList: public GrowableArray<CodeStub*> {


 383   Label         _patch_site_continuation;
 384   Register      _obj;
 385   CodeEmitInfo* _info;
 386   int           _index;  // index of the patchable oop or Klass* in nmethod oop or metadata table if needed
 387   static int    _patch_info_offset;
 388 
 389   void align_patch_site(MacroAssembler* masm);
 390 
 391  public:
 392   static int patch_info_offset() { return _patch_info_offset; }
 393 
 394   PatchingStub(MacroAssembler* masm, PatchID id, int index = -1):
 395       _id(id)
 396     , _info(NULL)
 397     , _index(index) {
 398     // force alignment of patch sites so we
 399     // can guarantee atomic writes to the patch site.
 400     align_patch_site(masm);
 401     _pc_start = masm->pc();
 402     masm->bind(_patch_site_entry);
 403   }
 404 
 405   virtual int nr_immediate_oops_patched() const  { 
 406     if (_id == load_mirror_id || _id == load_appendix_id) {
 407       return 1;
 408     }
 409     return 0; 
 410   }
 411 
 412   void install(MacroAssembler* masm, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
 413     _info = info;
 414     _obj = obj;
 415     masm->bind(_patch_site_continuation);
 416     _bytes_to_copy = masm->pc() - pc_start();
 417     if (_id == PatchingStub::access_field_id) {
 418       // embed a fixed offset to handle long patches which need to be offset by a word.
 419       // the patching code will just add the field offset field to this offset so
 420       // that we can refernce either the high or low word of a double word field.
 421       int field_offset = 0;
 422       switch (patch_code) {
 423       case lir_patch_low:         field_offset = lo_word_offset_in_bytes; break;
 424       case lir_patch_high:        field_offset = hi_word_offset_in_bytes; break;
 425       case lir_patch_normal:      field_offset = 0;                       break;
 426       default: ShouldNotReachHere();
 427       }
 428       NativeMovRegMem* n_move = nativeMovRegMem_at(pc_start());
 429       n_move->set_offset(field_offset);


< prev index next >