hotspot/src/cpu/sparc/vm/assembler_sparc.hpp
changeset 9976 6fef34e63df1
parent 9176 42d9d1010f38
child 10027 20cd71f29262
equal deleted inserted replaced
9975:82190b49ce14 9976:6fef34e63df1
   307       _index_or_disp(in_bytes(disp)) {
   307       _index_or_disp(in_bytes(disp)) {
   308   }
   308   }
   309 #endif
   309 #endif
   310 
   310 
   311   // accessors
   311   // accessors
   312   Register base()      const { return _base; }
   312   Register base()             const { return _base; }
   313   Register index()     const { return _index_or_disp.as_register(); }
   313   Register index()            const { return _index_or_disp.as_register(); }
   314   int      disp()      const { return _index_or_disp.as_constant(); }
   314   int      disp()             const { return _index_or_disp.as_constant(); }
   315 
   315 
   316   bool     has_index() const { return _index_or_disp.is_register(); }
   316   bool     has_index()        const { return _index_or_disp.is_register(); }
   317   bool     has_disp()  const { return _index_or_disp.is_constant(); }
   317   bool     has_disp()         const { return _index_or_disp.is_constant(); }
       
   318 
       
   319   bool     uses(Register reg) const { return base() == reg || (has_index() && index() == reg); }
   318 
   320 
   319   const relocInfo::relocType rtype() { return _rspec.type(); }
   321   const relocInfo::relocType rtype() { return _rspec.type(); }
   320   const RelocationHolder&    rspec() { return _rspec; }
   322   const RelocationHolder&    rspec() { return _rspec; }
   321 
   323 
   322   RelocationHolder rspec(int offset) const {
   324   RelocationHolder rspec(int offset) const {
   327 
   329 
   328   Address plus_disp(int plusdisp) const {     // bump disp by a small amount
   330   Address plus_disp(int plusdisp) const {     // bump disp by a small amount
   329     assert(_index_or_disp.is_constant(), "must have a displacement");
   331     assert(_index_or_disp.is_constant(), "must have a displacement");
   330     Address a(base(), disp() + plusdisp);
   332     Address a(base(), disp() + plusdisp);
   331     return a;
   333     return a;
       
   334   }
       
   335   bool is_same_address(Address a) const {
       
   336     // disregard _rspec
       
   337     return base() == a.base() && (has_index() ? index() == a.index() : disp() == a.disp());
   332   }
   338   }
   333 
   339 
   334   Address after_save() const {
   340   Address after_save() const {
   335     Address a = (*this);
   341     Address a = (*this);
   336     a._base = a._base->after_save();
   342     a._base = a._base->after_save();
   434 
   440 
   435   AddressLiteral(oop addr, relocInfo::relocType rtype = relocInfo::none)
   441   AddressLiteral(oop addr, relocInfo::relocType rtype = relocInfo::none)
   436     : _address((address) addr),
   442     : _address((address) addr),
   437       _rspec(rspec_from_rtype(rtype, (address) addr)) {}
   443       _rspec(rspec_from_rtype(rtype, (address) addr)) {}
   438 
   444 
       
   445   AddressLiteral(oop* addr, relocInfo::relocType rtype = relocInfo::none)
       
   446     : _address((address) addr),
       
   447       _rspec(rspec_from_rtype(rtype, (address) addr)) {}
       
   448 
   439   AddressLiteral(float* addr, relocInfo::relocType rtype = relocInfo::none)
   449   AddressLiteral(float* addr, relocInfo::relocType rtype = relocInfo::none)
   440     : _address((address) addr),
   450     : _address((address) addr),
   441       _rspec(rspec_from_rtype(rtype, (address) addr)) {}
   451       _rspec(rspec_from_rtype(rtype, (address) addr)) {}
   442 
   452 
   443   AddressLiteral(double* addr, relocInfo::relocType rtype = relocInfo::none)
   453   AddressLiteral(double* addr, relocInfo::relocType rtype = relocInfo::none)
   453   RelocationHolder rspec(int offset) const {
   463   RelocationHolder rspec(int offset) const {
   454     return offset == 0 ? _rspec : _rspec.plus(offset);
   464     return offset == 0 ? _rspec : _rspec.plus(offset);
   455   }
   465   }
   456 };
   466 };
   457 
   467 
       
   468 // Convenience classes
       
   469 class ExternalAddress: public AddressLiteral {
       
   470  private:
       
   471   static relocInfo::relocType reloc_for_target(address target) {
       
   472     // Sometimes ExternalAddress is used for values which aren't
       
   473     // exactly addresses, like the card table base.
       
   474     // external_word_type can't be used for values in the first page
       
   475     // so just skip the reloc in that case.
       
   476     return external_word_Relocation::can_be_relocated(target) ? relocInfo::external_word_type : relocInfo::none;
       
   477   }
       
   478 
       
   479  public:
       
   480   ExternalAddress(address target) : AddressLiteral(target, reloc_for_target(          target)) {}
       
   481   ExternalAddress(oop*    target) : AddressLiteral(target, reloc_for_target((address) target)) {}
       
   482 };
   458 
   483 
   459 inline Address RegisterImpl::address_in_saved_window() const {
   484 inline Address RegisterImpl::address_in_saved_window() const {
   460    return (Address(SP, (sp_offset_in_saved_window() * wordSize) + STACK_BIAS));
   485    return (Address(SP, (sp_offset_in_saved_window() * wordSize) + STACK_BIAS));
   461 }
   486 }
   462 
   487 
   853 
   878 
   854   // x is supposed to fit in a field "nbits" wide
   879   // x is supposed to fit in a field "nbits" wide
   855   // and be sign-extended. Check the range.
   880   // and be sign-extended. Check the range.
   856 
   881 
   857   static void assert_signed_range(intptr_t x, int nbits) {
   882   static void assert_signed_range(intptr_t x, int nbits) {
   858     assert( nbits == 32
   883     assert(nbits == 32 || (-(1 << nbits-1) <= x  &&  x < ( 1 << nbits-1)),
   859         ||  -(1 << nbits-1) <= x  &&  x < ( 1 << nbits-1),
   884            err_msg("value out of range: x=" INTPTR_FORMAT ", nbits=%d", x, nbits));
   860       "value out of range");
       
   861   }
   885   }
   862 
   886 
   863   static void assert_signed_word_disp_range(intptr_t x, int nbits) {
   887   static void assert_signed_word_disp_range(intptr_t x, int nbits) {
   864     assert( (x & 3) == 0, "not word aligned");
   888     assert( (x & 3) == 0, "not word aligned");
   865     assert_signed_range(x, nbits + 2);
   889     assert_signed_range(x, nbits + 2);
  2285   void set_varargs( Argument a, Register d );
  2309   void set_varargs( Argument a, Register d );
  2286 
  2310 
  2287   int total_frame_size_in_bytes(int extraWords);
  2311   int total_frame_size_in_bytes(int extraWords);
  2288 
  2312 
  2289   // used when extraWords known statically
  2313   // used when extraWords known statically
  2290   void save_frame(int extraWords);
  2314   void save_frame(int extraWords = 0);
  2291   void save_frame_c1(int size_in_bytes);
  2315   void save_frame_c1(int size_in_bytes);
  2292   // make a frame, and simultaneously pass up one or two register value
  2316   // make a frame, and simultaneously pass up one or two register value
  2293   // into the new register window
  2317   // into the new register window
  2294   void save_frame_and_mov(int extraWords, Register s1, Register d1, Register s2 = Register(), Register d2 = Register());
  2318   void save_frame_and_mov(int extraWords, Register s1, Register d1, Register s2 = Register(), Register d2 = Register());
  2295 
  2319 
  2454                                   Register temp_reg);
  2478                                   Register temp_reg);
  2455   void jump_to_method_handle_entry(Register mh_reg, Register temp_reg, bool emit_delayed_nop = true);
  2479   void jump_to_method_handle_entry(Register mh_reg, Register temp_reg, bool emit_delayed_nop = true);
  2456   // offset relative to Gargs of argument at tos[arg_slot].
  2480   // offset relative to Gargs of argument at tos[arg_slot].
  2457   // (arg_slot == 0 means the last argument, not the first).
  2481   // (arg_slot == 0 means the last argument, not the first).
  2458   RegisterOrConstant argument_offset(RegisterOrConstant arg_slot,
  2482   RegisterOrConstant argument_offset(RegisterOrConstant arg_slot,
       
  2483                                      Register temp_reg,
  2459                                      int extra_slot_offset = 0);
  2484                                      int extra_slot_offset = 0);
  2460   // Address of Gargs and argument_offset.
  2485   // Address of Gargs and argument_offset.
  2461   Address            argument_address(RegisterOrConstant arg_slot,
  2486   Address            argument_address(RegisterOrConstant arg_slot,
       
  2487                                       Register temp_reg,
  2462                                       int extra_slot_offset = 0);
  2488                                       int extra_slot_offset = 0);
  2463 
  2489 
  2464   // Stack overflow checking
  2490   // Stack overflow checking
  2465 
  2491 
  2466   // Note: this clobbers G3_scratch
  2492   // Note: this clobbers G3_scratch