hotspot/src/cpu/x86/vm/assembler_x86_64.cpp
author coleenp
Sun, 13 Apr 2008 17:43:42 -0400
changeset 360 21d113ecbf6a
parent 249 8a8601fb5571
child 365 01d8c42b8e6d
permissions -rw-r--r--
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_assembler_x86_64.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// Implementation of AddressLiteral
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
AddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  _is_lval = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  _target = target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  switch (rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  case relocInfo::oop_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
    // Oops are a special case. Normally they would be their own section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
    // but in cases like icBuffer they are literals in the code stream that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    // we don't have a section for. We use none so that we get a literal address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    // which is always patchable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  case relocInfo::external_word_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    _rspec = external_word_Relocation::spec(target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  case relocInfo::internal_word_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    _rspec = internal_word_Relocation::spec(target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  case relocInfo::opt_virtual_call_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _rspec = opt_virtual_call_Relocation::spec();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  case relocInfo::static_call_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    _rspec = static_call_Relocation::spec();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  case relocInfo::runtime_call_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    _rspec = runtime_call_Relocation::spec();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  case relocInfo::none:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// Implementation of Address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
Address Address::make_array(ArrayAddress adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Not implementable on 64bit machines
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Should have been handled higher up the call chain.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  return Address();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  AddressLiteral base = adr.base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  Address index = adr.index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  assert(index._disp == 0, "must not have disp"); // maybe it can?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  Address array(index._base, index._index, index._scale, (intptr_t) base.target());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  array._rspec = base._rspec;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  return array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// exceedingly dangerous constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
Address::Address(int disp, address loc, relocInfo::relocType rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  _base  = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  _index = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  _scale = no_scale;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  _disp  = disp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  switch (rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    case relocInfo::external_word_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      _rspec = external_word_Relocation::spec(loc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    case relocInfo::internal_word_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      _rspec = internal_word_Relocation::spec(loc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    case relocInfo::runtime_call_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      // HMM
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      _rspec = runtime_call_Relocation::spec();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    case relocInfo::none:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
// Convert the raw encoding form into the form expected by the constructor for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// Address.  An index of 4 (rsp) corresponds to having no index, so convert
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// that to noreg for the Address constructor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
Address Address::make_raw(int base, int index, int scale, int disp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  bool valid_index = index != rsp->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  if (valid_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    Address madr(as_Register(base), as_Register(index), (Address::ScaleFactor)scale, in_ByteSize(disp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    return madr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    Address madr(as_Register(base), noreg, Address::no_scale, in_ByteSize(disp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    return madr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// Implementation of Assembler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
int AbstractAssembler::code_fill_byte() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  return (u_char)'\xF4'; // hlt
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
// This should only be used by 64bit instructions that can use rip-relative
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
// it cannot be used by instructions that want an immediate value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
bool Assembler::reachable(AddressLiteral adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  int64_t disp;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
   130
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // None will force a 64bit literal to the code stream. Likely a placeholder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // for something that will be patched later and we need to certain it will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // always be reachable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  if (adr.reloc() == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  if (adr.reloc() == relocInfo::internal_word_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    // This should be rip relative and easily reachable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  if (adr.reloc() != relocInfo::external_word_type &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
      adr.reloc() != relocInfo::runtime_call_type ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // Stress the correction code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  if (ForceUnreachable) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    // Must be runtimecall reloc, see if it is in the codecache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    // Flipping stuff in the codecache to be unreachable causes issues
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    // with things like inline caches where the additional instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    // are not handled.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    if (CodeCache::find_blob(adr._target) == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // For external_word_type/runtime_call_type if it is reachable from where we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // are now (possibly a temp buffer) and where we might end up
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // anywhere in the codeCache then we are always reachable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // This would have to change if we ever save/restore shared code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // to be more pessimistic.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  disp = (int64_t)adr._target - ((int64_t)CodeCache::low_bound() + sizeof(int));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  if (!is_simm32(disp)) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  disp = (int64_t)adr._target - ((int64_t)CodeCache::high_bound() + sizeof(int));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  if (!is_simm32(disp)) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  disp = (int64_t)adr._target - ((int64_t)_code_pos + sizeof(int));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // Because rip relative is a disp + address_of_next_instruction and we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  // don't know the value of address_of_next_instruction we apply a fudge factor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // to make sure we will be ok no matter the size of the instruction we get placed into.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // We don't have to fudge the checks above here because they are already worst case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // 12 == override/rex byte, opcode byte, rm byte, sib byte, a 4-byte disp , 4-byte literal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // + 4 because better safe than sorry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  const int fudge = 12 + 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  if (disp < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    disp -= fudge;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    disp += fudge;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  return is_simm32(disp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
// make this go away eventually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
void Assembler::emit_data(jint data,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
                          relocInfo::relocType rtype,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
                          int format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  if (rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    emit_long(data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    emit_data(data, Relocation::spec_simple(rtype), format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
void Assembler::emit_data(jint data,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
                          RelocationHolder const& rspec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
                          int format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  assert(imm64_operand == 0, "default format must be imm64 in this file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  assert(imm64_operand != format, "must not be imm64");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  assert(inst_mark() != NULL, "must be inside InstructionMark");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  if (rspec.type() !=  relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      check_relocation(rspec, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    // Do not use AbstractAssembler::relocate, which is not intended for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    // embedded words.  Instead, relocate to the enclosing instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    // hack. call32 is too wide for mask so use disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    if (format == call32_operand)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      code_section()->relocate(inst_mark(), rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      code_section()->relocate(inst_mark(), rspec, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  emit_long(data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
void Assembler::emit_data64(jlong data,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
                            relocInfo::relocType rtype,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
                            int format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  if (rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    emit_long64(data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    emit_data64(data, Relocation::spec_simple(rtype), format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
void Assembler::emit_data64(jlong data,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
                            RelocationHolder const& rspec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
                            int format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  assert(imm64_operand == 0, "default format must be imm64 in this file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  assert(imm64_operand == format, "must be imm64");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  assert(inst_mark() != NULL, "must be inside InstructionMark");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  // Do not use AbstractAssembler::relocate, which is not intended for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // embedded words.  Instead, relocate to the enclosing instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  code_section()->relocate(inst_mark(), rspec, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  check_relocation(rspec, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  emit_long64(data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  assert(isByte(op1) && isByte(op2), "wrong opcode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  assert(isByte(imm8), "not a byte");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  assert((op1 & 0x01) == 0, "should be 8bit operation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  int dstenc = dst->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  if (dstenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    dstenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  emit_byte(op1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  emit_byte(op2 | dstenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
void Assembler::emit_arith(int op1, int op2, Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  assert(isByte(op1) && isByte(op2), "wrong opcode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  assert((op1 & 0x01) == 1, "should be 32bit operation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  int dstenc = dst->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  if (dstenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    dstenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  if (is8bit(imm32)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    emit_byte(op1 | 0x02); // set sign bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    emit_byte(op2 | dstenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    emit_byte(imm32 & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    emit_byte(op1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    emit_byte(op2 | dstenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
// immediate-to-memory forms
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
void Assembler::emit_arith_operand(int op1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
                                   Register rm, Address adr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
                                   int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  assert((op1 & 0x01) == 1, "should be 32bit operation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  if (is8bit(imm32)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    emit_byte(op1 | 0x02); // set sign bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    emit_operand(rm, adr, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    emit_byte(imm32 & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    emit_byte(op1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    emit_operand(rm, adr, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
void Assembler::emit_arith(int op1, int op2, Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  assert(isByte(op1) && isByte(op2), "wrong opcode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  int dstenc = dst->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  int srcenc = src->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  if (dstenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    dstenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  if (srcenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    srcenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  emit_byte(op1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  emit_byte(op2 | dstenc << 3 | srcenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
void Assembler::emit_operand(Register reg, Register base, Register index,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
                             Address::ScaleFactor scale, int disp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
                             RelocationHolder const& rspec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
                             int rip_relative_correction) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  relocInfo::relocType rtype = (relocInfo::relocType) rspec.type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  int regenc = reg->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  if (regenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    regenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  if (base->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    if (index->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      assert(scale != Address::no_scale, "inconsistent address");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      int indexenc = index->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      if (indexenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
        indexenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      int baseenc = base->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      if (baseenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
        baseenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
      // [base + index*scale + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
      if (disp == 0 && rtype == relocInfo::none  &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
          base != rbp && base != r13) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
        // [base + index*scale]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
        // [00 reg 100][ss index base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
        assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
        emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        emit_byte(scale << 6 | indexenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      } else if (is8bit(disp) && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
        // [base + index*scale + imm8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
        // [01 reg 100][ss index base] imm8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
        assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
        emit_byte(0x44 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
        emit_byte(scale << 6 | indexenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
        emit_byte(disp & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
        // [base + index*scale + disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
        // [10 reg 100][ss index base] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
        assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
        emit_byte(0x84 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
        emit_byte(scale << 6 | indexenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
        emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    } else if (base == rsp || base == r12) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      // [rsp + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
      if (disp == 0 && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        // [rsp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        // [00 reg 100][00 100 100]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
        emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        emit_byte(0x24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
      } else if (is8bit(disp) && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
        // [rsp + imm8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        // [01 reg 100][00 100 100] disp8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        emit_byte(0x44 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        emit_byte(0x24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        emit_byte(disp & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
        // [rsp + imm32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
        // [10 reg 100][00 100 100] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
        emit_byte(0x84 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
        emit_byte(0x24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
        emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
      // [base + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
      assert(base != rsp && base != r12, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
      int baseenc = base->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      if (baseenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        baseenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
      if (disp == 0 && rtype == relocInfo::none &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
          base != rbp && base != r13) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
        // [base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
        // [00 reg base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
        emit_byte(0x00 | regenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      } else if (is8bit(disp) && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
        // [base + disp8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
        // [01 reg base] disp8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
        emit_byte(0x40 | regenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
        emit_byte(disp & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
        // [base + disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
        // [10 reg base] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
        emit_byte(0x80 | regenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
        emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    if (index->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
      assert(scale != Address::no_scale, "inconsistent address");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
      int indexenc = index->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
      if (indexenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
        indexenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
      // [index*scale + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
      // [00 reg 100][ss index 101] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
      assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
      emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
      emit_byte(scale << 6 | indexenc << 3 | 0x05);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    } else if (rtype != relocInfo::none ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      // [disp] RIP-RELATIVE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
      // [00 000 101] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
      emit_byte(0x05 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
      // Note that the RIP-rel. correction applies to the generated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      // disp field, but _not_ to the target address in the rspec.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
      // disp was created by converting the target address minus the pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
      // at the start of the instruction. That needs more correction here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      // intptr_t disp = target - next_ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      assert(inst_mark() != NULL, "must be inside InstructionMark");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      address next_ip = pc() + sizeof(int32_t) + rip_relative_correction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      int64_t adjusted = (int64_t) disp -  (next_ip - inst_mark());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      assert(is_simm32(adjusted),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
             "must be 32bit offset (RIP relative address)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
      emit_data((int) adjusted, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      // [disp] ABSOLUTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
      // [00 reg 100][00 100 101] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
      emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      emit_byte(0x25);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
      emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
void Assembler::emit_operand(XMMRegister reg, Register base, Register index,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
                             Address::ScaleFactor scale, int disp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
                             RelocationHolder const& rspec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
                             int rip_relative_correction) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  relocInfo::relocType rtype = (relocInfo::relocType) rspec.type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  int regenc = reg->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  if (regenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    regenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  if (base->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    if (index->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      assert(scale != Address::no_scale, "inconsistent address");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      int indexenc = index->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
      if (indexenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
        indexenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
      int baseenc = base->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
      if (baseenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
        baseenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
      // [base + index*scale + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
      if (disp == 0 && rtype == relocInfo::none  &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
          base != rbp && base != r13) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
        // [base + index*scale]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
        // [00 reg 100][ss index base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
        assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
        emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
        emit_byte(scale << 6 | indexenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
      } else if (is8bit(disp) && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
        // [base + index*scale + disp8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
        // [01 reg 100][ss index base] disp8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
        assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
        emit_byte(0x44 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
        emit_byte(scale << 6 | indexenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
        emit_byte(disp & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
        // [base + index*scale + disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
        // [10 reg 100][ss index base] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
        assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
        emit_byte(0x84 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
        emit_byte(scale << 6 | indexenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
        emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    } else if (base == rsp || base == r12) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
      // [rsp + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
      if (disp == 0 && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
        // [rsp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
        // [00 reg 100][00 100 100]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
        emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
        emit_byte(0x24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
      } else if (is8bit(disp) && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
        // [rsp + imm8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
        // [01 reg 100][00 100 100] disp8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
        emit_byte(0x44 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
        emit_byte(0x24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
        emit_byte(disp & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
        // [rsp + imm32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
        // [10 reg 100][00 100 100] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
        emit_byte(0x84 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
        emit_byte(0x24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
        emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
      // [base + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
      assert(base != rsp && base != r12, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
      int baseenc = base->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
      if (baseenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
        baseenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
      if (disp == 0 && rtype == relocInfo::none &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
          base != rbp && base != r13) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
        // [base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
        // [00 reg base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
        emit_byte(0x00 | regenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
      } else if (is8bit(disp) && rtype == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
        // [base + imm8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
        // [01 reg base] disp8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
        emit_byte(0x40 | regenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
        emit_byte(disp & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
        // [base + imm32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
        // [10 reg base] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
        emit_byte(0x80 | regenc << 3 | baseenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
        emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    if (index->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
      assert(scale != Address::no_scale, "inconsistent address");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
      int indexenc = index->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
      if (indexenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
        indexenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
      // [index*scale + disp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
      // [00 reg 100][ss index 101] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
      assert(index != rsp, "illegal addressing mode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
      emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
      emit_byte(scale << 6 | indexenc << 3 | 0x05);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
      emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    } else if ( rtype != relocInfo::none ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
      // [disp] RIP-RELATIVE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
      // [00 reg 101] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
      emit_byte(0x05 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
      // Note that the RIP-rel. correction applies to the generated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
      // disp field, but _not_ to the target address in the rspec.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
      // disp was created by converting the target address minus the pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
      // at the start of the instruction. That needs more correction here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
      // intptr_t disp = target - next_ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
      assert(inst_mark() != NULL, "must be inside InstructionMark");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
      address next_ip = pc() + sizeof(int32_t) + rip_relative_correction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
      int64_t adjusted = (int64_t) disp -  (next_ip - inst_mark());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
      assert(is_simm32(adjusted),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
             "must be 32bit offset (RIP relative address)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      emit_data((int) adjusted, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
      // [disp] ABSOLUTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
      // [00 reg 100][00 100 101] disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
      emit_byte(0x04 | regenc << 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
      emit_byte(0x25);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
      emit_data(disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
// Secret local extension to Assembler::WhichOperand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
#define end_pc_operand (_WhichOperand_limit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
address Assembler::locate_operand(address inst, WhichOperand which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  // Decode the given instruction, and return the address of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  // an embedded 32-bit operand word.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  // If "which" is disp32_operand, selects the displacement portion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  // of an effective address specifier.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  // If "which" is imm64_operand, selects the trailing immediate constant.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  // If "which" is call32_operand, selects the displacement of a call or jump.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  // Caller is responsible for ensuring that there is such an operand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  // and that it is 32/64 bits wide.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  // If "which" is end_pc_operand, find the end of the instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  address ip = inst;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  bool is_64bit = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  debug_only(bool has_disp32 = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  int tail_size = 0; // other random bytes (#32, #16, etc.) at end of insn
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  again_after_prefix:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  switch (0xFF & *ip++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  // These convenience macros generate groups of "case" labels for the switch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
#define REP4(x) (x)+0: case (x)+1: case (x)+2: case (x)+3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
#define REP8(x) (x)+0: case (x)+1: case (x)+2: case (x)+3: \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
             case (x)+4: case (x)+5: case (x)+6: case (x)+7
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
#define REP16(x) REP8((x)+0): \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
              case REP8((x)+8)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  case CS_segment:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  case SS_segment:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  case DS_segment:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  case ES_segment:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  case FS_segment:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  case GS_segment:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    assert(0, "shouldn't have that prefix");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    assert(ip == inst + 1 || ip == inst + 2, "only two prefixes allowed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    goto again_after_prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  case 0x67:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  case REX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  case REX_B:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  case REX_X:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  case REX_XB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  case REX_R:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  case REX_RB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  case REX_RX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  case REX_RXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
//     assert(ip == inst + 1, "only one prefix allowed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    goto again_after_prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  case REX_W:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  case REX_WB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  case REX_WX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  case REX_WXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  case REX_WR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  case REX_WRB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  case REX_WRX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  case REX_WRXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    is_64bit = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
//     assert(ip == inst + 1, "only one prefix allowed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
    goto again_after_prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  case 0xFF: // pushq a; decl a; incl a; call a; jmp a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  case 0x88: // movb a, r
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  case 0x89: // movl a, r
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  case 0x8A: // movb r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  case 0x8B: // movl r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  case 0x8F: // popl a
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
   640
    debug_only(has_disp32 = true;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  case 0x68: // pushq #32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    if (which == end_pc_operand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
      return ip + 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    assert(0, "pushq has no disp32 or imm64");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  case 0x66: // movw ... (size prefix)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    again_after_size_prefix2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
    switch (0xFF & *ip++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    case REX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
    case REX_B:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    case REX_X:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
    case REX_XB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    case REX_R:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
    case REX_RB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    case REX_RX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
    case REX_RXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    case REX_W:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    case REX_WB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    case REX_WX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    case REX_WXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    case REX_WR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    case REX_WRB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
    case REX_WRX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
    case REX_WRXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
      goto again_after_size_prefix2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
    case 0x8B: // movw r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
    case 0x89: // movw a, r
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
    case 0xC7: // movw a, #16
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
      tail_size = 2;  // the imm16
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    case 0x0F: // several SSE/SSE2 variants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
      ip--;    // reparse the 0x0F
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
      goto again_after_prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  case REP8(0xB8): // movl/q r, #32/#64(oop?)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
    if (which == end_pc_operand)  return ip + (is_64bit ? 8 : 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    assert((which == call32_operand || which == imm64_operand) && is_64bit, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    return ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  case 0x69: // imul r, a, #32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  case 0xC7: // movl a, #32(oop?)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
    tail_size = 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
    debug_only(has_disp32 = true); // has both kinds of operands!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  case 0x0F: // movx..., etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
    switch (0xFF & *ip++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
    case 0x12: // movlps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
    case 0x28: // movaps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
    case 0x2E: // ucomiss
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    case 0x2F: // comiss
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
    case 0x54: // andps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    case 0x57: // xorps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
    case 0x6E: // movd
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    case 0x7E: // movd
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    case 0xAE: // ldmxcsr   a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
      debug_only(has_disp32 = true); // has both kinds of operands!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    case 0xAD: // shrd r, a, %cl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    case 0xAF: // imul r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    case 0xBE: // movsbl r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
    case 0xBF: // movswl r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    case 0xB6: // movzbl r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
    case 0xB7: // movzwl r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
    case REP16(0x40): // cmovl cc, r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
    case 0xB0: // cmpxchgb
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
    case 0xB1: // cmpxchg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
    case 0xC1: // xaddl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
    case 0xC7: // cmpxchg8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
    case REP16(0x90): // setcc a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
      debug_only(has_disp32 = true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
      // fall out of the switch to decode the address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
    case 0xAC: // shrd r, a, #8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
      debug_only(has_disp32 = true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
      tail_size = 1;  // the imm8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    case REP16(0x80): // jcc rdisp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
      if (which == end_pc_operand)  return ip + 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
      assert(which == call32_operand, "jcc has no disp32 or imm64");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
      return ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  case 0x81: // addl a, #32; addl r, #32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
    // also: orl, adcl, sbbl, andl, subl, xorl, cmpl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
    tail_size = 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
    debug_only(has_disp32 = true); // has both kinds of operands!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  case 0x83: // addl a, #8; addl r, #8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
    // also: orl, adcl, sbbl, andl, subl, xorl, cmpl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
    debug_only(has_disp32 = true); // has both kinds of operands!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
    tail_size = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  case 0x9B:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
    switch (0xFF & *ip++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
    case 0xD9: // fnstcw a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
      debug_only(has_disp32 = true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  case REP4(0x00): // addb a, r; addl a, r; addb r, a; addl r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  case REP4(0x10): // adc...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  case REP4(0x20): // and...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
  case REP4(0x30): // xor...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  case REP4(0x08): // or...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
  case REP4(0x18): // sbb...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  case REP4(0x28): // sub...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  case 0xF7: // mull a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
  case 0x87: // xchg r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
    debug_only(has_disp32 = true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
  case REP4(0x38): // cmp...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  case 0x8D: // lea r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
  case 0x85: // test r, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    debug_only(has_disp32 = true); // has both kinds of operands!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  case 0xC1: // sal a, #8; sar a, #8; shl a, #8; shr a, #8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  case 0xC6: // movb a, #8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  case 0x80: // cmpb a, #8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  case 0x6B: // imul r, a, #8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    debug_only(has_disp32 = true); // has both kinds of operands!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
    tail_size = 1; // the imm8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  case 0xE8: // call rdisp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  case 0xE9: // jmp  rdisp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
    if (which == end_pc_operand)  return ip + 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
    assert(which == call32_operand, "call has no disp32 or imm32");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
    return ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
  case 0xD1: // sal a, 1; sar a, 1; shl a, 1; shr a, 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  case 0xD3: // sal a, %cl; sar a, %cl; shl a, %cl; shr a, %cl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
  case 0xD9: // fld_s a; fst_s a; fstp_s a; fldcw a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  case 0xDD: // fld_d a; fst_d a; fstp_d a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
  case 0xDB: // fild_s a; fistp_s a; fld_x a; fstp_x a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
  case 0xDF: // fild_d a; fistp_d a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
  case 0xD8: // fadd_s a; fsubr_s a; fmul_s a; fdivr_s a; fcomp_s a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  case 0xDC: // fadd_d a; fsubr_d a; fmul_d a; fdivr_d a; fcomp_d a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  case 0xDE: // faddp_d a; fsubrp_d a; fmulp_d a; fdivrp_d a; fcompp_d a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    debug_only(has_disp32 = true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
  case 0xF3:                    // For SSE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
  case 0xF2:                    // For SSE2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
    switch (0xFF & *ip++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    case REX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    case REX_B:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
    case REX_X:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
    case REX_XB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
    case REX_R:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
    case REX_RB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
    case REX_RX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
    case REX_RXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
    case REX_W:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
    case REX_WB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
    case REX_WX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
    case REX_WXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
    case REX_WR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
    case REX_WRB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
    case REX_WRX:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
    case REX_WRXB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
      ip++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
      ip++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
    debug_only(has_disp32 = true); // has both kinds of operands!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
#undef REP8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
#undef REP16
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  assert(which != call32_operand, "instruction is not a call, jmp, or jcc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  assert(which != imm64_operand, "instruction is not a movq reg, imm64");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  assert(which != disp32_operand || has_disp32, "instruction has no disp32 field");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  // parse the output of emit_operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
  int op2 = 0xFF & *ip++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
  int base = op2 & 0x07;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  int op3 = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  const int b100 = 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  const int b101 = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  if (base == b100 && (op2 >> 6) != 3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
    op3 = 0xFF & *ip++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
    base = op3 & 0x07;   // refetch the base
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  // now ip points at the disp (if any)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  switch (op2 >> 6) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  case 0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
    // [00 reg  100][ss index base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
    // [00 reg  100][00   100  esp]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
    // [00 reg base]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
    // [00 reg  100][ss index  101][disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
    // [00 reg  101]               [disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
    if (base == b101) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
      if (which == disp32_operand)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
        return ip;              // caller wants the disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
      ip += 4;                  // skip the disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
  case 1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
    // [01 reg  100][ss index base][disp8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
    // [01 reg  100][00   100  esp][disp8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
    // [01 reg base]               [disp8]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
    ip += 1;                    // skip the disp8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  case 2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
    // [10 reg  100][ss index base][disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
    // [10 reg  100][00   100  esp][disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    // [10 reg base]               [disp32]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
    if (which == disp32_operand)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
      return ip;                // caller wants the disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
    ip += 4;                    // skip the disp32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  case 3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    // [11 reg base]  (not a memory addressing mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
  if (which == end_pc_operand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
    return ip + tail_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  assert(0, "fix locate_operand");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  return ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
address Assembler::locate_next_instruction(address inst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  // Secretly share code with locate_operand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  return locate_operand(inst, end_pc_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
void Assembler::check_relocation(RelocationHolder const& rspec, int format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  address inst = inst_mark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  assert(inst != NULL && inst < pc(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
         "must point to beginning of instruction");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  address opnd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  Relocation* r = rspec.reloc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
  if (r->type() == relocInfo::none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  } else if (r->is_call() || format == call32_operand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    opnd = locate_operand(inst, call32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  } else if (r->is_data()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
    assert(format == imm64_operand || format == disp32_operand, "format ok");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
    opnd = locate_operand(inst, (WhichOperand) format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
    assert(format == 0, "cannot specify a format");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  assert(opnd == pc(), "must put operand where relocs can find it");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
int Assembler::prefix_and_encode(int reg_enc, bool byteinst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
  if (reg_enc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
    prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
    reg_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  } else if (byteinst && reg_enc >= 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
    prefix(REX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  return reg_enc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
int Assembler::prefixq_and_encode(int reg_enc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
  if (reg_enc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
    prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
    prefix(REX_WB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
    reg_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  return reg_enc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
int Assembler::prefix_and_encode(int dst_enc, int src_enc, bool byteinst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  if (dst_enc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
    if (src_enc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
      prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
      src_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
    } else if (byteinst && src_enc >= 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
      prefix(REX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    if (src_enc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
      prefix(REX_R);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
      prefix(REX_RB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
      src_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
    dst_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
  return dst_enc << 3 | src_enc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
int Assembler::prefixq_and_encode(int dst_enc, int src_enc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
  if (dst_enc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
    if (src_enc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
      prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
      prefix(REX_WB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
      src_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
    if (src_enc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
      prefix(REX_WR);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
      prefix(REX_WRB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
      src_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
    dst_enc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
  return dst_enc << 3 | src_enc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
void Assembler::prefix(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
  if (reg->encoding() >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
    prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
void Assembler::prefix(Address adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
  if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
    if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
      prefix(REX_XB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
      prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
    if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
      prefix(REX_X);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
void Assembler::prefixq(Address adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
  if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
    if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
      prefix(REX_WXB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
      prefix(REX_WB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
    if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
      prefix(REX_WX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
      prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
void Assembler::prefix(Address adr, Register reg, bool byteinst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
  if (reg->encoding() < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
    if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
        prefix(REX_XB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
        prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
        prefix(REX_X);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
      } else if (reg->encoding() >= 4 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
        prefix(REX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
    if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
        prefix(REX_RXB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
        prefix(REX_RB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
        prefix(REX_RX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
        prefix(REX_R);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
void Assembler::prefixq(Address adr, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
  if (src->encoding() < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
    if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
        prefix(REX_WXB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
        prefix(REX_WB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
        prefix(REX_WX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
        prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
    if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
        prefix(REX_WRXB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
        prefix(REX_WRB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
        prefix(REX_WRX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
        prefix(REX_WR);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
void Assembler::prefix(Address adr, XMMRegister reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
  if (reg->encoding() < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
    if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
        prefix(REX_XB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
        prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
        prefix(REX_X);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
    if (adr.base_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
        prefix(REX_RXB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
        prefix(REX_RB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
      if (adr.index_needs_rex()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
        prefix(REX_RX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
        prefix(REX_R);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
void Assembler::emit_operand(Register reg, Address adr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
                             int rip_relative_correction) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
  emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
               adr._rspec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
               rip_relative_correction);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
void Assembler::emit_operand(XMMRegister reg, Address adr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
                             int rip_relative_correction) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
               adr._rspec,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
               rip_relative_correction);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
void Assembler::emit_farith(int b1, int b2, int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
  assert(isByte(b1) && isByte(b2), "wrong opcode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
  assert(0 <= i &&  i < 8, "illegal stack offset");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
  emit_byte(b1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
  emit_byte(b2 + i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
// pushad is invalid, use this instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
// NOTE: Kills flags!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
void Assembler::pushaq() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
  // we have to store original rsp.  ABI says that 128 bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
  // below rsp are local scratch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  movq(Address(rsp, -5 * wordSize), rsp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
  subq(rsp, 16 * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
  movq(Address(rsp, 15 * wordSize), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
  movq(Address(rsp, 14 * wordSize), rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
  movq(Address(rsp, 13 * wordSize), rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
  movq(Address(rsp, 12 * wordSize), rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
  // skip rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
  movq(Address(rsp, 10 * wordSize), rbp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  movq(Address(rsp, 9 * wordSize), rsi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
  movq(Address(rsp, 8 * wordSize), rdi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
  movq(Address(rsp, 7 * wordSize), r8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
  movq(Address(rsp, 6 * wordSize), r9);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
  movq(Address(rsp, 5 * wordSize), r10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
  movq(Address(rsp, 4 * wordSize), r11);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
  movq(Address(rsp, 3 * wordSize), r12);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  movq(Address(rsp, 2 * wordSize), r13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
  movq(Address(rsp, wordSize), r14);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
  movq(Address(rsp, 0), r15);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
// popad is invalid, use this instead
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
// NOTE: Kills flags!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
void Assembler::popaq() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
  movq(r15, Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
  movq(r14, Address(rsp, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
  movq(r13, Address(rsp, 2 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
  movq(r12, Address(rsp, 3 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
  movq(r11, Address(rsp, 4 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
  movq(r10, Address(rsp, 5 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
  movq(r9,  Address(rsp, 6 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
  movq(r8,  Address(rsp, 7 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
  movq(rdi, Address(rsp, 8 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
  movq(rsi, Address(rsp, 9 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
  movq(rbp, Address(rsp, 10 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
  // skip rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
  movq(rbx, Address(rsp, 12 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
  movq(rdx, Address(rsp, 13 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
  movq(rcx, Address(rsp, 14 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
  movq(rax, Address(rsp, 15 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
  addq(rsp, 16 * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
void Assembler::pushfq() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
  emit_byte(0x9C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
void Assembler::popfq() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
  emit_byte(0x9D);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
void Assembler::pushq(int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
  emit_byte(0x68);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
void Assembler::pushq(Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
  int encode = prefix_and_encode(src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
  emit_byte(0x50 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
void Assembler::pushq(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
  prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
  emit_operand(rsi, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
void Assembler::popq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
  emit_byte(0x58 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
void Assembler::popq(Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
  emit_byte(0x8F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
  emit_operand(rax, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
void Assembler::prefix(Prefix p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
  a_byte(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
void Assembler::movb(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
  prefix(src, dst, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
  emit_byte(0x8A);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
void Assembler::movb(Address dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
  emit_byte(0xC6);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
  emit_operand(rax, dst, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
  emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
void Assembler::movb(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
  prefix(dst, src, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
  emit_byte(0x88);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
void Assembler::movw(Address dst, int imm16) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
  emit_byte(0x66); // switch to 16-bit mode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
  emit_byte(0xC7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  emit_operand(rax, dst, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  emit_word(imm16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
void Assembler::movw(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
  emit_byte(0x8B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
void Assembler::movw(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
  emit_byte(0x89);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
// Uses zero extension.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
void Assembler::movl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  emit_byte(0xB8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
void Assembler::movl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
  emit_byte(0x8B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
void Assembler::movl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
  emit_byte(0x8B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
void Assembler::movl(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
  emit_byte(0xC7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
  emit_operand(rax, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
void Assembler::movl(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
  emit_byte(0x89);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
223
5c3b023117d9 6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents: 1
diff changeset
  1308
void Assembler::mov64(Register dst, intptr_t imm64) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
  emit_byte(0xB8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
  emit_long64(imm64);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
void Assembler::mov_literal64(Register dst, intptr_t imm64, RelocationHolder const& rspec) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
  emit_byte(0xB8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
  emit_data64(imm64, rspec);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
void Assembler::movq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
  emit_byte(0x8B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
void Assembler::movq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
  emit_byte(0x8B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
223
5c3b023117d9 6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents: 1
diff changeset
  1335
void Assembler::mov64(Address dst, intptr_t imm32) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
  assert(is_simm32(imm32), "lost bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
  emit_byte(0xC7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
  emit_operand(rax, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
void Assembler::movq(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
  prefixq(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
  emit_byte(0x89);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
void Assembler::movsbl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
  emit_byte(0xBE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
void Assembler::movsbl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
  int encode = prefix_and_encode(dst->encoding(), src->encoding(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
  emit_byte(0xBE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
void Assembler::movswl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
  emit_byte(0xBF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
void Assembler::movswl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
  emit_byte(0xBF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
void Assembler::movslq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
  emit_byte(0x63);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
void Assembler::movslq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
  emit_byte(0x63);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
void Assembler::movzbl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
  emit_byte(0xB6);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
void Assembler::movzbl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
  int encode = prefix_and_encode(dst->encoding(), src->encoding(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
  emit_byte(0xB6);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
void Assembler::movzwl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
  emit_byte(0xB7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
void Assembler::movzwl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  emit_byte(0xB7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
void Assembler::movss(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
  emit_byte(0x10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
void Assembler::movss(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
  emit_byte(0x10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
void Assembler::movss(Address dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
  emit_byte(0x11);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
void Assembler::movsd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
  emit_byte(0x10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
void Assembler::movsd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
  emit_byte(0x10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
void Assembler::movsd(Address dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
  emit_byte(0x11);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
// New cpus require to use movsd and movss to avoid partial register stall
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
// when loading from memory. But for old Opteron use movlpd instead of movsd.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
// The selection is done in MacroAssembler::movdbl() and movflt().
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
void Assembler::movlpd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
  emit_byte(0x12);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
void Assembler::movapd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  int dstenc = dst->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
  int srcenc = src->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
  if (dstenc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
    if (srcenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
      prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
      srcenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
    if (srcenc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
      prefix(REX_R);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
      prefix(REX_RB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
      srcenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
    dstenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
  emit_byte(0x28);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
  emit_byte(0xC0 | dstenc << 3 | srcenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
void Assembler::movaps(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
  int dstenc = dst->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
  int srcenc = src->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
  if (dstenc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
    if (srcenc >= 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
      prefix(REX_B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
      srcenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
    if (srcenc < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
      prefix(REX_R);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
      prefix(REX_RB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
      srcenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
    dstenc -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
  emit_byte(0x28);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
  emit_byte(0xC0 | dstenc << 3 | srcenc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
void Assembler::movdl(XMMRegister dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
  emit_byte(0x6E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
void Assembler::movdl(Register dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
  // swap src/dst to get correct prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
  int encode = prefix_and_encode(src->encoding(), dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
  emit_byte(0x7E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
void Assembler::movdq(XMMRegister dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
  emit_byte(0x6E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
void Assembler::movdq(Register dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
  // swap src/dst to get correct prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
  int encode = prefixq_and_encode(src->encoding(), dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
  emit_byte(0x7E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
void Assembler::pxor(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
  emit_byte(0xEF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
void Assembler::pxor(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
  emit_byte(0xEF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
void Assembler::movdqa(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
  emit_byte(0x6F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
void Assembler::movdqa(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
  emit_byte(0x6F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
void Assembler::movdqa(Address dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
  emit_byte(0x7F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
void Assembler::movq(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
  emit_byte(0x7E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
void Assembler::movq(Address dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
  emit_byte(0xD6);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
void Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
  assert(isByte(mode), "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
  emit_byte(0x70);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
  emit_byte(mode & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
void Assembler::pshufd(XMMRegister dst, Address src, int mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
  assert(isByte(mode), "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
  emit_byte(0x70);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
  emit_byte(mode & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
void Assembler::pshuflw(XMMRegister dst, XMMRegister src, int mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
  assert(isByte(mode), "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
  emit_byte(0x70);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
  emit_byte(mode & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
void Assembler::pshuflw(XMMRegister dst, Address src, int mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
  assert(isByte(mode), "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
  emit_byte(0x70);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
  emit_byte(mode & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
void Assembler::cmovl(Condition cc, Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
  emit_byte(0x40 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
void Assembler::cmovl(Condition cc, Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
  emit_byte(0x40 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
void Assembler::cmovq(Condition cc, Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
  emit_byte(0x40 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
void Assembler::cmovq(Condition cc, Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
  emit_byte(0x40 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
void Assembler::prefetch_prefix(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
  prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
void Assembler::prefetcht0(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
  prefetch_prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
  emit_byte(0x18);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
  emit_operand(rcx, src); // 1, src
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
void Assembler::prefetcht1(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
  prefetch_prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
  emit_byte(0x18);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
  emit_operand(rdx, src); // 2, src
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
void Assembler::prefetcht2(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
  prefetch_prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
  emit_byte(0x18);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
  emit_operand(rbx, src); // 3, src
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
void Assembler::prefetchnta(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
  prefetch_prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
  emit_byte(0x18);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
  emit_operand(rax, src); // 0, src
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
void Assembler::prefetchw(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
  prefetch_prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
  emit_byte(0x0D);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
  emit_operand(rcx, src); // 1, src
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
void Assembler::adcl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
  emit_arith(0x81, 0xD0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
void Assembler::adcl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
  emit_byte(0x13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
void Assembler::adcl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
  emit_arith(0x13, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
void Assembler::adcq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
  emit_arith(0x81, 0xD0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
void Assembler::adcq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
  emit_byte(0x13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
void Assembler::adcq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
  (int) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
  emit_arith(0x13, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
void Assembler::addl(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
  emit_arith_operand(0x81, rax, dst,imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
void Assembler::addl(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
  emit_byte(0x01);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
void Assembler::addl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
  emit_arith(0x81, 0xC0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
void Assembler::addl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
  emit_byte(0x03);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
void Assembler::addl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
  emit_arith(0x03, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
void Assembler::addq(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
  emit_arith_operand(0x81, rax, dst,imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
void Assembler::addq(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
  prefixq(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
  emit_byte(0x01);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
void Assembler::addq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
  emit_arith(0x81, 0xC0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
void Assembler::addq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1823
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1824
  emit_byte(0x03);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
void Assembler::addq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
  (void) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
  emit_arith(0x03, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
void Assembler::andl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
  emit_arith(0x81, 0xE0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
void Assembler::andl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1839
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
  emit_byte(0x23);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
void Assembler::andl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1846
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
  emit_arith(0x23, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1849
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
void Assembler::andq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1852
  emit_arith(0x81, 0xE0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
void Assembler::andq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
  emit_byte(0x23);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
void Assembler::andq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
  (int) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
  emit_arith(0x23, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
void Assembler::cmpb(Address dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1868
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1870
  emit_byte(0x80);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
  emit_operand(rdi, dst, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
  emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
void Assembler::cmpl(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
  emit_byte(0x81);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
  emit_operand(rdi, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1882
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
void Assembler::cmpl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
  emit_arith(0x81, 0xF8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
void Assembler::cmpl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
  emit_arith(0x3B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
void Assembler::cmpl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1894
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
  emit_byte(0x3B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
void Assembler::cmpq(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
  emit_byte(0x81);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
  emit_operand(rdi, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
void Assembler::cmpq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
  emit_arith(0x81, 0xF8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
void Assembler::cmpq(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
  prefixq(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
  emit_byte(0x3B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
void Assembler::cmpq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
  (void) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
  emit_arith(0x3B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
void Assembler::cmpq(Register dst, Address  src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
  emit_byte(0x3B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1928
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
void Assembler::ucomiss(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
  emit_byte(0x2E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
void Assembler::ucomisd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
  ucomiss(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
void Assembler::decl(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
  // Don't use it directly. Use MacroAssembler::decrementl() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
  // Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
  emit_byte(0xC8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
void Assembler::decl(Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
  // Don't use it directly. Use MacroAssembler::decrementl() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
  emit_operand(rcx, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
void Assembler::decq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
  // Don't use it directly. Use MacroAssembler::decrementq() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  // Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
  emit_byte(0xC8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
void Assembler::decq(Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
  // Don't use it directly. Use MacroAssembler::decrementq() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1969
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
  emit_operand(rcx, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
void Assembler::idivl(Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
  int encode = prefix_and_encode(src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
  emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
void Assembler::idivq(Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
  int encode = prefixq_and_encode(src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
  emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
void Assembler::cdql() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
  emit_byte(0x99);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
void Assembler::cdqq() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
  prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
  emit_byte(0x99);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
void Assembler::imull(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
  emit_byte(0xAF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
void Assembler::imull(Register dst, Register src, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
  if (is8bit(value)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
    emit_byte(0x6B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
    emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
    emit_byte(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
    emit_byte(0x69);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
    emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
    emit_long(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
void Assembler::imulq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
  emit_byte(0xAF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
void Assembler::imulq(Register dst, Register src, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
  if (is8bit(value)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
    emit_byte(0x6B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
    emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
    emit_byte(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
    emit_byte(0x69);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
    emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
    emit_long(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
void Assembler::incl(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
  // Don't use it directly. Use MacroAssembler::incrementl() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
  // Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
void Assembler::incl(Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  // Don't use it directly. Use MacroAssembler::incrementl() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
  emit_operand(rax, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
void Assembler::incq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
  // Don't use it directly. Use MacroAssembler::incrementq() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
  // Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
void Assembler::incq(Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
  // Don't use it directly. Use MacroAssembler::incrementq() instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
  emit_operand(rax, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
void Assembler::leal(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
  emit_byte(0x67); // addr32
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
  emit_byte(0x8D);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
void Assembler::leaq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
  emit_byte(0x8D);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
void Assembler::mull(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
  // was missing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
  prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
  emit_operand(rsp, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
void Assembler::mull(Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
  // was missing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
  int encode = prefix_and_encode(src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
  emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
void Assembler::negl(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
  emit_byte(0xD8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
void Assembler::negq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
  emit_byte(0xD8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
void Assembler::notl(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
  emit_byte(0xD0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
void Assembler::notq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
  emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
  emit_byte(0xD0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
void Assembler::orl(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
  emit_byte(0x81);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
  emit_operand(rcx, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
void Assembler::orl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
  emit_arith(0x81, 0xC8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
void Assembler::orl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
  emit_byte(0x0B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
void Assembler::orl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
  emit_arith(0x0B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
void Assembler::orq(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
  emit_byte(0x81);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
  emit_operand(rcx, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2155
void Assembler::orq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
  emit_arith(0x81, 0xC8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
void Assembler::orq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2161
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
  emit_byte(0x0B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
void Assembler::orq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
  (void) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
  emit_arith(0x0B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
void Assembler::rcll(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
  assert(isShiftCount(imm8), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
  if (imm8 == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
    emit_byte(0xD1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
    emit_byte(0xD0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
    emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
    emit_byte(0xD0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
    emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
void Assembler::rclq(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
  assert(isShiftCount(imm8 >> 1), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
  if (imm8 == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
    emit_byte(0xD1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
    emit_byte(0xD0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
    emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
    emit_byte(0xD0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
    emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
void Assembler::sarl(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
  assert(isShiftCount(imm8), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
  if (imm8 == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
    emit_byte(0xD1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
    emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
    emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
    emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
    emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
void Assembler::sarl(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
  emit_byte(0xD3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
  emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
void Assembler::sarq(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
  assert(isShiftCount(imm8 >> 1), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
  if (imm8 == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
    emit_byte(0xD1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
    emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
    emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
    emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
    emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
void Assembler::sarq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
  emit_byte(0xD3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
  emit_byte(0xF8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
void Assembler::sbbl(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
  emit_arith_operand(0x81, rbx, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
void Assembler::sbbl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
  emit_arith(0x81, 0xD8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
void Assembler::sbbl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
  emit_byte(0x1B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
void Assembler::sbbl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
  emit_arith(0x1B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
void Assembler::sbbq(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
  emit_arith_operand(0x81, rbx, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
void Assembler::sbbq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
  emit_arith(0x81, 0xD8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
void Assembler::sbbq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
  emit_byte(0x1B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
void Assembler::sbbq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
  (void) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
  emit_arith(0x1B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
void Assembler::shll(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
  assert(isShiftCount(imm8), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
  if (imm8 == 1 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
    emit_byte(0xD1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
    emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
    emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2290
    emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
    emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2292
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2293
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2295
void Assembler::shll(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2296
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2297
  emit_byte(0xD3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2298
  emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2299
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2300
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2301
void Assembler::shlq(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2302
  assert(isShiftCount(imm8 >> 1), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2303
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2304
  if (imm8 == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2305
    emit_byte(0xD1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2306
    emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2307
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2308
    emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2309
    emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
    emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2311
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2312
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2313
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
void Assembler::shlq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2315
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2316
  emit_byte(0xD3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2317
  emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2319
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2320
void Assembler::shrl(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2321
  assert(isShiftCount(imm8), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2322
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2323
  emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2324
  emit_byte(0xE8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2325
  emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2326
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2327
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2328
void Assembler::shrl(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2329
  int encode = prefix_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2330
  emit_byte(0xD3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2331
  emit_byte(0xE8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2332
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2333
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2334
void Assembler::shrq(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2335
  assert(isShiftCount(imm8 >> 1), "illegal shift count");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2336
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2337
  emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2338
  emit_byte(0xE8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2339
  emit_byte(imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2340
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2341
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2342
void Assembler::shrq(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2343
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2344
  emit_byte(0xD3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2345
  emit_byte(0xE8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2346
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2347
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2348
void Assembler::subl(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2349
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2350
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2351
  if (is8bit(imm32)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2352
    emit_byte(0x83);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2353
    emit_operand(rbp, dst, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2354
    emit_byte(imm32 & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2355
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2356
    emit_byte(0x81);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2357
    emit_operand(rbp, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2358
    emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2359
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2360
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2361
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2362
void Assembler::subl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2363
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2364
  emit_arith(0x81, 0xE8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2365
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2366
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2367
void Assembler::subl(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2368
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2369
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2370
  emit_byte(0x29);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
void Assembler::subl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
  emit_byte(0x2B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2380
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2381
void Assembler::subl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2382
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2383
  emit_arith(0x2B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2385
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2386
void Assembler::subq(Address dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2387
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2388
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2389
  if (is8bit(imm32)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2390
    emit_byte(0x83);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2391
    emit_operand(rbp, dst, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2392
    emit_byte(imm32 & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2393
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2394
    emit_byte(0x81);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2395
    emit_operand(rbp, dst, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2396
    emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2397
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2398
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2399
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2400
void Assembler::subq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2401
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2402
  emit_arith(0x81, 0xE8, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2403
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2405
void Assembler::subq(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2406
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2407
  prefixq(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2408
  emit_byte(0x29);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2409
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2410
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2411
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2412
void Assembler::subq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2413
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2414
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2415
  emit_byte(0x2B);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2416
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2417
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2418
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2419
void Assembler::subq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2420
  (void) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2421
  emit_arith(0x2B, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2423
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2424
void Assembler::testb(Register dst, int imm8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2425
  (void) prefix_and_encode(dst->encoding(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2426
  emit_arith_b(0xF6, 0xC0, dst, imm8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2427
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2428
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2429
void Assembler::testl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2430
  // not using emit_arith because test
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2431
  // doesn't support sign-extension of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2432
  // 8bit operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2433
  int encode = dst->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2434
  if (encode == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2435
    emit_byte(0xA9);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2436
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2437
    encode = prefix_and_encode(encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2438
    emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2439
    emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2440
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2441
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2442
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2443
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2444
void Assembler::testl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2445
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2446
  emit_arith(0x85, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2447
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2448
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2449
void Assembler::testq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2450
  // not using emit_arith because test
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2451
  // doesn't support sign-extension of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2452
  // 8bit operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2453
  int encode = dst->encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2454
  if (encode == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2455
    prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2456
    emit_byte(0xA9);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2457
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2458
    encode = prefixq_and_encode(encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2459
    emit_byte(0xF7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2460
    emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2461
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2462
  emit_long(imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2463
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2464
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2465
void Assembler::testq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2466
  (void) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2467
  emit_arith(0x85, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2468
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2469
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2470
void Assembler::xaddl(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2471
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2472
  prefix(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2473
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2474
  emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2475
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2476
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2477
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2478
void Assembler::xaddq(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2479
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2480
  prefixq(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2481
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2482
  emit_byte(0xC1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2483
  emit_operand(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2484
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2485
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2486
void Assembler::xorl(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2487
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2488
  emit_arith(0x81, 0xF0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2489
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2490
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2491
void Assembler::xorl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2492
  (void) prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2493
  emit_arith(0x33, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2494
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2495
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2496
void Assembler::xorl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2497
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2498
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2499
  emit_byte(0x33);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2500
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2501
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2502
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2503
void Assembler::xorq(Register dst, int imm32) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2504
  (void) prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2505
  emit_arith(0x81, 0xF0, dst, imm32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2506
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2507
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2508
void Assembler::xorq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2509
  (void) prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2510
  emit_arith(0x33, 0xC0, dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2511
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2512
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2513
void Assembler::xorq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2514
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2515
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2516
  emit_byte(0x33);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2517
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2518
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2519
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2520
void Assembler::bswapl(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2521
  int encode = prefix_and_encode(reg->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2522
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2523
  emit_byte(0xC8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2524
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2525
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2526
void Assembler::bswapq(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2527
  int encode = prefixq_and_encode(reg->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2528
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2529
  emit_byte(0xC8 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2530
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2531
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2532
void Assembler::lock() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2533
  emit_byte(0xF0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2534
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2535
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2536
void Assembler::xchgl(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2537
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2538
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2539
  emit_byte(0x87);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2540
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2541
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2542
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2543
void Assembler::xchgl(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2544
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2545
  emit_byte(0x87);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2546
  emit_byte(0xc0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2547
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2548
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2549
void Assembler::xchgq(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2550
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2551
  prefixq(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2552
  emit_byte(0x87);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2553
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2554
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2555
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2556
void Assembler::xchgq(Register dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2557
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2558
  emit_byte(0x87);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2559
  emit_byte(0xc0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2560
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2561
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2562
void Assembler::cmpxchgl(Register reg, Address adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2563
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2564
  prefix(adr, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2565
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2566
  emit_byte(0xB1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2567
  emit_operand(reg, adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2568
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2569
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2570
void Assembler::cmpxchgq(Register reg, Address adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2571
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2572
  prefixq(adr, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2573
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2574
  emit_byte(0xB1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2575
  emit_operand(reg, adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2576
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2577
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2578
void Assembler::hlt() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2579
  emit_byte(0xF4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2580
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2581
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2582
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2583
void Assembler::addr_nop_4() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2584
  // 4 bytes: NOP DWORD PTR [EAX+0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2585
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2586
  emit_byte(0x1F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2587
  emit_byte(0x40); // emit_rm(cbuf, 0x1, EAX_enc, EAX_enc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2588
  emit_byte(0);    // 8-bits offset (1 byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2589
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2590
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2591
void Assembler::addr_nop_5() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2592
  // 5 bytes: NOP DWORD PTR [EAX+EAX*0+0] 8-bits offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2593
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2594
  emit_byte(0x1F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2595
  emit_byte(0x44); // emit_rm(cbuf, 0x1, EAX_enc, 0x4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2596
  emit_byte(0x00); // emit_rm(cbuf, 0x0, EAX_enc, EAX_enc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2597
  emit_byte(0);    // 8-bits offset (1 byte)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2598
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2599
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2600
void Assembler::addr_nop_7() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2601
  // 7 bytes: NOP DWORD PTR [EAX+0] 32-bits offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2602
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2603
  emit_byte(0x1F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2604
  emit_byte(0x80); // emit_rm(cbuf, 0x2, EAX_enc, EAX_enc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2605
  emit_long(0);    // 32-bits offset (4 bytes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2606
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2607
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2608
void Assembler::addr_nop_8() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2609
  // 8 bytes: NOP DWORD PTR [EAX+EAX*0+0] 32-bits offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2610
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2611
  emit_byte(0x1F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2612
  emit_byte(0x84); // emit_rm(cbuf, 0x2, EAX_enc, 0x4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2613
  emit_byte(0x00); // emit_rm(cbuf, 0x0, EAX_enc, EAX_enc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2614
  emit_long(0);    // 32-bits offset (4 bytes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2615
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2616
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2617
void Assembler::nop(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2618
  assert(i > 0, " ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2619
  if (UseAddressNop && VM_Version::is_intel()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2620
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2621
    // Using multi-bytes nops "0x0F 0x1F [address]" for Intel
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2622
    //  1: 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2623
    //  2: 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2624
    //  3: 0x66 0x66 0x90 (don't use "0x0F 0x1F 0x00" - need patching safe padding)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2625
    //  4: 0x0F 0x1F 0x40 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2626
    //  5: 0x0F 0x1F 0x44 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2627
    //  6: 0x66 0x0F 0x1F 0x44 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2628
    //  7: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2629
    //  8: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2630
    //  9: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2631
    // 10: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2632
    // 11: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2633
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2634
    // The rest coding is Intel specific - don't use consecutive address nops
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2635
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2636
    // 12: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2637
    // 13: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2638
    // 14: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2639
    // 15: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2640
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2641
    while(i >= 15) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2642
      // For Intel don't generate consecutive addess nops (mix with regular nops)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2643
      i -= 15;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2644
      emit_byte(0x66);   // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2645
      emit_byte(0x66);   // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2646
      emit_byte(0x66);   // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2647
      addr_nop_8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2648
      emit_byte(0x66);   // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2649
      emit_byte(0x66);   // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2650
      emit_byte(0x66);   // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2651
      emit_byte(0x90);   // nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2652
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2653
    switch (i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2654
      case 14:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2655
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2656
      case 13:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2657
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2658
      case 12:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2659
        addr_nop_8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2660
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2661
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2662
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2663
        emit_byte(0x90); // nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2664
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2665
      case 11:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2666
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2667
      case 10:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2668
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2669
      case 9:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2670
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2671
      case 8:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2672
        addr_nop_8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2673
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2674
      case 7:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2675
        addr_nop_7();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2676
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2677
      case 6:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2678
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2679
      case 5:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2680
        addr_nop_5();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2681
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2682
      case 4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2683
        addr_nop_4();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2684
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2685
      case 3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2686
        // Don't use "0x0F 0x1F 0x00" - need patching safe padding
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2687
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2688
      case 2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2689
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2690
      case 1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2691
        emit_byte(0x90); // nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2692
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2693
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2694
        assert(i == 0, " ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2695
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2696
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2697
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2698
  if (UseAddressNop && VM_Version::is_amd()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2699
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2700
    // Using multi-bytes nops "0x0F 0x1F [address]" for AMD.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2701
    //  1: 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2702
    //  2: 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2703
    //  3: 0x66 0x66 0x90 (don't use "0x0F 0x1F 0x00" - need patching safe padding)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2704
    //  4: 0x0F 0x1F 0x40 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2705
    //  5: 0x0F 0x1F 0x44 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2706
    //  6: 0x66 0x0F 0x1F 0x44 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2707
    //  7: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2708
    //  8: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2709
    //  9: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2710
    // 10: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2711
    // 11: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2712
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2713
    // The rest coding is AMD specific - use consecutive address nops
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2714
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2715
    // 12: 0x66 0x0F 0x1F 0x44 0x00 0x00 0x66 0x0F 0x1F 0x44 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2716
    // 13: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00 0x66 0x0F 0x1F 0x44 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2717
    // 14: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2718
    // 15: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2719
    // 16: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2720
    //     Size prefixes (0x66) are added for larger sizes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2721
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2722
    while(i >= 22) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2723
      i -= 11;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2724
      emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2725
      emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2726
      emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2727
      addr_nop_8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2728
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2729
    // Generate first nop for size between 21-12
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2730
    switch (i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2731
      case 21:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2732
        i -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2733
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2734
      case 20:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2735
      case 19:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2736
        i -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2737
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2738
      case 18:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2739
      case 17:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2740
        i -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2741
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2742
      case 16:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2743
      case 15:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2744
        i -= 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2745
        addr_nop_8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2746
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2747
      case 14:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2748
      case 13:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2749
        i -= 7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2750
        addr_nop_7();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2751
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2752
      case 12:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2753
        i -= 6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2754
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2755
        addr_nop_5();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2756
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2757
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2758
        assert(i < 12, " ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2759
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2760
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2761
    // Generate second nop for size between 11-1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2762
    switch (i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2763
      case 11:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2764
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2765
      case 10:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2766
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2767
      case 9:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2768
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2769
      case 8:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2770
        addr_nop_8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2771
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2772
      case 7:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2773
        addr_nop_7();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2774
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2775
      case 6:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2776
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2777
      case 5:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2778
        addr_nop_5();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2779
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2780
      case 4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2781
        addr_nop_4();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2782
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2783
      case 3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2784
        // Don't use "0x0F 0x1F 0x00" - need patching safe padding
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2785
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2786
      case 2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2787
        emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2788
      case 1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2789
        emit_byte(0x90); // nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2790
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2791
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2792
        assert(i == 0, " ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2793
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2794
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2795
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2796
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2797
  // Using nops with size prefixes "0x66 0x90".
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2798
  // From AMD Optimization Guide:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2799
  //  1: 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2800
  //  2: 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2801
  //  3: 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2802
  //  4: 0x66 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2803
  //  5: 0x66 0x66 0x90 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2804
  //  6: 0x66 0x66 0x90 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2805
  //  7: 0x66 0x66 0x66 0x90 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2806
  //  8: 0x66 0x66 0x66 0x90 0x66 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2807
  //  9: 0x66 0x66 0x90 0x66 0x66 0x90 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2808
  // 10: 0x66 0x66 0x66 0x90 0x66 0x66 0x90 0x66 0x66 0x90
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2809
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2810
  while(i > 12) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2811
    i -= 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2812
    emit_byte(0x66); // size prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2813
    emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2814
    emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2815
    emit_byte(0x90); // nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2816
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2817
  // 1 - 12 nops
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2818
  if(i > 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2819
    if(i > 9) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2820
      i -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2821
      emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2822
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2823
    i -= 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2824
    emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2825
    emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2826
    emit_byte(0x90);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2827
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2828
  // 1 - 8 nops
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2829
  if(i > 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2830
    if(i > 6) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2831
      i -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2832
      emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2833
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2834
    i -= 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2835
    emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2836
    emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2837
    emit_byte(0x90);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2838
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2839
  switch (i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2840
    case 4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2841
      emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2842
    case 3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2843
      emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2844
    case 2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2845
      emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2846
    case 1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2847
      emit_byte(0x90);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2848
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2849
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2850
      assert(i == 0, " ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2851
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2852
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2853
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2854
void Assembler::ret(int imm16) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2855
  if (imm16 == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2856
    emit_byte(0xC3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2857
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2858
    emit_byte(0xC2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2859
    emit_word(imm16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2860
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2861
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2862
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2863
// copies a single word from [esi] to [edi]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2864
void Assembler::smovl() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2865
  emit_byte(0xA5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2866
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2867
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2868
// copies data from [rsi] to [rdi] using rcx words (m32)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2869
void Assembler::rep_movl() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2870
  // REP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2871
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2872
  // MOVSL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2873
  emit_byte(0xA5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2874
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2875
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2876
// copies data from [rsi] to [rdi] using rcx double words (m64)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2877
void Assembler::rep_movq() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2878
  // REP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2879
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2880
  // MOVSQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2881
  prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2882
  emit_byte(0xA5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2883
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2884
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2885
// sets rcx double words (m64) with rax value at [rdi]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2886
void Assembler::rep_set() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2887
  // REP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2888
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2889
  // STOSQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2890
  prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2891
  emit_byte(0xAB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2892
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2893
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2894
// scans rcx double words (m64) at [rdi] for occurance of rax
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2895
void Assembler::repne_scanq() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2896
  // REPNE/REPNZ
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2897
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2898
  // SCASQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2899
  prefix(REX_W);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2900
  emit_byte(0xAF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2901
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2902
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2903
void Assembler::repne_scanl() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2904
  // REPNE/REPNZ
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2905
  emit_byte(0xF2);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2906
  // SCASL
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2907
  emit_byte(0xAF);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2908
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2909
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  2910
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2911
void Assembler::setb(Condition cc, Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2912
  assert(0 <= cc && cc < 16, "illegal cc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2913
  int encode = prefix_and_encode(dst->encoding(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2914
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2915
  emit_byte(0x90 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2916
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2917
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2918
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2919
void Assembler::clflush(Address adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2920
  prefix(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2921
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2922
  emit_byte(0xAE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2923
  emit_operand(rdi, adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2924
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2925
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2926
void Assembler::call(Label& L, relocInfo::relocType rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2927
  if (L.is_bound()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2928
    const int long_size = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2929
    int offs = (int)( target(L) - pc() );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2930
    assert(offs <= 0, "assembler error");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2931
    InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2932
    // 1110 1000 #32-bit disp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2933
    emit_byte(0xE8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2934
    emit_data(offs - long_size, rtype, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2935
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2936
    InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2937
    // 1110 1000 #32-bit disp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2938
    L.add_patch_at(code(), locator());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2939
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2940
    emit_byte(0xE8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2941
    emit_data(int(0), rtype, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2942
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2943
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2944
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2945
void Assembler::call_literal(address entry, RelocationHolder const& rspec) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2946
  assert(entry != NULL, "call most probably wrong");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2947
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2948
  emit_byte(0xE8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2949
  intptr_t disp = entry - (_code_pos + sizeof(int32_t));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2950
  assert(is_simm32(disp), "must be 32bit offset (call2)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2951
  // Technically, should use call32_operand, but this format is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2952
  // implied by the fact that we're emitting a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2953
  emit_data((int) disp, rspec, disp32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2954
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2955
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2956
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2957
void Assembler::call(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2958
  // This was originally using a 32bit register encoding
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2959
  // and surely we want 64bit!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2960
  // this is a 32bit encoding but in 64bit mode the default
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2961
  // operand size is 64bit so there is no need for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2962
  // wide prefix. So prefix only happens if we use the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2963
  // new registers. Much like push/pop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2964
  int encode = prefixq_and_encode(dst->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2965
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2966
  emit_byte(0xD0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2967
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2968
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2969
void Assembler::call(Address adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2970
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2971
  prefix(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2972
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2973
  emit_operand(rdx, adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2974
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2975
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2976
void Assembler::jmp(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2977
  int encode = prefix_and_encode(reg->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2978
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2979
  emit_byte(0xE0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2980
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2981
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2982
void Assembler::jmp(Address adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2983
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2984
  prefix(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2985
  emit_byte(0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2986
  emit_operand(rsp, adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2987
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2988
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2989
void Assembler::jmp_literal(address dest, RelocationHolder const& rspec) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2990
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2991
  emit_byte(0xE9);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2992
  assert(dest != NULL, "must have a target");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2993
  intptr_t disp = dest - (_code_pos + sizeof(int32_t));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2994
  assert(is_simm32(disp), "must be 32bit offset (jmp)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2995
  emit_data(disp, rspec.reloc(), call32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2996
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2997
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2998
void Assembler::jmp(Label& L, relocInfo::relocType rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2999
  if (L.is_bound()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3000
    address entry = target(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3001
    assert(entry != NULL, "jmp most probably wrong");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3002
    InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3003
    const int short_size = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3004
    const int long_size = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3005
    intptr_t offs = entry - _code_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3006
    if (rtype == relocInfo::none && is8bit(offs - short_size)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3007
      emit_byte(0xEB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3008
      emit_byte((offs - short_size) & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3009
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3010
      emit_byte(0xE9);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3011
      emit_long(offs - long_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3012
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3013
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3014
    // By default, forward jumps are always 32-bit displacements, since
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3015
    // we can't yet know where the label will be bound.  If you're sure that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3016
    // the forward jump will not run beyond 256 bytes, use jmpb to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3017
    // force an 8-bit displacement.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3018
    InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3019
    relocate(rtype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3020
    L.add_patch_at(code(), locator());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3021
    emit_byte(0xE9);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3022
    emit_long(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3023
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3024
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3025
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3026
void Assembler::jmpb(Label& L) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3027
  if (L.is_bound()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3028
    const int short_size = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3029
    address entry = target(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3030
    assert(is8bit((entry - _code_pos) + short_size),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3031
           "Dispacement too large for a short jmp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3032
    assert(entry != NULL, "jmp most probably wrong");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3033
    intptr_t offs = entry - _code_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3034
    emit_byte(0xEB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3035
    emit_byte((offs - short_size) & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3036
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3037
    InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3038
    L.add_patch_at(code(), locator());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3039
    emit_byte(0xEB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3040
    emit_byte(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3041
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3042
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3043
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3044
void Assembler::jcc(Condition cc, Label& L, relocInfo::relocType rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3045
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3046
  relocate(rtype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3047
  assert((0 <= cc) && (cc < 16), "illegal cc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3048
  if (L.is_bound()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3049
    address dst = target(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3050
    assert(dst != NULL, "jcc most probably wrong");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3051
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3052
    const int short_size = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3053
    const int long_size = 6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3054
    intptr_t offs = (intptr_t)dst - (intptr_t)_code_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3055
    if (rtype == relocInfo::none && is8bit(offs - short_size)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3056
      // 0111 tttn #8-bit disp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3057
      emit_byte(0x70 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3058
      emit_byte((offs - short_size) & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3059
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3060
      // 0000 1111 1000 tttn #32-bit disp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3061
      assert(is_simm32(offs - long_size),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3062
             "must be 32bit offset (call4)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3063
      emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3064
      emit_byte(0x80 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3065
      emit_long(offs - long_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3066
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3067
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3068
    // Note: could eliminate cond. jumps to this jump if condition
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3069
    //       is the same however, seems to be rather unlikely case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3070
    // Note: use jccb() if label to be bound is very close to get
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3071
    //       an 8-bit displacement
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3072
    L.add_patch_at(code(), locator());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3073
    emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3074
    emit_byte(0x80 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3075
    emit_long(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3076
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3077
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3078
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3079
void Assembler::jccb(Condition cc, Label& L) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3080
  if (L.is_bound()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3081
    const int short_size = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3082
    const int long_size = 6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3083
    address entry = target(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3084
    assert(is8bit((intptr_t)entry - ((intptr_t)_code_pos + short_size)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3085
           "Dispacement too large for a short jmp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3086
    intptr_t offs = (intptr_t)entry - (intptr_t)_code_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3087
    // 0111 tttn #8-bit disp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3088
    emit_byte(0x70 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3089
    emit_byte((offs - short_size) & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3090
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3091
    InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3092
    L.add_patch_at(code(), locator());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3093
    emit_byte(0x70 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3094
    emit_byte(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3095
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3096
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3097
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3098
// FP instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3099
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3100
void Assembler::fxsave(Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3101
  prefixq(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3102
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3103
  emit_byte(0xAE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3104
  emit_operand(as_Register(0), dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3105
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3106
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3107
void Assembler::fxrstor(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3108
  prefixq(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3109
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3110
  emit_byte(0xAE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3111
  emit_operand(as_Register(1), src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3112
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3113
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3114
void Assembler::ldmxcsr(Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3115
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3116
  prefix(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3117
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3118
  emit_byte(0xAE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3119
  emit_operand(as_Register(2), src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3120
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3121
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3122
void Assembler::stmxcsr(Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3123
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3124
  prefix(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3125
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3126
  emit_byte(0xAE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3127
  emit_operand(as_Register(3), dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3128
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3129
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3130
void Assembler::addss(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3131
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3132
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3133
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3134
  emit_byte(0x58);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3135
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3136
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3137
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3138
void Assembler::addss(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3139
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3140
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3141
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3142
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3143
  emit_byte(0x58);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3144
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3145
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3146
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3147
void Assembler::subss(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3148
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3149
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3150
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3151
  emit_byte(0x5C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3152
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3155
void Assembler::subss(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3156
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3157
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3158
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3159
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3160
  emit_byte(0x5C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3161
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3162
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3163
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3164
void Assembler::mulss(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3165
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3166
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3167
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3168
  emit_byte(0x59);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3169
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3170
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3171
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3172
void Assembler::mulss(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3173
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3174
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3175
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3176
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3177
  emit_byte(0x59);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3178
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3181
void Assembler::divss(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3182
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3183
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3184
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3185
  emit_byte(0x5E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3186
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3188
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3189
void Assembler::divss(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3190
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3191
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3192
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3193
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3194
  emit_byte(0x5E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3195
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3196
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3197
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3198
void Assembler::addsd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3199
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3200
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3201
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3202
  emit_byte(0x58);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3203
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3204
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3205
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3206
void Assembler::addsd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3207
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3208
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3209
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3210
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3211
  emit_byte(0x58);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3212
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3213
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3214
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3215
void Assembler::subsd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3216
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3217
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3218
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3219
  emit_byte(0x5C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3220
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3221
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3222
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3223
void Assembler::subsd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3224
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3225
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3226
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3227
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3228
  emit_byte(0x5C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3229
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3230
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3231
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3232
void Assembler::mulsd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3233
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3234
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3235
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3236
  emit_byte(0x59);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3237
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3238
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3239
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3240
void Assembler::mulsd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3241
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3242
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3243
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3244
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3245
  emit_byte(0x59);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3246
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3247
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3248
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3249
void Assembler::divsd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3250
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3251
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3252
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3253
  emit_byte(0x5E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3254
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3255
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3256
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3257
void Assembler::divsd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3258
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3259
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3260
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3261
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3262
  emit_byte(0x5E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3263
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3264
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3265
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3266
void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3267
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3268
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3269
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3270
  emit_byte(0x51);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3271
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3272
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3274
void Assembler::sqrtsd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3275
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3276
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3277
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3278
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3279
  emit_byte(0x51);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3280
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3281
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3282
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3283
void Assembler::xorps(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3284
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3285
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3286
  emit_byte(0x57);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3287
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3288
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3289
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3290
void Assembler::xorps(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3291
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3292
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3293
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3294
  emit_byte(0x57);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3295
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3296
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3297
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3298
void Assembler::xorpd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3299
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3300
  xorps(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3301
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3302
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3303
void Assembler::xorpd(XMMRegister dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3304
  InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3305
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3306
  prefix(src, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3307
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3308
  emit_byte(0x57);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3309
  emit_operand(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3310
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3311
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3312
void Assembler::cvtsi2ssl(XMMRegister dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3313
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3314
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3315
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3316
  emit_byte(0x2A);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3317
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3318
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3319
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3320
void Assembler::cvtsi2ssq(XMMRegister dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3321
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3322
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3323
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3324
  emit_byte(0x2A);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3325
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3326
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3327
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3328
void Assembler::cvtsi2sdl(XMMRegister dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3329
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3330
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3331
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3332
  emit_byte(0x2A);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3333
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3334
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3335
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3336
void Assembler::cvtsi2sdq(XMMRegister dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3337
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3338
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3339
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3340
  emit_byte(0x2A);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3341
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3342
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3343
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3344
void Assembler::cvttss2sil(Register dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3345
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3346
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3347
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3348
  emit_byte(0x2C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3349
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3350
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3351
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3352
void Assembler::cvttss2siq(Register dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3353
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3354
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3355
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3356
  emit_byte(0x2C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3357
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3358
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3359
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3360
void Assembler::cvttsd2sil(Register dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3361
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3362
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3363
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3364
  emit_byte(0x2C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3365
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3366
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3367
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3368
void Assembler::cvttsd2siq(Register dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3369
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3370
  int encode = prefixq_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3371
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3372
  emit_byte(0x2C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3373
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3374
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3375
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3376
void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3377
  emit_byte(0xF3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3378
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3379
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3380
  emit_byte(0x5A);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3381
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3382
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3383
244
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3384
void Assembler::cvtdq2pd(XMMRegister dst, XMMRegister src) {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3385
  emit_byte(0xF3);
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3386
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3387
  emit_byte(0x0F);
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3388
  emit_byte(0xE6);
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3389
  emit_byte(0xC0 | encode);
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3390
}
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3391
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3392
void Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3393
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3394
  emit_byte(0x0F);
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3395
  emit_byte(0x5B);
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3396
  emit_byte(0xC0 | encode);
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3397
}
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
  3398
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3399
void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3400
  emit_byte(0xF2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3401
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3402
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3403
  emit_byte(0x5A);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3404
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3405
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3406
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3407
void Assembler::punpcklbw(XMMRegister dst, XMMRegister src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3408
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3409
  int encode = prefix_and_encode(dst->encoding(), src->encoding());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3410
  emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3411
  emit_byte(0x60);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3412
  emit_byte(0xC0 | encode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3413
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3414
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3415
// Implementation of MacroAssembler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3416
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3417
// On 32 bit it returns a vanilla displacement on 64 bit is a rip relative displacement
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3418
Address MacroAssembler::as_Address(AddressLiteral adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3419
  assert(!adr.is_lval(), "must be rval");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3420
  assert(reachable(adr), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3421
  return Address((int)(intptr_t)(adr.target() - pc()), adr.target(), adr.reloc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3423
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3424
Address MacroAssembler::as_Address(ArrayAddress adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3425
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3426
  AddressLiteral base = adr.base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3427
  lea(rscratch1, base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3428
  Address index = adr.index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3429
  assert(index._disp == 0, "must not have disp"); // maybe it can?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3430
  Address array(rscratch1, index._index, index._scale, index._disp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3431
  return array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3432
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3433
  return Address::make_array(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3434
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3435
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3436
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3437
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3438
void MacroAssembler::fat_nop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3439
  // A 5 byte nop that is safe for patching (see patch_verified_entry)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3440
  // Recommened sequence from 'Software Optimization Guide for the AMD
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3441
  // Hammer Processor'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3442
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3443
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3444
  emit_byte(0x90);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3445
  emit_byte(0x66);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3446
  emit_byte(0x90);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3447
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3448
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3449
static Assembler::Condition reverse[] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3450
    Assembler::noOverflow     /* overflow      = 0x0 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3451
    Assembler::overflow       /* noOverflow    = 0x1 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3452
    Assembler::aboveEqual     /* carrySet      = 0x2, below         = 0x2 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3453
    Assembler::below          /* aboveEqual    = 0x3, carryClear    = 0x3 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3454
    Assembler::notZero        /* zero          = 0x4, equal         = 0x4 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3455
    Assembler::zero           /* notZero       = 0x5, notEqual      = 0x5 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3456
    Assembler::above          /* belowEqual    = 0x6 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3457
    Assembler::belowEqual     /* above         = 0x7 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3458
    Assembler::positive       /* negative      = 0x8 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3459
    Assembler::negative       /* positive      = 0x9 */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3460
    Assembler::noParity       /* parity        = 0xa */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3461
    Assembler::parity         /* noParity      = 0xb */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3462
    Assembler::greaterEqual   /* less          = 0xc */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3463
    Assembler::less           /* greaterEqual  = 0xd */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3464
    Assembler::greater        /* lessEqual     = 0xe */ ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3465
    Assembler::lessEqual      /* greater       = 0xf, */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3466
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3467
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3468
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3469
// 32bit can do a case table jump in one instruction but we no longer allow the base
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3470
// to be installed in the Address class
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3471
void MacroAssembler::jump(ArrayAddress entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3472
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3473
  lea(rscratch1, entry.base());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3474
  Address dispatch = entry.index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3475
  assert(dispatch._base == noreg, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3476
  dispatch._base = rscratch1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3477
  jmp(dispatch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3478
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3479
  jmp(as_Address(entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3480
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3481
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3482
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3483
void MacroAssembler::jump(AddressLiteral dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3484
  if (reachable(dst)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3485
    jmp_literal(dst.target(), dst.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3486
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3487
    lea(rscratch1, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3488
    jmp(rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3489
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3490
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3491
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3492
void MacroAssembler::jump_cc(Condition cc, AddressLiteral dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3493
  if (reachable(dst)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3494
    InstructionMark im(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3495
    relocate(dst.reloc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3496
    const int short_size = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3497
    const int long_size = 6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3498
    int offs = (intptr_t)dst.target() - ((intptr_t)_code_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3499
    if (dst.reloc() == relocInfo::none && is8bit(offs - short_size)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3500
      // 0111 tttn #8-bit disp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3501
      emit_byte(0x70 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3502
      emit_byte((offs - short_size) & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3503
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3504
      // 0000 1111 1000 tttn #32-bit disp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3505
      emit_byte(0x0F);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3506
      emit_byte(0x80 | cc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3507
      emit_long(offs - long_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3508
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3509
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3510
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3511
    warning("reversing conditional branch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3512
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3513
    Label skip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3514
    jccb(reverse[cc], skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3515
    lea(rscratch1, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3516
    Assembler::jmp(rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3517
    bind(skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3518
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3519
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3520
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3521
// Wouldn't need if AddressLiteral version had new name
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3522
void MacroAssembler::call(Label& L, relocInfo::relocType rtype) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3523
  Assembler::call(L, rtype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3524
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3525
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3526
// Wouldn't need if AddressLiteral version had new name
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3527
void MacroAssembler::call(Register entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3528
  Assembler::call(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3529
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3530
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3531
void MacroAssembler::call(AddressLiteral entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3532
  if (reachable(entry)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3533
    Assembler::call_literal(entry.target(), entry.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3534
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3535
    lea(rscratch1, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3536
    Assembler::call(rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3537
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3538
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3539
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3540
void MacroAssembler::cmp8(AddressLiteral src1, int8_t src2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3541
  if (reachable(src1)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3542
    cmpb(as_Address(src1), src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3543
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3544
    lea(rscratch1, src1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3545
    cmpb(Address(rscratch1, 0), src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3546
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3547
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3548
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3549
void MacroAssembler::cmp32(AddressLiteral src1, int32_t src2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3550
  if (reachable(src1)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3551
    cmpl(as_Address(src1), src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3552
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3553
    lea(rscratch1, src1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3554
    cmpl(Address(rscratch1, 0), src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3555
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3556
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3557
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3558
void MacroAssembler::cmp32(Register src1, AddressLiteral src2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3559
  if (reachable(src2)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3560
    cmpl(src1, as_Address(src2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3561
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3562
    lea(rscratch1, src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3563
    cmpl(src1, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3564
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3565
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3566
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3567
void MacroAssembler::cmpptr(Register src1, AddressLiteral src2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3568
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3569
  if (src2.is_lval()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3570
    movptr(rscratch1, src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3571
    Assembler::cmpq(src1, rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3572
  } else if (reachable(src2)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3573
    cmpq(src1, as_Address(src2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3574
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3575
    lea(rscratch1, src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3576
    Assembler::cmpq(src1, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3577
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3578
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3579
  if (src2.is_lval()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3580
    cmp_literal32(src1, (int32_t) src2.target(), src2.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3581
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3582
    cmpl(src1, as_Address(src2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3583
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3584
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3585
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3586
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3587
void MacroAssembler::cmpptr(Address src1, AddressLiteral src2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3588
  assert(src2.is_lval(), "not a mem-mem compare");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3589
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3590
  // moves src2's literal address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3591
  movptr(rscratch1, src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3592
  Assembler::cmpq(src1, rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3593
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3594
  cmp_literal32(src1, (int32_t) src2.target(), src2.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3595
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3596
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3597
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3598
void MacroAssembler::cmp64(Register src1, AddressLiteral src2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3599
  assert(!src2.is_lval(), "should use cmpptr");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3600
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3601
  if (reachable(src2)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3602
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3603
    cmpq(src1, as_Address(src2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3604
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3605
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3606
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3607
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3608
    lea(rscratch1, src2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3609
    Assembler::cmpq(src1, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3610
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3611
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3612
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3613
void MacroAssembler::cmpxchgptr(Register reg, AddressLiteral adr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3614
  if (reachable(adr)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3615
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3616
    cmpxchgq(reg, as_Address(adr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3617
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3618
    cmpxchgl(reg, as_Address(adr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3619
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3620
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3621
    lea(rscratch1, adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3622
    cmpxchgq(reg, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3623
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3624
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3625
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3626
void MacroAssembler::incrementl(AddressLiteral dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3627
  if (reachable(dst)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3628
    incrementl(as_Address(dst));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3629
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3630
    lea(rscratch1, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3631
    incrementl(Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3632
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3633
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3634
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3635
void MacroAssembler::incrementl(ArrayAddress dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3636
  incrementl(as_Address(dst));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3637
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3638
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3639
void MacroAssembler::lea(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3640
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3641
  leaq(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3642
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3643
  leal(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3644
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3645
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3646
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3647
void MacroAssembler::lea(Register dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3648
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3649
    mov_literal64(dst, (intptr_t)src.target(), src.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3650
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3651
    mov_literal32(dst, (intptr_t)src.target(), src.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3652
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3653
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3654
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3655
void MacroAssembler::mov32(AddressLiteral dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3656
  if (reachable(dst)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3657
    movl(as_Address(dst), src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3658
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3659
    lea(rscratch1, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3660
    movl(Address(rscratch1, 0), src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3661
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3662
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3663
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3664
void MacroAssembler::mov32(Register dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3665
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3666
    movl(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3667
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3668
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3669
    movl(dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3670
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3671
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3672
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3673
void MacroAssembler::movdbl(XMMRegister dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3674
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3675
    if (UseXmmLoadAndClearUpper) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3676
      movsd (dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3677
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3678
      movlpd(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3679
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3680
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3681
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3682
    if (UseXmmLoadAndClearUpper) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3683
      movsd (dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3684
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3685
      movlpd(dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3686
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3687
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3688
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3689
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3690
void MacroAssembler::movflt(XMMRegister dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3691
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3692
    movss(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3693
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3694
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3695
    movss(dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3696
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3697
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3698
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3699
void MacroAssembler::movoop(Register dst, jobject obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3700
  mov_literal64(dst, (intptr_t)obj, oop_Relocation::spec_for_immediate());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3701
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3702
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3703
void MacroAssembler::movoop(Address dst, jobject obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3704
  mov_literal64(rscratch1, (intptr_t)obj, oop_Relocation::spec_for_immediate());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3705
  movq(dst, rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3706
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3707
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3708
void MacroAssembler::movptr(Register dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3709
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3710
  if (src.is_lval()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3711
    mov_literal64(dst, (intptr_t)src.target(), src.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3712
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3713
    if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3714
      movq(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3715
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3716
      lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3717
      movq(dst, Address(rscratch1,0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3718
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3719
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3720
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3721
  if (src.is_lval()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3722
    mov_literal32(dst, (intptr_t)src.target(), src.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3723
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3724
    movl(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3725
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3726
#endif // LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3727
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3728
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3729
void MacroAssembler::movptr(ArrayAddress dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3730
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3731
  movq(as_Address(dst), src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3732
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3733
  movl(as_Address(dst), src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3734
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3735
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3736
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3737
void MacroAssembler::pushoop(jobject obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3738
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3739
  movoop(rscratch1, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3740
  pushq(rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3741
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3742
  push_literal32((int32_t)obj, oop_Relocation::spec_for_immediate());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3743
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3744
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3745
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3746
void MacroAssembler::pushptr(AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3747
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3748
  lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3749
  if (src.is_lval()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3750
    pushq(rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3751
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3752
    pushq(Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3753
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3754
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3755
  if (src.is_lval()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3756
    push_literal((int32_t)src.target(), src.rspec());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3757
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3758
    pushl(as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3759
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3760
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3761
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3762
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3763
void MacroAssembler::ldmxcsr(AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3764
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3765
    Assembler::ldmxcsr(as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3766
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3767
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3768
    Assembler::ldmxcsr(Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3769
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3770
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3771
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3772
void MacroAssembler::movlpd(XMMRegister dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3773
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3774
    movlpd(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3775
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3776
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3777
    movlpd(dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3778
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3779
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3780
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3781
void MacroAssembler::movss(XMMRegister dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3782
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3783
    movss(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3784
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3785
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3786
    movss(dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3787
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3788
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3789
void MacroAssembler::xorpd(XMMRegister dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3790
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3791
    xorpd(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3792
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3793
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3794
    xorpd(dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3795
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3796
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3797
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3798
void MacroAssembler::xorps(XMMRegister dst, AddressLiteral src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3799
  if (reachable(src)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3800
    xorps(dst, as_Address(src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3801
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3802
    lea(rscratch1, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3803
    xorps(dst, Address(rscratch1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3804
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3805
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3806
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3807
void MacroAssembler::null_check(Register reg, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3808
  if (needs_explicit_null_check(offset)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3809
    // provoke OS NULL exception if reg = NULL by
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3810
    // accessing M[reg] w/o changing any (non-CC) registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3811
    cmpq(rax, Address(reg, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3812
    // Note: should probably use testl(rax, Address(reg, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3813
    //       may be shorter code (however, this version of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3814
    //       testl needs to be implemented first)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3815
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3816
    // nothing to do, (later) access of M[reg + offset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3817
    // will provoke OS NULL exception if reg = NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3818
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3819
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3820
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3821
int MacroAssembler::load_unsigned_byte(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3822
  int off = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3823
  movzbl(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3824
  return off;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3825
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3826
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3827
int MacroAssembler::load_unsigned_word(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3828
  int off = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3829
  movzwl(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3830
  return off;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3831
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3832
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3833
int MacroAssembler::load_signed_byte(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3834
  int off = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3835
  movsbl(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3836
  return off;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3837
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3838
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3839
int MacroAssembler::load_signed_word(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3840
  int off = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3841
  movswl(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3842
  return off;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3843
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3844
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3845
void MacroAssembler::incrementl(Register reg, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3846
  if (value == min_jint) { addl(reg, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3847
  if (value <  0) { decrementl(reg, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3848
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3849
  if (value == 1 && UseIncDec) { incl(reg) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3850
  /* else */      { addl(reg, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3851
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3852
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3853
void MacroAssembler::decrementl(Register reg, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3854
  if (value == min_jint) { subl(reg, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3855
  if (value <  0) { incrementl(reg, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3856
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3857
  if (value == 1 && UseIncDec) { decl(reg) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3858
  /* else */      { subl(reg, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3859
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3860
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3861
void MacroAssembler::incrementq(Register reg, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3862
  if (value == min_jint) { addq(reg, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3863
  if (value <  0) { decrementq(reg, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3864
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3865
  if (value == 1 && UseIncDec) { incq(reg) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3866
  /* else */      { addq(reg, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3867
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3868
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3869
void MacroAssembler::decrementq(Register reg, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3870
  if (value == min_jint) { subq(reg, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3871
  if (value <  0) { incrementq(reg, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3872
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3873
  if (value == 1 && UseIncDec) { decq(reg) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3874
  /* else */      { subq(reg, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3875
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3876
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3877
void MacroAssembler::incrementl(Address dst, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3878
  if (value == min_jint) { addl(dst, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3879
  if (value <  0) { decrementl(dst, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3880
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3881
  if (value == 1 && UseIncDec) { incl(dst) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3882
  /* else */      { addl(dst, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3883
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3884
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3885
void MacroAssembler::decrementl(Address dst, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3886
  if (value == min_jint) { subl(dst, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3887
  if (value <  0) { incrementl(dst, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3888
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3889
  if (value == 1 && UseIncDec) { decl(dst) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3890
  /* else */      { subl(dst, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3891
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3892
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3893
void MacroAssembler::incrementq(Address dst, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3894
  if (value == min_jint) { addq(dst, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3895
  if (value <  0) { decrementq(dst, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3896
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3897
  if (value == 1 && UseIncDec) { incq(dst) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3898
  /* else */      { addq(dst, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3899
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3900
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3901
void MacroAssembler::decrementq(Address dst, int value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3902
  if (value == min_jint) { subq(dst, value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3903
  if (value <  0) { incrementq(dst, -value); return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3904
  if (value == 0) {                        ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3905
  if (value == 1 && UseIncDec) { decq(dst) ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3906
  /* else */      { subq(dst, value)       ; return; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3907
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3908
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3909
void MacroAssembler::align(int modulus) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3910
  if (offset() % modulus != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3911
    nop(modulus - (offset() % modulus));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3912
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3913
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3914
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3915
void MacroAssembler::enter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3916
  pushq(rbp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3917
  movq(rbp, rsp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3918
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3919
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3920
void MacroAssembler::leave() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3921
  emit_byte(0xC9); // LEAVE
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3922
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3923
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3924
// C++ bool manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3925
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3926
void MacroAssembler::movbool(Register dst, Address src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3927
  if(sizeof(bool) == 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3928
    movb(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3929
  else if(sizeof(bool) == 2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3930
    movw(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3931
  else if(sizeof(bool) == 4)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3932
    movl(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3933
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3934
    // unsupported
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3935
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3936
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3937
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3938
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3939
void MacroAssembler::movbool(Address dst, bool boolconst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3940
  if(sizeof(bool) == 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3941
    movb(dst, (int) boolconst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3942
  else if(sizeof(bool) == 2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3943
    movw(dst, (int) boolconst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3944
  else if(sizeof(bool) == 4)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3945
    movl(dst, (int) boolconst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3946
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3947
    // unsupported
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3948
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3949
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3950
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3951
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3952
void MacroAssembler::movbool(Address dst, Register src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3953
  if(sizeof(bool) == 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3954
    movb(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3955
  else if(sizeof(bool) == 2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3956
    movw(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3957
  else if(sizeof(bool) == 4)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3958
    movl(dst, src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3959
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3960
    // unsupported
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3961
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3962
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3963
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3964
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3965
void MacroAssembler::testbool(Register dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3966
  if(sizeof(bool) == 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3967
    testb(dst, (int) 0xff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3968
  else if(sizeof(bool) == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3969
    // need testw impl
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3970
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3971
  } else if(sizeof(bool) == 4)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3972
    testl(dst, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3973
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3974
    // unsupported
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3975
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3976
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3977
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3978
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3979
void MacroAssembler::set_last_Java_frame(Register last_java_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3980
                                         Register last_java_fp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3981
                                         address  last_java_pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3982
  // determine last_java_sp register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3983
  if (!last_java_sp->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3984
    last_java_sp = rsp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3985
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3986
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3987
  // last_java_fp is optional
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3988
  if (last_java_fp->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3989
    movq(Address(r15_thread, JavaThread::last_Java_fp_offset()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3990
         last_java_fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3991
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3992
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3993
  // last_java_pc is optional
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3994
  if (last_java_pc != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3995
    Address java_pc(r15_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3996
                    JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3997
    lea(rscratch1, InternalAddress(last_java_pc));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3998
    movq(java_pc, rscratch1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3999
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4000
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4001
  movq(Address(r15_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4002
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4003
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4004
void MacroAssembler::reset_last_Java_frame(bool clear_fp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4005
                                           bool clear_pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4006
  // we must set sp to zero to clear frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4007
  movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4008
  // must clear fp, so that compiled frames are not confused; it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4009
  // possible that we need it only for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4010
  if (clear_fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4011
    movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4012
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4013
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4014
  if (clear_pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4015
    movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4016
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4017
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4019
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4020
// Implementation of call_VM versions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4021
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4022
void MacroAssembler::call_VM_leaf_base(address entry_point, int num_args) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4023
  Label L, E;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4025
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4026
  // Windows always allocates space for it's register args
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4027
  assert(num_args <= 4, "only register arguments supported");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4028
  subq(rsp,  frame::arg_reg_save_area_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4029
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4030
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4031
  // Align stack if necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4032
  testl(rsp, 15);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4033
  jcc(Assembler::zero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4035
  subq(rsp, 8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4036
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4037
    call(RuntimeAddress(entry_point));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4038
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4039
  addq(rsp, 8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4040
  jmp(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4041
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4042
  bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4043
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4044
    call(RuntimeAddress(entry_point));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4045
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4046
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4047
  bind(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4048
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4049
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4050
  // restore stack pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4051
  addq(rsp, frame::arg_reg_save_area_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4052
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4053
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4054
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4055
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4056
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4057
void MacroAssembler::call_VM_base(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4058
                                  Register java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4059
                                  Register last_java_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4060
                                  address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4061
                                  int num_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4062
                                  bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4063
  // determine last_java_sp register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4064
  if (!last_java_sp->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4065
    last_java_sp = rsp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4066
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4068
  // debugging support
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4069
  assert(num_args >= 0, "cannot have negative number of arguments");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4070
  assert(r15_thread != oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4071
         "cannot use the same register for java_thread & oop_result");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4072
  assert(r15_thread != last_java_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4073
         "cannot use the same register for java_thread & last_java_sp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4074
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4075
  // set last Java frame before call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4076
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4077
  // This sets last_Java_fp which is only needed from interpreted frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4078
  // and should really be done only from the interp_masm version before
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4079
  // calling the underlying call_VM. That doesn't happen yet so we set
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4080
  // last_Java_fp here even though some callers don't need it and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4081
  // also clear it below.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4082
  set_last_Java_frame(last_java_sp, rbp, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4083
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4084
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4085
    Label L, E;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4086
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4087
    // Align stack if necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4088
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4089
    assert(num_args <= 4, "only register arguments supported");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4090
    // Windows always allocates space for it's register args
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4091
    subq(rsp, frame::arg_reg_save_area_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4092
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4093
    testl(rsp, 15);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4094
    jcc(Assembler::zero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4095
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4096
    subq(rsp, 8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4097
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4098
      call(RuntimeAddress(entry_point));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4099
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4100
    addq(rsp, 8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4101
    jmp(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4102
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4103
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4104
    bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4105
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4106
      call(RuntimeAddress(entry_point));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4107
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4108
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4109
    bind(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4110
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4111
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4112
    // restore stack pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4113
    addq(rsp, frame::arg_reg_save_area_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4114
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4115
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4116
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4117
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4118
  pushq(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4119
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4120
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4121
    get_thread(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4122
    cmpq(r15_thread, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4123
    jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4124
    stop("MacroAssembler::call_VM_base: register not callee saved?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4125
    bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4127
  popq(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4128
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4129
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4130
  // reset last Java frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4131
  // This really shouldn't have to clear fp set note above at the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4132
  // call to set_last_Java_frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4133
  reset_last_Java_frame(true, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4134
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4135
  check_and_handle_popframe(noreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4136
  check_and_handle_earlyret(noreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4137
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4138
  if (check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4139
    cmpq(Address(r15_thread, Thread::pending_exception_offset()), (int) NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4140
    // This used to conditionally jump to forward_exception however it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4141
    // possible if we relocate that the branch will not reach. So we must jump
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4142
    // around so we can always reach
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4143
    Label ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4144
    jcc(Assembler::equal, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4145
    jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4146
    bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4148
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4149
  // get oop result if there is one and reset the value in the thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4150
  if (oop_result->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4151
    movq(oop_result, Address(r15_thread, JavaThread::vm_result_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4152
    movptr(Address(r15_thread, JavaThread::vm_result_offset()), NULL_WORD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4153
    verify_oop(oop_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4154
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4155
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4156
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4157
void MacroAssembler::check_and_handle_popframe(Register java_thread) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4158
void MacroAssembler::check_and_handle_earlyret(Register java_thread) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4159
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4160
void MacroAssembler::call_VM_helper(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4161
                                    address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4162
                                    int num_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4163
                                    bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4164
  // Java thread becomes first argument of C function
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4165
  movq(c_rarg0, r15_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4166
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4167
  // We've pushed one address, correct last_Java_sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4168
  leaq(rax, Address(rsp, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4169
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4170
  call_VM_base(oop_result, noreg, rax, entry_point, num_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4171
               check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4172
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4173
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4174
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4175
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4176
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4177
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4178
  Label C, E;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4179
  Assembler::call(C, relocInfo::none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4180
  jmp(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4181
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4182
  bind(C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4183
  call_VM_helper(oop_result, entry_point, 0, check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4184
  ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4185
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4186
  bind(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4188
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4189
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4190
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4191
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4192
                             Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4193
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4194
  assert(rax != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4195
  assert(c_rarg0 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4196
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4197
  Label C, E;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4198
  Assembler::call(C, relocInfo::none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4199
  jmp(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4200
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4201
  bind(C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4202
  // c_rarg0 is reserved for thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4203
  if (c_rarg1 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4204
    movq(c_rarg1, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4205
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4206
  call_VM_helper(oop_result, entry_point, 1, check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4207
  ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4208
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4209
  bind(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4210
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4211
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4212
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4213
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4214
                             Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4215
                             Register arg_2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4216
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4217
  assert(rax != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4218
  assert(rax != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4219
  assert(c_rarg0 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4220
  assert(c_rarg0 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4221
  assert(c_rarg1 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4222
  assert(c_rarg2 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4223
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4224
  Label C, E;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4225
  Assembler::call(C, relocInfo::none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4226
  jmp(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4227
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4228
  bind(C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4229
  // c_rarg0 is reserved for thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4230
  if (c_rarg1 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4231
    movq(c_rarg1, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4232
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4233
  if (c_rarg2 != arg_2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4234
    movq(c_rarg2, arg_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4235
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4236
  call_VM_helper(oop_result, entry_point, 2, check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4237
  ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4238
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4239
  bind(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4240
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4242
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4243
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4244
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4245
                             Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4246
                             Register arg_2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4247
                             Register arg_3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4248
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4249
  assert(rax != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4250
  assert(rax != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4251
  assert(rax != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4252
  assert(c_rarg0 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4253
  assert(c_rarg0 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4254
  assert(c_rarg0 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4255
  assert(c_rarg1 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4256
  assert(c_rarg1 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4257
  assert(c_rarg2 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4258
  assert(c_rarg2 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4259
  assert(c_rarg3 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4260
  assert(c_rarg3 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4261
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4262
  Label C, E;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4263
  Assembler::call(C, relocInfo::none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4264
  jmp(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4265
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4266
  bind(C);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4267
  // c_rarg0 is reserved for thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4268
  if (c_rarg1 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4269
    movq(c_rarg1, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4270
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4271
  if (c_rarg2 != arg_2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4272
    movq(c_rarg2, arg_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4273
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4274
  if (c_rarg3 != arg_3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4275
    movq(c_rarg3, arg_3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4276
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4277
  call_VM_helper(oop_result, entry_point, 3, check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4278
  ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4279
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4280
  bind(E);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4281
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4282
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4283
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4284
                             Register last_java_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4285
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4286
                             int num_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4287
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4288
  call_VM_base(oop_result, noreg, last_java_sp, entry_point, num_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4289
               check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4290
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4292
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4293
                             Register last_java_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4294
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4295
                             Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4296
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4297
  assert(c_rarg0 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4298
  assert(c_rarg1 != last_java_sp, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4299
  // c_rarg0 is reserved for thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4300
  if (c_rarg1 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4301
    movq(c_rarg1, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4302
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4303
  call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4304
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4305
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4306
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4307
                             Register last_java_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4308
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4309
                             Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4310
                             Register arg_2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4311
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4312
  assert(c_rarg0 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4313
  assert(c_rarg0 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4314
  assert(c_rarg1 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4315
  assert(c_rarg1 != last_java_sp, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4316
  assert(c_rarg2 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4317
  assert(c_rarg2 != last_java_sp, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4318
  // c_rarg0 is reserved for thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4319
  if (c_rarg1 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4320
    movq(c_rarg1, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4321
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4322
  if (c_rarg2 != arg_2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4323
    movq(c_rarg2, arg_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4324
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4325
  call_VM(oop_result, last_java_sp, entry_point, 2, check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4326
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4327
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4328
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4329
void MacroAssembler::call_VM(Register oop_result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4330
                             Register last_java_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4331
                             address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4332
                             Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4333
                             Register arg_2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4334
                             Register arg_3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4335
                             bool check_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4336
  assert(c_rarg0 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4337
  assert(c_rarg0 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4338
  assert(c_rarg0 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4339
  assert(c_rarg1 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4340
  assert(c_rarg1 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4341
  assert(c_rarg1 != last_java_sp, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4342
  assert(c_rarg2 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4343
  assert(c_rarg2 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4344
  assert(c_rarg2 != last_java_sp, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4345
  assert(c_rarg3 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4346
  assert(c_rarg3 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4347
  assert(c_rarg3 != last_java_sp, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4348
  // c_rarg0 is reserved for thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4349
  if (c_rarg1 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4350
    movq(c_rarg1, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4351
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4352
  if (c_rarg2 != arg_2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4353
    movq(c_rarg2, arg_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4354
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4355
  if (c_rarg3 != arg_3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4356
    movq(c_rarg2, arg_3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4357
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4358
  call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4359
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4360
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4361
void MacroAssembler::call_VM_leaf(address entry_point, int num_args) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4362
  call_VM_leaf_base(entry_point, num_args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4363
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4364
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4365
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4366
  if (c_rarg0 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4367
    movq(c_rarg0, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4368
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4369
  call_VM_leaf(entry_point, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4370
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4371
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4372
void MacroAssembler::call_VM_leaf(address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4373
                                  Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4374
                                  Register arg_2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4375
  assert(c_rarg0 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4376
  assert(c_rarg1 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4377
  if (c_rarg0 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4378
    movq(c_rarg0, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4379
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4380
  if (c_rarg1 != arg_2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4381
    movq(c_rarg1, arg_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4382
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4383
  call_VM_leaf(entry_point, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4385
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4386
void MacroAssembler::call_VM_leaf(address entry_point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4387
                                  Register arg_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4388
                                  Register arg_2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4389
                                  Register arg_3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4390
  assert(c_rarg0 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4391
  assert(c_rarg0 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4392
  assert(c_rarg1 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4393
  assert(c_rarg1 != arg_3, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4394
  assert(c_rarg2 != arg_1, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4395
  assert(c_rarg2 != arg_2, "smashed argument");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4396
  if (c_rarg0 != arg_1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4397
    movq(c_rarg0, arg_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4398
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4399
  if (c_rarg1 != arg_2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4400
    movq(c_rarg1, arg_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4401
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4402
  if (c_rarg2 != arg_3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4403
    movq(c_rarg2, arg_3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4404
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4405
  call_VM_leaf(entry_point, 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4406
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4407
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4408
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4409
// Calls to C land
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4410
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4411
// When entering C land, the rbp & rsp of the last Java frame have to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4412
// be recorded in the (thread-local) JavaThread object. When leaving C
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4413
// land, the last Java fp has to be reset to 0. This is required to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4414
// allow proper stack traversal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4415
void MacroAssembler::store_check(Register obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4416
  // Does a store check for the oop in register obj. The content of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4417
  // register obj is destroyed afterwards.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4418
  store_check_part_1(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4419
  store_check_part_2(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4420
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4421
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4422
void MacroAssembler::store_check(Register obj, Address dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4423
  store_check(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4424
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4425
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4426
// split the store check operation so that other instructions can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4427
// scheduled inbetween
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4428
void MacroAssembler::store_check_part_1(Register obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4429
  BarrierSet* bs = Universe::heap()->barrier_set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4430
  assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4431
  shrq(obj, CardTableModRefBS::card_shift);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4432
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4433
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4434
void MacroAssembler::store_check_part_2(Register obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4435
  BarrierSet* bs = Universe::heap()->barrier_set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4436
  assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4437
  CardTableModRefBS* ct = (CardTableModRefBS*)bs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4438
  assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4439
  ExternalAddress cardtable((address)ct->byte_map_base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4440
  Address index(noreg, obj, Address::times_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4441
  movb(as_Address(ArrayAddress(cardtable, index)), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4442
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4443
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4444
void MacroAssembler::c2bool(Register x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4445
  // implements x == 0 ? 0 : 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4446
  // note: must only look at least-significant byte of x
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4447
  //       since C-style booleans are stored in one byte
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4448
  //       only! (was bug)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4449
  andl(x, 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4450
  setb(Assembler::notZero, x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4451
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4452
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4453
int MacroAssembler::corrected_idivl(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4454
  // Full implementation of Java idiv and irem; checks for special
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4455
  // case as described in JVM spec., p.243 & p.271.  The function
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4456
  // returns the (pc) offset of the idivl instruction - may be needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4457
  // for implicit exceptions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4458
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4459
  //         normal case                           special case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4460
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4461
  // input : eax: dividend                         min_int
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4462
  //         reg: divisor   (may not be eax/edx)   -1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4463
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4464
  // output: eax: quotient  (= eax idiv reg)       min_int
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4465
  //         edx: remainder (= eax irem reg)       0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4466
  assert(reg != rax && reg != rdx, "reg cannot be rax or rdx register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4467
  const int min_int = 0x80000000;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4468
  Label normal_case, special_case;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4469
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4470
  // check for special case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4471
  cmpl(rax, min_int);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4472
  jcc(Assembler::notEqual, normal_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4473
  xorl(rdx, rdx); // prepare edx for possible special case (where
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4474
                  // remainder = 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4475
  cmpl(reg, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4476
  jcc(Assembler::equal, special_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4477
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4478
  // handle normal case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4479
  bind(normal_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4480
  cdql();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4481
  int idivl_offset = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4482
  idivl(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4483
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4484
  // normal and special case exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4485
  bind(special_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4486
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4487
  return idivl_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4488
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4489
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4490
int MacroAssembler::corrected_idivq(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4491
  // Full implementation of Java ldiv and lrem; checks for special
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4492
  // case as described in JVM spec., p.243 & p.271.  The function
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4493
  // returns the (pc) offset of the idivl instruction - may be needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4494
  // for implicit exceptions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4495
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4496
  //         normal case                           special case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4497
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4498
  // input : rax: dividend                         min_long
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4499
  //         reg: divisor   (may not be eax/edx)   -1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4500
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4501
  // output: rax: quotient  (= rax idiv reg)       min_long
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4502
  //         rdx: remainder (= rax irem reg)       0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4503
  assert(reg != rax && reg != rdx, "reg cannot be rax or rdx register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4504
  static const int64_t min_long = 0x8000000000000000;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4505
  Label normal_case, special_case;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4506
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4507
  // check for special case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4508
  cmp64(rax, ExternalAddress((address) &min_long));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4509
  jcc(Assembler::notEqual, normal_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4510
  xorl(rdx, rdx); // prepare rdx for possible special case (where
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4511
                  // remainder = 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4512
  cmpq(reg, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4513
  jcc(Assembler::equal, special_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4514
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4515
  // handle normal case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4516
  bind(normal_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4517
  cdqq();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4518
  int idivq_offset = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4519
  idivq(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4520
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4521
  // normal and special case exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4522
  bind(special_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4523
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4524
  return idivq_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4525
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4526
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4527
void MacroAssembler::push_IU_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4528
  pushfq();     // Push flags first because pushaq kills them
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4529
  subq(rsp, 8); // Make sure rsp stays 16-byte aligned
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4530
  pushaq();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4531
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4532
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4533
void MacroAssembler::pop_IU_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4534
  popaq();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4535
  addq(rsp, 8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4536
  popfq();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4537
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4538
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4539
void MacroAssembler::push_FPU_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4540
  subq(rsp, FPUStateSizeInWords * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4541
  fxsave(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4542
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4543
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4544
void MacroAssembler::pop_FPU_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4545
  fxrstor(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4546
  addq(rsp, FPUStateSizeInWords * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4547
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4548
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4549
// Save Integer and Float state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4550
// Warning: Stack must be 16 byte aligned
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4551
void MacroAssembler::push_CPU_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4552
  push_IU_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4553
  push_FPU_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4554
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4555
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4556
void MacroAssembler::pop_CPU_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4557
  pop_FPU_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4558
  pop_IU_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4559
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4560
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4561
void MacroAssembler::sign_extend_short(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4562
  movswl(reg, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4563
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4564
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4565
void MacroAssembler::sign_extend_byte(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4566
  movsbl(reg, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4567
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4568
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4569
void MacroAssembler::division_with_shift(Register reg, int shift_value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4570
  assert (shift_value > 0, "illegal shift value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4571
  Label _is_positive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4572
  testl (reg, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4573
  jcc (Assembler::positive, _is_positive);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4574
  int offset = (1 << shift_value) - 1 ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4575
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4576
  if (offset == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4577
    incrementl(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4578
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4579
    addl(reg, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4580
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4581
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4582
  bind (_is_positive);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4583
  sarl(reg, shift_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4584
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4585
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4586
void MacroAssembler::round_to_l(Register reg, int modulus) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4587
  addl(reg, modulus - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4588
  andl(reg, -modulus);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4589
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4590
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4591
void MacroAssembler::round_to_q(Register reg, int modulus) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4592
  addq(reg, modulus - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4593
  andq(reg, -modulus);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4594
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4595
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4596
void MacroAssembler::verify_oop(Register reg, const char* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4597
  if (!VerifyOops) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4598
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4599
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4600
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4601
  // Pass register number to verify_oop_subroutine
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4602
  char* b = new char[strlen(s) + 50];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4603
  sprintf(b, "verify_oop: %s: %s", reg->name(), s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4604
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4605
  pushq(rax); // save rax, restored by receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4606
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4607
  // pass args on stack, only touch rax
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4608
  pushq(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4609
  // avoid using pushptr, as it modifies scratch registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4610
  // and our contract is not to modify anything
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4611
  ExternalAddress buffer((address)b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4612
  movptr(rax, buffer.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4613
  pushq(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4614
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4615
  // call indirectly to solve generation ordering problem
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4616
  movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4617
  call(rax); // no alignment requirement
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4618
  // everything popped by receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4619
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4620
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4621
void MacroAssembler::verify_oop_addr(Address addr, const char* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4622
  if (!VerifyOops) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4623
  // Pass register number to verify_oop_subroutine
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4624
  char* b = new char[strlen(s) + 50];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4625
  sprintf(b, "verify_oop_addr: %s", s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4626
  pushq(rax);                          // save rax
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4627
  movq(addr, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4628
  pushq(rax);                          // pass register argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4629
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4630
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4631
  // avoid using pushptr, as it modifies scratch registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4632
  // and our contract is not to modify anything
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4633
  ExternalAddress buffer((address)b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4634
  movptr(rax, buffer.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4635
  pushq(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4636
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4637
  // call indirectly to solve generation ordering problem
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4638
  movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4639
  call(rax); // no alignment requirement
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4640
  // everything popped by receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4641
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4642
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4643
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4644
void MacroAssembler::stop(const char* msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4645
  address rip = pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4646
  pushaq(); // get regs on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4647
  lea(c_rarg0, ExternalAddress((address) msg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4648
  lea(c_rarg1, InternalAddress(rip));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4649
  movq(c_rarg2, rsp); // pass pointer to regs array
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4650
  andq(rsp, -16); // align stack as required by ABI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4651
  call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4652
  hlt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4653
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4654
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4655
void MacroAssembler::warn(const char* msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4656
  pushq(r12);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4657
  movq(r12, rsp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4658
  andq(rsp, -16);     // align stack as required by push_CPU_state and call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4659
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4660
  push_CPU_state();   // keeps alignment at 16 bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4661
  lea(c_rarg0, ExternalAddress((address) msg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4662
  call_VM_leaf(CAST_FROM_FN_PTR(address, warning), c_rarg0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4663
  pop_CPU_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4664
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4665
  movq(rsp, r12);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4666
  popq(r12);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4667
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4668
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4669
void MacroAssembler::debug(char* msg, int64_t pc, int64_t regs[]) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4670
  // In order to get locks to work, we need to fake a in_VM state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4671
  if (ShowMessageBoxOnError ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4672
    JavaThread* thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4673
    JavaThreadState saved_state = thread->thread_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4674
    thread->set_thread_state(_thread_in_vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4675
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4676
    if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  4677
      ttyLocker ttyl;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4678
      BytecodeCounter::print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4679
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4680
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4681
    // To see where a verify_oop failed, get $ebx+40/X for this frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4682
    // XXX correct this offset for amd64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4683
    // This is the value of eip which points to where verify_oop will return.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4684
    if (os::message_box(msg, "Execution stopped, print registers?")) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  4685
      ttyLocker ttyl;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4686
      tty->print_cr("rip = 0x%016lx", pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4687
      tty->print_cr("rax = 0x%016lx", regs[15]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4688
      tty->print_cr("rbx = 0x%016lx", regs[12]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4689
      tty->print_cr("rcx = 0x%016lx", regs[14]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4690
      tty->print_cr("rdx = 0x%016lx", regs[13]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4691
      tty->print_cr("rdi = 0x%016lx", regs[8]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4692
      tty->print_cr("rsi = 0x%016lx", regs[9]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4693
      tty->print_cr("rbp = 0x%016lx", regs[10]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4694
      tty->print_cr("rsp = 0x%016lx", regs[11]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4695
      tty->print_cr("r8  = 0x%016lx", regs[7]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4696
      tty->print_cr("r9  = 0x%016lx", regs[6]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4697
      tty->print_cr("r10 = 0x%016lx", regs[5]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4698
      tty->print_cr("r11 = 0x%016lx", regs[4]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4699
      tty->print_cr("r12 = 0x%016lx", regs[3]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4700
      tty->print_cr("r13 = 0x%016lx", regs[2]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4701
      tty->print_cr("r14 = 0x%016lx", regs[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4702
      tty->print_cr("r15 = 0x%016lx", regs[0]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4703
      BREAKPOINT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4704
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4705
    ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4706
  } else {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  4707
    ttyLocker ttyl;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4708
    ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4709
                    msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4710
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4711
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4712
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4713
void MacroAssembler::os_breakpoint() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4714
  // instead of directly emitting a breakpoint, call os:breakpoint for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4715
  // better debugability
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4716
  // This shouldn't need alignment, it's an empty function
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4717
  call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4718
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4719
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4720
// Write serialization page so VM thread can do a pseudo remote membar.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4721
// We use the current thread pointer to calculate a thread specific
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4722
// offset to write to within the page. This minimizes bus traffic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4723
// due to cache line collision.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4724
void MacroAssembler::serialize_memory(Register thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4725
                                      Register tmp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4726
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4727
  movl(tmp, thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4728
  shrl(tmp, os::get_serialize_page_shift_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4729
  andl(tmp, (os::vm_page_size() - sizeof(int)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4730
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4731
  Address index(noreg, tmp, Address::times_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4732
  ExternalAddress page(os::get_memory_serialize_page());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4733
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4734
  movptr(ArrayAddress(page, index), tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4735
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4736
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4737
void MacroAssembler::verify_tlab() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4738
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4739
  if (UseTLAB) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4740
    Label next, ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4741
    Register t1 = rsi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4742
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4743
    pushq(t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4744
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4745
    movq(t1, Address(r15_thread, in_bytes(JavaThread::tlab_top_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4746
    cmpq(t1, Address(r15_thread, in_bytes(JavaThread::tlab_start_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4747
    jcc(Assembler::aboveEqual, next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4748
    stop("assert(top >= start)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4749
    should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4750
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4751
    bind(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4752
    movq(t1, Address(r15_thread, in_bytes(JavaThread::tlab_end_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4753
    cmpq(t1, Address(r15_thread, in_bytes(JavaThread::tlab_top_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4754
    jcc(Assembler::aboveEqual, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4755
    stop("assert(top <= end)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4756
    should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4757
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4758
    bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4759
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4760
    popq(t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4761
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4762
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4763
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4764
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4765
// Defines obj, preserves var_size_in_bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4766
void MacroAssembler::eden_allocate(Register obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4767
                                   Register var_size_in_bytes,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4768
                                   int con_size_in_bytes,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4769
                                   Register t1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4770
                                   Label& slow_case) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4771
  assert(obj == rax, "obj must be in rax for cmpxchg");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4772
  assert_different_registers(obj, var_size_in_bytes, t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4773
  Register end = t1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4774
  Label retry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4775
  bind(retry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4776
  ExternalAddress heap_top((address) Universe::heap()->top_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4777
  movptr(obj, heap_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4778
  if (var_size_in_bytes == noreg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4779
    leaq(end, Address(obj, con_size_in_bytes));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4780
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4781
    leaq(end, Address(obj, var_size_in_bytes, Address::times_1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4782
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4783
  // if end < obj then we wrapped around => object too long => slow case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4784
  cmpq(end, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4785
  jcc(Assembler::below, slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4786
  cmpptr(end, ExternalAddress((address) Universe::heap()->end_addr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4787
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4788
  jcc(Assembler::above, slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4789
  // Compare obj with the top addr, and if still equal, store the new
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4790
  // top addr in end at the address of the top addr pointer. Sets ZF
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4791
  // if was equal, and clears it otherwise. Use lock prefix for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4792
  // atomicity on MPs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4793
  if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4794
    lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4795
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4796
  cmpxchgptr(end, heap_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4797
  // if someone beat us on the allocation, try again, otherwise continue
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4798
  jcc(Assembler::notEqual, retry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4799
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4800
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4801
// Defines obj, preserves var_size_in_bytes, okay for t2 == var_size_in_bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4802
void MacroAssembler::tlab_allocate(Register obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4803
                                   Register var_size_in_bytes,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4804
                                   int con_size_in_bytes,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4805
                                   Register t1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4806
                                   Register t2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4807
                                   Label& slow_case) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4808
  assert_different_registers(obj, t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4809
  assert_different_registers(obj, var_size_in_bytes, t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4810
  Register end = t2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4811
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4812
  verify_tlab();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4813
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4814
  movq(obj, Address(r15_thread, JavaThread::tlab_top_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4815
  if (var_size_in_bytes == noreg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4816
    leaq(end, Address(obj, con_size_in_bytes));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4817
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4818
    leaq(end, Address(obj, var_size_in_bytes, Address::times_1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4819
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4820
  cmpq(end, Address(r15_thread, JavaThread::tlab_end_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4821
  jcc(Assembler::above, slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4822
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4823
  // update the tlab top pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4824
  movq(Address(r15_thread, JavaThread::tlab_top_offset()), end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4825
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4826
  // recover var_size_in_bytes if necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4827
  if (var_size_in_bytes == end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4828
    subq(var_size_in_bytes, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4829
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4830
  verify_tlab();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4831
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4832
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4833
// Preserves rbx and rdx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4834
void MacroAssembler::tlab_refill(Label& retry,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4835
                                 Label& try_eden,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4836
                                 Label& slow_case) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4837
  Register top = rax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4838
  Register t1 = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4839
  Register t2 = rsi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4840
  Register t3 = r10;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4841
  Register thread_reg = r15_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4842
  assert_different_registers(top, thread_reg, t1, t2, t3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4843
                             /* preserve: */ rbx, rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4844
  Label do_refill, discard_tlab;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4845
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4846
  if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4847
    // No allocation in the shared eden.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4848
    jmp(slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4849
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4850
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4851
  movq(top, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4852
  movq(t1, Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4853
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4854
  // calculate amount of free space
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4855
  subq(t1, top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4856
  shrq(t1, LogHeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4857
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4858
  // Retain tlab and allocate object in shared space if
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4859
  // the amount free in the tlab is too large to discard.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4860
  cmpq(t1, Address(thread_reg, // size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4861
                   in_bytes(JavaThread::tlab_refill_waste_limit_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4862
  jcc(Assembler::lessEqual, discard_tlab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4863
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4864
  // Retain
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4865
  mov64(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4866
  addq(Address(thread_reg,  // size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4867
               in_bytes(JavaThread::tlab_refill_waste_limit_offset())),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4868
       t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4869
  if (TLABStats) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4870
    // increment number of slow_allocations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4871
    addl(Address(thread_reg, // unsigned int
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4872
                 in_bytes(JavaThread::tlab_slow_allocations_offset())),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4873
         1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4874
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4875
  jmp(try_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4876
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4877
  bind(discard_tlab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4878
  if (TLABStats) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4879
    // increment number of refills
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4880
    addl(Address(thread_reg, // unsigned int
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4881
                 in_bytes(JavaThread::tlab_number_of_refills_offset())),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4882
         1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4883
    // accumulate wastage -- t1 is amount free in tlab
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4884
    addl(Address(thread_reg, // unsigned int
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4885
                 in_bytes(JavaThread::tlab_fast_refill_waste_offset())),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4886
         t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4887
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4888
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4889
  // if tlab is currently allocated (top or end != null) then
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4890
  // fill [top, end + alignment_reserve) with array object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4891
  testq(top, top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4892
  jcc(Assembler::zero, do_refill);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4893
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4894
  // set up the mark word
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4895
  mov64(t3, (int64_t) markOopDesc::prototype()->copy_set_hash(0x2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4896
  movq(Address(top, oopDesc::mark_offset_in_bytes()), t3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4897
  // set the length to the remaining space
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4898
  subq(t1, typeArrayOopDesc::header_size(T_INT));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4899
  addq(t1, (int)ThreadLocalAllocBuffer::alignment_reserve());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4900
  shlq(t1, log2_intptr(HeapWordSize / sizeof(jint)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4901
  movq(Address(top, arrayOopDesc::length_offset_in_bytes()), t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4902
  // set klass to intArrayKlass
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4903
  movptr(t1, ExternalAddress((address) Universe::intArrayKlassObj_addr()));
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  4904
  store_klass(top, t1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4905
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4906
  // refill the tlab with an eden allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4907
  bind(do_refill);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4908
  movq(t1, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4909
  shlq(t1, LogHeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4910
  // add object_size ??
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4911
  eden_allocate(top, t1, 0, t2, slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4912
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4913
  // Check that t1 was preserved in eden_allocate.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4914
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4915
  if (UseTLAB) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4916
    Label ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4917
    Register tsize = rsi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4918
    assert_different_registers(tsize, thread_reg, t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4919
    pushq(tsize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4920
    movq(tsize, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4921
    shlq(tsize, LogHeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4922
    cmpq(t1, tsize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4923
    jcc(Assembler::equal, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4924
    stop("assert(t1 != tlab size)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4925
    should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4926
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4927
    bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4928
    popq(tsize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4929
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4930
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4931
  movq(Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())), top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4932
  movq(Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())), top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4933
  addq(top, t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4934
  subq(top, (int)ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4935
  movq(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4936
  verify_tlab();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4937
  jmp(retry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4938
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4939
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4940
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4941
int MacroAssembler::biased_locking_enter(Register lock_reg, Register obj_reg, Register swap_reg, Register tmp_reg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4942
                                         bool swap_reg_contains_mark,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4943
                                         Label& done, Label* slow_case,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4944
                                         BiasedLockingCounters* counters) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4945
  assert(UseBiasedLocking, "why call this otherwise?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4946
  assert(swap_reg == rax, "swap_reg must be rax for cmpxchgq");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4947
  assert(tmp_reg != noreg, "tmp_reg must be supplied");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4948
  assert_different_registers(lock_reg, obj_reg, swap_reg, tmp_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4949
  assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4950
  Address mark_addr      (obj_reg, oopDesc::mark_offset_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4951
  Address saved_mark_addr(lock_reg, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4952
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4953
  if (PrintBiasedLockingStatistics && counters == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4954
    counters = BiasedLocking::counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4955
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4956
  // Biased locking
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4957
  // See whether the lock is currently biased toward our thread and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4958
  // whether the epoch is still valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4959
  // Note that the runtime guarantees sufficient alignment of JavaThread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4960
  // pointers to allow age to be placed into low bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4961
  // First check to see whether biasing is even enabled for this object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4962
  Label cas_label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4963
  int null_check_offset = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4964
  if (!swap_reg_contains_mark) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4965
    null_check_offset = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4966
    movq(swap_reg, mark_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4967
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4968
  movq(tmp_reg, swap_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4969
  andq(tmp_reg, markOopDesc::biased_lock_mask_in_place);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4970
  cmpq(tmp_reg, markOopDesc::biased_lock_pattern);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4971
  jcc(Assembler::notEqual, cas_label);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4972
  // The bias pattern is present in the object's header. Need to check
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4973
  // whether the bias owner and the epoch are both still current.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  4974
  load_klass(tmp_reg, obj_reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4975
  movq(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4976
  orq(tmp_reg, r15_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4977
  xorq(tmp_reg, swap_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4978
  andq(tmp_reg, ~((int) markOopDesc::age_mask_in_place));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4979
  if (counters != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4980
    cond_inc32(Assembler::zero,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4981
               ExternalAddress((address) counters->anonymously_biased_lock_entry_count_addr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4982
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4983
  jcc(Assembler::equal, done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4984
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4985
  Label try_revoke_bias;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4986
  Label try_rebias;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4987
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4988
  // At this point we know that the header has the bias pattern and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4989
  // that we are not the bias owner in the current epoch. We need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4990
  // figure out more details about the state of the header in order to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4991
  // know what operations can be legally performed on the object's
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4992
  // header.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4993
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4994
  // If the low three bits in the xor result aren't clear, that means
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4995
  // the prototype header is no longer biased and we have to revoke
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4996
  // the bias on this object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4997
  testq(tmp_reg, markOopDesc::biased_lock_mask_in_place);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4998
  jcc(Assembler::notZero, try_revoke_bias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4999
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5000
  // Biasing is still enabled for this data type. See whether the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5001
  // epoch of the current bias is still valid, meaning that the epoch
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5002
  // bits of the mark word are equal to the epoch bits of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5003
  // prototype header. (Note that the prototype header's epoch bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5004
  // only change at a safepoint.) If not, attempt to rebias the object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5005
  // toward the current thread. Note that we must be absolutely sure
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5006
  // that the current epoch is invalid in order to do this because
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5007
  // otherwise the manipulations it performs on the mark word are
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5008
  // illegal.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5009
  testq(tmp_reg, markOopDesc::epoch_mask_in_place);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5010
  jcc(Assembler::notZero, try_rebias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5011
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5012
  // The epoch of the current bias is still valid but we know nothing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5013
  // about the owner; it might be set or it might be clear. Try to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5014
  // acquire the bias of the object using an atomic operation. If this
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5015
  // fails we will go in to the runtime to revoke the object's bias.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5016
  // Note that we first construct the presumed unbiased header so we
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5017
  // don't accidentally blow away another thread's valid bias.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5018
  andq(swap_reg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5019
       markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5020
  movq(tmp_reg, swap_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5021
  orq(tmp_reg, r15_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5022
  if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5023
    lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5024
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5025
  cmpxchgq(tmp_reg, Address(obj_reg, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5026
  // If the biasing toward our thread failed, this means that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5027
  // another thread succeeded in biasing it toward itself and we
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5028
  // need to revoke that bias. The revocation will occur in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5029
  // interpreter runtime in the slow case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5030
  if (counters != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5031
    cond_inc32(Assembler::zero,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5032
               ExternalAddress((address) counters->anonymously_biased_lock_entry_count_addr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5033
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5034
  if (slow_case != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5035
    jcc(Assembler::notZero, *slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5036
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5037
  jmp(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5038
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5039
  bind(try_rebias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5040
  // At this point we know the epoch has expired, meaning that the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5041
  // current "bias owner", if any, is actually invalid. Under these
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5042
  // circumstances _only_, we are allowed to use the current header's
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5043
  // value as the comparison value when doing the cas to acquire the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5044
  // bias in the current epoch. In other words, we allow transfer of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5045
  // the bias from one thread to another directly in this situation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5046
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5047
  // FIXME: due to a lack of registers we currently blow away the age
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5048
  // bits in this situation. Should attempt to preserve them.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5049
  load_klass(tmp_reg, obj_reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5050
  movq(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5051
  orq(tmp_reg, r15_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5052
  if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5053
    lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5054
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5055
  cmpxchgq(tmp_reg, Address(obj_reg, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5056
  // If the biasing toward our thread failed, then another thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5057
  // succeeded in biasing it toward itself and we need to revoke that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5058
  // bias. The revocation will occur in the runtime in the slow case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5059
  if (counters != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5060
    cond_inc32(Assembler::zero,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5061
               ExternalAddress((address) counters->rebiased_lock_entry_count_addr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5062
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5063
  if (slow_case != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5064
    jcc(Assembler::notZero, *slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5065
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5066
  jmp(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5068
  bind(try_revoke_bias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5069
  // The prototype mark in the klass doesn't have the bias bit set any
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5070
  // more, indicating that objects of this data type are not supposed
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5071
  // to be biased any more. We are going to try to reset the mark of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5072
  // this object to the prototype value and fall through to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5073
  // CAS-based locking scheme. Note that if our CAS fails, it means
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5074
  // that another thread raced us for the privilege of revoking the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5075
  // bias of this particular object, so it's okay to continue in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5076
  // normal locking code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5077
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5078
  // FIXME: due to a lack of registers we currently blow away the age
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5079
  // bits in this situation. Should attempt to preserve them.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5080
  load_klass(tmp_reg, obj_reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5081
  movq(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5082
  if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5083
    lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5084
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5085
  cmpxchgq(tmp_reg, Address(obj_reg, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5086
  // Fall through to the normal CAS-based lock, because no matter what
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5087
  // the result of the above CAS, some thread must have succeeded in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5088
  // removing the bias bit from the object's header.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5089
  if (counters != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5090
    cond_inc32(Assembler::zero,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5091
               ExternalAddress((address) counters->revoked_lock_entry_count_addr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5092
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5093
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5094
  bind(cas_label);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5095
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5096
  return null_check_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5097
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5098
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5099
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5100
void MacroAssembler::biased_locking_exit(Register obj_reg, Register temp_reg, Label& done) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5101
  assert(UseBiasedLocking, "why call this otherwise?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5102
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5103
  // Check for biased locking unlock case, which is a no-op
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5104
  // Note: we do not have to check the thread ID for two reasons.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5105
  // First, the interpreter checks for IllegalMonitorStateException at
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5106
  // a higher level. Second, if the bias was revoked while we held the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5107
  // lock, the object could not be rebiased toward another thread, so
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5108
  // the bias bit would be clear.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5109
  movq(temp_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5110
  andq(temp_reg, markOopDesc::biased_lock_mask_in_place);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5111
  cmpq(temp_reg, markOopDesc::biased_lock_pattern);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5112
  jcc(Assembler::equal, done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5114
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5115
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5116
void MacroAssembler::load_klass(Register dst, Register src) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5117
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5118
    movl(dst, Address(src, oopDesc::klass_offset_in_bytes()));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5119
    decode_heap_oop_not_null(dst);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5120
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5121
    movq(dst, Address(src, oopDesc::klass_offset_in_bytes()));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5122
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5123
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5124
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5125
void MacroAssembler::store_klass(Register dst, Register src) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5126
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5127
    encode_heap_oop_not_null(src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5128
    // zero the entire klass field first as the gap needs to be zeroed too.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5129
    movptr(Address(dst, oopDesc::klass_offset_in_bytes()), NULL_WORD);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5130
    movl(Address(dst, oopDesc::klass_offset_in_bytes()), src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5131
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5132
    movq(Address(dst, oopDesc::klass_offset_in_bytes()), src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5133
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5134
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5135
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5136
void MacroAssembler::load_heap_oop(Register dst, Address src) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5137
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5138
    movl(dst, src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5139
    decode_heap_oop(dst);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5140
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5141
    movq(dst, src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5142
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5143
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5144
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5145
void MacroAssembler::store_heap_oop(Address dst, Register src) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5146
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5147
    assert(!dst.uses(src), "not enough registers");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5148
    encode_heap_oop(src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5149
    movl(dst, src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5150
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5151
    movq(dst, src);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5152
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5153
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5154
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5155
// Algorithm must match oop.inline.hpp encode_heap_oop.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5156
void MacroAssembler::encode_heap_oop(Register r) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5157
  assert (UseCompressedOops, "should be compressed");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5158
#ifdef ASSERT
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5159
  Label ok;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5160
  pushq(rscratch1); // cmpptr trashes rscratch1
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5161
  cmpptr(r12_heapbase, ExternalAddress((address)Universe::heap_base_addr()));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5162
  jcc(Assembler::equal, ok);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5163
  stop("MacroAssembler::encode_heap_oop: heap base corrupted?");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5164
  bind(ok);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5165
  popq(rscratch1);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5166
#endif
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5167
  verify_oop(r);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5168
  testq(r, r);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5169
  cmovq(Assembler::equal, r, r12_heapbase);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5170
  subq(r, r12_heapbase);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5171
  shrq(r, LogMinObjAlignmentInBytes);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5172
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5173
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5174
void MacroAssembler::encode_heap_oop_not_null(Register r) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5175
  assert (UseCompressedOops, "should be compressed");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5176
#ifdef ASSERT
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5177
  Label ok;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5178
  testq(r, r);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5179
  jcc(Assembler::notEqual, ok);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5180
  stop("null oop passed to encode_heap_oop_not_null");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5181
  bind(ok);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5182
#endif
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5183
  verify_oop(r);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5184
  subq(r, r12_heapbase);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5185
  shrq(r, LogMinObjAlignmentInBytes);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5186
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5187
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5188
void  MacroAssembler::decode_heap_oop(Register r) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5189
  assert (UseCompressedOops, "should be compressed");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5190
#ifdef ASSERT
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5191
  Label ok;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5192
  pushq(rscratch1);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5193
  cmpptr(r12_heapbase,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5194
         ExternalAddress((address)Universe::heap_base_addr()));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5195
  jcc(Assembler::equal, ok);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5196
  stop("MacroAssembler::decode_heap_oop: heap base corrupted?");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5197
  bind(ok);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5198
  popq(rscratch1);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5199
#endif
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5200
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5201
  Label done;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5202
  shlq(r, LogMinObjAlignmentInBytes);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5203
  jccb(Assembler::equal, done);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5204
  addq(r, r12_heapbase);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5205
#if 0
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5206
   // alternate decoding probably a wash.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5207
   testq(r, r);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5208
   jccb(Assembler::equal, done);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5209
   leaq(r, Address(r12_heapbase, r, Address::times_8, 0));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5210
#endif
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5211
  bind(done);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5212
  verify_oop(r);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5213
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5214
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5215
void  MacroAssembler::decode_heap_oop_not_null(Register r) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5216
  assert (UseCompressedOops, "should only be used for compressed headers");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5217
  // Cannot assert, unverified entry point counts instructions (see .ad file)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5218
  // vtableStubs also counts instructions in pd_code_size_limit.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5219
  assert(Address::times_8 == LogMinObjAlignmentInBytes, "decode alg wrong");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5220
  leaq(r, Address(r12_heapbase, r, Address::times_8, 0));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5221
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5222
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5223
Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5224
  switch (cond) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5225
    // Note some conditions are synonyms for others
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5226
    case Assembler::zero:         return Assembler::notZero;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5227
    case Assembler::notZero:      return Assembler::zero;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5228
    case Assembler::less:         return Assembler::greaterEqual;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5229
    case Assembler::lessEqual:    return Assembler::greater;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5230
    case Assembler::greater:      return Assembler::lessEqual;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5231
    case Assembler::greaterEqual: return Assembler::less;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5232
    case Assembler::below:        return Assembler::aboveEqual;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5233
    case Assembler::belowEqual:   return Assembler::above;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5234
    case Assembler::above:        return Assembler::belowEqual;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5235
    case Assembler::aboveEqual:   return Assembler::below;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5236
    case Assembler::overflow:     return Assembler::noOverflow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5237
    case Assembler::noOverflow:   return Assembler::overflow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5238
    case Assembler::negative:     return Assembler::positive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5239
    case Assembler::positive:     return Assembler::negative;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5240
    case Assembler::parity:       return Assembler::noParity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5241
    case Assembler::noParity:     return Assembler::parity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5243
  ShouldNotReachHere(); return Assembler::overflow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5244
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5245
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5247
void MacroAssembler::cond_inc32(Condition cond, AddressLiteral counter_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5248
  Condition negated_cond = negate_condition(cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5249
  Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5250
  jcc(negated_cond, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5251
  atomic_incl(counter_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5252
  bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5253
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5254
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5255
void MacroAssembler::atomic_incl(AddressLiteral counter_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5256
  pushfq();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5257
  if (os::is_MP())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5258
    lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5259
  incrementl(counter_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5260
  popfq();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5261
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5262
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5263
SkipIfEqual::SkipIfEqual(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5264
    MacroAssembler* masm, const bool* flag_addr, bool value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5265
  _masm = masm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5266
  _masm->cmp8(ExternalAddress((address)flag_addr), value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5267
  _masm->jcc(Assembler::equal, _label);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5269
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5270
SkipIfEqual::~SkipIfEqual() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5271
  _masm->bind(_label);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5272
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5274
void MacroAssembler::bang_stack_size(Register size, Register tmp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5275
  movq(tmp, rsp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5276
  // Bang stack for total size given plus shadow page size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5277
  // Bang one page at a time because large size can bang beyond yellow and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5278
  // red zones.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5279
  Label loop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5280
  bind(loop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5281
  movl(Address(tmp, (-os::vm_page_size())), size );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5282
  subq(tmp, os::vm_page_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5283
  subl(size, os::vm_page_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5284
  jcc(Assembler::greater, loop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5285
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5286
  // Bang down shadow pages too.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5287
  // The -1 because we already subtracted 1 page.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5288
  for (int i = 0; i< StackShadowPages-1; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5289
    movq(Address(tmp, (-i*os::vm_page_size())), size );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5290
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5291
}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5292
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5293
void MacroAssembler::reinit_heapbase() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5294
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5295
    movptr(r12_heapbase, ExternalAddress((address)Universe::heap_base_addr()));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5296
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 249
diff changeset
  5297
}