1 /*
   2  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef CPU_X86_VM_STUBROUTINES_X86_HPP
  26 #define CPU_X86_VM_STUBROUTINES_X86_HPP
  27 
  28 // This file holds the platform specific parts of the StubRoutines
  29 // definition. See stubRoutines.hpp for a description on how to
  30 // extend it.
  31 
  32 static bool returns_to_call_stub(address return_pc) { return return_pc == _call_stub_return_address; }
  33 
  34 enum platform_dependent_constants {
  35   code_size1 = 20000 LP64_ONLY(+10000),         // simply increase if too small (assembler will crash if too small)
  36   code_size2 = 33800 LP64_ONLY(+10000)           // simply increase if too small (assembler will crash if too small)
  37 };
  38 
  39 class x86 {
  40  friend class StubGenerator;
  41  friend class VMStructs;
  42 
  43 #ifdef _LP64
  44  private:
  45   static address _get_previous_fp_entry;
  46   static address _get_previous_sp_entry;
  47 
  48   static address _f2i_fixup;
  49   static address _f2l_fixup;
  50   static address _d2i_fixup;
  51   static address _d2l_fixup;
  52 
  53   static address _float_sign_mask;
  54   static address _float_sign_flip;
  55   static address _double_sign_mask;
  56   static address _double_sign_flip;
  57 
  58   static address _load_barrier_slow_stub[];
  59   static address _load_barrier_weak_slow_stub[];
  60 
  61  public:
  62 
  63   static address load_barrier_slow_stub(Register reg) { return _load_barrier_slow_stub[reg->encoding()]; }
  64   static address load_barrier_weak_slow_stub(Register reg) { return _load_barrier_weak_slow_stub[reg->encoding()]; }
  65 
  66 
  67   static address get_previous_fp_entry() {
  68     return _get_previous_fp_entry;
  69   }
  70 
  71   static address get_previous_sp_entry() {
  72     return _get_previous_sp_entry;
  73   }
  74 
  75   static address f2i_fixup() {
  76     return _f2i_fixup;
  77   }
  78 
  79   static address f2l_fixup() {
  80     return _f2l_fixup;
  81   }
  82 
  83   static address d2i_fixup() {
  84     return _d2i_fixup;
  85   }
  86 
  87   static address d2l_fixup() {
  88     return _d2l_fixup;
  89   }
  90 
  91   static address float_sign_mask() {
  92     return _float_sign_mask;
  93   }
  94 
  95   static address float_sign_flip() {
  96     return _float_sign_flip;
  97   }
  98 
  99   static address double_sign_mask() {
 100     return _double_sign_mask;
 101   }
 102 
 103   static address double_sign_flip() {
 104     return _double_sign_flip;
 105   }
 106 #else // !LP64
 107 
 108  private:
 109   static address _verify_fpu_cntrl_wrd_entry;
 110 
 111  public:
 112   static address verify_fpu_cntrl_wrd_entry() { return _verify_fpu_cntrl_wrd_entry; }
 113 
 114 #endif // !LP64
 115 
 116  private:
 117   static address _verify_mxcsr_entry;
 118   // shuffle mask for fixing up 128-bit words consisting of big-endian 32-bit integers
 119   static address _key_shuffle_mask_addr;
 120 
 121   //shuffle mask for big-endian 128-bit integers
 122   static address _counter_shuffle_mask_addr;
 123 
 124   // masks and table for CRC32
 125   static uint64_t _crc_by128_masks[];
 126   static juint    _crc_table[];
 127   // table for CRC32C
 128   static juint* _crc32c_table;
 129   // swap mask for ghash
 130   static address _ghash_long_swap_mask_addr;
 131   static address _ghash_byte_swap_mask_addr;
 132 
 133   // upper word mask for sha1
 134   static address _upper_word_mask_addr;
 135   // byte flip mask for sha1
 136   static address _shuffle_byte_flip_mask_addr;
 137 
 138   //k256 table for sha256
 139   static juint _k256[];
 140   static address _k256_adr;
 141 #ifdef _LP64
 142   static juint _k256_W[];
 143   static address _k256_W_adr;
 144   static julong _k512_W[];
 145   static address _k512_W_addr;
 146   // byte flip mask for sha512
 147   static address _pshuffle_byte_flip_mask_addr_sha512;
 148 #endif
 149   // byte flip mask for sha256
 150   static address _pshuffle_byte_flip_mask_addr;
 151 
 152   //tables common for LIBM sin and cos
 153   static juint _ONEHALF[];
 154   static address _ONEHALF_adr;
 155   static juint _P_2[];
 156   static address _P_2_adr;
 157   static juint _SC_4[];
 158   static address _SC_4_adr;
 159   static juint _Ctable[];
 160   static address _Ctable_adr;
 161   static juint _SC_2[];
 162   static address _SC_2_adr;
 163   static juint _SC_3[];
 164   static address _SC_3_adr;
 165   static juint _SC_1[];
 166   static address _SC_1_adr;
 167   static juint _PI_INV_TABLE[];
 168   static address _PI_INV_TABLE_adr;
 169   static juint _PI_4[];
 170   static address _PI_4_adr;
 171   static juint _PI32INV[];
 172   static address _PI32INV_adr;
 173   static juint _SIGN_MASK[];
 174   static address _SIGN_MASK_adr;
 175   static juint _P_1[];
 176   static address _P_1_adr;
 177   static juint _P_3[];
 178   static address _P_3_adr;
 179   static juint _NEG_ZERO[];
 180   static address _NEG_ZERO_adr;
 181 
 182   //tables common for LIBM sincos and tancot
 183   static juint _L_2il0floatpacket_0[];
 184   static address _L_2il0floatpacket_0_adr;
 185   static juint _Pi4Inv[];
 186   static address _Pi4Inv_adr;
 187   static juint _Pi4x3[];
 188   static address _Pi4x3_adr;
 189   static juint _Pi4x4[];
 190   static address _Pi4x4_adr;
 191   static juint _ones[];
 192   static address _ones_adr;
 193 
 194  public:
 195   static address verify_mxcsr_entry()    { return _verify_mxcsr_entry; }
 196   static address key_shuffle_mask_addr() { return _key_shuffle_mask_addr; }
 197   static address counter_shuffle_mask_addr() { return _counter_shuffle_mask_addr; }
 198   static address crc_by128_masks_addr()  { return (address)_crc_by128_masks; }
 199   static address ghash_long_swap_mask_addr() { return _ghash_long_swap_mask_addr; }
 200   static address ghash_byte_swap_mask_addr() { return _ghash_byte_swap_mask_addr; }
 201   static address upper_word_mask_addr() { return _upper_word_mask_addr; }
 202   static address shuffle_byte_flip_mask_addr() { return _shuffle_byte_flip_mask_addr; }
 203   static address k256_addr()      { return _k256_adr; }
 204 #ifdef _LP64
 205   static address k256_W_addr()    { return _k256_W_adr; }
 206   static address k512_W_addr()    { return _k512_W_addr; }
 207   static address pshuffle_byte_flip_mask_addr_sha512() { return _pshuffle_byte_flip_mask_addr_sha512; }
 208 #endif
 209   static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; }
 210   static void generate_CRC32C_table(bool is_pclmulqdq_supported);
 211   static address _ONEHALF_addr()      { return _ONEHALF_adr; }
 212   static address _P_2_addr()      { return _P_2_adr; }
 213   static address _SC_4_addr()      { return _SC_4_adr; }
 214   static address _Ctable_addr()      { return _Ctable_adr; }
 215   static address _SC_2_addr()      { return _SC_2_adr; }
 216   static address _SC_3_addr()      { return _SC_3_adr; }
 217   static address _SC_1_addr()      { return _SC_1_adr; }
 218   static address _PI_INV_TABLE_addr()      { return _PI_INV_TABLE_adr; }
 219   static address _PI_4_addr()      { return _PI_4_adr; }
 220   static address _PI32INV_addr()      { return _PI32INV_adr; }
 221   static address _SIGN_MASK_addr()      { return _SIGN_MASK_adr; }
 222   static address _P_1_addr()      { return _P_1_adr; }
 223   static address _P_3_addr()      { return _P_3_adr; }
 224   static address _NEG_ZERO_addr()      { return _NEG_ZERO_adr; }
 225   static address _L_2il0floatpacket_0_addr()      { return _L_2il0floatpacket_0_adr; }
 226   static address _Pi4Inv_addr()      { return _Pi4Inv_adr; }
 227   static address _Pi4x3_addr()      { return _Pi4x3_adr; }
 228   static address _Pi4x4_addr()      { return _Pi4x4_adr; }
 229   static address _ones_addr()      { return _ones_adr; }
 230 
 231 };
 232 
 233 #endif // CPU_X86_VM_STUBROUTINES_X86_HPP