src/cpu/x86/vm/assembler_x86_64.hpp

Thu, 12 Jun 2008 13:50:55 -0700

author
ysr
date
Thu, 12 Jun 2008 13:50:55 -0700
changeset 779
6aae2f9d0294
parent 777
37f87013dfd8
parent 617
44abbb0d4c18
child 791
1ee8caae33af
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 class BiasedLockingCounters;
    27 // Contains all the definitions needed for amd64 assembly code generation.
    29 #ifdef _LP64
    30 // Calling convention
    31 class Argument VALUE_OBJ_CLASS_SPEC {
    32  public:
    33   enum {
    34 #ifdef _WIN64
    35     n_int_register_parameters_c   = 4, // rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
    36     n_float_register_parameters_c = 4,  // xmm0 - xmm3 (c_farg0, c_farg1, ... )
    37 #else
    38     n_int_register_parameters_c   = 6, // rdi, rsi, rdx, rcx, r8, r9 (c_rarg0, c_rarg1, ...)
    39     n_float_register_parameters_c = 8,  // xmm0 - xmm7 (c_farg0, c_farg1, ... )
    40 #endif  // _WIN64
    41     n_int_register_parameters_j   = 6, // j_rarg0, j_rarg1, ...
    42     n_float_register_parameters_j = 8  // j_farg0, j_farg1, ...
    43   };
    44 };
    47 // Symbolically name the register arguments used by the c calling convention.
    48 // Windows is different from linux/solaris. So much for standards...
    50 #ifdef _WIN64
    52 REGISTER_DECLARATION(Register, c_rarg0, rcx);
    53 REGISTER_DECLARATION(Register, c_rarg1, rdx);
    54 REGISTER_DECLARATION(Register, c_rarg2, r8);
    55 REGISTER_DECLARATION(Register, c_rarg3, r9);
    57 REGISTER_DECLARATION(XMMRegister, c_farg0, xmm0);
    58 REGISTER_DECLARATION(XMMRegister, c_farg1, xmm1);
    59 REGISTER_DECLARATION(XMMRegister, c_farg2, xmm2);
    60 REGISTER_DECLARATION(XMMRegister, c_farg3, xmm3);
    62 #else
    64 REGISTER_DECLARATION(Register, c_rarg0, rdi);
    65 REGISTER_DECLARATION(Register, c_rarg1, rsi);
    66 REGISTER_DECLARATION(Register, c_rarg2, rdx);
    67 REGISTER_DECLARATION(Register, c_rarg3, rcx);
    68 REGISTER_DECLARATION(Register, c_rarg4, r8);
    69 REGISTER_DECLARATION(Register, c_rarg5, r9);
    71 REGISTER_DECLARATION(XMMRegister, c_farg0, xmm0);
    72 REGISTER_DECLARATION(XMMRegister, c_farg1, xmm1);
    73 REGISTER_DECLARATION(XMMRegister, c_farg2, xmm2);
    74 REGISTER_DECLARATION(XMMRegister, c_farg3, xmm3);
    75 REGISTER_DECLARATION(XMMRegister, c_farg4, xmm4);
    76 REGISTER_DECLARATION(XMMRegister, c_farg5, xmm5);
    77 REGISTER_DECLARATION(XMMRegister, c_farg6, xmm6);
    78 REGISTER_DECLARATION(XMMRegister, c_farg7, xmm7);
    80 #endif  // _WIN64
    82 // Symbolically name the register arguments used by the Java calling convention.
    83 // We have control over the convention for java so we can do what we please.
    84 // What pleases us is to offset the java calling convention so that when
    85 // we call a suitable jni method the arguments are lined up and we don't
    86 // have to do little shuffling. A suitable jni method is non-static and a
    87 // small number of arguments (two fewer args on windows)
    88 //
    89 //        |-------------------------------------------------------|
    90 //        | c_rarg0   c_rarg1  c_rarg2 c_rarg3 c_rarg4 c_rarg5    |
    91 //        |-------------------------------------------------------|
    92 //        | rcx       rdx      r8      r9      rdi*    rsi*       | windows (* not a c_rarg)
    93 //        | rdi       rsi      rdx     rcx     r8      r9         | solaris/linux
    94 //        |-------------------------------------------------------|
    95 //        | j_rarg5   j_rarg0  j_rarg1 j_rarg2 j_rarg3 j_rarg4    |
    96 //        |-------------------------------------------------------|
    98 REGISTER_DECLARATION(Register, j_rarg0, c_rarg1);
    99 REGISTER_DECLARATION(Register, j_rarg1, c_rarg2);
   100 REGISTER_DECLARATION(Register, j_rarg2, c_rarg3);
   101 // Windows runs out of register args here
   102 #ifdef _WIN64
   103 REGISTER_DECLARATION(Register, j_rarg3, rdi);
   104 REGISTER_DECLARATION(Register, j_rarg4, rsi);
   105 #else
   106 REGISTER_DECLARATION(Register, j_rarg3, c_rarg4);
   107 REGISTER_DECLARATION(Register, j_rarg4, c_rarg5);
   108 #endif // _WIN64
   109 REGISTER_DECLARATION(Register, j_rarg5, c_rarg0);
   111 REGISTER_DECLARATION(XMMRegister, j_farg0, xmm0);
   112 REGISTER_DECLARATION(XMMRegister, j_farg1, xmm1);
   113 REGISTER_DECLARATION(XMMRegister, j_farg2, xmm2);
   114 REGISTER_DECLARATION(XMMRegister, j_farg3, xmm3);
   115 REGISTER_DECLARATION(XMMRegister, j_farg4, xmm4);
   116 REGISTER_DECLARATION(XMMRegister, j_farg5, xmm5);
   117 REGISTER_DECLARATION(XMMRegister, j_farg6, xmm6);
   118 REGISTER_DECLARATION(XMMRegister, j_farg7, xmm7);
   120 REGISTER_DECLARATION(Register, rscratch1, r10);  // volatile
   121 REGISTER_DECLARATION(Register, rscratch2, r11);  // volatile
   123 REGISTER_DECLARATION(Register, r12_heapbase, r12); // callee-saved
   124 REGISTER_DECLARATION(Register, r15_thread, r15);   // callee-saved
   126 #endif // _LP64
   128 // Address is an abstraction used to represent a memory location
   129 // using any of the amd64 addressing modes with one object.
   130 //
   131 // Note: A register location is represented via a Register, not
   132 //       via an address for efficiency & simplicity reasons.
   134 class ArrayAddress;
   136 class Address VALUE_OBJ_CLASS_SPEC {
   137  public:
   138   enum ScaleFactor {
   139     no_scale = -1,
   140     times_1  =  0,
   141     times_2  =  1,
   142     times_4  =  2,
   143     times_8  =  3
   144   };
   146  private:
   147   Register         _base;
   148   Register         _index;
   149   ScaleFactor      _scale;
   150   int              _disp;
   151   RelocationHolder _rspec;
   153   // Easily misused constructors make them private
   154   Address(int disp, address loc, relocInfo::relocType rtype);
   155   Address(int disp, address loc, RelocationHolder spec);
   157  public:
   158   // creation
   159   Address()
   160     : _base(noreg),
   161       _index(noreg),
   162       _scale(no_scale),
   163       _disp(0) {
   164   }
   166   // No default displacement otherwise Register can be implicitly
   167   // converted to 0(Register) which is quite a different animal.
   169   Address(Register base, int disp)
   170     : _base(base),
   171       _index(noreg),
   172       _scale(no_scale),
   173       _disp(disp) {
   174   }
   176   Address(Register base, Register index, ScaleFactor scale, int disp = 0)
   177     : _base (base),
   178       _index(index),
   179       _scale(scale),
   180       _disp (disp) {
   181     assert(!index->is_valid() == (scale == Address::no_scale),
   182            "inconsistent address");
   183   }
   185   // The following two overloads are used in connection with the
   186   // ByteSize type (see sizes.hpp).  They simplify the use of
   187   // ByteSize'd arguments in assembly code. Note that their equivalent
   188   // for the optimized build are the member functions with int disp
   189   // argument since ByteSize is mapped to an int type in that case.
   190   //
   191   // Note: DO NOT introduce similar overloaded functions for WordSize
   192   // arguments as in the optimized mode, both ByteSize and WordSize
   193   // are mapped to the same type and thus the compiler cannot make a
   194   // distinction anymore (=> compiler errors).
   196 #ifdef ASSERT
   197   Address(Register base, ByteSize disp)
   198     : _base(base),
   199       _index(noreg),
   200       _scale(no_scale),
   201       _disp(in_bytes(disp)) {
   202   }
   204   Address(Register base, Register index, ScaleFactor scale, ByteSize disp)
   205     : _base(base),
   206       _index(index),
   207       _scale(scale),
   208       _disp(in_bytes(disp)) {
   209     assert(!index->is_valid() == (scale == Address::no_scale),
   210            "inconsistent address");
   211   }
   212 #endif // ASSERT
   214   // accessors
   215   bool uses(Register reg) const {
   216     return _base == reg || _index == reg;
   217   }
   219   // Convert the raw encoding form into the form expected by the constructor for
   220   // Address.  An index of 4 (rsp) corresponds to having no index, so convert
   221   // that to noreg for the Address constructor.
   222   static Address make_raw(int base, int index, int scale, int disp);
   224   static Address make_array(ArrayAddress);
   225   Register base() const {
   226     return _base;
   227   }
   229   Register index() const {
   230     return _index;
   231   }
   233   int disp() const {
   234     return _disp;
   235   }
   238  private:
   239   bool base_needs_rex() const {
   240     return _base != noreg && _base->encoding() >= 8;
   241   }
   243   bool index_needs_rex() const {
   244     return _index != noreg &&_index->encoding() >= 8;
   245   }
   247   relocInfo::relocType reloc() const { return _rspec.type(); }
   249   friend class Assembler;
   250   friend class MacroAssembler;
   251   friend class LIR_Assembler; // base/index/scale/disp
   252 };
   254 //
   255 // AddressLiteral has been split out from Address because operands of this type
   256 // need to be treated specially on 32bit vs. 64bit platforms. By splitting it out
   257 // the few instructions that need to deal with address literals are unique and the
   258 // MacroAssembler does not have to implement every instruction in the Assembler
   259 // in order to search for address literals that may need special handling depending
   260 // on the instruction and the platform. As small step on the way to merging i486/amd64
   261 // directories.
   262 //
   263 class AddressLiteral VALUE_OBJ_CLASS_SPEC {
   264   friend class ArrayAddress;
   265   RelocationHolder _rspec;
   266   // Typically we use AddressLiterals we want to use their rval
   267   // However in some situations we want the lval (effect address) of the item.
   268   // We provide a special factory for making those lvals.
   269   bool _is_lval;
   271   // If the target is far we'll need to load the ea of this to
   272   // a register to reach it. Otherwise if near we can do rip
   273   // relative addressing.
   275   address          _target;
   277  protected:
   278   // creation
   279   AddressLiteral()
   280     : _is_lval(false),
   281       _target(NULL)
   282   {}
   284   public:
   287   AddressLiteral(address target, relocInfo::relocType rtype);
   289   AddressLiteral(address target, RelocationHolder const& rspec)
   290     : _rspec(rspec),
   291       _is_lval(false),
   292       _target(target)
   293   {}
   295   AddressLiteral addr() {
   296     AddressLiteral ret = *this;
   297     ret._is_lval = true;
   298     return ret;
   299   }
   302  private:
   304   address target() { return _target; }
   305   bool is_lval() { return _is_lval; }
   307   relocInfo::relocType reloc() const { return _rspec.type(); }
   308   const RelocationHolder& rspec() const { return _rspec; }
   310   friend class Assembler;
   311   friend class MacroAssembler;
   312   friend class Address;
   313   friend class LIR_Assembler;
   314 };
   316 // Convience classes
   317 class RuntimeAddress: public AddressLiteral {
   319   public:
   321   RuntimeAddress(address target) : AddressLiteral(target, relocInfo::runtime_call_type) {}
   323 };
   325 class OopAddress: public AddressLiteral {
   327   public:
   329   OopAddress(address target) : AddressLiteral(target, relocInfo::oop_type){}
   331 };
   333 class ExternalAddress: public AddressLiteral {
   335   public:
   337   ExternalAddress(address target) : AddressLiteral(target, relocInfo::external_word_type){}
   339 };
   341 class InternalAddress: public AddressLiteral {
   343   public:
   345   InternalAddress(address target) : AddressLiteral(target, relocInfo::internal_word_type) {}
   347 };
   349 // x86 can do array addressing as a single operation since disp can be an absolute
   350 // address but amd64 can't [e.g. array_base(rx, ry:width) ]. We create a class
   351 // that expresses the concept but does extra magic on amd64 to get the final result
   353 class ArrayAddress VALUE_OBJ_CLASS_SPEC {
   354   private:
   356   AddressLiteral _base;
   357   Address        _index;
   359   public:
   361   ArrayAddress() {};
   362   ArrayAddress(AddressLiteral base, Address index): _base(base), _index(index) {};
   363   AddressLiteral base() { return _base; }
   364   Address index() { return _index; }
   366 };
   368 // The amd64 Assembler: Pure assembler doing NO optimizations on
   369 // the instruction level (e.g. mov rax, 0 is not translated into xor
   370 // rax, rax!); i.e., what you write is what you get. The Assembler is
   371 // generating code into a CodeBuffer.
   373 const int FPUStateSizeInWords = 512 / wordSize;
   375 class Assembler : public AbstractAssembler  {
   376   friend class AbstractAssembler; // for the non-virtual hack
   377   friend class StubGenerator;
   380  protected:
   381 #ifdef ASSERT
   382   void check_relocation(RelocationHolder const& rspec, int format);
   383 #endif
   385   inline void emit_long64(jlong x);
   387   void emit_data(jint data, relocInfo::relocType rtype, int format /* = 1 */);
   388   void emit_data(jint data, RelocationHolder const& rspec, int format /* = 1 */);
   389   void emit_data64(jlong data, relocInfo::relocType rtype, int format = 0);
   390   void emit_data64(jlong data, RelocationHolder const& rspec, int format = 0);
   392   // Helper functions for groups of instructions
   393   void emit_arith_b(int op1, int op2, Register dst, int imm8);
   395   void emit_arith(int op1, int op2, Register dst, int imm32);
   396   // only x86??
   397   void emit_arith(int op1, int op2, Register dst, jobject obj);
   398   void emit_arith(int op1, int op2, Register dst, Register src);
   400   void emit_operand(Register reg,
   401                     Register base, Register index, Address::ScaleFactor scale,
   402                     int disp,
   403                     RelocationHolder const& rspec,
   404                     int rip_relative_correction = 0);
   405   void emit_operand(Register reg, Address adr,
   406                     int rip_relative_correction = 0);
   407   void emit_operand(XMMRegister reg,
   408                     Register base, Register index, Address::ScaleFactor scale,
   409                     int disp,
   410                     RelocationHolder const& rspec,
   411                     int rip_relative_correction = 0);
   412   void emit_operand(XMMRegister reg, Address adr,
   413                     int rip_relative_correction = 0);
   415   // Immediate-to-memory forms
   416   void emit_arith_operand(int op1, Register rm, Address adr, int imm32);
   418   void emit_farith(int b1, int b2, int i);
   420   bool reachable(AddressLiteral adr);
   422   // These are all easily abused and hence protected
   424   // Make these disappear in 64bit mode since they would never be correct
   425 #ifndef _LP64
   426   void cmp_literal32(Register src1, int32_t imm32, RelocationHolder const& rspec);
   427   void cmp_literal32(Address src1, int32_t imm32, RelocationHolder const& rspec);
   429   void mov_literal32(Register dst, int32_t imm32, RelocationHolder const& rspec);
   430   void mov_literal32(Address dst, int32_t imm32, RelocationHolder const& rspec);
   432   void push_literal32(int32_t imm32, RelocationHolder const& rspec);
   433 #endif // _LP64
   436   void mov_literal64(Register dst, intptr_t imm64, RelocationHolder const& rspec);
   438   // These are unique in that we are ensured by the caller that the 32bit
   439   // relative in these instructions will always be able to reach the potentially
   440   // 64bit address described by entry. Since they can take a 64bit address they
   441   // don't have the 32 suffix like the other instructions in this class.
   442   void jmp_literal(address entry, RelocationHolder const& rspec);
   443   void call_literal(address entry, RelocationHolder const& rspec);
   445  public:
   446   enum Condition { // The amd64 condition codes used for conditional jumps/moves.
   447     zero          = 0x4,
   448     notZero       = 0x5,
   449     equal         = 0x4,
   450     notEqual      = 0x5,
   451     less          = 0xc,
   452     lessEqual     = 0xe,
   453     greater       = 0xf,
   454     greaterEqual  = 0xd,
   455     below         = 0x2,
   456     belowEqual    = 0x6,
   457     above         = 0x7,
   458     aboveEqual    = 0x3,
   459     overflow      = 0x0,
   460     noOverflow    = 0x1,
   461     carrySet      = 0x2,
   462     carryClear    = 0x3,
   463     negative      = 0x8,
   464     positive      = 0x9,
   465     parity        = 0xa,
   466     noParity      = 0xb
   467   };
   469   enum Prefix {
   470     // segment overrides
   471     // XXX remove segment prefixes
   472     CS_segment = 0x2e,
   473     SS_segment = 0x36,
   474     DS_segment = 0x3e,
   475     ES_segment = 0x26,
   476     FS_segment = 0x64,
   477     GS_segment = 0x65,
   479     REX        = 0x40,
   481     REX_B      = 0x41,
   482     REX_X      = 0x42,
   483     REX_XB     = 0x43,
   484     REX_R      = 0x44,
   485     REX_RB     = 0x45,
   486     REX_RX     = 0x46,
   487     REX_RXB    = 0x47,
   489     REX_W      = 0x48,
   491     REX_WB     = 0x49,
   492     REX_WX     = 0x4A,
   493     REX_WXB    = 0x4B,
   494     REX_WR     = 0x4C,
   495     REX_WRB    = 0x4D,
   496     REX_WRX    = 0x4E,
   497     REX_WRXB   = 0x4F
   498   };
   500   enum WhichOperand {
   501     // input to locate_operand, and format code for relocations
   502     imm64_operand  = 0,          // embedded 64-bit immediate operand
   503     disp32_operand = 1,          // embedded 32-bit displacement
   504     call32_operand = 2,          // embedded 32-bit self-relative displacement
   505 #ifndef AMD64
   506     _WhichOperand_limit = 3
   507 #else
   508      narrow_oop_operand = 3,     // embedded 32-bit immediate narrow oop
   509     _WhichOperand_limit = 4
   510 #endif
   511   };
   513   public:
   515   // Creation
   516   Assembler(CodeBuffer* code)
   517     : AbstractAssembler(code) {
   518   }
   520   // Decoding
   521   static address locate_operand(address inst, WhichOperand which);
   522   static address locate_next_instruction(address inst);
   524   // Utilities
   526  static bool is_simm(int64_t x, int nbits) { return -( CONST64(1) << (nbits-1) )  <= x   &&   x  <  ( CONST64(1) << (nbits-1) ); }
   527  static bool is_simm32 (int64_t x) { return x == (int64_t)(int32_t)x; }
   530   // Stack
   531   void pushaq();
   532   void popaq();
   534   void pushfq();
   535   void popfq();
   537   void pushq(int imm32);
   539   void pushq(Register src);
   540   void pushq(Address src);
   542   void popq(Register dst);
   543   void popq(Address dst);
   545   // Instruction prefixes
   546   void prefix(Prefix p);
   548   int prefix_and_encode(int reg_enc, bool byteinst = false);
   549   int prefixq_and_encode(int reg_enc);
   551   int prefix_and_encode(int dst_enc, int src_enc, bool byteinst = false);
   552   int prefixq_and_encode(int dst_enc, int src_enc);
   554   void prefix(Register reg);
   555   void prefix(Address adr);
   556   void prefixq(Address adr);
   558   void prefix(Address adr, Register reg,  bool byteinst = false);
   559   void prefixq(Address adr, Register reg);
   561   void prefix(Address adr, XMMRegister reg);
   563   // Moves
   564   void movb(Register dst, Address src);
   565   void movb(Address dst, int imm8);
   566   void movb(Address dst, Register src);
   568   void movw(Address dst, int imm16);
   569   void movw(Register dst, Address src);
   570   void movw(Address dst, Register src);
   572   void movl(Register dst, int imm32);
   573   void movl(Register dst, Register src);
   574   void movl(Register dst, Address src);
   575   void movl(Address dst, int imm32);
   576   void movl(Address dst, Register src);
   578   void movq(Register dst, Register src);
   579   void movq(Register dst, Address src);
   580   void movq(Address dst, Register src);
   581   // These prevent using movq from converting a zero (like NULL) into Register
   582   // by giving the compiler two choices it can't resolve
   583   void movq(Address dst, void* dummy);
   584   void movq(Register dst, void* dummy);
   586   void mov64(Register dst, intptr_t imm64);
   587   void mov64(Address dst, intptr_t imm64);
   589   void movsbl(Register dst, Address src);
   590   void movsbl(Register dst, Register src);
   591   void movswl(Register dst, Address src);
   592   void movswl(Register dst, Register src);
   593   void movslq(Register dst, Address src);
   594   void movslq(Register dst, Register src);
   596   void movzbl(Register dst, Address src);
   597   void movzbl(Register dst, Register src);
   598   void movzwl(Register dst, Address src);
   599   void movzwl(Register dst, Register src);
   601  protected: // Avoid using the next instructions directly.
   602   // New cpus require use of movsd and movss to avoid partial register stall
   603   // when loading from memory. But for old Opteron use movlpd instead of movsd.
   604   // The selection is done in MacroAssembler::movdbl() and movflt().
   605   void movss(XMMRegister dst, XMMRegister src);
   606   void movss(XMMRegister dst, Address src);
   607   void movss(Address dst, XMMRegister src);
   608   void movsd(XMMRegister dst, XMMRegister src);
   609   void movsd(Address dst, XMMRegister src);
   610   void movsd(XMMRegister dst, Address src);
   611   void movlpd(XMMRegister dst, Address src);
   612   // New cpus require use of movaps and movapd to avoid partial register stall
   613   // when moving between registers.
   614   void movapd(XMMRegister dst, XMMRegister src);
   615   void movaps(XMMRegister dst, XMMRegister src);
   616  public:
   618   void movdl(XMMRegister dst, Register src);
   619   void movdl(Register dst, XMMRegister src);
   620   void movdq(XMMRegister dst, Register src);
   621   void movdq(Register dst, XMMRegister src);
   623   void cmovl(Condition cc, Register dst, Register src);
   624   void cmovl(Condition cc, Register dst, Address src);
   625   void cmovq(Condition cc, Register dst, Register src);
   626   void cmovq(Condition cc, Register dst, Address src);
   628   // Prefetches
   629  private:
   630   void prefetch_prefix(Address src);
   631  public:
   632   void prefetcht0(Address src);
   633   void prefetcht1(Address src);
   634   void prefetcht2(Address src);
   635   void prefetchnta(Address src);
   636   void prefetchw(Address src);
   638   // Arithmetics
   639   void adcl(Register dst, int imm32);
   640   void adcl(Register dst, Address src);
   641   void adcl(Register dst, Register src);
   642   void adcq(Register dst, int imm32);
   643   void adcq(Register dst, Address src);
   644   void adcq(Register dst, Register src);
   646   void addl(Address dst, int imm32);
   647   void addl(Address dst, Register src);
   648   void addl(Register dst, int imm32);
   649   void addl(Register dst, Address src);
   650   void addl(Register dst, Register src);
   651   void addq(Address dst, int imm32);
   652   void addq(Address dst, Register src);
   653   void addq(Register dst, int imm32);
   654   void addq(Register dst, Address src);
   655   void addq(Register dst, Register src);
   657   void andl(Register dst, int imm32);
   658   void andl(Register dst, Address src);
   659   void andl(Register dst, Register src);
   660   void andq(Register dst, int imm32);
   661   void andq(Register dst, Address src);
   662   void andq(Register dst, Register src);
   664   void cmpb(Address dst, int imm8);
   665   void cmpl(Address dst, int imm32);
   666   void cmpl(Register dst, int imm32);
   667   void cmpl(Register dst, Register src);
   668   void cmpl(Register dst, Address src);
   669   void cmpq(Address dst, int imm32);
   670   void cmpq(Address dst, Register src);
   671   void cmpq(Register dst, int imm32);
   672   void cmpq(Register dst, Register src);
   673   void cmpq(Register dst, Address src);
   675   void ucomiss(XMMRegister dst, XMMRegister src);
   676   void ucomisd(XMMRegister dst, XMMRegister src);
   678  protected:
   679   // Don't use next inc() and dec() methods directly. INC & DEC instructions
   680   // could cause a partial flag stall since they don't set CF flag.
   681   // Use MacroAssembler::decrement() & MacroAssembler::increment() methods
   682   // which call inc() & dec() or add() & sub() in accordance with
   683   // the product flag UseIncDec value.
   685   void decl(Register dst);
   686   void decl(Address dst);
   687   void decq(Register dst);
   688   void decq(Address dst);
   690   void incl(Register dst);
   691   void incl(Address dst);
   692   void incq(Register dst);
   693   void incq(Address dst);
   695  public:
   696   void idivl(Register src);
   697   void idivq(Register src);
   698   void cdql();
   699   void cdqq();
   701   void imull(Register dst, Register src);
   702   void imull(Register dst, Register src, int value);
   703   void imulq(Register dst, Register src);
   704   void imulq(Register dst, Register src, int value);
   706   void leal(Register dst, Address src);
   707   void leaq(Register dst, Address src);
   709   void mull(Address src);
   710   void mull(Register src);
   712   void negl(Register dst);
   713   void negq(Register dst);
   715   void notl(Register dst);
   716   void notq(Register dst);
   718   void orl(Address dst, int imm32);
   719   void orl(Register dst, int imm32);
   720   void orl(Register dst, Address src);
   721   void orl(Register dst, Register src);
   722   void orq(Address dst, int imm32);
   723   void orq(Register dst, int imm32);
   724   void orq(Register dst, Address src);
   725   void orq(Register dst, Register src);
   727   void rcll(Register dst, int imm8);
   728   void rclq(Register dst, int imm8);
   730   void sarl(Register dst, int imm8);
   731   void sarl(Register dst);
   732   void sarq(Register dst, int imm8);
   733   void sarq(Register dst);
   735   void sbbl(Address dst, int imm32);
   736   void sbbl(Register dst, int imm32);
   737   void sbbl(Register dst, Address src);
   738   void sbbl(Register dst, Register src);
   739   void sbbq(Address dst, int imm32);
   740   void sbbq(Register dst, int imm32);
   741   void sbbq(Register dst, Address src);
   742   void sbbq(Register dst, Register src);
   744   void shll(Register dst, int imm8);
   745   void shll(Register dst);
   746   void shlq(Register dst, int imm8);
   747   void shlq(Register dst);
   749   void shrl(Register dst, int imm8);
   750   void shrl(Register dst);
   751   void shrq(Register dst, int imm8);
   752   void shrq(Register dst);
   754   void subl(Address dst, int imm32);
   755   void subl(Address dst, Register src);
   756   void subl(Register dst, int imm32);
   757   void subl(Register dst, Address src);
   758   void subl(Register dst, Register src);
   759   void subq(Address dst, int imm32);
   760   void subq(Address dst, Register src);
   761   void subq(Register dst, int imm32);
   762   void subq(Register dst, Address src);
   763   void subq(Register dst, Register src);
   765   void testb(Register dst, int imm8);
   766   void testl(Register dst, int imm32);
   767   void testl(Register dst, Register src);
   768   void testq(Register dst, int imm32);
   769   void testq(Register dst, Register src);
   771   void xaddl(Address dst, Register src);
   772   void xaddq(Address dst, Register src);
   774   void xorl(Register dst, int imm32);
   775   void xorl(Register dst, Address src);
   776   void xorl(Register dst, Register src);
   777   void xorq(Register dst, int imm32);
   778   void xorq(Register dst, Address src);
   779   void xorq(Register dst, Register src);
   781   // Miscellaneous
   782   void bswapl(Register reg);
   783   void bswapq(Register reg);
   784   void lock();
   786   void xchgl(Register reg, Address adr);
   787   void xchgl(Register dst, Register src);
   788   void xchgq(Register reg, Address adr);
   789   void xchgq(Register dst, Register src);
   791   void cmpxchgl(Register reg, Address adr);
   792   void cmpxchgq(Register reg, Address adr);
   794   void nop(int i = 1);
   795   void addr_nop_4();
   796   void addr_nop_5();
   797   void addr_nop_7();
   798   void addr_nop_8();
   800   void hlt();
   801   void ret(int imm16);
   802   void smovl();
   803   void rep_movl();
   804   void rep_movq();
   805   void rep_set();
   806   void repne_scanl();
   807   void repne_scanq();
   808   void setb(Condition cc, Register dst);
   810   void clflush(Address adr);
   812   enum Membar_mask_bits {
   813     StoreStore = 1 << 3,
   814     LoadStore  = 1 << 2,
   815     StoreLoad  = 1 << 1,
   816     LoadLoad   = 1 << 0
   817   };
   819   // Serializes memory.
   820   void membar(Membar_mask_bits order_constraint) {
   821     // We only have to handle StoreLoad and LoadLoad
   822     if (order_constraint & StoreLoad) {
   823       // MFENCE subsumes LFENCE
   824       mfence();
   825     } /* [jk] not needed currently: else if (order_constraint & LoadLoad) {
   826          lfence();
   827     } */
   828   }
   830   void lfence() {
   831     emit_byte(0x0F);
   832     emit_byte(0xAE);
   833     emit_byte(0xE8);
   834   }
   836   void mfence() {
   837     emit_byte(0x0F);
   838     emit_byte(0xAE);
   839     emit_byte(0xF0);
   840   }
   842   // Identify processor type and features
   843   void cpuid() {
   844     emit_byte(0x0F);
   845     emit_byte(0xA2);
   846   }
   848   void cld() { emit_byte(0xfc);
   849   }
   851   void std() { emit_byte(0xfd);
   852   }
   855   // Calls
   857   void call(Label& L, relocInfo::relocType rtype);
   858   void call(Register reg);
   859   void call(Address adr);
   861   // Jumps
   863   void jmp(Register reg);
   864   void jmp(Address adr);
   866   // Label operations & relative jumps (PPUM Appendix D)
   867   // unconditional jump to L
   868   void jmp(Label& L, relocInfo::relocType rtype = relocInfo::none);
   871   // Unconditional 8-bit offset jump to L.
   872   // WARNING: be very careful using this for forward jumps.  If the label is
   873   // not bound within an 8-bit offset of this instruction, a run-time error
   874   // will occur.
   875   void jmpb(Label& L);
   877   // jcc is the generic conditional branch generator to run- time
   878   // routines, jcc is used for branches to labels. jcc takes a branch
   879   // opcode (cc) and a label (L) and generates either a backward
   880   // branch or a forward branch and links it to the label fixup
   881   // chain. Usage:
   882   //
   883   // Label L;      // unbound label
   884   // jcc(cc, L);   // forward branch to unbound label
   885   // bind(L);      // bind label to the current pc
   886   // jcc(cc, L);   // backward branch to bound label
   887   // bind(L);      // illegal: a label may be bound only once
   888   //
   889   // Note: The same Label can be used for forward and backward branches
   890   // but it may be bound only once.
   892   void jcc(Condition cc, Label& L,
   893            relocInfo::relocType rtype = relocInfo::none);
   895   // Conditional jump to a 8-bit offset to L.
   896   // WARNING: be very careful using this for forward jumps.  If the label is
   897   // not bound within an 8-bit offset of this instruction, a run-time error
   898   // will occur.
   899   void jccb(Condition cc, Label& L);
   901   // Floating-point operations
   903   void fxsave(Address dst);
   904   void fxrstor(Address src);
   905   void ldmxcsr(Address src);
   906   void stmxcsr(Address dst);
   908   void addss(XMMRegister dst, XMMRegister src);
   909   void addss(XMMRegister dst, Address src);
   910   void subss(XMMRegister dst, XMMRegister src);
   911   void subss(XMMRegister dst, Address src);
   912   void mulss(XMMRegister dst, XMMRegister src);
   913   void mulss(XMMRegister dst, Address src);
   914   void divss(XMMRegister dst, XMMRegister src);
   915   void divss(XMMRegister dst, Address src);
   916   void addsd(XMMRegister dst, XMMRegister src);
   917   void addsd(XMMRegister dst, Address src);
   918   void subsd(XMMRegister dst, XMMRegister src);
   919   void subsd(XMMRegister dst, Address src);
   920   void mulsd(XMMRegister dst, XMMRegister src);
   921   void mulsd(XMMRegister dst, Address src);
   922   void divsd(XMMRegister dst, XMMRegister src);
   923   void divsd(XMMRegister dst, Address src);
   925   // We only need the double form
   926   void sqrtsd(XMMRegister dst, XMMRegister src);
   927   void sqrtsd(XMMRegister dst, Address src);
   929   void xorps(XMMRegister dst, XMMRegister src);
   930   void xorps(XMMRegister dst, Address src);
   931   void xorpd(XMMRegister dst, XMMRegister src);
   932   void xorpd(XMMRegister dst, Address src);
   934   void cvtsi2ssl(XMMRegister dst, Register src);
   935   void cvtsi2ssq(XMMRegister dst, Register src);
   936   void cvtsi2sdl(XMMRegister dst, Register src);
   937   void cvtsi2sdq(XMMRegister dst, Register src);
   938   void cvttss2sil(Register dst, XMMRegister src); // truncates
   939   void cvttss2siq(Register dst, XMMRegister src); // truncates
   940   void cvttsd2sil(Register dst, XMMRegister src); // truncates
   941   void cvttsd2siq(Register dst, XMMRegister src); // truncates
   942   void cvtss2sd(XMMRegister dst, XMMRegister src);
   943   void cvtsd2ss(XMMRegister dst, XMMRegister src);
   944   void cvtdq2pd(XMMRegister dst, XMMRegister src);
   945   void cvtdq2ps(XMMRegister dst, XMMRegister src);
   947   void pxor(XMMRegister dst, Address src);       // Xor Packed Byte Integer Values
   948   void pxor(XMMRegister dst, XMMRegister src);   // Xor Packed Byte Integer Values
   950   void movdqa(XMMRegister dst, Address src);     // Move Aligned Double Quadword
   951   void movdqa(XMMRegister dst, XMMRegister src);
   952   void movdqa(Address     dst, XMMRegister src);
   954   void movq(XMMRegister dst, Address src);
   955   void movq(Address dst, XMMRegister src);
   957   void pshufd(XMMRegister dst, XMMRegister src, int mode); // Shuffle Packed Doublewords
   958   void pshufd(XMMRegister dst, Address src,     int mode);
   959   void pshuflw(XMMRegister dst, XMMRegister src, int mode); // Shuffle Packed Low Words
   960   void pshuflw(XMMRegister dst, Address src,     int mode);
   962   void psrlq(XMMRegister dst, int shift); // Shift Right Logical Quadword Immediate
   964   void punpcklbw(XMMRegister dst, XMMRegister src); // Interleave Low Bytes
   965   void punpcklbw(XMMRegister dst, Address src);
   966 };
   969 // MacroAssembler extends Assembler by frequently used macros.
   970 //
   971 // Instructions for which a 'better' code sequence exists depending
   972 // on arguments should also go in here.
   974 class MacroAssembler : public Assembler {
   975  friend class LIR_Assembler;
   976  protected:
   978   Address as_Address(AddressLiteral adr);
   979   Address as_Address(ArrayAddress adr);
   981   // Support for VM calls
   982   //
   983   // This is the base routine called by the different versions of
   984   // call_VM_leaf. The interpreter may customize this version by
   985   // overriding it for its purposes (e.g., to save/restore additional
   986   // registers when doing a VM call).
   988   virtual void call_VM_leaf_base(
   989     address entry_point,               // the entry point
   990     int     number_of_arguments        // the number of arguments to
   991                                        // pop after the call
   992   );
   994   // This is the base routine called by the different versions of
   995   // call_VM. The interpreter may customize this version by overriding
   996   // it for its purposes (e.g., to save/restore additional registers
   997   // when doing a VM call).
   998   //
   999   // If no java_thread register is specified (noreg) than rdi will be
  1000   // used instead. call_VM_base returns the register which contains
  1001   // the thread upon return. If a thread register has been specified,
  1002   // the return value will correspond to that register. If no
  1003   // last_java_sp is specified (noreg) than rsp will be used instead.
  1004   virtual void call_VM_base(           // returns the register
  1005                                        // containing the thread upon
  1006                                        // return
  1007     Register oop_result,               // where an oop-result ends up
  1008                                        // if any; use noreg otherwise
  1009     Register java_thread,              // the thread if computed
  1010                                        // before ; use noreg otherwise
  1011     Register last_java_sp,             // to set up last_Java_frame in
  1012                                        // stubs; use noreg otherwise
  1013     address  entry_point,              // the entry point
  1014     int      number_of_arguments,      // the number of arguments (w/o
  1015                                        // thread) to pop after the
  1016                                        // call
  1017     bool     check_exceptions          // whether to check for pending
  1018                                        // exceptions after return
  1019   );
  1021   // This routines should emit JVMTI PopFrame handling and ForceEarlyReturn code.
  1022   // The implementation is only non-empty for the InterpreterMacroAssembler,
  1023   // as only the interpreter handles PopFrame and ForceEarlyReturn requests.
  1024   virtual void check_and_handle_popframe(Register java_thread);
  1025   virtual void check_and_handle_earlyret(Register java_thread);
  1027   void call_VM_helper(Register oop_result,
  1028                       address entry_point,
  1029                       int number_of_arguments,
  1030                       bool check_exceptions = true);
  1032  public:
  1033   MacroAssembler(CodeBuffer* code) : Assembler(code) {}
  1035   // Support for NULL-checks
  1036   //
  1037   // Generates code that causes a NULL OS exception if the content of
  1038   // reg is NULL.  If the accessed location is M[reg + offset] and the
  1039   // offset is known, provide the offset. No explicit code generation
  1040   // is needed if the offset is within a certain range (0 <= offset <=
  1041   // page_size).
  1042   void null_check(Register reg, int offset = -1);
  1043   static bool needs_explicit_null_check(intptr_t offset);
  1045   // Required platform-specific helpers for Label::patch_instructions.
  1046   // They _shadow_ the declarations in AbstractAssembler, which are undefined.
  1047   void pd_patch_instruction(address branch, address target);
  1048 #ifndef PRODUCT
  1049   static void pd_print_patched_instruction(address branch);
  1050 #endif
  1053   // The following 4 methods return the offset of the appropriate move
  1054   // instruction.  Note: these are 32 bit instructions
  1056   // Support for fast byte/word loading with zero extension (depending
  1057   // on particular CPU)
  1058   int load_unsigned_byte(Register dst, Address src);
  1059   int load_unsigned_word(Register dst, Address src);
  1061   // Support for fast byte/word loading with sign extension (depending
  1062   // on particular CPU)
  1063   int load_signed_byte(Register dst, Address src);
  1064   int load_signed_word(Register dst, Address src);
  1066   // Support for inc/dec with optimal instruction selection depending
  1067   // on value
  1068   void incrementl(Register reg, int value = 1);
  1069   void decrementl(Register reg, int value = 1);
  1070   void incrementq(Register reg, int value = 1);
  1071   void decrementq(Register reg, int value = 1);
  1073   void incrementl(Address dst, int value = 1);
  1074   void decrementl(Address dst, int value = 1);
  1075   void incrementq(Address dst, int value = 1);
  1076   void decrementq(Address dst, int value = 1);
  1078   // Support optimal SSE move instructions.
  1079   void movflt(XMMRegister dst, XMMRegister src) {
  1080     if (UseXmmRegToRegMoveAll) { movaps(dst, src); return; }
  1081     else                       { movss (dst, src); return; }
  1084   void movflt(XMMRegister dst, Address src) { movss(dst, src); }
  1086   void movflt(XMMRegister dst, AddressLiteral src);
  1088   void movflt(Address dst, XMMRegister src) { movss(dst, src); }
  1090   void movdbl(XMMRegister dst, XMMRegister src) {
  1091     if (UseXmmRegToRegMoveAll) { movapd(dst, src); return; }
  1092     else                       { movsd (dst, src); return; }
  1095   void movdbl(XMMRegister dst, AddressLiteral src);
  1097   void movdbl(XMMRegister dst, Address src) {
  1098     if (UseXmmLoadAndClearUpper) { movsd (dst, src); return; }
  1099     else                         { movlpd(dst, src); return; }
  1102   void movdbl(Address dst, XMMRegister src) { movsd(dst, src); }
  1104   void incrementl(AddressLiteral dst);
  1105   void incrementl(ArrayAddress dst);
  1107   // Alignment
  1108   void align(int modulus);
  1110   // Misc
  1111   void fat_nop(); // 5 byte nop
  1114   // C++ bool manipulation
  1116   void movbool(Register dst, Address src);
  1117   void movbool(Address dst, bool boolconst);
  1118   void movbool(Address dst, Register src);
  1119   void testbool(Register dst);
  1121   // oop manipulations
  1122   void load_klass(Register dst, Register src);
  1123   void store_klass(Register dst, Register src);
  1124   void store_klass_gap(Register dst, Register src);
  1126   void load_prototype_header(Register dst, Register src);
  1128   void load_heap_oop(Register dst, Address src);
  1129   void store_heap_oop(Address dst, Register src);
  1130   void encode_heap_oop(Register r);
  1131   void decode_heap_oop(Register r);
  1132   void encode_heap_oop_not_null(Register r);
  1133   void decode_heap_oop_not_null(Register r);
  1134   void encode_heap_oop_not_null(Register dst, Register src);
  1135   void decode_heap_oop_not_null(Register dst, Register src);
  1137   void set_narrow_oop(Register dst, jobject obj);
  1139   // Stack frame creation/removal
  1140   void enter();
  1141   void leave();
  1143   // Support for getting the JavaThread pointer (i.e.; a reference to
  1144   // thread-local information) The pointer will be loaded into the
  1145   // thread register.
  1146   void get_thread(Register thread);
  1148   void int3();
  1150   // Support for VM calls
  1151   //
  1152   // It is imperative that all calls into the VM are handled via the
  1153   // call_VM macros.  They make sure that the stack linkage is setup
  1154   // correctly. call_VM's correspond to ENTRY/ENTRY_X entry points
  1155   // while call_VM_leaf's correspond to LEAF entry points.
  1156   void call_VM(Register oop_result,
  1157                address entry_point,
  1158                bool check_exceptions = true);
  1159   void call_VM(Register oop_result,
  1160                address entry_point,
  1161                Register arg_1,
  1162                bool check_exceptions = true);
  1163   void call_VM(Register oop_result,
  1164                address entry_point,
  1165                Register arg_1, Register arg_2,
  1166                bool check_exceptions = true);
  1167   void call_VM(Register oop_result,
  1168                address entry_point,
  1169                Register arg_1, Register arg_2, Register arg_3,
  1170                bool check_exceptions = true);
  1172   // Overloadings with last_Java_sp
  1173   void call_VM(Register oop_result,
  1174                Register last_java_sp,
  1175                address entry_point,
  1176                int number_of_arguments = 0,
  1177                bool check_exceptions = true);
  1178   void call_VM(Register oop_result,
  1179                Register last_java_sp,
  1180                address entry_point,
  1181                Register arg_1, bool
  1182                check_exceptions = true);
  1183   void call_VM(Register oop_result,
  1184                Register last_java_sp,
  1185                address entry_point,
  1186                Register arg_1, Register arg_2,
  1187                bool check_exceptions = true);
  1188   void call_VM(Register oop_result,
  1189                Register last_java_sp,
  1190                address entry_point,
  1191                Register arg_1, Register arg_2, Register arg_3,
  1192                bool check_exceptions = true);
  1194   void call_VM_leaf(address entry_point,
  1195                     int number_of_arguments = 0);
  1196   void call_VM_leaf(address entry_point,
  1197                     Register arg_1);
  1198   void call_VM_leaf(address entry_point,
  1199                     Register arg_1, Register arg_2);
  1200   void call_VM_leaf(address entry_point,
  1201                     Register arg_1, Register arg_2, Register arg_3);
  1203   // last Java Frame (fills frame anchor)
  1204   void set_last_Java_frame(Register last_java_sp,
  1205                            Register last_java_fp,
  1206                            address last_java_pc);
  1207   void reset_last_Java_frame(bool clear_fp, bool clear_pc);
  1209   // Stores
  1210   void store_check(Register obj);                // store check for
  1211                                                  // obj - register is
  1212                                                  // destroyed
  1213                                                  // afterwards
  1214   void store_check(Register obj, Address dst);   // same as above, dst
  1215                                                  // is exact store
  1216                                                  // location (reg. is
  1217                                                  // destroyed)
  1219   void g1_write_barrier_pre(Register obj, Register tmp, Register tmp2, bool tosca_live );
  1220   void g1_write_barrier_post(Register store_addr, Register new_val, Register tmp, Register tmp2);
  1222   // split store_check(Register obj) to enhance instruction interleaving
  1223   void store_check_part_1(Register obj);
  1224   void store_check_part_2(Register obj);
  1226   // C 'boolean' to Java boolean: x == 0 ? 0 : 1
  1227   void c2bool(Register x);
  1229   // Int division/reminder for Java
  1230   // (as idivl, but checks for special case as described in JVM spec.)
  1231   // returns idivl instruction offset for implicit exception handling
  1232   int corrected_idivl(Register reg);
  1233   // Long division/reminder for Java
  1234   // (as idivq, but checks for special case as described in JVM spec.)
  1235   // returns idivq instruction offset for implicit exception handling
  1236   int corrected_idivq(Register reg);
  1238   // Push and pop integer/fpu/cpu state
  1239   void push_IU_state();
  1240   void pop_IU_state();
  1242   void push_FPU_state();
  1243   void pop_FPU_state();
  1245   void push_CPU_state();
  1246   void pop_CPU_state();
  1248   // Sign extension
  1249   void sign_extend_short(Register reg);
  1250   void sign_extend_byte(Register reg);
  1252   // Division by power of 2, rounding towards 0
  1253   void division_with_shift(Register reg, int shift_value);
  1255   // Round up to a power of two
  1256   void round_to_l(Register reg, int modulus);
  1257   void round_to_q(Register reg, int modulus);
  1259   // allocation
  1260   void eden_allocate(
  1261     Register obj,               // result: pointer to object after
  1262                                 // successful allocation
  1263     Register var_size_in_bytes, // object size in bytes if unknown at
  1264                                 // compile time; invalid otherwise
  1265     int con_size_in_bytes,      // object size in bytes if known at
  1266                                 // compile time
  1267     Register t1,                // temp register
  1268     Label& slow_case            // continuation point if fast
  1269                                 // allocation fails
  1270     );
  1271   void tlab_allocate(
  1272     Register obj,               // result: pointer to object after
  1273                                 // successful allocation
  1274     Register var_size_in_bytes, // object size in bytes if unknown at
  1275                                 // compile time; invalid otherwise
  1276     int con_size_in_bytes,      // object size in bytes if known at
  1277                                 // compile time
  1278     Register t1,                // temp register
  1279     Register t2,                // temp register
  1280     Label& slow_case            // continuation point if fast
  1281                                 // allocation fails
  1282   );
  1283   void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case);
  1285   //----
  1287   // Debugging
  1289   // only if +VerifyOops
  1290   void verify_oop(Register reg, const char* s = "broken oop");
  1291   void verify_oop_addr(Address addr, const char * s = "broken oop addr");
  1293   // if heap base register is used - reinit it with the correct value
  1294   void reinit_heapbase();
  1296   // only if +VerifyFPU
  1297   void verify_FPU(int stack_depth, const char* s = "illegal FPU state") {}
  1299   // prints msg, dumps registers and stops execution
  1300   void stop(const char* msg);
  1302   // prints message and continues
  1303   void warn(const char* msg);
  1305   static void debug(char* msg, int64_t pc, int64_t regs[]);
  1307   void os_breakpoint();
  1309   void untested()
  1311     stop("untested");
  1314   void unimplemented(const char* what = "")
  1316     char* b = new char[1024];
  1317     sprintf(b, "unimplemented: %s", what);
  1318     stop(b);
  1321   void should_not_reach_here()
  1323     stop("should not reach here");
  1326   // Stack overflow checking
  1327   void bang_stack_with_offset(int offset)
  1329     // stack grows down, caller passes positive offset
  1330     assert(offset > 0, "must bang with negative offset");
  1331     movl(Address(rsp, (-offset)), rax);
  1334   // Writes to stack successive pages until offset reached to check for
  1335   // stack overflow + shadow pages.  Also, clobbers tmp
  1336   void bang_stack_size(Register offset, Register tmp);
  1338   // Support for serializing memory accesses between threads.
  1339   void serialize_memory(Register thread, Register tmp);
  1341   void verify_tlab();
  1343   // Biased locking support
  1344   // lock_reg and obj_reg must be loaded up with the appropriate values.
  1345   // swap_reg must be rax and is killed.
  1346   // tmp_reg must be supplied and is killed.
  1347   // If swap_reg_contains_mark is true then the code assumes that the
  1348   // mark word of the object has already been loaded into swap_reg.
  1349   // Optional slow case is for implementations (interpreter and C1) which branch to
  1350   // slow case directly. Leaves condition codes set for C2's Fast_Lock node.
  1351   // Returns offset of first potentially-faulting instruction for null
  1352   // check info (currently consumed only by C1). If
  1353   // swap_reg_contains_mark is true then returns -1 as it is assumed
  1354   // the calling code has already passed any potential faults.
  1355   int biased_locking_enter(Register lock_reg, Register obj_reg, Register swap_reg, Register tmp_reg,
  1356                            bool swap_reg_contains_mark,
  1357                            Label& done, Label* slow_case = NULL,
  1358                            BiasedLockingCounters* counters = NULL);
  1359   void biased_locking_exit (Register obj_reg, Register temp_reg, Label& done);
  1361   Condition negate_condition(Condition cond);
  1363   // Instructions that use AddressLiteral operands. These instruction can handle 32bit/64bit
  1364   // operands. In general the names are modified to avoid hiding the instruction in Assembler
  1365   // so that we don't need to implement all the varieties in the Assembler with trivial wrappers
  1366   // here in MacroAssembler. The major exception to this rule is call
  1368   // Arithmetics
  1370   void cmp8(AddressLiteral src1, int8_t imm32);
  1372   void cmp32(AddressLiteral src1, int32_t src2);
  1373   // compare reg - mem, or reg - &mem
  1374   void cmp32(Register src1, AddressLiteral src2);
  1376   void cmp32(Register src1, Address src2);
  1378 #ifndef _LP64
  1379   void cmpoop(Address dst, jobject obj);
  1380   void cmpoop(Register dst, jobject obj);
  1381 #endif // _LP64
  1383   // NOTE src2 must be the lval. This is NOT an mem-mem compare
  1384   void cmpptr(Address src1, AddressLiteral src2);
  1386   void cmpptr(Register src1, AddressLiteral src);
  1388   // will be cmpreg(?)
  1389   void cmp64(Register src1, AddressLiteral src);
  1391   void cmpxchgptr(Register reg, Address adr);
  1392   void cmpxchgptr(Register reg, AddressLiteral adr);
  1394   // Helper functions for statistics gathering.
  1395   // Conditionally (atomically, on MPs) increments passed counter address, preserving condition codes.
  1396   void cond_inc32(Condition cond, AddressLiteral counter_addr);
  1397   // Unconditional atomic increment.
  1398   void atomic_incl(AddressLiteral counter_addr);
  1401   void lea(Register dst, AddressLiteral src);
  1402   void lea(Register dst, Address src);
  1405   // Calls
  1406   void call(Label& L, relocInfo::relocType rtype);
  1407   void call(Register entry);
  1408   void call(AddressLiteral entry);
  1410   // Jumps
  1412   // 32bit can do a case table jump in one instruction but we no longer allow the base
  1413   // to be installed in the Address class
  1414   void jump(ArrayAddress entry);
  1416   void jump(AddressLiteral entry);
  1417   void jump_cc(Condition cc, AddressLiteral dst);
  1419   // Floating
  1421   void ldmxcsr(Address src) { Assembler::ldmxcsr(src); }
  1422   void ldmxcsr(AddressLiteral src);
  1424 private:
  1425   // these are private because users should be doing movflt/movdbl
  1427   void movss(XMMRegister dst, XMMRegister src) { Assembler::movss(dst, src); }
  1428   void movss(Address dst, XMMRegister src)       { Assembler::movss(dst, src); }
  1429   void movss(XMMRegister dst, Address src)       { Assembler::movss(dst, src); }
  1430   void movss(XMMRegister dst, AddressLiteral src);
  1432   void movlpd(XMMRegister dst, Address src)      {Assembler::movlpd(dst, src); }
  1433   void movlpd(XMMRegister dst, AddressLiteral src);
  1435 public:
  1438   void xorpd(XMMRegister dst, XMMRegister src) {Assembler::xorpd(dst, src); }
  1439   void xorpd(XMMRegister dst, Address src)       {Assembler::xorpd(dst, src); }
  1440   void xorpd(XMMRegister dst, AddressLiteral src);
  1442   void xorps(XMMRegister dst, XMMRegister src) {Assembler::xorps(dst, src); }
  1443   void xorps(XMMRegister dst, Address src)       {Assembler::xorps(dst, src); }
  1444   void xorps(XMMRegister dst, AddressLiteral src);
  1447   // Data
  1449   void movoop(Register dst, jobject obj);
  1450   void movoop(Address dst, jobject obj);
  1452   void movptr(ArrayAddress dst, Register src);
  1453   void movptr(Register dst, AddressLiteral src);
  1455   void movptr(Register dst, intptr_t src);
  1456   void movptr(Address dst, intptr_t src);
  1458   void movptr(Register dst, ArrayAddress src);
  1460   // to avoid hiding movl
  1461   void mov32(AddressLiteral dst, Register src);
  1462   void mov32(Register dst, AddressLiteral src);
  1464   void pushoop(jobject obj);
  1466   // Can push value or effective address
  1467   void pushptr(AddressLiteral src);
  1469 };
  1471 /**
  1472  * class SkipIfEqual:
  1474  * Instantiating this class will result in assembly code being output that will
  1475  * jump around any code emitted between the creation of the instance and it's
  1476  * automatic destruction at the end of a scope block, depending on the value of
  1477  * the flag passed to the constructor, which will be checked at run-time.
  1478  */
  1479 class SkipIfEqual {
  1480  private:
  1481   MacroAssembler* _masm;
  1482   Label _label;
  1484  public:
  1485    SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value);
  1486    ~SkipIfEqual();
  1487 };
  1490 #ifdef ASSERT
  1491 inline bool AbstractAssembler::pd_check_instruction_mark() { return true; }
  1492 #endif

mercurial